
اس حکمت عملی کا نام “OBVious MA Strategy OBV اور MA کراس سگنل پر مبنی رجحان سے باخبر رہنے کی حکمت عملی” ہے۔ اس کا بنیادی مقصد ٹریڈنگ سگنل پیدا کرنے کے لئے OBV ((On Balance Volume) اشارے اور متحرک اوسط کے کراس کا استعمال کرنا ہے۔ OBV ایک اہم رجحان سگنل فراہم کرسکتا ہے۔ اس حکمت عملی میں OBV کو توڑنے والی حرکت پذیری اوسط کو داخلہ اور باہر نکلنے کی شرط کے طور پر استعمال کیا جاتا ہے تاکہ اس رجحان کو پکڑ سکے۔
یہ حکمت عملی OBV اور MA کراس پر مبنی ایک سادہ رجحان کی پیروی کا طریقہ پیش کرتی ہے۔ اس کی خوبی یہ ہے کہ یہ منطقی طور پر واضح ہے ، وقت پر رجحانات کو پکڑنے کے قابل ہے ، اور باہر جانے والے ایم اے کو الگ تھلگ کرکے پوزیشن پر لچکدار کنٹرول فراہم کیا جاسکتا ہے۔ اس کی خرابی یہ ہے کہ اس میں خطرے سے متعلق کنٹرول اقدامات اور سگنل کی تصدیق کے ذرائع کی کمی ہے۔ اس کے بعد رجحانات کو فلٹر کرنے ، پیرامیٹرز کو بہتر بنانے ، پوزیشن مینجمنٹ ، اور دیگر سگنلوں کو جوڑنے کے سلسلے میں بہتری لائی جاسکتی ہے ، تاکہ اسٹریٹجی کی زیادہ مستحکم کارکردگی حاصل کی جاسکے۔ یہ حکمت عملی ایک رہنمائی سگنل کے طور پر کام کرنے کے لئے موزوں ہے ، جو دیگر حکمت عملیوں کے ساتھ مل کر استعمال کی جاسکتی ہے۔
/*backtest
start: 2023-04-23 00:00:00
end: 2024-04-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ThousandX_Trader
//@version=5
strategy(title="OBVious MA Strategy [1000X]", overlay=false,
initial_capital=10000, margin_long=0.1, margin_short=0.1,
default_qty_type=strategy.percent_of_equity, default_qty_value=100,
slippage=1, commission_type=strategy.commission.percent, commission_value=0.1)
// Direction Input ///
tradeDirection = input.string("long", title="Direction", options=["long", "short"], group = "Direction Filter")
///////////////////////////////////////
// 1000X OBV MA INDICATOR //
///////////////////////////////////////
// OBV Trend Length Inputs //
long_entry_length = input(190, title="Long Entry MA Length", group = "Moving Average Settings")
long_exit_length = input(202, title="Long Exit MA Length", group = "Moving Average Settings")
short_entry_length = input(395, title="Short MA Entry Length", group = "Moving Average Settings")
short_exit_length = input(300, title="Short Exit MA Length", group = "Moving Average Settings")
// OBV Calculation
obv = ta.cum(ta.change(close) >= 0 ? volume : -volume)
// Calculate OBV Moving Averages
obv_ma_long_entry = ta.sma(obv, long_entry_length)
obv_ma_long_exit = ta.sma(obv, long_exit_length)
obv_ma_short_entry = ta.sma(obv, short_entry_length)
obv_ma_short_exit = ta.sma(obv, short_exit_length)
///////////////////////////////////////
// STRATEGY RULES //
///////////////////////////////////////
longCondition = ta.crossover(obv, obv_ma_long_entry) and tradeDirection != "short" and strategy.position_size <= 0
longExitCondition = ta.crossunder(obv, obv_ma_long_exit)
shortCondition = ta.crossunder(obv, obv_ma_short_entry) and tradeDirection != "long" and strategy.position_size >= 0
shortExitCondition = ta.crossover(obv, obv_ma_short_exit)
///////////////////////////////////////
// ORDER EXECUTION //
///////////////////////////////////////
// Close opposite trades before entering new ones
if (longCondition and strategy.position_size < 0)
strategy.close("Short Entry")
if (shortCondition and strategy.position_size > 0)
strategy.close("Long Entry")
// Enter new trades
if (longCondition)
strategy.entry("Long Entry", strategy.long)
if (shortCondition)
strategy.entry("Short Entry", strategy.short)
// Exit conditions
if (longExitCondition)
strategy.close("Long Entry")
if (shortExitCondition)
strategy.close("Short Entry")
///////////////////////////////////////
// PLOTTING //
///////////////////////////////////////
// Plot OBV line with specified color
plot(obv, title="OBV", color=color.new(#2962FF, 0), linewidth=1)
// Conditionally plot Long MAs with specified colors based on Direction Filter
plot(tradeDirection == "long" ? obv_ma_long_entry : na, title="Long Entry MA", color=color.new(color.rgb(2, 130, 228), 0), linewidth=1)
plot(tradeDirection == "long" ? obv_ma_long_exit : na, title="Long Exit MA", color=color.new(color.rgb(106, 168, 209), 0), linewidth=1)
// Conditionally plot Short MAs with specified colors based on Direction Filter
plot(tradeDirection == "short" ? obv_ma_short_entry : na, title="Short Entry MA", color=color.new(color.rgb(163, 2, 227), 0), linewidth=1)
plot(tradeDirection == "short" ? obv_ma_short_exit : na, title="Short Exit MA", color=color.new(color.rgb(192, 119, 205), 0), linewidth=1)