পরিবর্তনের হার পরিমাণগত কৌশল

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

img

সারসংক্ষেপ

এই কৌশলটি বাজারের দিকনির্দেশ নির্ধারণ এবং ট্রেডিং সংকেত তৈরি করতে রেট অফ চেঞ্জ (আরওসি) সূচক ব্যবহার করে। কৌশলটির মূল ধারণাটি দীর্ঘমেয়াদী প্রবণতা অনুসরণ করা এবং বৃহত্তর ঝুঁকি গ্রহণ করে বাজারের চেয়ে ভাল পারফর্ম করা।

কৌশলগত যুক্তি

প্রবেশের নিয়ম

  • যদি ROC> 0 হয় তবে লং যান; যদি ROC < 0 হয় তবে শর্ট যান। বাজারের দিকনির্দেশ বিচার করতে ROC এর ইতিবাচক / নেতিবাচক ব্যবহার করুন।
  • ভোল্টেবিলিটি ফিল্টার করার জন্য, শুধুমাত্র যদি ROC পরপর দুই দিন একই দিকে থাকে তবে ট্রেডিং সিগন্যাল ইস্যু করুন।

হারানো বন্ধ করুন

৬% স্টপ লস সেট করা আছে। যখন স্টপ লস ট্রিগার করা হয়, পজিশন রিভার্স করা হয়। এটি নির্দেশ করে যে আমরা বাজারের ভুল দিকে হতে পারি তাই আমরা অবিলম্বে বেরিয়ে যাই।

এন্টি-বুল মেকানিজম

যদি ROC 200 এর উপরে যায় তবে বাজারটি একটি বুদবুদ হিসাবে বিবেচিত হয়। যখন ROC বুদবুদ অঞ্চলের নীচে ফিরে আসে, তখন সংকেতটি সক্রিয় হয়। বুদবুদটি কমপক্ষে 1 সপ্তাহের জন্য স্থায়ী হয়।

অর্থ ব্যবস্থাপনা

ফিক্সড পজিশন সাইজিং + ইনক্রিমেন্টাল পদ্ধতি ব্যবহার করুন। প্রতি $400 লাভ / ক্ষতির জন্য $200 দ্বারা অবস্থান বৃদ্ধি / হ্রাস করুন। এটি আমাদের পিরামিড মুনাফা করতে দেয় কিন্তু ড্রডাউনও বৃদ্ধি করে।

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

এই কৌশলটির সুবিধাঃ

  1. দীর্ঘমেয়াদী ইতিবাচক রিটার্ন প্রদানের সম্ভাবনা রয়েছে এমন দর্শন অনুসরণ করে।
  2. ঝুঁকি নিয়ন্ত্রণ এবং স্বল্পমেয়াদী অস্থিরতা কমাতে স্টপ লস ব্যবহার করুন।
  3. এন্টি-বুল মেশিন শীর্ষগুলিকে তাড়া করা এড়ায়।
  4. ফিক্সড পজিশন + ইনক্রিমেন্টাল পদ্ধতি আপট্রেন্ডে এক্সপোনেন্সিয়াল বৃদ্ধি সৃষ্টি করে।

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

কিছু ঝুঁকিও রয়েছেঃ

  1. ROC ইন্ডিকেটর whipsaws প্রবণ যা মিথ্যা সংকেত উৎপন্ন। ফিল্টারিং জন্য অন্যান্য সূচক সঙ্গে একত্রিত বিবেচনা।
  2. ট্রেডিং খরচ বিবেচনা করা হয় না যা প্রকৃত আয় হ্রাস করে।
  3. এন্টি-বুল প্যারামিটার মিটিংও প্রবণতা মিস করে।
  4. ক্রমবর্ধমান আকার হারাতে হারাতে বৃদ্ধি পায়।

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

