
এটি একটি ট্রেডিং কৌশল যা একটি বছরের সময়কালে উচ্চ এবং নিম্ন বিশ্লেষণের উপর ভিত্তি করে একটি এসএমএ (একটি সরল চলমান গড়) এর উপর ভিত্তি করে। এই কৌশলটি সম্ভাব্য ট্রেডিং সংকেতগুলি সনাক্ত করার জন্য একটি চলমান গড় গণনা করে এবং এটিকে ঐতিহাসিক উচ্চ এবং নিম্নের সাথে তুলনা করে। কৌশলটি দীর্ঘমেয়াদী পশ্চাদপসরণ সময়কাল ব্যবহার করে, যা মাঝারি এবং দীর্ঘমেয়াদী প্রবণতা ট্রেডিংয়ের জন্য উপযুক্ত।
কৌশলটির মূল যুক্তি নিম্নলিখিত মূল পদক্ষেপগুলির উপর ভিত্তি করে:
এটি লেনদেনের পরিমাণ বিশ্লেষণের উপর ভিত্তি করে একটি মাঝারি এবং দীর্ঘমেয়াদী প্রবণতা ট্র্যাকিং কৌশল, বাজার প্রবণতা ক্যাপচার করার জন্য ক্রয় ও বিক্রয় পরিমাণের পার্থক্যের historicalতিহাসিক উচ্চ এবং নিম্নের বিশ্লেষণ করে। কৌশলটি যুক্তিসঙ্গতভাবে ডিজাইন করা হয়েছে, ঝুঁকি নিয়ন্ত্রণ করা হয়েছে, তবে বাজারের পরিবেশের সাথে অভিযোজনযোগ্যতা এবং প্যারামিটার অপ্টিমাইজেশনের বিষয়ে মনোযোগ দেওয়া দরকার। প্রস্তাবিত অপ্টিমাইজেশনের দিকনির্দেশের মাধ্যমে কৌশলটি আরও বাড়ানোর জায়গা রয়েছে।
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Delta SMA 1-Year High/Low Strategy", overlay = false, margin_long = 100, margin_short = 100)
// Inputs
delta_sma_length = input.int(14, title="Delta SMA Length", minval=1) // SMA length for Delta
lookback_days = 365 // Lookback period fixed to 1 year
// Function to calculate buy and sell volume
buy_volume = close > open ? volume : na
sell_volume = close < open ? volume : na
// Calculate the Delta
delta = nz(buy_volume, 0) - nz(sell_volume, 0)
// Calculate Delta SMA
delta_sma = ta.sma(delta, delta_sma_length)
// Lookback period in bars (1 bar = 1 day)
desired_lookback_bars = lookback_days
// Ensure lookback doesn't exceed available historical data
max_lookback_bars = math.min(desired_lookback_bars, 365) // Cap at 365 bars (1 year)
// Calculate Delta SMA low and high within the valid lookback period
delta_sma_low_1yr = ta.lowest(delta_sma, max_lookback_bars)
delta_sma_high_1yr = ta.highest(delta_sma, max_lookback_bars)
// Define thresholds for buy and sell conditions
very_low_threshold = delta_sma_low_1yr * 0.7
above_70_threshold = delta_sma_high_1yr * 0.9
below_60_threshold = delta_sma_high_1yr * 0.5
// Track if `delta_sma` was very low and persist the state
var bool was_very_low = false
if delta_sma < very_low_threshold
was_very_low := true
if ta.crossover(delta_sma, 10000)
was_very_low := false // Reset after crossing 0
// Track if `delta_sma` crossed above 70% of the high
var bool crossed_above_70 = false
if ta.crossover(delta_sma, above_70_threshold)
crossed_above_70 := true
if delta_sma < below_60_threshold*0.5 and crossed_above_70
crossed_above_70 := false // Reset after triggering sell
// Buy condition: `delta_sma` was very low and now crosses 0
buy_condition = was_very_low and ta.crossover(delta_sma, 0)
// Sell condition: `delta_sma` crossed above 70% of the high and now drops below 60%
sell_condition = crossed_above_70 and delta_sma < below_60_threshold
// Place a long order when buy condition is met
if buy_condition
strategy.entry("Buy", strategy.long)
// Place a short order when sell condition is met
if sell_condition
strategy.close("Buy")
// Plot Delta SMA and thresholds for visualization
plot(delta_sma, color=color.blue, title="Delta SMA")
plot(very_low_threshold, color=color.green, title="70% of 1-Year Delta SMA Low", linewidth=2)
plot(above_70_threshold, color=color.purple, title="70% of 1-Year Delta SMA High", linewidth=2)
plot(below_60_threshold, color=color.red, title="60% of 1-Year Delta SMA High", linewidth=2)
// Optional: Plot Buy and Sell signals on the chart
//plotshape(series=buy_condition, title="Buy Signal", location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text="BUY")
//plotshape(series=sell_condition, title="Sell Signal", location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text="SELL")