ইএমএ ভিত্তিক ট্রাফিক লাইট ট্রেডিং কৌশল

লেখক:চাওঝাং, তারিখ: ২০২৩-১১-২৪ 15:46:48
ট্যাগঃ

img

সারসংক্ষেপ

এই কৌশলটি লাল, হলুদ এবং সবুজ ট্র্যাফিক লাইটের অনুরূপ, তাদের বিন্যাস আদেশের উপর ভিত্তি করে ট্রেডিং সংকেত তৈরি করতে বিভিন্ন সময়ের 4 টি ইএমএ লাইন ব্যবহার করে। সুতরাং এটিকে ট্র্যাফিক লাইট ট্রেডিং কৌশল বলা হয়। এটি ট্রেডিং সিদ্ধান্তের নির্ভুলতা উন্নত করার লক্ষ্যে ট্রেডিংয়ের প্রবণতা এবং বিপরীত উভয় দৃষ্টিকোণ থেকে বাজারকে ব্যাপকভাবে বিচার করে।

কৌশল নীতি

  1. ফাস্ট (৮ পিরিয়ড), মিডিয়াম (১৪ পিরিয়ড) এবং লেট (১৬ পিরিয়ড) এর ৩টি ইএমএ লাইন এবং ফিল্টার হিসেবে ১টি লং পিরিয়ড (১০০ পিরিয়ড) ইএমএ লাইন সেট করুন।

  2. ৩টি EMA লাইনের ক্রম এবং ফিল্টারের সাথে তাদের ক্রসওভারের ভিত্তিতে দীর্ঘ এবং স্বল্প সুযোগ নির্ধারণ করুনঃ

  • যখন দ্রুত লাইন মাঝারি লাইনের উপরে অতিক্রম করে বা মাঝারি লাইন ধীর লাইনের উপরে অতিক্রম করে, এটি দীর্ঘ সংকেত হিসাবে নির্ধারিত হয়।

  • যখন মাঝারি রেখা দ্রুত রেখার নীচে অতিক্রম করে, তখন এটি দীর্ঘ সংকেত হিসাবে নির্ধারিত হয়।

  • যখন দ্রুত লাইন মাঝারি লাইনের নীচে অতিক্রম করে বা মাঝারি লাইন ধীর লাইনের নীচে অতিক্রম করে, এটি সংক্ষিপ্ত সংকেত হিসাবে নির্ধারিত হয়।

  • যখন মাঝারি রেখা দ্রুত রেখার উপরে অতিক্রম করে, তখন এটি বন্ধ সংক্ষিপ্ত সংকেত হিসাবে নির্ধারিত হয়।

  1. ট্রেন্ডের দিকনির্দেশনা এবং শক্তি নির্ধারণ করুন ৩টি EMA লাইনের ক্রসওভারের মাধ্যমে, EMA লাইনের মধ্যে ক্রসওভার এবং ফিল্টার দিয়ে বিপরীত পয়েন্ট নির্ধারণ করুন, যা প্রবণতা অনুসরণ এবং বিপরীত ট্রেডিংকে জৈবিকভাবে অন্তর্ভুক্ত করে।

সুবিধা বিশ্লেষণ

এই কৌশলটি প্রবণতা অনুসরণ এবং বিপরীত ট্রেডিং উভয় সুবিধা একত্রিত করে, যা বাজারের সুযোগগুলি ভালভাবে ধরতে পারে। প্রধান সুবিধাগুলি হলঃ

  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)



আরো