var inside_bar = array.new_int(0) var inside_bar_high = array.new_float(0) var inside_bar_low = array.new_float(0) var motherCandleIndex = 0 var motherCandleHigh = 0.0 var motherCandleLow = 0.0 var motherCandleRange = 0.0 var target1Buy = 0.0 var target2Buy = 0.0 var target1Sell = 0.0 var target2Sell = 0.0
var motherCandleH = line.new(na, na, na, na, extend=extend.right, color=color.green) var motherCandleL = line.new(na, na, na, na, extend=extend.right, color=color.red) var motherCandleHLabel = label.new(na, na, style=label.style_label_left, textcolor=color.green, color=color.new(color.green, 80)) var motherCandleLLabel = label.new(na, na, style=label.style_label_left, textcolor=color.red, color=color.new(color.red, 80))
var longT1 = line.new(na, na, na, na, extend=extend.right) var longT2 = line.new(na, na, na, na, extend=extend.right) var shortT1 = line.new(na, na, na, na, extend=extend.right) var shortT2 = line.new(na, na, na, na, extend=extend.right)
var longT1Label = label.new(na, na, textcolor=color.blue, style=label.style_label_left, color=color.new(color.blue, 80)) var longT2Label = label.new(na, na, textcolor=color.blue, style=label.style_label_left, color=color.new(color.blue, 80)) var shortT1Label = label.new(na, na, textcolor=color.blue, style=label.style_label_left, color=color.new(color.blue, 80)) var shortT2Label = label.new(na, na, textcolor=color.blue, style=label.style_label_left, color=color.new(color.blue, 80))
var longT1Line = input.bool(title='Show Long T1', defval=true, group='Long') var longT2Line = input.bool(title='Show Long T2', defval=true, group='Long')
var shortT1Line = input.bool(title='Show Short T1', defval=true, group='Short') var shortT2Line = input.bool(title='Show Short T2', defval=true, group='Short')
var longT1Range = input.float(title='Long T1', defval=1, group='Long (x times above range of mother candle)', tooltip='Line will be plotted above high of mother candle. If value entered is 1, then T1 = range of mother candle x 1') var longT2Range = input.float(title='Long T2', defval=1.5, group='Long (x times above range of mother candle)', tooltip='Line will be plotted above high of mother candle. If value entered is 2, then T2 = range of mother candle x 2')
var shortT1Range = input.float(title='Short T1', defval=1, group='Short (x times below range of mother candle)', tooltip='Line will be plotted below low of mother candle. If value entered is 1, then T1 = range of mother candle x 1') var shortT2Range = input.float(title='Short T2', defval=1.5, group='Short (x times below range of mother candle)', tooltip='Line will be plotted below low of mother candle. If value entered is 2, then T2 = range of mother candle x 1')
hi = high lo = low op = open cl = close
isInside() => previousBar = 1 bodyStatus = cl >= op ? 1 : -1 isInsidePattern = hi < hi[previousBar] and lo > lo[previousBar] isInsidePattern ? bodyStatus : 0
newDay = ta.change(time('D'))
if newDay array.clear(inside_bar) array.clear(inside_bar_high) array.clear(inside_bar_low)
if isInside() and array.size(inside_bar) <= 0 array.push(inside_bar, bar_index) array.push(inside_bar_high, hi[1]) array.push(inside_bar_low, lo[1])
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.