ملٹی موونگ ایوریج ٹرینڈ سٹرینتھ ٹریڈنگ اسٹریٹیجی - متحرک اوسط انحراف پر مبنی لچکدار ذہین تجارتی نظام

MA ATR HTF RR TP SL
تخلیق کی تاریخ: 2024-12-11 17:46:33 آخر میں ترمیم کریں: 2024-12-11 17:46:33
کاپی: 0 کلکس کی تعداد: 446
1
پر توجہ دیں
1617
پیروکار

ملٹی موونگ ایوریج ٹرینڈ سٹرینتھ ٹریڈنگ اسٹریٹیجی - متحرک اوسط انحراف پر مبنی لچکدار ذہین تجارتی نظام

جائزہ

یہ حکمت عملی ایک ذہین تجارتی نظام ہے جو ایک سے زیادہ منتقل اوسط اور رجحان کی طاقت پر مبنی ہے۔ یہ مارکیٹ میں رجحان کی طاقت کی پیمائش کرتا ہے جس میں قیمتوں اور مختلف دورانیہ کی متحرک اوسط کے مابین انحراف کی مقدار کا تجزیہ کیا جاتا ہے ، اور اے ٹی آر کی اتار چڑھاؤ کی شرح کے اشارے کے ساتھ مل کر پوزیشن مینجمنٹ اور رسک کنٹرول کے لئے۔ یہ حکمت عملی انتہائی تخصیص پذیر ہے اور مختلف مارکیٹ کے ماحول اور تجارت کی ضروریات کے مطابق پیرامیٹرز کو لچکدار طریقے سے ایڈجسٹ کرسکتی ہے۔

حکمت عملی کا اصول

