
এই কৌশলটি একটি মাল্টি-ডিমেনশনাল ট্রেডিং সিস্টেম যা জিগজ্যাগ এবং উইলিয়ামসকে একত্রিত করে। এই কৌশলটি গুরুত্বপূর্ণ ব্যাপ্তি উচ্চতা এবং নিম্নতা সনাক্ত করে এবং উইলিয়ামসকে ব্যবহার করে যখন বাজারটি ওভারবই বা ওভারসোল অবস্থায় পৌঁছে যায়। এই সংমিশ্রণটি কেবল বাজারের প্রধান প্রবণতা ঘুরিয়ে দেওয়ার পয়েন্টগুলিই ক্যাপচার করতে পারে না, তবে গতিশীলতা নিশ্চিতকরণের মাধ্যমে লেনদেনের নির্ভুলতা বাড়িয়ে তুলতে পারে।
এই কৌশলটির মূল যুক্তি দুটি প্রধান উপাদান নিয়ে গঠিতঃ
কৌশলগত লেনদেনের নিয়মাবলী নিম্নরূপঃ
এটি একটি সম্পূর্ণ ট্রেডিং সিস্টেম যা প্রবণতা ট্র্যাকিং এবং গতিশীল ট্রেডিংয়ের সমন্বয় করে। একাধিক প্রযুক্তিগত সূচকগুলির সমন্বয়মূলক কার্যকারিতার মাধ্যমে, উচ্চতর হার বজায় রাখার সময় কার্যকরভাবে ঝুঁকি নিয়ন্ত্রণ করা যায়। যদিও কিছুটা পিছিয়ে থাকা সত্ত্বেও, যুক্তিসঙ্গত প্যারামিটার অপ্টিমাইজেশন এবং ঝুঁকি পরিচালনার মাধ্যমে স্থিতিশীল ট্রেডিং কার্যকারিতা অর্জন করা যায়। এই কৌশলটি মাঝারি এবং দীর্ঘমেয়াদী প্রবণতার জন্য বিশেষভাবে উপযুক্ত, যখন বাজারে সুস্পষ্ট দিকনির্দেশের সুযোগ উপস্থিত হয় তখন আরও ভাল কাজ করে।
/*backtest
start: 2024-02-18 00:00:00
end: 2025-02-15 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Zig Zag + Williams %R Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=300)
// ====================
// === Parameters
// ====================
// Zig Zag parameters
zigzag_depth = input.int(5, title="Zig Zag Depth", minval=1)
zigzag_deviation = input.float(1.0, title="Zig Zag Deviation (%)", minval=0.1, step=0.1)
// Williams %R parameters
williams_length = input.int(14, title="Williams %R Length", minval=1)
williams_overbought = input.int(-20, title="Williams %R Overbought", minval=-100, maxval=0)
williams_oversold = input.int(-80, title="Williams %R Oversold", minval=-100, maxval=0)
// ====================
// === Zig Zag Calculation
// ====================
// Initialize variables
var float last_pivot_high = na
var float last_pivot_low = na
var int zz_dir = 0 // 1 for uptrend, -1 for downtrend
// Calculate pivots
pivot_high = ta.pivothigh(high, zigzag_depth, zigzag_depth)
pivot_low = ta.pivotlow(low, zigzag_depth, zigzag_depth)
// Update Zig Zag direction and last pivots with deviation
if (not na(pivot_high))
if (zz_dir != -1) // Only change to downtrend if not already in downtrend
if (na(last_pivot_high) or (high[zigzag_depth] > last_pivot_high * (1 + zigzag_deviation / 100)))
last_pivot_high := high[zigzag_depth]
zz_dir := -1
label.new(bar_index[zigzag_depth], high[zigzag_depth], text="PH", color=color.red, style=label.style_label_down)
if (not na(pivot_low))
if (zz_dir != 1) // Only change to uptrend if not already in uptrend
if (na(last_pivot_low) or (low[zigzag_depth] < last_pivot_low * (1 - zigzag_deviation / 100)))
last_pivot_low := low[zigzag_depth]
zz_dir := 1
label.new(bar_index[zigzag_depth], low[zigzag_depth], text="PL", color=color.green, style=label.style_label_up)
// ====================
// === Williams %R Calculation
// ====================
// Calculate Williams %R manually
highest_high = ta.highest(high, williams_length)
lowest_low = ta.lowest(low, williams_length)
williams_r = (highest_high - close) / (highest_high - lowest_low) * -100
// ====================
// === Trade Conditions
// ====================
// Assign crossover and crossunder results to variables
crossover_williams = ta.crossover(williams_r, williams_oversold)
crossunder_williams = ta.crossunder(williams_r, williams_overbought)
// Define trade conditions
longCondition = (zz_dir == 1) and crossover_williams
shortCondition = (zz_dir == -1) and crossunder_williams
// ====================
// === Trading
// ====================
// Enter Long
if (longCondition)
strategy.entry("Long", strategy.long)
label.new(bar_index, low, text="BUY", color=color.green, style=label.style_label_up)
// Enter Short
if (shortCondition)
strategy.entry("Short", strategy.short)
label.new(bar_index, high, text="SELL", color=color.red, style=label.style_label_down)
// ====================
// === Visualization
// ====================
// Plot Zig Zag pivot shapes
plotshape(series=(not na(pivot_high) and high[zigzag_depth] == last_pivot_high), title="Swing High", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="ZZ High")
plotshape(series=(not na(pivot_low) and low[zigzag_depth] == last_pivot_low), title="Swing Low", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="ZZ Low")
// Plot Williams %R
hline(williams_overbought, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(williams_oversold, "Oversold", color=color.green, linestyle=hline.style_dashed)
plot(williams_r, title="Williams %R", color=color.blue)
// Debug plot for Zig Zag direction
plot(zz_dir, title="Zig Zag Direction", color=color.orange, linewidth=2)
// ====================
// === Risk Management
// ====================
// Risk parameters
stop_loss_perc = input.float(1.0, title="Stop Loss (%)") / 100
take_profit_perc = input.float(2.0, title="Take Profit (%)") / 100
// Stop Loss and Take Profit for Long
if (longCondition)
strategy.exit("Long Exit", from_entry="Long", stop=close * (1 - stop_loss_perc), limit=close * (1 + take_profit_perc))
// Stop Loss and Take Profit for Short
if (shortCondition)
strategy.exit("Short Exit", from_entry="Short", stop=close * (1 + stop_loss_perc), limit=close * (1 - take_profit_perc))