بہترین ٹریلنگ لے منافع کی حکمت عملی

مصنف:چاؤ ژانگ، تاریخ: 2023-10-07 10:28:54
ٹیگز:

جائزہ

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

حکمت عملی منطق

حکمت عملی میں مندرجہ ذیل اہم حصے شامل ہیں:

  1. تیز رفتار اور سست رفتار اوسط کا حساب لگائیں۔ تیز رفتار ایم اے مدت 20 ہے اور سست ایم اے مدت 50 ہے۔

  2. داخلہ کی شرائط کا تعین کریں۔ جب تیز ایم اے سست ایم اے سے عبور کرتا ہے تو طویل ہوجائیں ، جب تیز ایم اے سست ایم اے سے نیچے گزرتا ہے تو مختصر ہوجائیں۔

  3. رجحان کی سمت کا تعین کریں۔ طویل اور مختصر سگنلز کے بعد باروں کی تعداد ریکارڈ کریں، فیصلہ کریں کہ یہ ایک اپ ٹرینڈ ہے یا ڈاؤن ٹرینڈ۔

  4. داخلہ قیمت۔ لاگ ان کی قیمت کے طور پر ٹریڈنگ سگنل ٹرگر ہونے پر قیمت ریکارڈ کریں۔

  5. منافع لینے کی لکیریں مقرر کریں۔ لمبے عرصے کے لئے ، منافع لینے کی شرح زیادہ ہے * (1 + منافع لینے کا فیصد) ؛ شارٹس کے لئے ، منافع لینے کی شرح کم ہے * (1 - منافع لینے کا فیصد) ۔

  6. منافع لینے کے پیچھے۔ منافع لینے کی لائن ایڈجسٹ کرتی رہتی ہے، منافع بخش سمت کے حق میں مقررہ فیصد منتقل کرتی ہے۔

  7. منافع ٹرگر لے لو. جب قیمت منافع لائن لے، منافع کے لئے پوزیشن بند.

  8. ایک اختیاری چالو کرنے کی خصوصیت بھی ہے۔ صرف اس وقت جب قیمت پہلی بار چالو کرنے کی سطح کو توڑ دے گی تو منافع لینے کا فائدہ اٹھایا جائے گا۔

فوائد کا تجزیہ

اس حکمت عملی کا سب سے بڑا فائدہ یہ ہے کہ منافع حاصل کرنے کے ذریعے منافع کو زیادہ سے زیادہ کرنا۔ جب قیمت فائدہ مند سمت میں چلتی ہے تو ، منافع میں مقفل ہونے کے ل profit منافع کی سمت میں آگے بڑھتی رہتی ہے۔

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

رجحان، داخلہ، منافع حاصل کرنے کے مجموعے کے ذریعے، یہ مسلسل منافع حاصل کرنے اور زیادہ سے زیادہ واپسی حاصل کرنے کے لئے رجحان پر سوار ہوسکتا ہے.

خطرے کا تجزیہ

اہم خطرہ یہ ہے کہ منافع حاصل کرنے کے لئے مناسب قیمت کی نقل و حرکت کی ضرورت ہے۔ اگر قیمت تیزی سے الٹ جاتی ہے تو ، اس سے نقصانات ہوسکتے ہیں۔

اس کے علاوہ، غیر مستحکم مارکیٹوں میں اکثر منافع لینے کا عمل نقصان کا سبب بن سکتا ہے۔

اور غلط طریقے سے مقرر کردہ پیرامیٹرز جیسے بہت زیادہ منافع کا تناسب خطرے کو بڑھا سکتا ہے۔

خطرے کا انتظام مناسب منافع کا تناسب طے کرکے ، متزلزل مارکیٹوں میں تجارت سے گریز کرکے ، یا اسٹاپ نقصان کا استعمال کرکے کیا جاسکتا ہے۔