حکمت عملی کی بنیادی منطق درج ذیل پہلوؤں پر مبنی ہے:

  1. رجحانات کی سمت اور کراس سگنل کی شناخت کے لئے دو مختلف ادوار (فاسٹ اور سست) کی متحرک اوسط کا استعمال کریں
  2. رجحان کی طاقت کو قیمتوں کے متحرک اوسط سے انحراف کی حساب سے مقدار میں شمار کریں (پوائنٹس میں)
  3. K لائن شکلوں کے ساتھ مل کر ((سگھلنا ، ہتھوڑا ، شوٹنگ اسٹار ، کراس اسٹار ، وغیرہ) معاون تصدیق کے اشارے کے طور پر
  4. اے ٹی آر اشارے کا استعمال کرتے ہوئے اسٹاپ نقصان اور منافع کے اہداف کا متحرک حساب کتاب
  5. آرڈر مینجمنٹ کا استعمال کرتے ہوئے جزوی منافع اور ٹریکنگ نقصانات

اسٹریٹجک فوائد

  1. سسٹم میں بہت زیادہ موافقت ہے ، جس کو پیرامیٹرز کے ذریعہ مختلف مارکیٹ کے حالات کے مطابق ڈھال لیا جاسکتا ہے
  2. ٹرینڈ کی طاقت کی پیمائش کرکے اس کی شدت کی پیمائش کریں اور جب رجحان کمزور ہو تو بار بار تجارت سے گریز کریں
  3. متعدد تکنیکی اشارے اور شکل کی توثیق کے ساتھ مل کر ، تجارتی سگنل کی وشوسنییتا میں اضافہ
  4. اے ٹی آر پر مبنی متحرک اسٹاپ نقصان کا استعمال کرتے ہوئے ، خطرے کو مناسب طریقے سے کنٹرول کریں
  5. واپسی اور فکسڈ پوزیشن دونوں فنڈ مینجمنٹ کی حمایت کریں
  6. منافع کو مؤثر طریقے سے بچانے کے لئے جزوی منافع اور ٹریکنگ اسٹاپ نقصان کی خصوصیات

اسٹریٹجک رسک

  1. زلزلے کی منڈیوں میں زیادہ جعلی سگنل پیدا ہوسکتے ہیں ، زلزلے کے اشارے کو فلٹر کرنے کی سفارش کی جاتی ہے
  2. ایک سے زیادہ اشارے کے جوڑے سے تجارت کے مواقع ضائع ہوسکتے ہیں
  3. پیرامیٹرز کو زیادہ سے زیادہ بہتر بنانے سے زیادہ فٹ ہونے کا خطرہ ہوسکتا ہے
  4. کم لیکویڈیٹی والے بازاروں میں ، بڑے پیمانے پر تجارت میں سلائڈ پوائنٹ کا خطرہ ہوسکتا ہے
  5. معقول اسٹاپ نقصان کا تناسب لگانے کی ضرورت ہے تاکہ ایک ہی وقت میں بہت زیادہ نقصان سے بچا جاسکے

حکمت عملی کی اصلاح کی سمت

  1. ٹرینڈ کی تصدیق کے لئے ایک معاون اشارے کے طور پر ٹرانزیکشن کی مقدار کا اشارے شامل کیا جاسکتا ہے
  2. مارکیٹ میں اتار چڑھاؤ کے اشارے متعارف کرانے پر غور کریں
  3. مختلف ٹائم فریموں کے لئے رجحانات کی مستقل مزاجی پر مبنی سگنل فلٹرنگ
  4. مزید سٹاپ نقصان کے اختیارات جیسے ٹائم سٹاپ
  5. حکمت عملی کی موافقت کو بہتر بنانے کے لیے انکولی پیرامیٹر کی اصلاح کے طریقہ کار کو تیار کریں۔

خلاصہ کریں۔

یہ حکمت عملی ایک جامع تجارتی نظام کی تعمیر کرتی ہے جس میں چلتی اوسط ، رجحان کی طاقت کی مقدار ، K لائن کی شکل اور متحرک خطرے کا انتظام شامل ہے۔ یہ حکمت عملی کی منطق کی سادگی کو برقرار رکھتا ہے اور متعدد تصدیق کے طریقہ کار کے ذریعہ تجارت کی وشوسنییتا کو بڑھاتا ہے۔ حکمت عملی کی اعلی تخصیص پذیری اس کو مختلف تجارتی طرزوں اور مارکیٹ کے حالات کے مطابق ڈھالنے کی اجازت دیتی ہے ، لیکن اس کے استعمال میں پیرامیٹرز کی اصلاح اور خطرے پر قابو پانے پر توجہ دی جانی چاہئے۔

حکمت عملی کا ماخذ کوڈ
/*backtest
start: 2024-12-03 00:00:00
end: 2024-12-10 00:00:00
period: 10m
basePeriod: 10m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Customizable Strategy with Signal Intensity Based on Pips Above/Below MAs", overlay=true)

// Customizable Inputs
// Account and Risk Management
account_size = input.int(100000, title="Account Size (USD)", minval=1)
compounded_results = input.bool(true, title="Compounded Results")
risk_per_trade = input.float(1.0, title="Risk per Trade (%)", minval=0.1, maxval=100) / 100

// Moving Averages Settings
ma1_length = input.int(50, title="Moving Average 1 Length", minval=1)
ma2_length = input.int(200, title="Moving Average 2 Length", minval=1)

// Higher Time Frame for Moving Averages
ma_htf = input.timeframe("D", title="Higher Time Frame for MA Delay")

// Signal Intensity Range based on pips
signal_intensity_min = input.int(0, title="Signal Intensity Start (Pips)", minval=0, maxval=1000)
signal_intensity_max = input.int(1000, title="Signal Intensity End (Pips)", minval=0, maxval=1000)

// ATR-Based Stop Loss and Take Profit
atr_length = input.int(14, title="ATR Length", minval=1)
atr_multiplier_stop = input.float(1.5, title="Stop Loss Size (ATR Multiplier)", minval=0.1)
atr_multiplier_take_profit = input.float(2.5, title="Take Profit Size (ATR Multiplier)", minval=0.1)

// Trailing Stop and Partial Profit
trailing_stop_rr = input.float(2.0, title="Trailing Stop (R:R)", minval=0)
partial_profit_percentage = input.float(50, title="Take Partial Profit (%)", minval=0, maxval=100)

// Trend Filter Settings
trend_filter_enabled = input.bool(true, title="Trend Filter Enabled")
trend_filter_sensitivity = input.float(50, title="Trend Filter Sensitivity", minval=0, maxval=100)

// Candle Pattern Type for Entry
entry_candle_type = input.string("Any", title="Entry Candle Type", options=["Any", "Engulfing", "Hammer", "Shooting Star", "Doji"])

// Moving Average Entry Conditions
ma_entry_condition = input.string("Both", title="MA Entry", options=["Fast Above Slow", "Fast Below Slow", "Both"])

// Trade Direction (Long, Short, or Both)
trade_direction = input.string("Both", title="Trade Direction", options=["Long", "Short", "Both"])

// ATR Calculation
atr_value = ta.atr(atr_length)

// Moving Average Calculations (using Higher Time Frame)
ma1_htf = ta.sma(request.security(syminfo.tickerid, ma_htf, close), ma1_length)
ma2_htf = ta.sma(request.security(syminfo.tickerid, ma_htf, close), ma2_length)

// Candle Pattern Conditions
is_engulfing = close[1] < open[1] and close > open and high > high[1] and low < low[1]
is_hammer = (high - low) > 3 * (close - open) and (close > open) and (low == ta.lowest(low, 5))
is_shooting_star = (high - low) > 3 * (open - close) and (open > close) and (high == ta.highest(high, 5))
is_doji = (close - open) <= ((high - low) * 0.1)

// Apply the selected candle pattern
candle_condition = false
if entry_candle_type == "Any"
    candle_condition := true
if entry_candle_type == "Engulfing"
    candle_condition := is_engulfing
if entry_candle_type == "Hammer"
    candle_condition := is_hammer
if entry_candle_type == "Shooting Star"
    candle_condition := is_shooting_star
if entry_candle_type == "Doji"
    candle_condition := is_doji

// Moving Average Entry Conditions
ma_cross_above = ta.crossover(ma1_htf, ma2_htf)
ma_cross_below = ta.crossunder(ma1_htf, ma2_htf)

// Calculate pips distance to MAs and normalize it for signal intensity
pip_size = syminfo.mintick * 10  // Assuming Forex; for other asset classes, modify as needed

// Calculate distances in pips between price and MAs
distance_to_ma1_pips = math.abs(close - ma1_htf) / pip_size
distance_to_ma2_pips = math.abs(close - ma2_htf) / pip_size

// Calculate signal intensity based on the pips distance
// Normalize the signal intensity between the user-specified min and max
signal_intensity = math.min(math.max((distance_to_ma1_pips + distance_to_ma2_pips), signal_intensity_min), signal_intensity_max)

// Trend Filter Condition (Optional)
trend_condition = false
if trend_filter_enabled
    trend_condition := ta.sma(close, ma2_length) > ta.sma(close, ma2_length + int(trend_filter_sensitivity))

// Entry Conditions Based on MA, Candle Patterns, and Trade Direction
long_condition = (trade_direction == "Long" or trade_direction == "Both") and (ma_entry_condition == "Fast Above Slow" or ma_entry_condition == "Both") and ma_cross_above and candle_condition and (not trend_filter_enabled or trend_condition) and signal_intensity > signal_intensity_min
short_condition = (trade_direction == "Short" or trade_direction == "Both") and (ma_entry_condition == "Fast Below Slow" or ma_entry_condition == "Both") and ma_cross_below and candle_condition and (not trend_filter_enabled or not trend_condition) and signal_intensity > signal_intensity_min

// Position Sizing Based on Risk Per Trade and ATR for Stop Loss
risk_amount = account_size * risk_per_trade
stop_loss_atr = atr_multiplier_stop * atr_value

// Calculate the position size based on the risk amount and ATR stop loss
position_size = risk_amount / stop_loss_atr

// If compounded results are not enabled, adjust position size for non-compounded returns
if not compounded_results
    position_size := position_size / account_size * 100000  // Adjust for non-compounded results

// Convert take profit and stop loss from ATR to USD
pip_value = syminfo.mintick * 10  // Assuming Forex; for other asset classes, modify as needed
take_profit_atr = atr_multiplier_take_profit * atr_value
take_profit_usd = (take_profit_atr * pip_value) * position_size
stop_loss_usd = (stop_loss_atr * pip_value) * position_size

// Trailing Stop
trail_stop_level = trailing_stop_rr * stop_loss_atr

// Initialize long_box_id and short_box_id as boxes (not ints)
var box long_box_id = na
var box short_box_id = na

// Track Monthly Profit
var float monthly_profit = 0.0
if (month(timenow) != month(timenow[1]))  // New month
    monthly_profit := 0

// Long Trade Management
if long_condition
    strategy.entry("Long", strategy.long, qty=position_size)
    // Partial Profit at 50% position close when 1:1 risk/reward
    strategy.exit("Partial Profit", from_entry="Long", limit=strategy.position_avg_price + stop_loss_atr, qty_percent=partial_profit_percentage / 100)
    // Full take profit and stop loss with trailing stop
    strategy.exit("Take Profit Long", from_entry="Long", limit=strategy.position_avg_price + take_profit_atr, stop=strategy.position_avg_price - stop_loss_atr, trail_offset=trail_stop_level)

    // Delete the old box if it exists
    if not na(long_box_id)
        box.delete(long_box_id)
    
    // Plot Take Profit and Stop Loss for Long Positions
    // long_box_id := box.new(left=bar_index - 1, top=strategy.position_avg_price + take_profit_atr, right=bar_index, bottom=strategy.position_avg_price - stop_loss_atr, bgcolor=color.new(color.green, 90), border_width=1, border_color=color.new(color.green, 0))

// Short Trade Management
if short_condition
    strategy.entry("Short", strategy.short, qty=position_size)
    // Partial Profit at 50% position close when 1:1 risk/reward
    strategy.exit("Partial Profit", from_entry="Short", limit=strategy.position_avg_price - stop_loss_atr, qty_percent=partial_profit_percentage / 100)
    // Full take profit and stop loss with trailing stop
    strategy.exit("Take Profit Short", from_entry="Short", limit=strategy.position_avg_price - take_profit_atr, stop=strategy.position_avg_price + stop_loss_atr, trail_offset=trail_stop_level)

    // Delete the old box if it exists
    // if not na(short_box_id)
    //     box.delete(short_box_id)

    // Plot Take Profit and Stop Loss for Short Positions
    // short_box_id := box.new(left=bar_index - 1, top=strategy.position_avg_price + stop_loss_atr, right=bar_index, bottom=strategy.position_avg_price - take_profit_atr, bgcolor=color.new(color.red, 90), border_width=1, border_color=color.new(color.red, 0))

// Plot MAs and Signals
plot(ma1_htf, color=color.blue, title="MA1 (HTF)")
plot(ma2_htf, color=color.red, title="MA2 (HTF)")
plotshape(series=long_condition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=short_condition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")