can you flip the indicator , make the green buy in the down and sell on up // This Pine…
- User
can you flip the indicator , make the green buy in the down and sell on up // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © wbburgin
//@version=5 strategy("Zero-lag Volatility-Breakout EMA Trend Strategy",overlay=false,shorttitle="ZL-VBEMA Trend Strategy", initial_capital=1000,default_qty_type=strategy.percent_of_equity,default_qty_value=10,commission_value=0.1)
tt1 = "If selected, the strategy will not close long or short positions until the opposite signal is received. This"+ " exposes you to more risk but potentially could generate larger returns."
src = input.source(close,"Source") lx = input.int(200,"EMA Difference Length") bbmult = input.float(2.0,"Standard Deviation Multiple") useBinaryStrategy = input.bool(true,"Use Binary Strategy",tooltip = tt1)
hJumper = math.max(src,ta.ema(src,lx)) lJumper = math.min(src,ta.ema(src,lx))
dif = (hJumper / lJumper) - 1
[bbm,bbu,bbl] = ta.bb(dif,lx,bbmult)
plot(dif,color=color.white,title="Zero lag EMA Difference") plot(bbu,color=color.lime,title="Bollinger Top") plot(bbl,color=color.red,title="Bollinger Bottom") plot(bbm,color=color.yellow,title="Bollinger Middle")
sigEnter = ta.crossover(dif,bbu) sigExit = ta.crossunder(dif,bbm) emaBase = ta.ema(src,lx) enterLong = sigEnter and emaBase > emaBase[1] enterShort = sigEnter and emaBase < emaBase[1]
plotshape(enterLong,style=shape.labelup,location=location.bottom,color=color.green,size=size.tiny) plotshape(enterShort,style=shape.labeldown,location=location.top,color=color.red,size=size.tiny)
if enterLong strategy.entry("Long",strategy.long) if enterShort strategy.entry("Short",strategy.short) if not useBinaryStrategy and sigExit strategy.close("Long") strategy.close("Short")
- Assistant
To flip the indicator such that the green "buy" signals appear at the top and the "sell" signals appear at the bottom, you need to adjust the
plotshapefunction calls. Here's the modified script://@version=5 strategy("Zero-lag Volatility-Breakout EMA Trend Strategy", overlay=false, shorttitle="ZL-VBEMA Trend Strategy", initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_value=0.1) tt1 = "If selected, the strategy will not close long or short positions until the opposite signal is received. This" + " exposes you to more risk but potentially could generate larger returns." src = input.source(close, "Source") lx = input.int(200, "EMA Difference Length") bbmult = input.float(2.0, "Standard Deviation Multiple") useBinaryStrategy = input.bool(true, "Use Binary Strategy", tooltip = tt1) hJumper = math.max(src, ta.ema(src, lx)) lJumper = math.min(src, ta.ema(src, lx)) dif = (hJumper / lJumper) - 1 [bbm, bbu, bbl] = ta.bb(dif, lx, bbmult) plot(dif, color=color.white, title="Zero lag EMA Difference") plot(bbu, color=color.lime, title="Bollinger Top") plot(bbl, color=color.red, title="Bollinger Bottom") plot(bbm, color=color.yellow, title="Bollinger Middle") sigEnter = ta.crossover(dif, bbu) sigExit = ta.crossunder(dif, bbm) emaBase = ta.ema(src, lx) enterLong = sigEnter and emaBase > emaBase[1] enterShort = sigEnter and emaBase < emaBase[1] // Flip the buy and sell plots plotshape(enterLong, style=shape.labeldown, location=location.top, color=color.green, size=size.tiny) plotshape(enterShort, style=shape.labelup, location=location.bottom, color=color.red, size=size.tiny) if enterLong strategy.entry("Long", strategy.long) if enterShort strategy.entry("Short", strategy.short) if not useBinaryStrategy and sigExit strategy.close("Long") strategy.close("Short")