
এই কৌশলটি একটি গতিশীল গ্রিড ট্রেডিং সিস্টেম যা টিটিএম সূচকগুলির উপর ভিত্তি করে, উচ্চ এবং নিম্ন পয়েন্টের সূচকীয় মুভিং গড় ((EMA) গণনা করে বাজারের প্রবণতার দিকটি নির্ধারণ করে এবং গতিশীল আপডেট হওয়া বেস মূল্যের চারপাশে গ্রিড ট্রেডিং সিস্টেম স্থাপন করে। গ্রিডের দিকনির্দেশ এবং মূল্যের স্তরগুলি প্রবণতার গতিশীলতার সাথে সামঞ্জস্যপূর্ণ, যখন দামগুলি পূর্বনির্ধারিত গ্রিডের স্তর অতিক্রম করে তখন লেনদেন সম্পাদন করে, প্রতিটি লেনদেনের ঝুঁকি অ্যাকাউন্টের সুবিধার জন্য একটি নির্দিষ্ট শতাংশ।
কৌশলটির কেন্দ্রীয় যুক্তিটি টিটিএম স্ট্যাটাস গণনা, যা নিম্নলিখিত পদক্ষেপগুলি দ্বারা বাস্তবায়িত হয়ঃ
গ্রিড ট্রেডিং সিস্টেম টিটিএম অবস্থা অনুযায়ী গতিশীলভাবে সামঞ্জস্য করেঃ
এই কৌশলটি টিটিএম প্রবণতা বিচারকে গতিশীল গ্রিড ট্রেডিংয়ের সাথে একত্রিত করে একটি স্বতঃস্ফূর্ত, ঝুঁকি-নিয়ন্ত্রিত ট্রেডিং সিস্টেম অর্জন করে। গ্রিডের দিকনির্দেশ এবং মূল্যের স্তরকে গতিশীলভাবে সামঞ্জস্য করে, কৌশলটি বিভিন্ন বাজার পরিবেশের সাথে আরও ভালভাবে খাপ খাইয়ে নিতে পারে। যদিও কিছু অন্তর্নিহিত ঝুঁকি রয়েছে, তবে যুক্তিসঙ্গত প্যারামিটার সেট এবং অপ্টিমাইজেশনের ব্যবস্থা করে কৌশলটির ভাল ব্যবহারিক মূল্য এবং বিকাশের সম্ভাবনা রয়েছে।
/*backtest
start: 2024-12-04 00:00:00
end: 2024-12-11 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("TTM Grid Strategy", overlay=true)
// Input parameters
int ttmPeriod = input.int(6, minval=1, title="TTM Period")
int gridLevels = input.int(5, minval=2, title="Grid Levels")
float gridSpacing = input.float(0.01, minval=0.0001, title="Grid Spacing (%)")
// Calculate TTM State
ttmState() =>
lowMA = ta.ema(low, ttmPeriod)
highMA = ta.ema(high, ttmPeriod)
lowThird = (highMA - lowMA) / 3 + lowMA
highThird = 2 * (highMA - lowMA) / 3 + lowMA
if close > highThird
1
else if close < lowThird
0
else
-1
// State tracking variables
var float gridBasePrice = 0.0
var int gridDirection = -1
// Determine grid state
updateGridState(float currentClose, int currentState) =>
float newBasePrice = gridBasePrice
int newDirection = gridDirection
if currentState != -1 and currentState != gridDirection
newBasePrice := currentClose
newDirection := currentState
[newBasePrice, newDirection]
// Calculate grid levels
calcGridLevels(float basePrice, int direction, int levels) =>
float[] buyLevels = array.new_float(levels)
float[] sellLevels = array.new_float(levels)
for i = 1 to levels
multiplier = i * gridSpacing
if direction == 1 // Buy grid
array.set(buyLevels, i-1, basePrice * (1 - multiplier))
array.set(sellLevels, i-1, basePrice * (1 + multiplier))
else // Sell grid
array.set(buyLevels, i-1, basePrice * (1 + multiplier))
array.set(sellLevels, i-1, basePrice * (1 - multiplier))
[buyLevels, sellLevels]
// Execute grid trades
executeGridTrades(float basePrice, int direction, int levels) =>
[buyLevels, sellLevels] = calcGridLevels(basePrice, direction, levels)
for i = 0 to levels - 1
float buyLevel = array.get(buyLevels, i)
float sellLevel = array.get(sellLevels, i)
if direction == 1 // Buy grid
if low <= buyLevel
strategy.entry("GridBuy" + str.tostring(i), strategy.long, comment="Buy Level " + str.tostring(i))
if high >= sellLevel
strategy.entry("GridSell" + str.tostring(i), strategy.short, comment="Sell Level " + str.tostring(i))
else // Sell grid
if high >= buyLevel
strategy.entry("GridBuy" + str.tostring(i), strategy.long, comment="Buy Level " + str.tostring(i))
if low <= sellLevel
strategy.entry("GridSell" + str.tostring(i), strategy.short, comment="Sell Level " + str.tostring(i))
// Main strategy logic
currentState = ttmState()
[newGridBasePrice, newGridDirection] = updateGridState(close, currentState)
// Update global variables
if newGridBasePrice != gridBasePrice
gridBasePrice := newGridBasePrice
if newGridDirection != gridDirection
gridDirection := newGridDirection
// Execute grid trades
executeGridTrades(newGridBasePrice, newGridDirection, gridLevels)
// Visualization
plotColor = newGridDirection == 1 ? color.green : color.red
plot(newGridBasePrice, color=plotColor, style=plot.style_cross)