কৌশলটি অপ্টিমাইজ করার কিছু উপায়ঃ

  1. ফিল্টার সিগন্যালগুলিতে অন্যান্য সূচক যোগ করুন, যেমন এমএ, ভোল্টেবিলিটি ইত্যাদি।
  2. ভাল বুদবুদ সনাক্তকরণের জন্য এন্টি-বুল প্যারামিটার অপ্টিমাইজ করুন।
  3. ঝুঁকি/উপার্জনের ভারসাম্য বাড়ানোর জন্য স্থির পজিশন এবং ইনক্রিমেন্টাল রেসিওগুলিকে সামঞ্জস্য করা।
  4. বড় ক্ষতি হলে স্বয়ংক্রিয় স্টপ লস যোগ করুন।
  5. ট্রেডিং খরচ বিবেচনা করুন এবং সেই অনুযায়ী প্রবেশের নিয়ম নির্ধারণ করুন।

সিদ্ধান্ত

সংক্ষেপে, এটি একটি দীর্ঘমেয়াদী প্রবণতা যা ROC সূচকের চারপাশে কেন্দ্রীভূত কৌশল অনুসরণ করে। এটি উচ্চতর ঝুঁকি গ্রহণ করে আলফা উত্পন্ন করার লক্ষ্য রাখে। আরও অপ্টিমাইজেশানগুলি এর সম্ভাব্যতা উন্নত করতে পারে। কীটি উপযুক্ত ঝুঁকি সহনশীলতা খুঁজে পাওয়া।


