Add snippets/three-strike_detector_v6.pine
This commit is contained in:
50
snippets/three-strike_detector_v6.pine
Normal file
50
snippets/three-strike_detector_v6.pine
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
//@version=6
|
||||||
|
indicator("Three Strike Detector", overlay=true)
|
||||||
|
|
||||||
|
// Function to define a long candle
|
||||||
|
// Function to define a long candle
|
||||||
|
is_long_candle(open, high, close, low, min_length) =>
|
||||||
|
body_length = math.abs(close - open)
|
||||||
|
total_range = high - low
|
||||||
|
|
||||||
|
// Long candle condition:
|
||||||
|
// 1. Body is at least min_length of the total range
|
||||||
|
body_length >= total_range * min_length
|
||||||
|
|
||||||
|
// Function to detect the three strike pattern
|
||||||
|
is_three_strike(open, high, close, low) =>
|
||||||
|
// Define minimum body length for long candles
|
||||||
|
min_long_body = 0.5 // Adjust this value as needed
|
||||||
|
|
||||||
|
// Check for bullish three strike
|
||||||
|
isBullishLong1 = is_long_candle(open[1], high[1], close[1], low[1], min_long_body) and close[1] < close[2]
|
||||||
|
isBullishLong2 = is_long_candle(open[2], high[2], close[2], low[2], min_long_body) and close[2] < close[3]
|
||||||
|
isBullishLong3 = is_long_candle(open[3], high[3], close[3], low[3], min_long_body)
|
||||||
|
isBullishEngulfing = open[4] < low[3] and close[4] > high[1]
|
||||||
|
isBullishThreeStrike = isBullishLong1 and isBullishLong2 and isBullishLong3 and isBullishEngulfing
|
||||||
|
|
||||||
|
// Check for bearish three strike
|
||||||
|
isBearishLong1 = is_long_candle(open[1], high[1], close[1], low[1], min_long_body) and close[1] > close[2]
|
||||||
|
isBearishLong2 = is_long_candle(open[2], high[2], close[2], low[2], min_long_body) and close[2] > close[3]
|
||||||
|
isBearishLong3 = is_long_candle(open[3], high[3], close[3], low[3], min_long_body)
|
||||||
|
isBearishEngulfing = open[4] > high[3] and close[4] < low[1]
|
||||||
|
isBearishThreeStrike = isBearishLong1 and isBearishLong2 and isBearishLong3 and isBearishEngulfing
|
||||||
|
|
||||||
|
[isBullishThreeStrike, isBearishThreeStrike]
|
||||||
|
|
||||||
|
[isBullTS, isBearTS] = is_three_strike(open, high, close, low)
|
||||||
|
|
||||||
|
// Plot the three strike pattern with an arrow
|
||||||
|
plotchar(isBullTS,
|
||||||
|
title="Three Strike",
|
||||||
|
char="3",
|
||||||
|
location=location.belowbar,
|
||||||
|
color=color.green,
|
||||||
|
size=size.small)
|
||||||
|
|
||||||
|
plotchar(isBearTS,
|
||||||
|
title="Three Strike",
|
||||||
|
char="3",
|
||||||
|
location=location.belowbar,
|
||||||
|
color=color.red,
|
||||||
|
size=size.small)
|
||||||
Reference in New Issue
Block a user