
اس حکمت عملی میں انڈیکس کی حرکت پذیر اوسط ((EMA) اور سپر ٹرینڈ اشارے ((Supertrend) کا امتزاج کیا گیا ہے تاکہ خرید و فروخت کے اشارے پیدا کیے جائیں۔ جب قیمت اوپر سے 20 دن کی ای ایم اے کو توڑتی ہے اور سپر ٹرینڈ اشارے بیس رجحان میں ہوتا ہے تو ، خریدنے کا اشارہ پیدا ہوتا ہے۔ جب قیمت نیچے سے 20 دن کی ای ایم اے کو توڑتی ہے اور سپر ٹرینڈ اشارے نیچے کی طرف ہوتا ہے تو ، فروخت کا اشارہ پیدا ہوتا ہے۔ اس حکمت عملی کا مقصد رجحان سازی کی صورتحال کو پکڑنا ہے ، جبکہ غلط سگنل کو کم کرنے کے لئے ای ایم اے کو بطور فلٹرنگ شرط کے طور پر استعمال کرنا ہے۔
اس حکمت عملی کا مقصد رجحان سازی کو پکڑنے کے لئے 20 دن کے ای ایم اے اور سپر ٹرینڈ اشارے کے ساتھ مل کر خرید و فروخت کے اشارے پیدا کرنا ہے۔ حکمت عملی کا فائدہ یہ ہے کہ منطق آسان ہے ، ای ایم اے اور سپر ٹرینڈ اشارے کے ساتھ مل کر جعلی سگنل کو مؤثر طریقے سے کم کیا جاسکتا ہے۔ تاہم ، اتار چڑھاؤ کی منڈیوں میں ، حکمت عملی میں اکثر تجارت کی جاسکتی ہے ، اور خطرے سے متعلق انتظامات کی کمی ہے۔ مستقبل میں حکمت عملی کو بہتر بنانے کے لئے اسٹاپ نقصانات ، پوزیشن مینجمنٹ اور پیرامیٹرز کی اصلاح جیسے طریقوں پر غور کیا جاسکتا ہے۔ مجموعی طور پر ، یہ حکمت عملی رجحان سازی کے لئے ایک آسان اور موثر سوچ پیش کرتی ہے ، لیکن عملی استعمال میں مزید اصلاح اور بہتری کی ضرورت ہے۔
/*backtest
start: 2023-06-11 00:00:00
end: 2024-06-16 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("20 EMA and Supertrend Strategy", overlay=true)
// Inputs
emaLength = input(20, title="EMA Length")
supertrendMultiplier = input.float(3.0, title="Supertrend Multiplier")
supertrendPeriod = input(10, title="Supertrend Period")
// EMA Calculation
ema = ta.ema(close, emaLength)
// Supertrend Calculation
Periods = supertrendPeriod
src = hl2
Multiplier = supertrendMultiplier
changeATR= input.bool(true, title="Change ATR Calculation Method?")
showsignals = input.bool(true, title="Show Buy/Sell Signals?")
highlighting = input.bool(true, title="Highlighter On/Off?")
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - (Multiplier * atr)
up1 = na(up[1]) ? up : up[1]
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + (Multiplier * atr)
dn1 = na(dn[1]) ? dn : dn[1]
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := na(trend[1]) ? trend : trend[1]
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(series=buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
plotshape(series=buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.white)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(series=sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
plotshape(series=sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.white)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=1)
longFillColor = highlighting ? (trend == 1 ? color.new(color.green, 90) : color.new(color.white, 0)) : color.new(color.white, 0)
shortFillColor = highlighting ? (trend == -1 ? color.new(color.red, 90) : color.new(color.white, 0)) : color.new(color.white, 0)
fill(mPlot, upPlot, title="UpTrend Highlighter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highlighter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
// Buy and Sell Signals based on EMA and Supertrend
buySignalEMA = ta.crossover(close, ema) and trend == 1
sellSignalEMA = ta.crossunder(close, ema) and trend == -1
// Plot EMA
plot(ema, color=color.blue, title="20 EMA")
// Plot Buy and Sell Signals
plotshape(series=buySignalEMA, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=sellSignalEMA, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")
// Strategy Entries and Exits
if (buySignalEMA)
strategy.entry("Buy", strategy.long)
if (sellSignalEMA)
strategy.close("Buy")