/*backtest
start: 2022-12-05 00:00:00
end: 2023-12-11 00:00:00
period: 1d
basePeriod: 1h
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/
// © gsanson66


//This strategy use the Rate of Change (ROC) of the closing price to send enter signal. 
//@version=5
strategy("RATE OF CHANGE BACKTESTING", shorttitle="ROC BACKTESTING", overlay=false, precision=3, initial_capital=1000, default_qty_type=strategy.cash, default_qty_value=950, commission_type=strategy.commission.percent, commission_value=0.18)


//--------------------------------FUNCTIONS-----------------------------------//

//@function Displays text passed to `txt` when called.
debugLabel(txt, color, loc) =>
    label.new(bar_index, loc, text = txt, color=color, style = label.style_label_lower_right, textcolor = color.black, size = size.small)

//@function which looks if the close date of the current bar falls inside the date range
inBacktestPeriod(start, end) => (time >= start) and (time <= end)


//----------------------------------USER INPUTS----------------------------------//

//Technical parameters
rocLength = input.int(defval=365, minval=0, title='ROC Length', group="Technical parameters")
bubbleValue = input.int(defval=200, minval=0, title="ROC Bubble signal", group="Technical parameters")
//Risk management
stopLossInput = input.float(defval=10, minval=0, title="Stop Loss (in %)", group="Risk Management")
//Money management
fixedRatio = input.int(defval=400, minval=1, title="Fixed Ratio Value ($)", group="Money Management")
increasingOrderAmount = input.int(defval=200, minval=1, title="Increasing Order Amount ($)", group="Money Management")
//Backtesting period
startDate = input(title="Start Date", defval=timestamp("1 Jan 2017 00:00:00"), group="Backtesting Period")
endDate = input(title="End Date", defval=timestamp("1 July 2024 00:00:00"), group="Backtesting Period")


//-------------------------------------VARIABLES INITIALISATION-----------------------------//

roc = (close/close[rocLength] - 1)*100
midlineConst = 0
var bool inBubble = na
bool shortBubbleCondition = na
equity = strategy.equity - strategy.openprofit
strategy.initial_capital = 50000
var float capital_ref = strategy.initial_capital
var float cashOrder = strategy.initial_capital * 0.95
bool inRange = na


//------------------------------CHECKING SOME CONDITIONS ON EACH SCRIPT EXECUTION-------------------------------//

//Checking if the date belong to the range
inRange := true

//Checking if we are in a bubble
if roc > bubbleValue and not inBubble
    inBubble := true

//Checking if the bubble is over
if roc < 0 and inBubble
    inBubble := false

//Checking the condition to short the bubble : The ROC must be above the bubblevalue for at least 1 week
if roc[1]>bubbleValue and roc[2]>bubbleValue and roc[3]>bubbleValue and roc[4]>bubbleValue and roc[5]>bubbleValue and roc[6]>bubbleValue and roc[7]>bubbleValue
    shortBubbleCondition := true

//Checking performances of the strategy
if equity > capital_ref + fixedRatio
    spread = (equity - capital_ref)/fixedRatio
    nb_level = int(spread)
    increasingOrder = nb_level * increasingOrderAmount
    cashOrder := cashOrder + increasingOrder
    capital_ref := capital_ref + nb_level*fixedRatio
if equity < capital_ref - fixedRatio
    spread = (capital_ref - equity)/fixedRatio
    nb_level = int(spread)
    decreasingOrder = nb_level * increasingOrderAmount
    cashOrder := cashOrder - decreasingOrder
    capital_ref := capital_ref - nb_level*fixedRatio

//Checking if we close all trades in case where we exit the backtesting period
if strategy.position_size!=0 and not inRange
    debugLabel("END OF BACKTESTING PERIOD : we close the trade", color=color.rgb(116, 116, 116), loc=roc)
    strategy.close_all()


//-------------------------------LONG/SHORT CONDITION-------------------------------//

//Long condition
//We reduce noise by taking signal only if the last roc value is in the same side as the current one
if (strategy.position_size<=0 and ta.crossover(roc, midlineConst)[1] and roc>0 and inRange)
    //If we were in a short position, we pass to a long position
    qty = cashOrder/close
    strategy.entry("Long", strategy.long, qty)
    stopLoss = close * (1-stopLossInput/100)
    strategy.exit("Long Risk Managment", "Long", stop=stopLoss)

//Short condition
//We take a short position if we are in a bubble and roc is decreasing
if (strategy.position_size>=0 and ta.crossunder(roc, midlineConst)[1] and roc<0 and inRange) or 
     (strategy.position_size>=0 and inBubble and ta.crossunder(roc, bubbleValue) and shortBubbleCondition and inRange)
    //If we were in a long position, we pass to a short position
    qty = cashOrder/close
    strategy.entry("Short", strategy.short, qty)
    stopLoss = close * (1+stopLossInput/100)
    strategy.exit("Short Risk Managment", "Short", stop=stopLoss)


//--------------------------------RISK MANAGEMENT--------------------------------------//

//We manage our risk and change the sense of position after SL is hitten
if strategy.position_size == 0 and inRange
    //We find the direction of the last trade
    id = strategy.closedtrades.entry_id(strategy.closedtrades-1)
    if id == "Short"
        qty = cashOrder/close
        strategy.entry("Long", strategy.long, qty)
        stopLoss = close * (1-stopLossInput/100)
        strategy.exit("Long Risk Managment", "Long", stop=stopLoss)
    else if id =="Long"
        qty = cashOrder/close
        strategy.entry("Short", strategy.short, qty)
        stopLoss = close * (1+stopLossInput/100)
        strategy.exit("Short Risk Managment", "Short", stop=stopLoss)


//---------------------------------PLOTTING ELEMENTS---------------------------------------//

//Plotting of ROC
rocPlot = plot(roc, "ROC", color=#7E57C2)
midline = hline(0, "ROC Middle Band", color=color.new(#787B86, 25))
midLinePlot = plot(0, color = na, editable = false, display = display.none)
fill(rocPlot, midLinePlot, 40, 0, top_color = strategy.position_size>0 ? color.new(color.green, 0) : strategy.position_size<0 ? color.new(color.red, 0) : na, bottom_color = strategy.position_size>0 ? color.new(color.green, 100) : strategy.position_size<0 ? color.new(color.red, 100) : na,  title = "Positive area")
fill(rocPlot, midLinePlot, 0,  -40,  top_color = strategy.position_size<0 ? color.new(color.red, 100) : strategy.position_size>0 ? color.new(color.green, 100) : na, bottom_color = strategy.position_size<0 ? color.new(color.red, 0) : strategy.position_size>0 ? color.new(color.green, 0) : na, title = "Negative area")


আরো