স্টপ লস এবং টেক প্রফিট ট্র্যাকিং সহ সেরা এবিসিডি প্যাটার্ন ট্রেডিং কৌশল

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

img

I. কৌশলগত ওভারভিউ

এই কৌশলটির নাম Best ABCD Pattern Strategy (with Stop Loss and Take Profit Tracking) । এটি একটি পরিমাণগত কৌশল যা একটি স্পষ্ট ABCD মূল্য প্যাটার্ন মডেলের উপর ভিত্তি করে ট্রেড করে। মূল ধারণাটি একটি সম্পূর্ণ ABCD মডেল সনাক্ত করার পরে ABCD প্যাটার্নের দিক অনুযায়ী দীর্ঘ বা সংক্ষিপ্ত যেতে হবে, এবং স্টপ লস সেট করুন এবং অবস্থানগুলি পরিচালনা করতে মুনাফা ট্র্যাকিং নিন।

২. কৌশলগত নীতি

  1. জিগজ্যাগ লাইন পেতে বলিংজার ব্যান্ড ব্যবহার করে মূল্যের চূড়ান্ত পয়েন্টগুলি চিহ্নিত করুন।

  2. ZigZag লাইনে সম্পূর্ণ ABCD প্যাটার্নগুলি সনাক্ত করুন। পয়েন্ট A, B, C এবং D নির্দিষ্ট আনুপাতিক সম্পর্ক পূরণ করতে হবে। যোগ্য ABCD প্যাটার্নগুলি সনাক্ত করার পরে দীর্ঘ বা ছোট যান।

  3. ঝুঁকি নিয়ন্ত্রণের জন্য পজিশন খোলার পরে ট্রেলিং স্টপ লস সেট করুন। নির্দিষ্ট লাভের স্তরে পৌঁছানোর পরে কিছু মুনাফা লক করতে প্রথমে স্থির স্টপ লস ব্যবহার করুন।

  4. একইভাবে, সময়মতো পর্যাপ্ত মুনাফা নিশ্চিত করতে এবং ক্ষতি এড়াতে ট্রেইলিং টেক লাভও সেট করা হয়। ট্রেইলিং টেক লাভও দুটি পর্যায়ে কাজ করেঃ প্রথমে স্থির লাভ এবং তারপরে ট্রেইলিং লাভ।

  5. যখন মূল্য ট্রেলিং স্টপ লস বা ট্রেডিং চক্র শেষ করতে মুনাফা নিতে সক্ষম হয় তখন অবস্থান বন্ধ করুন।

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

  1. জিগজ্যাগ লাইন সনাক্ত করতে বোলিংজার ব্যান্ড ব্যবহার করা ঐতিহ্যগত জিগজ্যাগের সমস্যাগুলি পুনরায় আঁকা এড়ায়, ট্রেডিং সংকেতগুলিকে আরও নির্ভরযোগ্য করে তোলে।

  2. এবিসিডি প্যাটার্ন ট্রেডিং মডেল পর্যাপ্ত ট্রেডিং সুযোগ সহ পরিপক্ক এবং স্থিতিশীল। এছাড়াও অবস্থান দিক নির্ধারণ করা সহজ।

  3. দুই ধাপের ট্রেলিং স্টপ লস এবং লাভ নেওয়ার সেটিংস ঝুঁকিগুলি আরও ভালভাবে নিয়ন্ত্রণ করতে এবং লাভ সুরক্ষিত করতে সহায়তা করে। ট্রেলিং বৈশিষ্ট্যগুলি নমনীয়তা সরবরাহ করে।

  4. স্টপ লস, লাভ গ্রহণ এবং ট্রেলিং অ্যাক্টিভেশনের শতাংশের মতো যুক্তিসঙ্গত পরামিতি নকশা নমনীয়তার জন্য কাস্টমাইজযোগ্য।

  5. এই কৌশলটি ফরেক্স, ক্রিপ্টোকারেন্সি, স্টক সূচক ইত্যাদি সহ যেকোনো ট্রেডিং যন্ত্রের জন্য ব্যবহার করা যেতে পারে।

IV. ঝুঁকি বিশ্লেষণ

  1. অন্যান্য কৌশলগুলির তুলনায় এবিসিডি প্যাটার্নগুলির জন্য ট্রেডিংয়ের সুযোগগুলি এখনও সীমিত, পর্যাপ্ত ফ্রিকোয়েন্সি নিশ্চিত করে না।

  2. ব্যাপ্তি বাজারের সময়, স্টপ লস এবং লাভ নিতে প্রায়শই ট্রিগার করা যেতে পারে। প্যারামিটারগুলিকে স্টপ লস / লাভের ব্যাপ্তি প্রসারিত করার মতো সমন্বয় প্রয়োজন।

  3. লেনদেনের যন্ত্রপাতিগুলির তরলতার প্রতি মনোযোগ দিতে হবে। অনির্বাহী পণ্যগুলির জন্য স্লিপিংয়ের বিষয়টি বিবেচনা করা দরকার।

  4. এই কৌশলটি লেনদেনের ব্যয়ের প্রতি সংবেদনশীল। কম কমিশন হার সহ ব্রোকার এবং অ্যাকাউন্টগুলি পছন্দ করা হয়।

  5. কিছু পরামিতি আরও অপ্টিমাইজ করা যেতে পারে, যেমন ট্রেলিং স্টপ লস এবং লাভ নেওয়ার জন্য অ্যাক্টিভেশন স্তর। সর্বোত্তমটি খুঁজে পেতে আরও মান পরীক্ষা করা যেতে পারে।

