মূল্য পরিবর্তনের হার এবং চলমান গড়ের উপর ভিত্তি করে পরিমাণগত কৌশল


সৃষ্টির তারিখ: 2023-12-11 11:18:56 অবশেষে সংশোধন করুন: 2023-12-11 11:18:56
অনুলিপি: 1 ক্লিকের সংখ্যা: 727
1
ফোকাস
1621
অনুসারী

মূল্য পরিবর্তনের হার এবং চলমান গড়ের উপর ভিত্তি করে পরিমাণগত কৌশল

ওভারভিউ

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

কৌশল নীতি

কেনাকাটা লজিক

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

যুক্তি বিক্রয়

  1. মূল্য পরিবর্তনের হার ROC গণনা করুন এবং বিক্রয়ের জন্য একটি মূল্য হ্রাস লাইন সেট করুন।
  2. যখন দামের সীমা অতিক্রান্ত হয়, তখন মূল্যের সীমা অতিক্রম করা হয়, এই পয়েন্টটি রেকর্ড করা হয় এবং একটি সীমাবদ্ধ লাইন বিক্রয় শুরু হয়।
  3. সীমাবদ্ধ লাইন বিক্রি করুন ইনপুট প্যারামিটার অনুযায়ী স্থায়িত্ব সেট করুন, মেয়াদ শেষ হওয়ার পরে বন্ধ করুন।
  4. যখন দাম বাড়তে থাকে এবং সীমাবদ্ধ লাইন বিক্রি করে, তখন সমস্ত মাল্টি-হেড পজিশন বন্ধ করে দেওয়া হয়।

ঝুঁকি নিয়ন্ত্রণ

কৌশল বিল্ট-ইন স্টপ লস এবং স্টপ স্টপ ফাংশন, কাস্টমাইজযোগ্য প্যারামিটার, রিয়েল-টাইম পজিশনের ঝুঁকি নিয়ন্ত্রণ করে।

আমানত ব্যবস্থা

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

সামর্থ্য বিশ্লেষণ

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

ঝুঁকি ও সমাধান

  1. বাজার যখন তীব্রভাবে অস্থির হয়, তখন কৌশলটি অতিরিক্ত পজিশন খোলার জন্য হতে পারে। সমাধানটি হল যুক্তিসঙ্গতভাবে পজিশন বাড়ানোর পরামিতি সেট করা এবং পজিশনের মোট সংখ্যা নিয়ন্ত্রণ করা।
  2. দামের অস্থিরতার প্রবণতা অজানা হলে, স্টপ-অফ বা স্টপ-অফ দামগুলি প্রায়শই ট্রিগার করা যেতে পারে। স্টপ-অফ স্টপ-অফের মাত্রা যথাযথভাবে প্রশস্ত করা যেতে পারে, বা এই বৈশিষ্ট্যটি বন্ধ করা যেতে পারে।

অপ্টিমাইজেশান পরামর্শ

  1. অন্য সূচকগুলির সাথে মিলিত হয়ে প্রবেশের সময়গুলি ফিল্টার করুন। উদাহরণস্বরূপ, গড়ের সাথে মিলিত হওয়া, কেবলমাত্র যখন দাম গড়ের নীচে পড়ে তখনই আরওসি সূচকটি গ্রহণ করা হয়।
  2. অপ্টিমাইজ করা হয়, নির্দিষ্ট শর্ত পূরণ হলেই পজিশন বাড়ানো শুরু করা হয়। যেমন, যদি দাম আবারও একটি নির্দিষ্ট মাত্রা অতিক্রম করে তবে পজিশন বাড়ানো অব্যাহত থাকে।
  3. বিভিন্ন জাতের প্যারামিটার সেটিংগুলি ব্যাপকভাবে পরিবর্তিত হয় এবং সর্বোত্তম প্যারামিটার সমন্বয় অর্জনের জন্য পর্যাপ্ত ফিডব্যাক এবং সিমুলেশন প্রয়োজন।
  4. স্টপ-অফ-লস (Stop-Off Loss) সেট করতে পারেন, বাজার ওঠানামা অনুযায়ী বিভিন্ন স্টপ-অফ-লস (Stop-Off Loss) সেট করতে পারেন।

