EMA پر مبنی ٹریفک لائٹ ٹریڈنگ کی حکمت عملی

مصنف:چاؤ ژانگ، تاریخ: 2023-11-24 15:46:48
ٹیگز:

img

جائزہ

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

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

  1. تیز رفتار (8 دورانیے) ، درمیانے (14 دورانیے) اور سست (16 دورانیے) کی 3 EMA لائنیں مرتب کریں، اس کے علاوہ فلٹر کے طور پر 1 طویل مدت (100 دورانیے) EMA لائن۔

  2. طویل اور مختصر مواقع کا تعین 3 ای ایم اے لائنوں کے ترتیب اور فلٹر کے ساتھ ان کے کراس اوور کے مطابق کریں:

  • جب تیز رفتار لائن درمیانی لائن کے اوپر عبور کرتی ہے یا درمیانی لائن سست لائن کے اوپر عبور کرتی ہے ، تو اسے طویل سگنل کے طور پر طے کیا جاتا ہے۔

  • جب میڈیم لائن فاسٹ لائن سے نیچے گزرتی ہے تو اسے قریبی طویل سگنل کے طور پر مقرر کیا جاتا ہے۔

  • جب تیز رفتار لائن درمیانی لائن سے نیچے گزرتی ہے یا درمیانی لائن سست لائن سے نیچے گزرتی ہے تو ، اس کا تعین مختصر سگنل کے طور پر کیا جاتا ہے۔

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

  1. رجحان کی سمت اور طاقت کا اندازہ 3 ای ایم اے لائنوں کے ترتیب کے ذریعے کریں ، جس میں ای ایم اے لائنوں اور فلٹر کے مابین کراس اوور کے ساتھ مل کر الٹ پوائنٹس کا تعین کرنے کے لئے ، جس میں رجحان کی پیروی اور الٹ ٹریڈنگ کو نامیاتی طور پر شامل کیا گیا ہے۔

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

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

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

پیرامیٹر کی اصلاح کے ذریعے، یہ حکمت عملی زیادہ مصنوعات کو اپنانے کے قابل ہے اور بیک ٹسٹ میں مضبوط منافع بخش اور استحکام کا مظاہرہ کیا ہے.

خطرے کا تجزیہ

اس حکمت عملی کے اہم خطرات میں شامل ہیں:

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

اسٹریٹجی کے استحکام کو مزید بہتر بنانے اور خطرات پر قابو پانے کے لئے پیرامیٹرز کو بہتر بنانے ، اسٹاپ نقصان کی سطح کا تعین کرنے ، محتاط تجارت وغیرہ کی تجویز کی جاتی ہے۔

اصلاح کی ہدایات

اس حکمت عملی کی اصلاح کی اہم سمتیں:

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

حکمت عملی کے استحکام اور منافع میں مسلسل اضافہ متعدد پہلوؤں میں پیرامیٹرز کی ایڈجسٹمنٹ اور رسک کنٹرول کے اقدامات متعارف کرانے سے حاصل کیا جاسکتا ہے۔

نتیجہ

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