اصلاح

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

  1. بہتر مجموعے تلاش کرنے کے لئے مختلف ادوار کی جانچ کرکے ایم اے پیرامیٹرز کو بہتر بنائیں۔

  2. مختلف چالو کرنے کی سطح کی جانچ کی طرف سے چالو کرنے کی خصوصیت کو بہتر بنائیں.

  3. بیک ٹسٹنگ کے ذریعے منافع کا فیصد بہتر بنائیں۔

  4. خطرے کو کنٹرول کرنے کے لئے مناسب سطحوں پر سٹاپ نقصان شامل کریں.

  5. اضافی فلٹرز جیسے حجم، اے ٹی آر سٹاپ وغیرہ کی جانچ کریں۔

  6. مختلف مارکیٹوں جیسے اسٹاک، فاریکس، کرپٹو پر ٹیسٹ.

نتیجہ

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


/*backtest
start: 2023-01-01 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@author=Daveatt

SystemName = "BEST Trailing Profit Strategy"
// This string is to personalize the text that appears with your orders on the chart through strategy() calls and entry/exit markers, and in the alert default message.
// Although leaving it empty will not cause problems in study mode,
TradeId = "BEST"
// These values are used both in the strategy() header and in the script's relevant inputs as default values so they match.
// Unless these values match in the script's Inputs and the TV backtesting Properties, results between them cannot be compared.
InitCapital = 1000000
InitPosition = 100
InitCommission = 0.075
InitPyramidMax = 1
CalcOnorderFills = true
CalcOnTick = true
DefaultQtyType = strategy.fixed
DefaultQtyValue = strategy.fixed
Precision = 2
Overlay=true

// strategy(title=SystemName, shorttitle=SystemName, overlay=Overlay, 
//  pyramiding=InitPyramidMax, initial_capital=InitCapital, default_qty_type=DefaultQtyType, default_qty_value=InitPosition, commission_type=strategy.commission.percent, 
//  commission_value=InitCommission, calc_on_order_fills=CalcOnorderFills, calc_on_every_tick=CalcOnTick, precision=2)


// strategy(title=SystemName, shorttitle=SystemName, overlay=true, 
//  pyramiding=0, default_qty_value=100, precision=7, currency=currency.USD,
//  commission_value=0.2,commission_type=strategy.commission.percent, initial_capital=10000)

//
//  Author:   Daveatt
//  Revision: R0.1 Beta
//  Date:     8-Dec-2019
//

// inputs

src   = input(defval=close, type=input.source, title="Source")

slowLength   = input(20, "Fast Length",minval=2,step=1)
fastLength   = input(50, "Fast Length",minval=2,step=1)

// Calculate moving averages
fastSMA = sma(src, slowLength)
slowSMA = sma(src, fastLength)

// Calculate trading conditions
enterLong  = crossover(fastSMA, slowSMA)
enterShort = crossunder(fastSMA, slowSMA)

// trend states
since_buy  = barssince(enterLong)
since_sell = barssince(enterShort)
buy_trend  = since_sell > since_buy
sell_trend = since_sell < since_buy 

change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1])

// get the entry price
entry_price = valuewhen(enterLong or enterShort, src, 0)

// Plot moving averages
plot(series=fastSMA, color=color.teal)
plot(series=slowSMA, color=color.orange)

// Plot the entries
plotshape(enterLong, style=shape.circle, location=location.belowbar, color=color.green, size=size.small)
plotshape(enterShort, style=shape.circle, location=location.abovebar, color=color.red, size=size.small)



///////////////////////////////
//======[ Take Profit ]======//
///////////////////////////////

// Use TP?
useTP = input(true, "Use take profit")
// TP trailing
ProfitTrailPerc     = input(1.0, "Trailing Profit (%)",minval=0,step=0.5,type=input.float) * 0.01

use_TP_Trigger = input(true, "Use Take Profit Trigger")
// Will trigger the take profit trailing once reached
takeProfitTrigger   = input(3.0, "Take Profit Trigger (%)",minval=0,step=0.5,type=input.float) * 0.01


// ttp := ttp>tp ? tp : ttp

takeprofitPriceTrigger = 0.0
takeprofitPriceTrigger := if (use_TP_Trigger)
    if (buy_trend)
        entry_price * (1 + takeProfitTrigger) 
    else
        entry_price * (1 - takeProfitTrigger)
else
    -1

//plot(entry_price, title='entry_price', transp=100)

var TP_Trigger_Long_HIT = false
TP_Trigger_Long_HIT := useTP and use_TP_Trigger and buy_trend and high >= takeprofitPriceTrigger
 ? true : TP_Trigger_Long_HIT[1]


var TP_Trigger_Short_HIT = false
TP_Trigger_Short_HIT := useTP and use_TP_Trigger and sell_trend and low <= takeprofitPriceTrigger
 ? true : TP_Trigger_Short_HIT[1]


display_long_TP_trigger     = useTP and buy_trend  and TP_Trigger_Long_HIT == false 
 and takeprofitPriceTrigger != -1
display_short_TP_trigger    = useTP and sell_trend and TP_Trigger_Short_HIT == false 
 and takeprofitPriceTrigger != -1
display_TP_trigger          = display_long_TP_trigger or display_short_TP_trigger


//🔷🔷🔷
// @hugo: Will display the TP trigger as long as not hit
// once the TP trigger is hit, the TP trailing will activate
plot(display_TP_trigger ? takeprofitPriceTrigger : na, title='takeprofitPriceTrigger', transp=0, color=color.orange, 
 style=plot.style_cross, linewidth=3)

longTrailTP= 0.0, shortTrailTP = 0.0

// Trailing Profit
// Start trailing once trigger is reached
longTrailTP := if useTP and buy_trend 
    tpValue = high * (1 + ProfitTrailPerc)
    max(tpValue, longTrailTP[1])
else
    0

shortTrailTP := if useTP and sell_trend
    tpValue = low * (1 - ProfitTrailPerc)
    min(tpValue, shortTrailTP[1])
else
    999999

//plot(longTrailTP, title='debug longTrailTP', transp=100)
//plot(shortTrailTP, title='debug shortTrailTP', transp=100)

//////////////////////////////////////////////////////////////////////////////////////////
//*** TRAILING TAKE PROFIT HIT CONDITIONS TO BE USED IN ALERTS  ***//
//////////////////////////////////////////////////////////////////////////////////////////