সারসংক্ষেপ

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

কৌশল সোর্স কোড
/*backtest
start: 2022-12-04 00:00:00
end: 2023-12-10 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/
// @version=4
// © A3Sh

// Rate of price change / Price averaging strategy //
// When the price drops to a specified percentage, a Long Entry Threshold is setup.
// The Long Entry Threshold is only active for a specified number of bars and will de-activate when not crossed. 
// When the price drops further and crosses the Entry Threshold with a minimum of a specified percentage, a Long Position is entered. 
// The same reverse logic used to close the Long Position.
// Stop loss and take profit are active by default. With proper tweaking of the settings it is possible to de-activate SL and TP.

// The strategy is inspired by the following strategies:
// Price Change Scalping Strategy developed by Prosum Solutions, https://www.tradingview.com/script/ue7Uc3sN-Price-Change-Scalping-Strategy-v1-0-0/
// Scalping Dips On Trend Strategy developed by Coinrule, https://www.tradingview.com/script/iHHO0PJA-Scalping-Dips-On-Trend-by-Coinrule/

strategy(title = "ROC_PA_Strategy_@A3Sh", overlay = true )

// Portfolio & Leverage Example
// credit: @RafaelZioni, https://www.tradingview.com/script/xGk5K4DE-BTC-15-min/
ge(value, precision) => round(value * (pow(10, precision))) / pow(10, precision)

port     = input(25, group = "Risk", title = "Portfolio Percentage", type = input.float, step = 0.1, minval = 0.1, maxval = 200)
leverage = input(1,  group = "Risk", title = "Leverage", minval = 1, maxval = 100)
mm       = input(5,  group = "Risk", title = "Broker Maintenance Margin Percentage", type = input.float, step = 0.1, minval = 0.1, maxval = 200)

c = ge((strategy.equity * leverage / open) * (port  / 100), 4)

// Take Profit
tpa = input(true, type = input.bool,  title = "Take Profit", group = "Risk", inline = "Take Profit")
tpp = input(5.6,    type = input.float, title = "Percentage" , group = "Risk", step = 0.1, minval = 0.1, inline = "Take Profit")
tp  = strategy.position_avg_price + (strategy.position_avg_price / 100 * tpp)
plot (tpa and strategy.position_size > 0 ? tp : na, color = color.gray, title = "take profit", style= plot.style_linebr, linewidth = 1)

// Stop Loss
sla = input(true, type = input.bool, title = "Stop Lossss ", group = "Risk", inline = "Stop Loss")
slp = input(2.5,   type = input.float, title = "Percentage",   group = "Risk", step = 0.1, minval = 0.1, inline = "Stop Loss")
sl  = strategy.position_avg_price - (strategy.position_avg_price / 100 *slp)
plot (sla and strategy.position_size > 0 ? sl : na, color = color.red, title = "stopp loss", style= plot.style_linebr, linewidth = 1)

stopLoss = sla ? sl : na

// Long position entry layers. Percentage from the entry price of the the first long
ps2 = input(2, group = "Price Averaging Layers", title = "2nd Layer Long Entry %", step = 0.1)
ps3 = input(5, group = "Price Averaging Layers", title = "3rd Layer Long Entry %", step = 0.1)
ps4 = input(9, group = "Price Averaging Layers", title = "4th Layer Long Entry %", step = 0.1)

// ROC_Trigger Logic to open Long Position
rocLookBack  = input(3,   group = "ROC Logic to OPEN Long Entry", title="Rate of Change bar lookback")
rocThreshold = input(0.5, group = "ROC Logic to OPEN Long Entry", title="ROC Threshold % to Setup Long Entry", step = 0.1)
entryLimit   = input(0.5, group = "ROC Logic to OPEN Long Entry", title="Price Drop Threshold % to OPEN Long Entry", step = 0.1)
entryTime    = input(3,   group = "ROC Logic to OPEN Long Entry", title="Duration of Long Entry Threshold Line in bars")
minLimit     = input(0.8, group = "ROC Logic to OPEN Long Entry", title="Min % of Price Drop to OPEN Long Entry", step = 0.1)

//ROC calculation based to the price level of previous X bars
roc = close[rocLookBack]  - (close / 100 * rocThreshold)
plot (roc, color = color.gray, title = "roc threshold", linewidth = 1 , transp = 20)

rocT1      = open > roc and close < roc ? 1 : 0 // When the price CROSSES the Entry Limit
rocT2      = (open < roc) and (close < roc) ? 1 : 0 // When the price is BELOW the Entry Limit
rocTrigger = rocT1 or rocT2

// Condition for Setting Up a Long Entry Thershold Line
rocCrossed    = false
var SetUpLong = false

if rocTrigger and not SetUpLong

    rocCrossed := true
    SetUpLong  := true

// Defining the Value of the Long Entry Thershold
condforValue = rocCrossed and (open - low) / (open / 100) > 0 or (open < roc and close < roc) ? low - (close / 100 * entryLimit) : roc - (close / 100 * entryLimit)
openValue    = valuewhen (rocCrossed, condforValue, 0)

// Defining the length of the Long Entry Thershold in bars, specified with an input parameter
sincerocCrossed = barssince (rocCrossed)
plotLineOpen    = (sincerocCrossed <= entryTime) ? openValue : na
endLineOpen     = sincerocCrossed == entryTime  ? 1 : 0

// Set the conditions back to false when the Entry Limit Threshold Line ends after specied number of bars
if endLineOpen and SetUpLong
    
    rocCrossed := false
    SetUpLong  := false    

// Set minimum percentage of price drop to open a Long Position.
minThres = (open - close) / (open / 100) > minLimit ? 1 : 0

// Open Long Trigger
openLong = crossunder (close, plotLineOpen) and strategy.position_size == 0 and minThres

plot (strategy.position_size == 0 ? plotLineOpen : na, title = "Long Entry Threshold", color= color.yellow, style= plot.style_linebr, linewidth = 2)

// Show vertical dashed line when long condition is triggered 
// credit: @midtownsk8rguy, https://www.tradingview.com/script/EmTkvfCM-vline-Function-for-Pine-Script-v4-0/
vline(BarIndex, Color, LineStyle, LineWidth) => 
    return = line.new(BarIndex, low - tr, BarIndex, high + tr, xloc.bar_index, extend.both, Color, LineStyle, LineWidth) 
// if (openLong)
//     vline(bar_index, color.blue, line.style_dashed, 1)

// ROC_Trigger Logic to close Long Position
rocLookBackL    = input(3,   group = "ROC Logic to CLOSE Long Entry", title = "Rate of Change bar lookback")
entryThresholdL = input(0.8, group = "ROC Logic to CLOSE Long Entry", title = "ROC Threshold % to Setup Close Threshold", step = 0.1) // Percentage from close price
entryLimit_CL   = input(1.7, group = "ROC Logic to CLOSE Long Entry", title = "Price Rise Threshold % to CLOSE Long Entry", step = 0.1) // Percentage from roc threshold
entryTime_CL    = input(3,   group = "ROC Logic to CLOSE Long Entry", title = "Duration of Entry Limit in bars")

roc_CL = close[rocLookBackL]  + (close/100 *entryThresholdL)
//plot(rocL, color=color.gray, linewidth=1, transp=20)

rocT1_CL = open < roc_CL and close > roc_CL ? 1 : 0
rocT2_CL = (open > roc_CL) and (close > roc_CL)  ? 1 : 0 
rocTrigger_CL = rocT1_CL or rocT2_CL

// Condition for Setting Up a Long CLOSE Thershold Line
rocCrossed_CL  = false

var SetUpClose = false

if rocTrigger_CL and not SetUpClose
    // The trigger for condA occurs and the last condition set was condB.
    rocCrossed_CL := true
    SetUpClose    := true

// Defining the Value of the Long CLOSE Thershold
condforValue_CL= rocCrossed_CL and (high - open) / (open / 100) > 0 or (open > roc_CL and close > roc_CL) ? high + (close / 100 * entryLimit_CL) : roc_CL + (close / 100 * entryLimit_CL)
closeValue = valuewhen (rocCrossed_CL, condforValue_CL, 0)

// Defining the length of the Long CLOSE Thershold in bars, specified with an input parameter
sincerocCrossed_CL = barssince(rocCrossed_CL)
plotLineClose = (sincerocCrossed_CL <= entryTime_CL) ? closeValue : na
endLineClose = (sincerocCrossed_CL == entryTime_CL)  ? 1 : 0

// Set the conditions back to false when the CLOSE Limit Threshold Line ends after specied number of bars
if endLineClose and SetUpClose

    rocCrossed_CL := false
    SetUpClose := false    

plot(strategy.position_size > 0 ? plotLineClose : na, color = color.white, title = "Close Long Threshold", style = plot.style_linebr, linewidth = 2)

// ROC Close + Take Profit combined
closeCondition = close < tp ? plotLineClose : tpa ? tp : plotLineClose

// Store values to create and plot the different PA layers
long1 = valuewhen(openLong, close, 0)
long2 = valuewhen(openLong, close - (close / 100 * ps2), 0)
long3 = valuewhen(openLong, close - (close / 100 * ps3), 0)
long4 = valuewhen(openLong, close - (close / 100 * ps4), 0)

eps1 = 0.00
eps1 := na(eps1[1]) ? na : eps1[1]

eps2 = 0.00
eps2 := na(eps2[1]) ? na : eps2[1]

eps3 = 0.00
eps3 := na(eps3[1]) ? na : eps3[1]

eps4 = 0.00
eps4 := na(eps4[1]) ? na : eps4[1]

plot (strategy.position_size > 0 ? eps1 : na, title = "Long 1 Layer", style = plot.style_linebr)
plot (strategy.position_size > 0 ? eps2 : na, title = "Long 2 Layer", style = plot.style_linebr)
plot (strategy.position_size > 0 ? eps3 : na, title = "Long 3 Layer", style = plot.style_linebr)
plot (strategy.position_size > 0 ? eps4 : na, title = "Long 4 Layer", style = plot.style_linebr)

// Ener Long Positions
if (openLong and strategy.opentrades == 0) 
    eps1 := long1
    eps2 := long2
    eps3 := long3
    eps4 := long4
    strategy.entry("Long1", strategy.long, c, comment = "a=binance2 e=binance s=bnbusdt b=buy q=20% t=market")

if (strategy.opentrades == 1)
    strategy.entry("Long2", strategy.long, c, limit = eps2, comment = "a=binance2 e=binance s=bnbusdt b=buy q=25% t=market")

if (strategy.opentrades == 2)
    strategy.entry("Long3", strategy.long, c, limit = eps3, comment = "a=binance2 e=binance s=bnbusdt b=buy q=33.3% t=market")

if (strategy.opentrades == 3)
    strategy.entry("Long4", strategy.long, c, limit = eps4, comment = "a=binance2 e=binance s=bnbusdt b=buy q=50% t=market")

// Setup Limit Close / Take Profit / Stop Loss order 
strategy.exit("Exit", stop = stopLoss, limit = closeCondition, when =(rocTrigger_CL and strategy.position_size > 0), comment= "a=binance2 e=binance s=bnbusdt b=sell q=100% t=market")

// Make sure that all open limit orders are canceled after exiting all the positions 
longClose = strategy.position_size[1] > 0 and strategy.position_size == 0 ? 1 : 0   

if longClose
    strategy.cancel_all()