//@version=4
study(title="forexoz", overlay = true)

// Inputs
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
c = input(10, title = "ATR Period")
h = input(false, title = "Signals from Heikin Ashi Candles")

xATR = atr(c)
nLoss = a * xATR

src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close

xATRTrailingStop = 0.0
xATRTrailingStop := iff(src > nz(xATRTrailingStop, 0) and src > nz(xATRTrailingStop, 0), max(nz(xATRTrailingStop), src - nLoss),
iff(src < nz(xATRTrailingStop, 0) and src < nz(xATRTrailingStop, 0), min(nz(xATRTrailingStop), src + nLoss),
iff(src > nz(xATRTrailingStop, 0), src - nLoss, src + nLoss)))

pos = 0
pos := iff(src < nz(xATRTrailingStop, 0) and src > nz(xATRTrailingStop, 0), 1,
iff(src > nz(xATRTrailingStop, 0) and src < nz(xATRTrailingStop, 0), -1, nz(pos, 0)))

xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue

ema = ema(src,1)
above = crossover(ema, xATRTrailingStop)
below = crossover(xATRTrailingStop, ema)

buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below

barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop

plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)

barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)

alertcondition(buy, "UT Long", "UT Long")
alertcondition(sell, "UT Short", "UT Short")
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.