
এই কৌশলটি হেইকিন আশি গ্রাফের উপর ভিত্তি করে একটি প্রবণতা ট্র্যাকিং সিস্টেম। উচ্চতর সময়কালের সময় হিসাব করে এবং কম সময়কালের ট্রেডিং সিদ্ধান্তে এটি প্রয়োগ করে, এটি কার্যকরভাবে বাজারের গোলমালের প্রভাবকে হ্রাস করে। কৌশলটি নমনীয় ট্রেডিং দিকনির্দেশের বিকল্প সরবরাহ করে, কেবলমাত্র আরও, কেবলমাত্র শূন্য বা দ্বি-মুখী বাণিজ্য করতে পারে এবং স্টপ লস স্টপ ফাংশনটি সংহত করে, সম্পূর্ণ স্বয়ংক্রিয় ট্রেডিং প্রক্রিয়া অর্জন করে।
কৌশলটির কেন্দ্রীয় যুক্তি হ’ল হাইকিন আশি চার্টটি উচ্চ সময়কালের সময়কালে প্রবণতা সনাক্ত করার জন্য মসৃণতার বৈশিষ্ট্য ব্যবহার করে। হেইকিন আশি চার্টটি খোলার এবং বন্ধের দামের উপর চলমান গড় গণনা করে কার্যকরভাবে বাজার শব্দটি ফিল্টার করতে এবং মূল প্রবণতাকে তুলে ধরতে সক্ষম। যখন সবুজ বাগানটি উত্থানের প্রবণতা দেখায়, তখন সিস্টেমটি একাধিক মোডে অবস্থান নেয়; যখন লাল বাগানটি হ্রাসের প্রবণতা দেখায়, তখন সিস্টেমটি খালি মোডে অবস্থান নেয়। কৌশলটিতে শতাংশ-ভিত্তিক স্টপ লস এবং স্টপ মেশিন রয়েছে যা ঝুঁকি নিয়ন্ত্রণে সহায়তা করে এবং মুনাফা লক করে।
এই কৌশলটি বহু-চক্রীয় হেইকিন আশি সূচকের মসৃণ বৈশিষ্ট্য দ্বারা কার্যকরভাবে বাজার প্রবণতা ক্যাপচার করে এবং একটি উন্নত ঝুঁকি ব্যবস্থাপনা ব্যবস্থার মাধ্যমে প্রত্যাহার নিয়ন্ত্রণ করে। কৌশলটির নমনীয়তা এবং স্কেলযোগ্যতা এটিকে ভাল ব্যবহারিক মূল্য দেয়, ক্রমাগত অপ্টিমাইজেশন এবং উন্নতির মাধ্যমে বিভিন্ন বাজার পরিবেশের সাথে খাপ খাইয়ে নিতে সক্ষম। যদিও কিছু ঝুঁকি রয়েছে, যুক্তিসঙ্গত প্যারামিটার সেট এবং ঝুঁকি পরিচালনার মাধ্যমে স্থিতিশীল ব্যবসায়ের পারফরম্যান্স অর্জন করা যায়।
/*backtest
start: 2024-11-10 00:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Optimized Heikin Ashi Strategy with Buy/Sell Options", overlay=true)
// User inputs for customizing backtest settings
startDate = input(timestamp("2023-01-01 00:00"), title="Backtest Start Date", tooltip="Start date for the backtest")
endDate = input(timestamp("2024-01-01 00:00"), title="Backtest End Date", tooltip="End date for the backtest")
// Input for Heikin Ashi timeframe optimization
ha_timeframe = input.timeframe("D", title="Heikin Ashi Timeframe", tooltip="Choose the timeframe for Heikin Ashi candles")
// Inputs for optimizing stop loss and take profit
use_stop_loss = input.bool(true, title="Use Stop Loss")
stop_loss_percent = input.float(2.0, title="Stop Loss (%)", minval=0.0, tooltip="Set stop loss percentage")
use_take_profit = input.bool(true, title="Use Take Profit")
take_profit_percent = input.float(4.0, title="Take Profit (%)", minval=0.0, tooltip="Set take profit percentage")
// Input to choose Buy or Sell
trade_type = input.string("Buy Only", options=["Buy Only", "Sell Only"], title="Trade Type", tooltip="Choose whether to only Buy or only Sell")
// Heikin Ashi calculation on a user-defined timeframe
ha_open = request.security(syminfo.tickerid, ha_timeframe, ta.sma(open, 2), barmerge.gaps_off, barmerge.lookahead_on)
ha_close = request.security(syminfo.tickerid, ha_timeframe, ta.sma(close, 2), barmerge.gaps_off, barmerge.lookahead_on)
ha_high = request.security(syminfo.tickerid, ha_timeframe, math.max(high, close), barmerge.gaps_off, barmerge.lookahead_on)
ha_low = request.security(syminfo.tickerid, ha_timeframe, math.min(low, open), barmerge.gaps_off, barmerge.lookahead_on)
// Heikin Ashi candle colors
ha_bullish = ha_close > ha_open // Green candle
ha_bearish = ha_close < ha_open // Red candle
// Backtest period filter
inDateRange = true
// Trading logic depending on user input
if (inDateRange) // Ensures trades happen only in the selected period
if (trade_type == "Buy Only") // Buy when green, Sell when red
if (ha_bullish and strategy.position_size <= 0) // Buy on green candle only if no position is open
strategy.entry("Buy", strategy.long)
if (ha_bearish and strategy.position_size > 0) // Sell on red candle (close the long position)
strategy.close("Buy")
if (trade_type == "Sell Only") // Sell when red, Exit sell when green
if (ha_bearish and strategy.position_size >= 0) // Sell on red candle only if no position is open
strategy.entry("Sell", strategy.short)
if (ha_bullish and strategy.position_size < 0) // Exit the sell position on green candle
strategy.close("Sell")
// Add Stop Loss and Take Profit conditions if enabled
if (use_stop_loss)
strategy.exit("Stop Loss", from_entry="Buy", stop=strategy.position_avg_price * (1 - stop_loss_percent / 100))
if (use_take_profit)
strategy.exit("Take Profit", from_entry="Buy", limit=strategy.position_avg_price * (1 + take_profit_percent / 100))
// Plot Heikin Ashi candles on the chart
plotcandle(ha_open, ha_high, ha_low, ha_close, color=ha_bullish ? color.green : color.red)