/*backtest
start: 2023-01-01 00:00:00
end: 2023-11-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © maxits

// 4HS Crypto Market Strategy
// This strategy uses 4 ema to get Long or Short Signals
// Length are: 8, 14, 16, 100
// We take long positions when the order of the emas is the following:
// green > yellow > red (As the color of Traffic Lights) and they are above white ema (Used as a filter for long positions)
  
// We take short positions when the order of the emas is the following:
// green < yellow < red (As the color of inverse Traffic Lights) and they are below white ema (Used as a filter for short positions)

//@version=4
strategy(title="Trafic Lights Strategy",
         shorttitle="TLS",
         overlay=true,
         initial_capital=1000,
         default_qty_value=20,
         default_qty_type=strategy.percent_of_equity,
         commission_value=0.1,
         pyramiding=0
         )

// User Inputs
// i_time         = input(defval = timestamp("28 May 2017 13:30 +0000"), title = "Start Time", type = input.time) //Starting time for Backtesting

sep1           = input(title="============ System Conditions ============", type=input.bool, defval=false)

enable_Long    = input(true, title="Enable Long Positions")   // Enable long  Positions
enable_Short   = input(true, title="Enable Short Positions") // Enable short Positions

sep2           = input(title="============ Indicator Parameters ============", type=input.bool, defval=false)

f_length       = input(title="Fast EMA Length",   type=input.integer, defval=8,   minval=1) 
m_length       = input(title="Medium EMA Length", type=input.integer, defval=14,   minval=1) 
s_length       = input(title="Slow EMA Length",   type=input.integer, defval=16,  minval=1) 
filter_L       = input(title="EMA Filter",        type=input.integer, defval=100, minval=1) 
filterRes      = input(title="Filter Resolution", type=input.resolution, defval="D")        // ema Filter Time Frame

sep3           = input(title="============LONG Profit-Loss Parameters============", type=input.bool, defval=false)

e_Long_TP      = input(true, title="Enable a Profit Level?")
e_Long_SL      = input(false, title="Enable a S.Loss Level?")
e_Long_TS      = input(true, title="Enable a Trailing Stop?")           
long_TP_Input  = input(40.0,   title='Take Profit %',   type=input.float,   minval=0)/100
long_SL_Input  = input(1.0,   title='Stop Loss %',     type=input.float,   minval=0)/100 
atrLongMultip  = input(2.0,   title='ATR Multiplier',  type=input.float,   minval=0.1)   // Parameters to calculate Trailing Stop Loss
atrLongLength  = input(14,    title='ATR Length',      type=input.integer, minval=1)

sep4           = input(title="============SHORT Profit-Loss Parameters============", type=input.bool, defval=false)

e_Short_TP     = input(true, title="Enable a Profit Level?")
e_Short_SL     = input(false, title="Enable a S.Loss Level?")
e_Short_TS     = input(true, title="Enable a Trailing Stop?")
short_TP_Input = input(30.0,   title='Take Profit %',   type=input.float,   minval=0)/100
short_SL_Input = input(1.0,   title='Stop Loss %',     type=input.float,   minval=0)/100
atrShortMultip = input(2.0,   title='ATR Multiplier',  type=input.float,   minval=0.1)
atrShortLength = input(14,    title='ATR Length',      type=input.integer, minval=1)

// Indicators

fema   = ema(close, f_length)
mema   = ema(close, m_length)
sema   = ema(close, s_length)
filter = security(syminfo.tickerid, filterRes, ema(close, filter_L))

plot(fema,   title="Fast EMA",   color=color.new(color.green,  0))
plot(mema,   title="Medi EMA",   color=color.new(color.yellow, 0))
plot(sema,   title="Slow EMA",   color=color.new(color.red,    0))
plot(filter, title="EMA Filter", color=color.new(color.white,  0))

// Entry Conditions

longTrade  = strategy.position_size >  0
shortTrade = strategy.position_size <  0
notInTrade = strategy.position_size == 0
inTrade    = strategy.position_size != 0
priceEntry = strategy.position_avg_price

goLong  = fema > mema and mema > sema and fema > filter and  enable_Long  and (crossover (fema, mema) or crossover (mema, sema) or crossover (sema, filter))
goShort = fema < mema and mema < sema and fema < filter and  enable_Short and (crossunder (fema, mema) or crossunder (mema, sema) or crossunder (sema, filter))

close_L = crossunder(fema, mema)
close_S = crossover (fema, mema)

// Profit and Loss conditions

// Long
 
long_TP = priceEntry * (1 + long_TP_Input)  // Long Position Take Profit Calculation
long_SL = priceEntry * (1 - long_SL_Input)  // Long Position Stop Loss Calculation
atrLong = atr(atrLongLength)                // Long Position ATR Calculation
long_TS = low - atrLong * atrLongMultip

long_T_stop  = 0.0                          // Code for calculating Long Positions Trailing Stop Loss/
long_T_stop := if (longTrade)
    longStop = long_TS
    max(long_T_stop[1], longStop)
else 
    0
    
//Short

short_TP = priceEntry * (1 - short_TP_Input) // Long  Position Take Profit Calculation
short_SL = priceEntry * (1 + short_SL_Input) // Short Position Stop Loss Calculation
atrShort = atr(atrShortLength)               // Short Position ATR Calculation
short_TS = high + atrShort * atrShortMultip

short_T_stop   = 0.0                // Code for calculating Short Positions Trailing Stop Loss/
short_T_stop  := if shortTrade
    shortStop  = short_TS
    min(short_T_stop[1], shortStop)
else 
    9999999

// Strategy Long Entry

if goLong and notInTrade 
    strategy.entry("Go Long", long=strategy.long, comment="Go Long", alert_message="Open Long Position")

if longTrade and close_L
    strategy.close("Go Long", when=close_L, comment="Close Long", alert_message="Close Long Position")
    
if e_Long_TP    // Algorithm for Enabled Long Position Profit Loss Parameters
    if (e_Long_TS and not e_Long_SL)
        strategy.exit("Long TP & TS", "Go Long", limit = long_TP, stop = long_T_stop)
    else
        if (e_Long_SL and not e_Long_TS)
            strategy.exit("Long TP & TS", "Go Long",limit = long_TP, stop = long_SL)
        else 
            strategy.exit("Long TP & TS", "Go Long",limit = long_TP)
else
    if not e_Long_TP 
        if (e_Long_TS and not e_Long_SL)
            strategy.exit("Long TP & TS", "Go Long", stop = long_T_stop)
        else
            if (e_Long_SL and not e_Long_TS)
                strategy.exit("Long TP & TS", "Go Long",stop = long_SL)
    

// Strategy Short Entry

if goShort and notInTrade 
    strategy.entry("Go Short", long=strategy.short, comment="Go Short", alert_message="Open Short Position")

if shortTrade and close_S
    strategy.close("Go Short", comment="Close Short", alert_message="Close Short Position")

if e_Short_TP   // Algorithm for Enabled Short Position Profit Loss Parameters
    if (e_Short_TS and not e_Short_SL)
        strategy.exit("Short TP & TS", "Go Short", limit = short_TP, stop = short_T_stop)
    else
        if (e_Short_SL and not e_Short_TS)
            strategy.exit("Short TP & SL", "Go Short",limit = short_TP, stop = short_SL)
        else 
            strategy.exit("Short TP & TS", "Go Short",limit = short_TP)
else
    if not e_Short_TP 
        if (e_Short_TS and not e_Short_SL)
            strategy.exit("Short TS", "Go Short", stop = short_T_stop)
        else
            if (e_Short_SL and not e_Short_TS)
                strategy.exit("Short SL", "Go Short",stop = short_SL)

// Long  Position Profit and Loss Plotting

plot(longTrade and e_Long_TP  and long_TP                          ? long_TP      : na, title="TP Level", color=color.green, style=plot.style_linebr, linewidth=2)
plot(longTrade and e_Long_SL  and long_SL and not e_Long_TS        ? long_SL      : na, title="SL Level", color=color.red,   style=plot.style_linebr, linewidth=2)
plot(longTrade and e_Long_TS  and long_T_stop and not e_Long_SL    ? long_T_stop  : na, title="TS Level", color=color.red,   style=plot.style_linebr, linewidth=2)

// Short Position Profit and Loss Plotting

plot(shortTrade and e_Short_TP and short_TP                        ? short_TP     : na, title="TP Level", color=color.green, style=plot.style_linebr, linewidth=2)
plot(shortTrade and e_Short_SL and short_SL and not e_Short_TS     ? short_SL     : na, title="SL Level", color=color.red,   style=plot.style_linebr, linewidth=2)
plot(shortTrade and e_Short_TS and short_T_stop and not e_Short_SL ? short_T_stop : na, title="TS Level", color=color.red,   style=plot.style_linebr, linewidth=2)



مزید