
یہ حکمت عملی ایک رجحان ٹریکنگ سسٹم ہے جو روایتی تکنیکی تجزیہ اور جدید مصنوعی ذہانت کے طریقوں کو جوڑتا ہے۔ یہ بنیادی طور پر اشاریہ کی حرکت پذیری اوسط ((EMA) اور سادہ حرکت پذیری اوسط ((SMA) کو رجحان فلٹر کے طور پر استعمال کرتا ہے ، جبکہ انٹری ٹائمنگ کو بہتر بنانے کے لئے پیش گوئی ماڈل متعارف کرایا گیا ہے۔ حکمت عملی کو خاص طور پر یومیہ لائن کی سطح کے لئے بہتر بنایا گیا ہے ، جس کا مقصد درمیانی اور طویل مدتی مارکیٹ کے رجحانات کو پکڑنا ہے۔
اس حکمت عملی کی بنیادی منطق تین اہم اجزاء پر مشتمل ہے:
ٹریڈنگ سگنل کی پیداوار کو رجحان کی سمت اور پیش گوئی سگنل کی مستقل مزاجی کو پورا کرنے کی ضرورت ہے ، یعنی:
اس حکمت عملی میں روایتی تکنیکی تجزیہ اور جدید پیش گوئی کے طریقوں کو ملا کر ایک مضبوط رجحان ٹریکنگ سسٹم بنایا گیا ہے۔ اس کے بنیادی فوائد میں منطق کی وضاحت ، خطرے کی قابو پانے اور مضبوط توسیع پذیری ہے۔ اس حکمت عملی کو بہتر بنانے کے ذریعے ، خاص طور پر پیش گوئی کے ماڈل اور خطرے کے کنٹرول میں بہتری کے ذریعہ ، اس حکمت عملی کی استحکام اور منافع کو مزید بڑھانے کی امید ہے۔ یہ حکمت عملی سرمایہ کاروں کے لئے موزوں ہے جو درمیانی اور طویل مدتی مستحکم منافع کی تلاش میں ہیں۔
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("My Strategy", overlay=true)
// Parameters (adjust as needed)
neighborsCount = 8
maxBarsBack = 2000
featureCount = 5
useDynamicExits = true
useEmaFilter = true
emaPeriod = 200
useSmaFilter = true
smaPeriod = 200
// Moving Average Calculations
ema = ta.ema(close, emaPeriod)
sma = ta.sma(close, smaPeriod)
// Trend Conditions
isEmaUptrend = close > ema
isEmaDowntrend = close < ema
isSmaUptrend = close > sma
isSmaDowntrend = close < sma
// Model Prediction (Replace with your real model)
// Here a simulation is used, replace it with real predictions
prediction = math.random() * 2 - 1 // Random value between -1 and 1
// Entry Signals
isNewBuySignal = prediction > 0 and isEmaUptrend and isSmaUptrend
isNewSellSignal = prediction < 0 and isEmaDowntrend and isSmaDowntrend
// Exit Signals
var int barsHeld = 0
var bool in_position = false
var int entry_bar = 0
if isNewBuySignal and not in_position
in_position := true
entry_bar := bar_index
barsHeld := 1
else if isNewSellSignal and not in_position
in_position := true
entry_bar := bar_index
barsHeld := 1
else if in_position
barsHeld := barsHeld + 1
if barsHeld == 4
in_position := false
endLongTradeStrict = barsHeld == 4 and isNewBuySignal[1]
endShortTradeStrict = barsHeld == 4 and isNewSellSignal[1]
// Backtest Logic
var float totalProfit = 0
var float entryPrice = na
var int tradeDirection = 0
if isNewBuySignal and tradeDirection <= 0
entryPrice := close
tradeDirection := 1
strategy.entry("Long", strategy.long)
if isNewSellSignal and tradeDirection >= 0
entryPrice := close
tradeDirection := -1
strategy.entry("Short", strategy.short)
if (endLongTradeStrict and tradeDirection == 1) or (endShortTradeStrict and tradeDirection == -1)
exitPrice = close
profit = (exitPrice - entryPrice) / entryPrice
if tradeDirection == -1
profit := (entryPrice - exitPrice) / entryPrice
totalProfit := totalProfit + profit
tradeDirection := 0
strategy.close_all()
plot(close, color=color.blue)
plot(ema, color=color.orange)
plot(sma, color=color.purple)