Ciao, chiedo la traduzione se possibile di un indicatore che pare interessante.
//@version=5
indicator(“Aleem Trend”, overlay=true)
// Inputs for Supertrend and EMA
atrLength = input.int(10, “ATR Length for Supertrend”, minval=1)
factor = input.float(3.0, “Factor for Supertrend”, minval=0.1)
length = input.int(200, “EMA Length”, minval=1)
showStrend = input(false, title=”Show Supertrend Line”)
showEma200 = input(false, title=”Show 200 EMA Line”)
// EMA and Supertrend Calculations
ema200 = ta.ema(close, length)
[strend, _] = ta.supertrend(factor, atrLength)
// Supertrend Direction
bullish = strend < close
bearish = strend > close
// Define the crossing of the 200 EMA
crossedAbove200EMA = (close > ema200) and (close[1] <= ema200)
crossedBelow200EMA = (close < ema200) and (close[1] >= ema200)
// Exit Signals
trendChangeToBearish = bearish and not bearish[1]
trendChangeToBullish = bullish and not bullish[1]
var bool alreadyBought = false // This variable will track if we’ve already bought
var bool alreadySold = false // This variable will track if we’ve already sold
// Reset the buy/sell signal when the opposite signal is triggered
if trendChangeToBearish
alreadyBought := false
if trendChangeToBullish
alreadySold := false
// Buy Signal
buySignal = not alreadyBought and ((crossedAbove200EMA and bullish) or (trendChangeToBullish and close > ema200))
if buySignal
alreadyBought := true // Set the flag to true when buy signal is triggered
// Sell Signal
sellSignal = not alreadySold and ((crossedBelow200EMA and bearish) or (trendChangeToBearish and close < ema200))
if sellSignal
alreadySold := true // Set the flag to true when sell signal is triggered
// Exit Buy Signal
exitBuySignal = trendChangeToBearish and close > ema200
if exitBuySignal
alreadyBought := false // Reset the flag when exiting the buy
// Exit Sell Signal
exitSellSignal = trendChangeToBullish and close < ema200
if exitSellSignal
alreadySold := false // Reset the flag when exiting the sell
// Signal Plots
plotshape(series=buySignal, title=”Buy Signal”, location=location.belowbar, color=color.green, style=shape.labelup, text=”BUY”)
plotshape(series=sellSignal, title=”Sell Signal”, location=location.abovebar, color=color.red, style=shape.labeldown, text=”SELL”)
plotshape(series=exitBuySignal, title=”Exit Buy Signal”, location=location.abovebar, color=color.orange, style=shape.xcross, text=”EXIT”)
plotshape(series=exitSellSignal, title=”Exit Sell Signal”, location=location.belowbar, color=color.orange, style=shape.xcross, text=”EXIT”)
// Plot Supertrend and 200 EMA based on user input
plot(showStrend ? strend : na, color=strend < close ? color.green : color.red, title=”Supertrend”, linewidth=2)
plot(showEma200 ? ema200 : na, color=color.blue, title=”200 EMA”, linewidth=1)