
এই নিবন্ধে একটি কুইন্ট ট্রেডিং কৌশল সম্পর্কে আলোচনা করা হয়েছে, যা চলমান গড়ের ক্রস নীতির উপর ভিত্তি করে। এই কৌশলটি দামের সাথে চলমান গড়ের সম্পর্কের তুলনা করে, পলিথিনের দিকনির্দেশনা নির্ধারণ করে এবং স্টপ-অফ-লস পয়েন্ট সেট করার সময় ঝুঁকি নিয়ন্ত্রণ করে। কৌশল কোডটি পাইন স্ক্রিপ্ট ব্যবহার করে লেখা হয়েছে এবং ধান ট্রেডিং প্ল্যাটফর্মের এপিআইকে সংহত করেছে, যা কৌশল সংকেতগুলির স্বয়ংক্রিয় ট্রেডিংয়ের অনুমতি দেয়।
এই কৌশলটির কেন্দ্রবিন্দু হল চলমান গড়, একটি নির্দিষ্ট সময়ের মধ্যে বন্ধের দামের সরল চলমান গড় গণনা করে একটি প্রবণতা বিচার করার ভিত্তি হিসাবে। যখন দাম গড় লাইন অতিক্রম করে তখন একটি মাল্টিসিগন্যাল উত্পন্ন হয় এবং নীচে একটি খালি সিগন্যাল উত্পন্ন হয়। একই সাথে, এক্সট্রিম ফাংশন ব্যবহার করে ফিল্টারিং ক্রমাগত পুনরাবৃত্তি সংকেত, সংকেত গুণমান উন্নত করে। কৌশলটি বর্তমান পজিশনের দিকনির্দেশ এবং মূল্যের সাথে গড় লাইনের অবস্থানের সম্পর্ক অনুসারে উপযুক্ত স্টপ লস মূল্য সেট করে, প্রতিটি লেনদেনের ঝুঁকি এবং লাভ নিয়ন্ত্রণ করে।
মুভিং এভারেজ ক্রসিং একটি সহজ এবং সহজেই ব্যবহারযোগ্য ট্রেন্ড ট্র্যাকিং পদ্ধতি যা বাজারের মাঝারি এবং দীর্ঘমেয়াদী প্রবণতাকে কার্যকরভাবে ক্যাপচার করতে পারে। যুক্তিসঙ্গতভাবে প্যারামিটার সেট করে, কৌশলটি প্রবণতার পরিস্থিতিতে স্থিতিশীল উপার্জন করতে পারে। স্টপ লস সেটিংটি প্রত্যাহার নিয়ন্ত্রণ করতে এবং ঝুঁকি-লাভের অনুপাত বাড়ানোর পক্ষে সহায়ক। কৌশল কোড লজিক পরিষ্কার, ফাংশন মডিউলাইজেশন, পাঠযোগ্যতা এবং এক্সটেনসিবিলিটি ব্যবহার করে। তদতিরিক্ত, কৌশলটি ধনএপিআই প্ল্যাটফর্মকে সংহত করে, সিগন্যালের অটোমেটেড অর্ডার ট্রেডিং উপলব্ধ করে, কার্যকরকরণের দক্ষতা বাড়ায়।
মুভিং এভারেজ মূলত একটি পিছিয়ে পড়া সূচক, যখন বাজার ঘুরিয়ে দেয়, তখন সংকেত বিলম্বিত হতে পারে, যার ফলে সেরা ট্রেডিং সময়টি মিস করা বা মিথ্যা সংকেত তৈরি করা যায়। প্যারামিটার সেটিং অনুপযুক্তভাবে কৌশলটির কার্যকারিতা প্রভাবিত করতে পারে, বিভিন্ন বাজার বৈশিষ্ট্য এবং চক্র অনুসারে অপ্টিমাইজ করা প্রয়োজন। ফিক্সড শতাংশ স্টপ লস বাজার ওঠানামা পরিবর্তনের সাথে খাপ খাইয়ে নিতে অক্ষম হতে পারে, এবং প্যারামিটার সেটিং অনুপযুক্তভাবে ক্ষতির ঝুঁকি রয়েছে।
চলমান গড় ক্রসিং কৌশলটি একটি সহজ ব্যবহারিক পরিমাণযুক্ত ট্রেডিং কৌশল যা প্রবণতা অনুসরণ এবং স্টপ লস নিয়ন্ত্রণের মাধ্যমে প্রবণতার পরিস্থিতিতে মুনাফা অর্জন করতে পারে। তবে কৌশলটির নিজস্ব কিছু সীমাবদ্ধতা রয়েছে, বাজারের বৈশিষ্ট্য এবং ঝুঁকির পছন্দ অনুসারে অপ্টিমাইজেশন এবং উন্নতি করা প্রয়োজন। বাস্তব প্রয়োগে, কঠোর শৃঙ্খলা এবং ঝুঁকি নিয়ন্ত্রণে মনোযোগ দেওয়া দরকার। কৌশল প্রোগ্রামিং পিন স্ক্রিপ্টের মতো পেশাদার ভাষার সাহায্যে ট্রেডিং প্ল্যাটফর্ম এপিআইকে একীভূত করতে পারে, কৌশলটির স্বয়ংক্রিয় সম্পাদন সম্ভব।
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © syam-mohan-vs @ T7 - wwww.t7wealth.com www.t7trade.com
//This is an educational code done to describe the fundemantals of pine scritpting language and integration with Indian discount broker Dhan. This strategy is not tested or recommended for live trading.
//@version=5
strategy("Pine & Dhan - Moving Average Crossover Strategy", overlay=true)
//Remove excess signals
exrem(condition1, condition2) =>
temp = false
temp := na(temp[1]) ? false : not temp[1] and condition1 ? true : temp[1] and condition2 ? false : temp[1]
ta.change(temp) == true ? true : false
// Define MA period
ma_period = input(20, title = "MA Length")
// Define target and stop loss levels
target_percentage = input.float(title="Target Profit (%)", defval=2.0)
stop_loss_percentage = input.float(title="Stop Loss (%)", defval=1.0)
// Calculate the MA
ma = ta.sma(close, ma_period)
// Entry conditions
long_entry = close >= ma
short_entry = close < ma
// Calculate target and stop loss prices
target_price = long_entry ? strategy.position_avg_price + (close * (target_percentage / 100)) : strategy.position_avg_price - (close * (target_percentage / 100))
stop_loss_price = short_entry ? strategy.position_avg_price + (close * (stop_loss_percentage/ 100)) : strategy.position_avg_price - (close * (stop_loss_percentage / 100))
long_entry := exrem(long_entry,short_entry)
short_entry := exrem(short_entry,long_entry)
// Plot the MA
plot(ma, color=color.blue, linewidth=2, title="MA")
// Plot the entry and exit signals
plotshape(long_entry, style=shape.arrowup, color=color.green, size=size.small,location = location.belowbar)
plotshape(short_entry, style=shape.arrowdown, color=color.red, size=size.small,location = location.abovebar)
//Find absolute value of positon size to exit position properly
size = math.abs(strategy.position_size)
//Replace these four JSON strings with those generated from user Dhan account
long_msg = '{"secret":"C0B2u","alertType":"multi_leg_order","order_legs":[{"transactionType":"B","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"NIFTY1!","instrument":"FUT","productType":"I","sort_order":"1","price":"0"}]}'
long_exit_msg = '{"secret":"C0B2u","alertType":"multi_leg_order","order_legs":[{"transactionType":"S","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"NIFTY1!","instrument":"FUT","productType":"M","sort_order":"1","price":"0"}]}'
short_msg = '{"secret":"C0B2u","alertType":"multi_leg_order","order_legs":[{"transactionType":"S","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"NIFTY1!","instrument":"FUT","productType":"M","sort_order":"1","price":"0"}]}'
short_exit_msg = '{"secret":"C0B2u","alertType":"multi_leg_order","order_legs":[{"transactionType":"B","orderType":"MKT","quantity":"1","exchange":"NSE","symbol":"NIFTY1!","instrument":"FUT","productType":"M","sort_order":"1","price":"0"}]}'
// Submit orders based on signals
if(strategy.position_size == 0)
if long_entry
strategy.order("Long", strategy.long,alert_message=long_msg)
if short_entry
strategy.order("Short", strategy.short,alert_message=short_msg)
if(strategy.position_size > 0)
if(short_entry)
strategy.order("Short", strategy.short, qty = size, alert_message=short_msg)
else
strategy.exit("Long Exit", from_entry="Long", qty = size, stop=stop_loss_price, limit= target_price, alert_message=long_exit_msg)
if(strategy.position_size < 0)
if(long_entry)
strategy.order("Long", strategy.long, qty = size, alert_message=long_msg)
else
strategy.exit("Short Exit", from_entry="Short", qty = size, stop=stop_loss_price, limit= target_price, alert_message=short_exit_msg)