V. অপ্টিমাইজেশান নির্দেশাবলী

  1. অন্যান্য সূচকগুলির সাথে যুক্ত করে আরও ফিল্টার যুক্ত করা কিছু মিথ্যা সংকেত এড়ায় এবং অকার্যকর ট্রেডগুলি হ্রাস করে।

  2. তিন-বিভাগের বাজার কাঠামোর উপর বিচার যোগ করুন, শুধুমাত্র তৃতীয় বিভাগে ট্রেড গ্রহণ করুন। এটি জয়ের হার উন্নত করতে পারে।

  3. সর্বোত্তম স্তর খুঁজে পেতে প্রাথমিক মূলধন পরীক্ষা এবং অপ্টিমাইজ করুন। উভয় খুব বড় এবং খুব ছোট আকার রিটার্ন হার ক্ষতি।

  4. দীর্ঘমেয়াদে পরামিতিগুলির দৃঢ়তা পরীক্ষা করার জন্য নমুনার বাইরে ডেটা দিয়ে অগ্রগতির বিশ্লেষণ পরিচালনা করুন।

  5. অ্যাক্টিভেশন শর্ত এবং পিছনে স্টপ লস এর স্লিপ আকার অপ্টিমাইজ করা চালিয়ে যান এবং দক্ষতা উন্নত করতে মুনাফা নিন। সেটিংসের অপ্টিমাইজেশান কখনও শেষ হয় না।

৬. কৌশলগত সংক্ষিপ্তসার

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


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

// @version=4
// @author=Daveatt - BEST

// ABCD Pattern Strat

StrategyName        = "BEST ABCD Pattern Strategy (Trailing SL + TP)"
ShortStrategyName   = "BEST ABCD Strategy (Trailing)" 

strategy(title=StrategyName, shorttitle=ShortStrategyName, overlay=true )

filterBW = input(false, title="filter Bill Williams Fractals?")

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////// UTILITIES ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

//  ||-----------------------------------------------------------------------------------------------------||
//  ||---   Fractal Recognition Functions:  ---------------------------------------------------------------||
isRegularFractal(mode, _high, _low) =>
    ret = mode == 1 ? _high[4] < _high[3] and _high[3] < _high[2] and _high[2] > _high[1] and _high[1] > _high[0] :
     mode == -1 ? _low[4] > _low[3] and _low[3] > _low[2] and _low[2] < _low[1] and _low[1] < _low[0] : false

isBWFractal(mode, _high, _low) =>
    ret = mode == 1 ? _high[4] < _high[2] and _high[3] <= _high[2] and _high[2] >= _high[1] and _high[2] > _high[0] :
     mode == -1 ? _low[4] > _low[2] and _low[3] >= _low[2] and _low[2] <= _low[1] and _low[2] < _low[0] : false

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////////////////////////////// ABCD PATTERN ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

f_abcd()=>

    _r = timeframe.period
    _g = barmerge.gaps_off
    _l = barmerge.lookahead_on

    _high = high
    _low = low

    filteredtopf = filterBW ? isRegularFractal(1, _high, _low) : isBWFractal(1, _high, _low)
    filteredbotf = filterBW ? isRegularFractal(-1, _high, _low) : isBWFractal(-1, _high, _low)

    //  ||---   ZigZag:
    istop = filteredtopf
    isbot = filteredbotf
    topcount = barssince(istop)
    botcount = barssince(isbot)

    zigzag = (istop and topcount[1] > botcount[1] ? _high[2] :
     isbot and topcount[1] < botcount[1] ? _low[2] : na)

    x = valuewhen(zigzag, zigzag, 4) 
    a = valuewhen(zigzag, zigzag, 3) 
    b = valuewhen(zigzag, zigzag, 2) 
    c = valuewhen(zigzag, zigzag, 1) 
    d = valuewhen(zigzag, zigzag, 0)

    xab = (abs(b-a)/abs(x-a))
    xad = (abs(a-d)/abs(x-a))
    abc = (abs(b-c)/abs(a-b))
    bcd = (abs(c-d)/abs(b-c))

    // ABCD Part
    _abc = abc >= 0.382 and abc <= 0.886
    _bcd = bcd >= 1.13 and bcd <= 2.618
    
    _bull_abcd = _abc and _bcd and d < c 
    _bear_abcd = _abc and _bcd and d > c

    _bull   = _bull_abcd and not _bull_abcd[1]
    _bear   = _bear_abcd and not _bear_abcd[1]

    [_bull, _bear, zigzag]

