Message
Message
0 at
https://mozilla.org/MPL/2.0/
// © Matb09
//@version=5
strategy('Opening Range & Daily and Weekly Pivots - Strategy - pineconnector - V2',
shorttitle='ORB + Pivots - MT5 - V2', overlay=true)
// Strategy Logic //
KZNY = time("D", ny)
kzny_session = na(KZNY) ? na : color.green
bgcolor(kzny_session, transp=80)
// Flat Market //
FMfilter = input.bool(defval=false, title='Enable Flat Market Filter?', group="Flat
Market filter")
invert_FMfilter = input.bool(defval=false, title='Inverse Flat Market Filter?',
group="Flat Market filter")
PlotFMfilter = input.bool(defval=false, title='Plot Flat Market Filter?',
group="Flat Market filter")
FMBBlength = 20
FMBBsrc = close
FMBBmult = 2 //input.float(2.0, minval=0.001, maxval=50, title="StdDev")
FMBBbasis = ta.sma(FMBBsrc, FMBBlength)
FMBBdev = FMBBmult * ta.stdev(FMBBsrc, FMBBlength)
FMBBThreshold_Width = input.float(0.8, minval=0, maxval=10, step=0.05, title="BB
Threshold Width %", tooltip='Wont enter trades if BB width less than this %',
group="Flat Market filter")
//BBThreshold_Width = FMBBThreshold_Width / 1000
//Display Indicator
plot(PlotFMfilter ? FMBBbasis:na, title="Basis", color=#FF6D00)
BBp1 = plot(PlotFMfilter ?FMBBupper :na, "Upper", color=FMBBcolor)
BBp2 = plot(PlotFMfilter ?FMBBlower:na, "Lower", color=FMBBcolor)
fill(BBp1, BBp2, title = "Background", color=FMBackBBcolor)
//Alerts
AlertFlatflag = FMBBThreshold_Width > FMWperc ? true : false
AlertNotFlatflag = FMBBThreshold_Width > FMWperc ? false : true
//// End Flat Makert ////
// OBR Logic //
sessionInput = input.session("0930-1000", title="ORB Timeframe", group="OBR
settings")
t = time(timeframe.period, sessionInput)
if is_first
orb_high := high
orb_low := low
ema_filter_long := use_ema_filter ? open > ema : true
ema_filter_short := use_ema_filter ? open < ema : true
flat_market := FMfilter ? (invert_FMfilter ? FMWperc > FMBBThreshold_Width :
FMWperc < FMBBThreshold_Width) : true
else
orb_high := orb_high[1]
orb_low := orb_low[1]
if high > orb_high and in_session
orb_high := high
if low < orb_low and in_session
orb_low := low
///////////// ATR
atrPeriod = input.int(title='ATR Period', defval=14, minval=1, group = "ATR
Inputs")
srcAtr = input(title='Source Upper', defval=close, group = "ATR Inputs")
atrMultiplier = input.float(title='ATR Multiplier Upper', defval=2.2, group = "ATR
Inputs")
atr = ta.atr(atrPeriod)
atr_low = srcAtr - atr * atrMultiplier
atr_up = srcAtr + atr * atrMultiplier
isNewDay = ta.change(dayofmonth)
BarsSinceLastclose() =>
bar_index - strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1)
if use_trailing
if strategy.position_size > 0 and atr_low > stop_value
stop_value := atr_low
strategy.exit("Long", stop = stop_value, limit = tp_value)
alert(str.tostring(pine_id)+',newsltplong,' +syminfo.ticker+ ',sl='
+str.tostring(stop_value), alert.freq_once_per_bar_close)
if strategy.position_size < 0 and atr_up < stop_value
stop_value := atr_up
strategy.exit("Short", stop = stop_value, limit = tp_value)
alert(str.tostring(pine_id)+',newsltpshort,' +syminfo.ticker+ ',sl='
+str.tostring(stop_value), alert.freq_once_per_bar_close)