এই কৌশলটি বিভিন্ন সময়ের চলমান গড় গণনা করে, বর্তমান প্রবণতার দিকটি সনাক্ত করে এবং আরএসআই সূচকের সাথে একত্রিত হয়ে একটি ক্রয়-বিক্রয় সংকেত প্রেরণ করে। যখন স্বল্পমেয়াদী চলমান গড়ের উপরে দীর্ঘমেয়াদী চলমান গড় অতিক্রম করা হয়, তখন ট্রেন্ডটি আপ বলে মনে করে একটি ক্রয়-বিক্রয় অপারেশন করা হয়। যখন স্বল্পমেয়াদী চলমান গড়ের নীচে দীর্ঘমেয়াদী চলমান গড় অতিক্রম করা হয়, তখন ট্রেন্ডটি বিপরীত বলে মনে করে একটি বিক্রয় অপারেশন করা হয়।
১০, ২০, ৫০, ১০০ এবং ২০০ দিনের সরল চলমান গড় গণনা করুন।
১৪ দিনের আরএসআই গণনা করা হয়েছে।
যখন 10 দিনের এসএমএ 50 দিনের এসএমএ অতিক্রম করে এবং আরএসআই 30 এর চেয়ে বড় হয় এবং 20 দিনের এসএমএ 100 দিনের এসএমএর চেয়ে বেশি বা সমান হয় বা 50 দিনের এসএমএ 100 দিনের এসএমএর চেয়ে বেশি বা সমান হয় তখন ক্রয় করা হয়।
সেট করুন স্টপ লস মূল্য ক্রয় পয়েন্ট হিসাবে 1 গুণ বিয়োগ স্টপ লস শতাংশ।
নিম্নলিখিত পরিস্থিতিতে বিক্রয় করা হয়ঃ
এই কৌশলটি বাজারের প্রবণতার দিকটি নির্ধারণ করে এবং ঝুঁকি নিয়ন্ত্রণের জন্য স্টপ সেট করে। RSI সূচকটি মিথ্যা ব্রেকিংয়ের জন্য ব্যবহৃত হয়। দীর্ঘমেয়াদী এসএমএ-তে দীর্ঘমেয়াদী এসএমএ-তে ক্রয় করার সময় ক্রয় করা হয়, যা একটি প্রবণতা দেখায়, এবং স্টক ধরে রাখার সময় একটি স্টপ লাইন সেট করা হয়। ট্রেন্ড বিপরীত সংকেত বা স্টপ মূল্য ট্রিগার হওয়ার সময় স্টক বিক্রি করা হয়।
চলমান গড়ের চক্র এবং স্টপ লস পয়েন্টগুলিকে সামঞ্জস্য করার মাধ্যমে অপ্টিমাইজেশন করা যেতে পারে। অন্যান্য সূচকগুলির সাথে মিলিত হয়ে সিদ্ধান্ত গ্রহণের সঠিকতা বাড়ানোর জন্যও বিবেচনা করা যেতে পারে।
এই কৌশলটি সামগ্রিকভাবে সুস্পষ্ট, প্রবণতা নির্ধারণের জন্য একটি চলমান গড় ব্যবহার করে এবং ঝুঁকি নিয়ন্ত্রণের জন্য একটি স্টপ সেট করে। এটি একটি সাধারণ প্রবণতা অনুসরণ কৌশল। প্যারামিটার অপ্টিমাইজেশন এবং অন্যান্য বিচার সূচক যুক্ত করে, কৌশলগত প্রতিক্রিয়া এবং রিয়েল-টাইম পারফরম্যান্সকে আরও উন্নত করা যেতে পারে। তবে কোনও কৌশলই নিখুঁত হতে পারে না, বাজার পরিস্থিতি অনুসারে ক্রমাগত সমন্বয় এবং অপ্টিমাইজেশনের প্রয়োজন, বাজারের অনিশ্চয়তার সাথে মোকাবিলা করার জন্য ঝুঁকি পরিচালনার সাথে মিলিত।
/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("MA_Script", overlay=true)
// STEP 1:
// Configure trail stop level with input options (optional)
longTrailPerc=input(title="Trail Long Loss (%)", type=input.float, minval=0.0, step=0.05, defval=0.1)
// Configure backtest start date with inputs
startDate=input(title="Start Date", type=input.integer, defval=1, minval=1, maxval=31)
startMonth=input(title="Start Month", type=input.integer, defval=1, minval=1, maxval=12)
startYear=input(title="Start Year", type=input.integer, defval=2020, minval=1800, maxval=2100)
// See if this bar's time happened on/after start date
afterStartDate=(time >=timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0))
// Calculate Relative Strength Index
rsiValue=rsi(close, 14)
// Calculate moving averages
MA10_Val =sma(close, 10)
//plot(MA10_Val, color=color.yellow, linewidth=1)
MA20_Val =sma(close, 20)
plot(MA20_Val, color=color.green, linewidth=1)
MA50_Val =sma(close, 50)
plot(MA50_Val, color=color.red, linewidth=1)
MA100_Val =sma(close, 100)
plot(MA100_Val, color=color.blue, linewidth=1)
MA200_Val =sma(close, 200)
plot(MA200_Val, color=color.purple, linewidth=1)
// Calculate candlestick
C_BodyHi = max(close, open)
C_BodyLo = min(close, open)
C_Body = C_BodyHi - C_BodyLo
C_UpShadow = high - C_BodyHi
C_DnShadow = C_BodyLo - low
// STEP 2:
// Calculate entry trading conditions
buyCondition_1=crossover(MA10_Val, MA50_Val) and (rsiValue > 30) and ((MA20_Val >= MA100_Val) or (MA50_Val >= MA100_Val))
avg_price = (close + open)/2
// First Entry
if (afterStartDate)
strategy.entry(id="Entry_Trade_1", long=true, limit=avg_price, when=buyCondition_1)
plotchar(afterStartDate and crossover(MA10_Val, MA50_Val), textcolor = color.blue, text = 'MA\n')
// Determine trail stop loss prices
longStopPrice=0.0
longStopPrice :=if (strategy.position_size > 0)
stopValue=C_BodyHi * (1 - longTrailPerc)
max(stopValue, longStopPrice[1])
else
0
plot(longStopPrice, color=color.orange, linewidth=1)
bought_1=strategy.position_size[0] > strategy.position_size[1]
entry_Point_1=valuewhen(bought_1, avg_price, 0)
// STEP 3:
// Calculate exit trading conditions
sellCondition_2=crossunder(MA10_Val, MA50_Val) and (close < MA20_Val)
sellCondition_3_temp=valuewhen((C_BodyHi >= entry_Point_1*1.2), 1, 0)
sellCondition_1=(entry_Point_1*0.95 > close) and (sellCondition_3_temp != 1)
sellCondition_3=(sellCondition_3_temp == 1) and (strategy.position_size > 0) and close <= longStopPrice
plotchar((sellCondition_3 == 1) and (strategy.position_size > 0) and close <= longStopPrice, textcolor = color.red, text = 'TS\n', show_last = 11)
plotchar(crossunder(MA10_Val, MA50_Val), textcolor = color.red, text = 'MA\n')
id_val = ""
stop_val = close
condition = false
if sellCondition_1
id_val := "Exit By Stop Loss At 7%"
stop_val := entry_Point_1*0.93
condition := true
else if sellCondition_2
id_val := "Exit By Take Profit based on MA"
stop_val := close
condition := true
else if sellCondition_3
id_val := "Exit By Trailing Stop"
stop_val := longStopPrice
condition := true
// Submit exit orders for trail stop loss price
if (strategy.position_size > 0)
//strategy.exit(id="Exit By Stop Loss At 7%", from_entry="Entry_Trade_1", stop=entry_Point_1*0.93, when=sellCondition_1)
//strategy.exit(id="Exit By Take Profit based on MA", from_entry="Entry_Trade_1", stop=close, when=sellCondition_2)
strategy.exit(id=id_val, from_entry="Entry_Trade_1", stop=stop_val, when=condition)