lapos_x = timenow + round(change(time)*12)

[isLong, isShort, zigzag]  = f_abcd()

plot(zigzag, title= 'ZigZag', color=color.black, offset=-2)
plotshape(isLong, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), size=size.normal, text="ABCD", textcolor=color.white)
plotshape(isShort, style=shape.labeldown, location=location.abovebar, color=color.new(color.maroon, 0), size=size.normal, text="ABCD", textcolor=color.white)


long_entry_price    = valuewhen(isLong, close, 0)
short_entry_price   = valuewhen(isShort, close, 0)

sinceNUP = barssince(isLong)
sinceNDN = barssince(isShort)

buy_trend   = sinceNDN > sinceNUP
sell_trend  = sinceNDN < sinceNUP

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

entry_price  = buy_trend ? long_entry_price : short_entry_price

///////////////////////////////
//======[ Trailing STOP ]======//
///////////////////////////////

// use SL?
useSL = input(true, "Use stop Loss")
// Configure trail stop level with input
StopTrailPerc = input(title="Trail Loss (%)", type=input.float, minval=0.0, step=0.1, defval=3) * 0.01
// Will trigger the take profit trailing once reached
use_SL_Trigger = input(true, "Use stop Loss Trigger")
StopTrailTrigger   = input(2.0, "SL Trigger (%)",minval=0,step=0.5,type=input.float) * 0.01


StopLossPriceTrigger = 0.0
StopLossPriceTrigger := if (use_SL_Trigger)
    if buy_trend
        entry_price * (1 + StopTrailTrigger) 
    else
        entry_price * (1 - StopTrailTrigger)
else
    -1


var SL_Trigger_Long_HIT = false
SL_Trigger_Long_HIT := useSL and use_SL_Trigger and buy_trend and high >= StopLossPriceTrigger
 ? true : SL_Trigger_Long_HIT[1]


var SL_Trigger_Short_HIT = false
SL_Trigger_Short_HIT := useSL and use_SL_Trigger and sell_trend and low <= StopLossPriceTrigger
 ? true : SL_Trigger_Short_HIT[1]


display_long_SL_trigger     = useSL and buy_trend  and use_SL_Trigger 
 and SL_Trigger_Long_HIT == false and StopLossPriceTrigger != -1
display_short_SL_trigger    = useSL and sell_trend and use_SL_Trigger 
 and SL_Trigger_Short_HIT == false and StopLossPriceTrigger != -1
display_SL_trigger          = display_long_SL_trigger or display_short_SL_trigger

plot(display_SL_trigger ? StopLossPriceTrigger : na, title='SLPriceTrigger', transp=0, 
 color=color.maroon, style=plot.style_circles, linewidth=3)


// Determine trail stop loss prices
longStopPrice = 0.0, shortStopPrice = 0.0

longStopPrice := if useSL and buy_trend
    stopValue = low * (1 - StopTrailPerc)
    max(stopValue, longStopPrice[1])
else
    0

shortStopPrice := if useSL and sell_trend
    stopValue = high * (1 + StopTrailPerc)
    min(stopValue, shortStopPrice[1])
else
    999999

//////////////////////////////////////////////////////////////////////////////////////////
//*** STOP LOSS HIT CONDITIONS  ***//
//////////////////////////////////////////////////////////////////////////////////////////

cond_long_stop_loss_hit  = useSL and buy_trend and crossunder(low, longStopPrice[1]) 
 and (SL_Trigger_Long_HIT or use_SL_Trigger == false)
cond_short_stop_loss_hit = useSL and sell_trend and crossover(high, shortStopPrice[1]) 
 and (SL_Trigger_Short_HIT or use_SL_Trigger == false)


// Plot stop loss values for confirmation
plot(series=useSL and buy_trend and low >= longStopPrice 
 and (SL_Trigger_Long_HIT or use_SL_Trigger == false)
 ? longStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Long Trail Stop")

plot(series=useSL and sell_trend and high <= shortStopPrice 
 and (SL_Trigger_Short_HIT or use_SL_Trigger == false)
 ? shortStopPrice : na,
 color=color.fuchsia, style=plot.style_cross,
 linewidth=2, title="Short Trail Stop")


///////////////////////////////
//======[ 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 or cond_long_stop_loss_hit
close_short = cond_short_trail_tp_hit or cond_short_stop_loss_hit


strategy.entry("Long", 1, when=isLong)
strategy.close("Long", when=close_long)

strategy.entry("Short", 0,  when=isShort)
strategy.close("Short", when=close_short)

if change_trend
    SL_Trigger_Long_HIT := false
    SL_Trigger_Short_HIT := false
    TP_Trigger_Long_HIT := false
    TP_Trigger_Short_HIT := false

আরো