
اس حکمت عملی میں ایک سے زیادہ انڈیکس کے متحرک اوسط ((EMA) ، نسبتا strong مضبوط اشارے ((RSI) اور معیاری فرق سے باہر نکلنے کی شرائط پر مبنی ممکنہ خرید و فروخت کے مواقع کی نشاندہی کی گئی ہے۔ مارکیٹ کے رجحانات کی سمت اور طاقت کا تجزیہ کرنے کے لئے قلیل مدتی ((6، 8، 12 دن) ، درمیانی مدت ((55 دن) اور طویل مدتی ((150، 200، 250 دن) کے EMA کا استعمال کیا گیا ہے۔ آر ایس آئی نے متحرک مقدار کا اندازہ لگانے اور اوورلوڈ یا اوور سیل کی نشاندہی کرنے کے لئے تشکیل پذیر خرید ((30) اور بیچنے والے ((70) کی سطح کا استعمال کیا۔ اس حکمت عملی میں ایک انوکھا باہر نکلنے کا طریقہ کار بھی استعمال کیا گیا ہے ، جس سے ممکنہ تحفظ یا نقصان کو کم کرنے کا ایک طریقہ فراہم کیا جاتا ہے جب اختتامی قیمت 12 ویں EMA کے تشکیل پذیر معیاری فرق کی حد ((0.5) کو چھوتی ہے۔
اس مضمون میں ایک کثیر متحرک اوسط ، آر ایس آئی اور معیاری آفسیٹ آؤٹ پٹ پر مبنی ہائی بریک ٹریڈنگ حکمت عملی پیش کی گئی ہے۔ اس حکمت عملی میں رجحانات اور حرکیات کی دو جہتوں سے مارکیٹ کا تجزیہ کیا گیا ہے ، اور رجحانات کے مواقع کو پکڑنے کے ساتھ ساتھ خطرے پر قابو پانے کے لئے ایک منفرد معیاری آفسیٹ میکانزم کا استعمال کیا گیا ہے۔ حکمت عملی کی سوچ واضح ، منطقی طور پر سخت ہے ، اور کوڈ کو سادہ اور موثر بنانے کے لئے بنایا گیا ہے۔
/*backtest
start: 2023-03-22 00:00:00
end: 2024-03-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Candle Height Breakout with Configurable Exit and Signal Control", shorttitle="CHB Single Signal", overlay=true)
// Input parameters for EMA filter and its length
useEmaFilter = input.bool(true, "Use EMA Filter", group="Entry Conditions")
emaFilterLength = input.int(55, "EMA Filter Length", minval=1, group="Entry Conditions")
candleCount = input.int(4, "SamG Configurable Candle Count for Entry", minval=3, maxval=4, step=1, group="Entry Conditions")
exitEmaLength = input.int(12, "Exit EMA Length", minval=1, group="Exit Conditions", defval=12)
exitStdDevMultiplier = input.float(0.5, "Exit Std Dev Multiplier", minval=0.1, maxval=2.0, step=0.1, group="Exit Conditions")
// State variables to track if we are in a long or short position
var bool inLong = false
var bool inShort = false
// Calculating EMAs with fixed periods for visual reference
ema6 = ta.ema(close, 6)
ema8 = ta.ema(close, 8)
ema12 = ta.ema(close, 12)
ema55 = ta.ema(close, 55)
ema100 = ta.ema(close, 100)
ema150 = ta.ema(close, 150)
ema200 = ta.ema(close, 200)
emaFilter = ta.ema(close, emaFilterLength)
exitEma = ta.ema(close, exitEmaLength)
// Plotting EMAs
plot(ema6, "EMA 6", color=color.red)
plot(ema8, "EMA 8", color=color.orange)
plot(ema12, "EMA 12", color=color.yellow)
plot(ema55, "EMA 55", color=color.green)
plot(ema100, "EMA 100", color=color.blue)
plot(ema150, "EMA 150", color=color.purple)
plot(ema200, "EMA 200", color=color.fuchsia)
plot(emaFilter, "EMA Filter", color=color.black)
plot(exitEma, "Exit EMA", color=color.gray)
// Calculating the highest and lowest of the last N candles based on user input
highestOfN = ta.highest(high[1], candleCount)
lowestOfN = ta.lowest(low[1], candleCount)
// Entry Conditions with EMA Filter
longEntryCondition = not inLong and not inShort and (close > highestOfN) and (not useEmaFilter or (useEmaFilter and close > emaFilter))
shortEntryCondition = not inLong and not inShort and (close < lowestOfN) and (not useEmaFilter or (useEmaFilter and close < emaFilter))
// Update position state on entry
if (longEntryCondition)
strategy.entry("Buy", strategy.long, comment="B")
inLong := true
inShort := false
if (shortEntryCondition)
strategy.entry("Sell", strategy.short, comment="S")
inLong := false
inShort := true
// Exit Conditions based on configurable EMA and Std Dev Multiplier
smaForExit = ta.sma(close, exitEmaLength)
upperExitBand = smaForExit + exitStdDevMultiplier * ta.stdev(close, exitEmaLength)
lowerExitBand = smaForExit - exitStdDevMultiplier * ta.stdev(close, exitEmaLength)
exitConditionLong = inLong and (close < upperExitBand or close < exitEma)
exitConditionShort = inShort and (close > lowerExitBand or close > exitEma)
// Strategy exits
if (exitConditionLong)
strategy.close("Buy", comment="Exit")
inLong := false
if (exitConditionShort)
strategy.close("Sell", comment="Exit")
inShort := false
// Visualizing entry and exit points
plotshape(series=longEntryCondition, style=shape.labelup, location=location.belowbar, color=color.green, size=size.tiny, title="Buy Signal", text="B")
plotshape(series=shortEntryCondition, style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, title="Sell Signal", text="S")