Aqi signal

Aqi signal

//@version=5
strategy("Trend-Based Buy/Sell Signals", overlay=true)

// Input settings
length = input(50, title="Moving Average Length")
adxLength = input(14, title="ADX Length")

// Indicators
ma50 = ta.sma(close, length)
= ta.dmi(adxLength)

// Buy & Sell conditions
buyCondition = ta.crossover(close, ma50) and adx > 20 and pdi > ndi
sellCondition = ta.crossunder(close, ma50) and adx > 20 and ndi > pdi

// Plot Buy and Sell signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="BUY")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="SELL")

// Execute orders
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.close("Buy", when=sellCondition)
strategy.entry("Sell", strategy.short, when=sellCondition)
strategy.close("Sell", when=buyCondition)

// Plot indicators
plot(ma50, title="50 MA", color=color.blue)

Read More

Share:

Latest News