
এই কৌশলটি একটি উচ্চতর ফিউচার ট্রেডিং সিস্টেম যা একাধিক প্রযুক্তিগত শর্ত এবং উচ্চতর সময়সীমার বিশ্লেষণের সাথে মিলিত হয় যাতে উচ্চ সম্ভাব্যতার ব্যবসায়ের সুযোগগুলি সনাক্ত করা যায়। এই কৌশলটি একাধিক শর্তাদির সমন্বয় ভিত্তিক পদ্ধতি গ্রহণ করে, যার জন্য একাধিক প্রযুক্তিগত শর্তাদি একসাথে পূরণ করা প্রয়োজন যাতে ট্রেডিংয়ে প্রবেশ করা যায়। এটি বেশ কয়েকটি উন্নত প্রযুক্তিগত ধারণাগুলিকে সংহত করে, যার মধ্যে রয়েছে ন্যায্য মূল্যের ফাঁক (এফভিজি), অর্ডার ব্লক (অর্ডার ব্লক), তরলতা স্ক্যান (লিউডিটি স্যুইপস) এবং কাঠামোগত ব্রেকআউট (বিওএস) সংকেত, এবং একই সাথে বিভিন্ন সময়কালীন সময়কালের নির্দেশক ব্যবহার করে ট্রেন্ডের দিকনির্দেশ নিশ্চিত করে।
এই কৌশলটির কেন্দ্রবিন্দু হল বিভিন্ন প্রযুক্তিগত বিশ্লেষণ পদ্ধতির সংমিশ্রণ যা নিশ্চিত করে যে একাধিক সূচক একই সাথে সংকেত দেয় তখনই ট্রেডিংয়ে প্রবেশ করা হয়। বিশেষত, কৌশলটিতে নিম্নলিখিত কয়েকটি মূল উপাদান রয়েছেঃ
কৌশলটি কেবলমাত্র তখনই একটি প্রবেশের সংকেত তৈরি করে যখন কমপক্ষে দুটি মৌলিক শর্ত থাকে (একটি ডিফল্ট মোডে একটি) এবং কাঠামোগত বিরতি সংকেত এবং একই সাথে উচ্চতর সময়কালের প্রবণতাগুলির সাথে সামঞ্জস্যপূর্ণ।
ঝুঁকি ব্যবস্থাপনার দিক থেকে, এই কৌশলটি ATR ব্যবহার করে (অর্ধ-সত্যিকারের তরঙ্গদৈর্ঘ্য) গতিশীল স্টপ অবস্থান সেট করতে, স্টপ দূরত্বটি সাধারণত এটিআর মানের 1.5 গুণ বেশি। এই পদ্ধতিটি উচ্চ তরঙ্গদৈর্ঘ্যের সময় স্টপ দূরত্ব বাড়ায় এবং নিম্ন তরঙ্গদৈর্ঘ্যের সময় দূরত্ব হ্রাস করে, যা স্টপকে আরও স্মার্ট করে তোলে।
মুনাফা শেষ হলে, এই কৌশলটি ব্যাচেলিং মুনাফা পদ্ধতি ব্যবহার করে, যখন ঝুঁকি সমতুল্য ((1R) মুনাফা অর্জন করা হয় তখন 50% অবস্থান লাভ করে, এবং অবশিষ্ট অবস্থানের স্টপ লসকে ব্যানার পজিশনে স্থানান্তরিত করে, যার ফলে ঝুঁকিমুক্ত ব্যবসায়ের সুযোগ তৈরি হয়। এছাড়াও, একটি সময় ভিত্তিক প্রস্থান ব্যবস্থা রয়েছে, যদি নির্দিষ্ট সময়ের মধ্যে (ডিফল্ট 30 মিনিট) ট্রেডটি লাভজনক দিকে না যায় তবে এটি স্বয়ংক্রিয়ভাবে বন্ধ হয়ে যায়।
এছাড়া, এই কৌশলটিতে অ্যাকাউন্ট ম্যানেজমেন্টের বৈশিষ্ট্য রয়েছে, যখন অ্যাকাউন্টের মুনাফা পূর্বনির্ধারিত লক্ষ্যমাত্রা (৩০০০ ডলার) বা ট্রিগার স্টপ লস (২৫০০ ডলার মুনাফার পরে অ্যাকাউন্ট ট্র্যাকিং শুরু করে) পৌঁছে যায় তখন স্বয়ংক্রিয়ভাবে সমস্ত অবস্থান থেকে বেরিয়ে আসে।
কোডের গভীর বিশ্লেষণের পরে, আমরা নিম্নলিখিত সুস্পষ্ট সুবিধাগুলির কথা বলতে পারিঃ
এই কৌশলটি ভালভাবে পরিকল্পিত হলেও, এর মধ্যে কিছু সম্ভাব্য ঝুঁকি রয়েছে, যেমনঃ
কোড বিশ্লেষণের উপর ভিত্তি করে, নিম্নলিখিত কয়েকটি সম্ভাব্য অপ্টিমাইজেশান দিক রয়েছেঃ
এটি একটি সুনির্দিষ্টভাবে পরিকল্পিত মাল্টি-ইনডিকেটর ফিউচার ট্রেডিং কৌশল যা বিভিন্ন উন্নত প্রযুক্তিগত বিশ্লেষণের ধারণাগুলিকে একত্রিত করে এবং এটির একটি নিখুঁত ঝুঁকি ব্যবস্থাপনা এবং তহবিল পরিচালনার বৈশিষ্ট্য রয়েছে। এটি একাধিক শর্তের সম্মতি এবং উচ্চ সময়কালের প্রবণতা নিশ্চিতকরণের মাধ্যমে মিথ্যা সংকেত হ্রাস করে এবং এটিআর-ভিত্তিক গতিশীল স্টপ লস এবং ব্যাচ লভ্যাংশ কৌশল ব্যবহার করে ঝুঁকি-রিটার্ন অনুপাতকে অনুকূল করে তোলে।
এই কৌশলটির প্রধান সুবিধা হল এর বহু স্তরের নিশ্চিতকরণ ব্যবস্থা এবং বুদ্ধিমান ঝুঁকি ব্যবস্থাপনা, যা এটিকে কম ঝুঁকি বজায় রেখে উচ্চ সম্ভাব্যতার ব্যবসায়ের সুযোগগুলি ধরতে সক্ষম করে। যাইহোক, কৌশলটির জটিলতা এছাড়াও প্যারামিটার অপ্টিমাইজেশন এবং বাজারের অভিযোজনযোগ্যতার চ্যালেঞ্জ নিয়ে আসে, যা ক্রমাগত পর্যবেক্ষণ এবং নিয়মিত সমন্বয় দ্বারা কার্যকরতা বজায় রাখার প্রয়োজন।
সুপারিশকৃত অপ্টিমাইজেশান ব্যবস্থা বাস্তবায়নের মাধ্যমে, বিশেষ করে বাজারের অবস্থার সাথে মানিয়ে নেওয়ার ক্ষমতা বৃদ্ধি এবং ঝুঁকি ব্যবস্থাপনা সিস্টেমের উন্নতি, এই কৌশলটি বিভিন্ন বাজারের পরিবেশে স্থিতিশীল পারফরম্যান্স বজায় রাখার সম্ভাবনা রয়েছে। সামগ্রিকভাবে, এটি একটি উন্নত কৌশল যা অভিজ্ঞ ব্যবসায়ীদের ব্যবহারের জন্য উপযুক্ত এবং যথাযথ পর্যবেক্ষণ এবং সমন্বয় সহ ট্রেডিং সিস্টেমের একটি শক্তিশালী হাতিয়ার হতে পারে।
/*backtest
start: 2024-04-02 00:00:00
end: 2025-04-01 00:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
// @version=5
strategy("NQ Futures Trading Strategy", overlay=true, initial_capital=50000, default_qty_type=strategy.cash, default_qty_value=5000)
// ==========================================
// Parameters
// ==========================================
// Account Parameters
accountSize = 50000
profitGoal = 3000
trailingThreshold = 2500
stopsTrailing = 52650
// Trading Parameters
atrLength = input.int(14, "ATR Period", minval=1)
atrMultiplier = input.float(1.5, "ATR Multiplier for SL", minval=0.5, maxval=3.0, step=0.1)
timeoutPeriod = input.int(30, "Exit after X minutes if trade doesn't move favorably", minval=5, maxval=120)
// FVG (Fair Value Gap) Parameters
fvgLength = input.int(5, "FVG Look-back Period", minval=2, maxval=20)
fvgThreshold = input.float(0.1, "FVG Size Threshold (%)", minval=0.05, maxval=1.0, step=0.05) * 0.01
// Order Block Parameters
obLength = input.int(5, "Order Block Look-back Period", minval=2, maxval=20)
obThreshold = input.float(0.1, "Order Block Size Threshold (%)", minval=0.05, maxval=1.0, step=0.05) * 0.01
// Liquidity Sweep Parameters
sweepLength = input.int(5, "Liquidity Sweep Look-back Period", minval=2, maxval=20)
sweepThreshold = input.float(0.05, "Sweep Size Threshold (%)", minval=0.01, maxval=0.5, step=0.01) * 0.01
// Break of Structure Parameters
bosLength = input.int(5, "BOS Look-back Period", minval=2, maxval=20)
bosThreshold = input.float(0.05, "BOS Size Threshold (%)", minval=0.01, maxval=0.5, step=0.01) * 0.01
// Debug Mode
debugMode = input.bool(false, "Debug Mode (more signals)")
// Higher Timeframe Trend Parameters
htfPeriod1 = input.timeframe("15", "First Higher Timeframe")
htfPeriod2 = input.timeframe("60", "Second Higher Timeframe")
// ==========================================
// Indicators & Calculations
// ==========================================
// ATR Calculation
atr = ta.atr(atrLength)
// Higher Timeframe EMAs for Trend Determination
htf1_ema20 = request.security(syminfo.tickerid, htfPeriod1, ta.ema(close, 20), barmerge.gaps_off, barmerge.lookahead_off)
htf1_ema50 = request.security(syminfo.tickerid, htfPeriod1, ta.ema(close, 50), barmerge.gaps_off, barmerge.lookahead_off)
htf2_ema20 = request.security(syminfo.tickerid, htfPeriod2, ta.ema(close, 20), barmerge.gaps_off, barmerge.lookahead_off)
htf2_ema50 = request.security(syminfo.tickerid, htfPeriod2, ta.ema(close, 50), barmerge.gaps_off, barmerge.lookahead_off)
// Higher Timeframe Trend
htf1_bullish = htf1_ema20 > htf1_ema50
htf1_bearish = htf1_ema20 < htf1_ema50
htf2_bullish = htf2_ema20 > htf2_ema50
htf2_bearish = htf2_ema20 < htf2_ema50
// ==========================================
// Entry Conditions
// ==========================================
// 1. Fair Value Gap (FVG)
bullishFVG = false
bearishFVG = false
for i = 1 to fvgLength
if low[i] > high[i+2] and (low[i] - high[i+2]) / high[i+2] > fvgThreshold
bullishFVG := true
if high[i] < low[i+2] and (low[i+2] - high[i]) / high[i] > fvgThreshold
bearishFVG := true
// 2. Inverse Fair Value Gap
inverseBullishFVG = false
inverseBearishFVG = false
for i = 1 to fvgLength
if high[i+1] < low[i+2] and close[i] > open[i] and close[i] > high[i+1]
inverseBullishFVG := true
if low[i+1] > high[i+2] and close[i] < open[i] and close[i] < low[i+1]
inverseBearishFVG := true
// 3. Order Block / Breaker Block
bullishOrderBlock = false
bearishOrderBlock = false
for i = 1 to obLength
if close[i+1] < open[i+1] and (open[i+1] - close[i+1]) / close[i+1] > obThreshold and close[i] > open[i]
bullishOrderBlock := true
if close[i+1] > open[i+1] and (close[i+1] - open[i+1]) / open[i+1] > obThreshold and close[i] < open[i]
bearishOrderBlock := true
// 4. Liquidity Sweep
bullishSweep = false
bearishSweep = false
lowestLow = ta.lowest(low, sweepLength+1)
highestHigh = ta.highest(high, sweepLength+1)
if low[1] < lowestLow[2] and close > open
bullishSweep := true
if high[1] > highestHigh[2] and close < open
bearishSweep := true
// 5. Break of Structure (BOS)
bullishBOS = false
bearishBOS = false
prevHigh = high[2]
prevLow = low[2]
if high > prevHigh and low[1] < low[2]
bullishBOS := true
if low < prevLow and high[1] > high[2]
bearishBOS := true
// Simpler version for debug mode
if debugMode
bullishBOS := close > open and close > close[1]
bearishBOS := close < open and close < close[1]
// ==========================================
// Signal Generation
// ==========================================
// Count valid entry conditions
bullishConditions = bullishFVG ? 1 : 0
bullishConditions := bullishConditions + (inverseBullishFVG ? 1 : 0)
bullishConditions := bullishConditions + (bullishOrderBlock ? 1 : 0)
bullishConditions := bullishConditions + (bullishSweep ? 1 : 0)
bearishConditions = bearishFVG ? 1 : 0
bearishConditions := bearishConditions + (inverseBearishFVG ? 1 : 0)
bearishConditions := bearishConditions + (bearishOrderBlock ? 1 : 0)
bearishConditions := bearishConditions + (bearishSweep ? 1 : 0)
// Entry signals (need at least 2 conditions + BOS confirmation)
// In debug mode, require only 1 condition
minConditions = debugMode ? 1 : 2
longSignal = bullishConditions >= minConditions and bullishBOS and (htf1_bullish or htf2_bullish)
shortSignal = bearishConditions >= minConditions and bearishBOS and (htf1_bearish or htf2_bearish)
// Debug mode override for testing
if debugMode
longSignal := longSignal or (bullishBOS and htf1_bullish)
shortSignal := shortSignal or (bearishBOS and htf1_bearish)
// ==========================================
// Risk Management
// ==========================================
// Calculate dynamic stop loss based on ATR
longStopDistance = atr * atrMultiplier
shortStopDistance = atr * atrMultiplier
// Default fixed values for testing
if debugMode
longStopDistance := close * 0.01 // 1% stop
shortStopDistance := close * 0.01 // 1% stop
// Calculate position size based on risk
nqPointValue = 20 // Each point is $20 for NQ
longPositionSize = math.floor(2000 / (longStopDistance * nqPointValue))
shortPositionSize = math.floor(2000 / (shortStopDistance * nqPointValue))
// Ensure at least 1 contract
longPositionSize := math.max(longPositionSize, 1)
shortPositionSize := math.max(shortPositionSize, 1)
// Variables to track entry time
var int entryTime = 0
var float equityCurve = accountSize
// ==========================================
// Strategy Execution
// ==========================================
// Make sure we don't get multiple signals on the same bar
var longEnteredThisBar = false
var shortEnteredThisBar = false
longEnteredThisBar := false
shortEnteredThisBar := false
// Entry conditions
if longSignal and not longEnteredThisBar and strategy.position_size <= 0
strategy.close_all()
strategy.entry("Long", strategy.long, qty=longPositionSize)
longEnteredThisBar := true
entryTime := time
if shortSignal and not shortEnteredThisBar and strategy.position_size >= 0
strategy.close_all()
strategy.entry("Short", strategy.short, qty=shortPositionSize)
shortEnteredThisBar := true
entryTime := time
// Take profit and stop loss orders
if strategy.position_size > 0
stopPrice = strategy.position_avg_price - longStopDistance
takeProfitPrice1 = strategy.position_avg_price + longStopDistance
strategy.exit("Long TP1", "Long", qty_percent=50, limit=takeProfitPrice1, stop=stopPrice)
// Move stop to breakeven after 1R move
if high >= takeProfitPrice1
strategy.exit("Long BE", "Long", stop=strategy.position_avg_price)
if strategy.position_size < 0
stopPrice = strategy.position_avg_price + shortStopDistance
takeProfitPrice1 = strategy.position_avg_price - shortStopDistance
strategy.exit("Short TP1", "Short", qty_percent=50, limit=takeProfitPrice1, stop=stopPrice)
// Move stop to breakeven after 1R move
if low <= takeProfitPrice1
strategy.exit("Short BE", "Short", stop=strategy.position_avg_price)
// Time-based exit
if strategy.position_size != 0
currentTime = time
if (currentTime - entryTime) >= timeoutPeriod * 60000 // Convert minutes to milliseconds
strategy.close_all(comment="Time Exit")
// ==========================================
// Trailing Stop for Account Management
// ==========================================
// Update equity curve
equityCurve := strategy.equity
// Check if profit target is reached or trailing stop is hit
if strategy.equity >= accountSize + profitGoal
strategy.close_all(comment="Profit Goal")
if strategy.equity >= accountSize + trailingThreshold
trailingStop = math.max(accountSize, strategy.equity - trailingThreshold)
if strategy.equity <= trailingStop
strategy.close_all(comment="Trailing Stop")
// Stop trailing if account reaches the stop trailing threshold
if strategy.equity >= stopsTrailing
strategy.close_all(comment="Stop Trailing")
// ==========================================
// Plotting
// ==========================================
// Plot entry conditions
plotshape(longSignal, title="Long Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(shortSignal, title="Short Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// Plot current position
bgcolor(strategy.position_size > 0 ? color.new(color.green, 90) : strategy.position_size < 0 ? color.new(color.red, 90) : na)
// Alert conditions
alertcondition(longSignal, title="Long Entry Signal", message="NQ LONG ENTRY: {{ticker}}, Price: {{close}}")
alertcondition(shortSignal, title="Short Entry Signal", message="NQ SHORT ENTRY: {{ticker}}, Price: {{close}}")
alertcondition(strategy.position_size > 0 and high >= strategy.position_avg_price + longStopDistance, title="Long Take Profit", message="NQ LONG TP: {{ticker}}, Price: {{close}}")
alertcondition(strategy.position_size < 0 and low <= strategy.position_avg_price - shortStopDistance, title="Short Take Profit", message="NQ SHORT TP: {{ticker}}, Price: {{close}}")
alertcondition(strategy.position_size > 0 and low <= strategy.position_avg_price - longStopDistance, title="Long Stop Loss", message="NQ LONG SL: {{ticker}}, Price: {{close}}")
alertcondition(strategy.position_size < 0 and high >= strategy.position_avg_price + shortStopDistance, title="Short Stop Loss", message="NQ SHORT SL: {{ticker}}, Price: {{close}}")