//🔷🔷🔷
// @hugo: I use crossover/crossunder for the alerts to trigger the events only once
cond_long_trail_tp_hit      = useTP and buy_trend   and crossover(high, longTrailTP[1]) 
 and (TP_Trigger_Long_HIT or use_TP_Trigger == false)
cond_short_trail_tp_hit     = useTP and sell_trend  and crossunder(low, shortTrailTP[1]) 
 and (TP_Trigger_Short_HIT or use_TP_Trigger == false)
// 🔷🔷🔷


// Plot take profits values for confirmation
// Display the trailing TP until not hit
plot(series= useTP and buy_trend and high <= longTrailTP and 
 (TP_Trigger_Long_HIT or use_TP_Trigger == false) ? longTrailTP : na,
 color=color.aqua, style=plot.style_circles,
 linewidth=2, title="Long Trail TP")

plot(series= useTP and sell_trend and low >= shortTrailTP and 
 (TP_Trigger_Short_HIT or use_TP_Trigger == false) ? shortTrailTP : na,
 color=color.aqua, style=plot.style_circles,
 linewidth=2, title="Short Trail TP")


close_long  = cond_long_trail_tp_hit
close_short = cond_short_trail_tp_hit

// Submit entry orders
strategy.entry("EL", long=true, when=enterLong)
strategy.close("EL", when=close_long)

//if (enterShort)
strategy.entry("ES", long=false, when=enterShort)
strategy.close("ES", when=close_short)


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// ALERTS ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////
//* Put Entry Alerts below *//
//////////////////////////////

// IN STUDY MODE ONLY

// ⚠️⚠️⚠️ For alerts on the signal itself ⚠️⚠️⚠️
//alertcondition(buy_event, "Open Long", "LONG")
//alertcondition(sell_event, "Open Short", "SHORT")

// For the closes you will want to trigger these alerts on condition with alert 
// option "Once Per Bar" for TP and SL

if change_trend
    TP_Trigger_Long_HIT := false
    TP_Trigger_Short_HIT := false

مزید