Aleem trend indicator
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Aleem trend indicator
- This topic has 1 reply, 2 voices, and was last updated 1 week ago by
Iván.
-
-
08/27/2025 at 9:00 PM #250129
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)08/28/2025 at 8:45 AM #250137ecco qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124//-----------------------------------------//// PRC_Aleem Trend (by Aleemullahkhan)// version = 0// 28.08.2025// Iván González @ www.prorealcode.com// Sharing ProRealTime knowledge//-----------------------------------------//// --- Parámetros Configurables ---//-----------------------------------------//ONCE atrLength = 10 // Longitud ATR para SupertrendONCE factor = 3.0 // Factor para SupertrendONCE length = 200 // Longitud de la EMAONCE showStrend = 1 // 1=Sí, 0=No - Mostrar Línea SupertrendONCE showEma200 = 1 // 1=Sí, 0=No - Mostrar Línea EMA 200//-----------------------------------------//// --- Cálculos Principales ---//-----------------------------------------//ema200 = ExponentialAverage[length](close)strend = Supertrend[factor, atrLength]// --- Definición de la Dirección de la Tendencia ---bullish = (strend < close)bearish = (strend > close)// --- Detección de Cruces y Cambios de Tendencia ---crossedAbove200EMA = (close CROSSES OVER ema200)crossedBelow200EMA = (close CROSSES UNDER ema200)trendChangeToBearish = (bearish AND NOT bearish[1])trendChangeToBullish = (bullish AND NOT bullish[1])// --- Variables de Estado para Evitar Señales Repetidas ---ONCE alreadyBought = 0 // 1=Comprado, 0=No compradoONCE alreadySold = 0 // 1=Vendido, 0=No vendido// --- Lógica de Reseteo de las Banderas ---IF trendChangeToBearish THENalreadyBought = 0ENDIFIF trendChangeToBullish THENalreadySold = 0ENDIF//-----------------------------------------//// --- Lógica de Señales de Entrada ---//-----------------------------------------//// Señal de ComprabuySignal = (alreadyBought = 0) AND ((crossedAbove200EMA AND bullish) OR (trendChangeToBullish AND close > ema200))IF buySignal THENalreadyBought = 1 // Activa la bandera para no volver a comprarENDIF// Señal de VentasellSignal = (alreadySold = 0) AND ((crossedBelow200EMA AND bearish) OR (trendChangeToBearish AND close < ema200))IF sellSignal THENalreadySold = 1 // Activa la bandera para no volver a venderENDIF//-----------------------------------------//// --- Lógica de Señales de Salida ---//-----------------------------------------//// Señal de Salida de Compra (cuando la Supertrend se vuelve bajista)exitBuySignal = trendChangeToBearish AND close > ema200IF exitBuySignal THENalreadyBought = 0 // Resetea la bandera al salirENDIF// Señal de Salida de Venta (cuando la Supertrend se vuelve alcista)exitSellSignal = trendChangeToBullish AND close < ema200IF exitSellSignal THENalreadySold = 0 // Resetea la bandera al salirENDIF//-----------------------------------------//// --- Dibujo de las Señales en el Gráfico ---//-----------------------------------------//offset = AverageTrueRange[14] * 0.5IF buySignal THENDRAWARROWUP(barindex, low - offset) COLOURED("green")DRAWTEXT("BUY", barindex, low - offset * 2) COLOURED("green")ENDIFIF sellSignal THENDRAWARROWDOWN(barindex, high + offset) COLOURED("red")DRAWTEXT("SELL", barindex, high + offset * 2) COLOURED("red")ENDIFIF exitBuySignal THENDRAWTEXT("X", barindex, high + offset, sansserif,bold,20) COLOURED("orange")ENDIFIF exitSellSignal THENDRAWTEXT("X", barindex, low - offset,sansserif,bold,20) COLOURED("orange")ENDIF//-----------------------------------------//// --- Dibujo Condicional de las Líneas ---//-----------------------------------------//plotStrend = UNDEFINEDplotEma200 = UNDEFINEDIF showStrend = 1 THENplotStrend = strendENDIFIF showEma200 = 1 THENplotEma200 = ema200ENDIF// Coloreado dinámico para la línea de SupertrendstrendColorR = 0strendColorG = 0strendColorB = 0IF bullish THENstrendColorR = 0strendColorG = 200strendColorB = 0ELSEstrendColorR = 255strendColorG = 0strendColorB = 0ENDIF//-----------------------------------------//RETURN plotStrend COLOURED(strendColorR, strendColorG, strendColorB) AS "Supertrend", plotEma200 COLOURED("blue") AS "EMA 200"1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on