
یہ حکمت عملی ایک متحرک ڈی سی اے حکمت عملی ہے جو تجارت کے حجم اور قیمت کے خلاف ورزی پر مبنی ہے۔ یہ حالیہ قیمت کی کم سطح کی نشاندہی کرکے پوزیشنوں کو شروع کرتی ہے اور جب قیمت اس کم سطح کو توڑتی ہے اور تجارت میں اضافہ ہوتا ہے۔ قیمتوں میں کمی جاری رہنے کے دوران ، حکمت عملی متحرک طور پر ہر پوزیشن کی تعداد کو ایڈجسٹ کرتی ہے ، اس کی بنیاد پر کہ فلوٹنگ نقصان کی مقدار کتنی ہے ، جب تک کہ پوزیشنوں کی مقررہ کل تعداد تک نہ پہنچ جائے۔
اس حکمت عملی میں ، خطرات کو کنٹرول کرتے ہوئے ، پوزیشنوں کی تعداد کو متحرک طور پر ایڈجسٹ کرنے اور پیرامیٹرز کی ترتیب کو تاریخی اعداد و شمار کا حوالہ دیتے ہوئے ، قیمتوں میں ردوبدل کی صورت میں زیادہ منافع حاصل کرنے کی کوشش کی جاتی ہے۔ تاہم ، حکمت عملی کی کارکردگی کا انحصار پیرامیٹرز کی ترتیب اور مارکیٹ کی صورتحال پر بہت زیادہ ہوتا ہے ، اور اس میں ابھی بھی کچھ خطرہ موجود ہے۔ مزید اشارے متعارف کرانے ، فنڈ مینجمنٹ کو بہتر بنانے اور اسٹاپ نقصان کو ایڈجسٹ کرنے جیسے طریقوں سے حکمت عملی کی کارکردگی کو مزید بہتر بنایا جاسکتا ہے۔
/*backtest
start: 2024-04-04 00:00:00
end: 2024-04-11 00:00:00
period: 1m
basePeriod: 1m
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/
// © AHMEDABDELAZIZZIZO
//@version=5
strategy("Qfl Dca strategy", overlay=true)
// Parameters
swing = input(3 , title = "Swing Points")
mediandropmult = input.float(1.1, "Median drop Mult", step=0.1 , tooltip = "The script Calculate The Median Drop for all last Bases That Was cracked you can Increase or decrease it")
floatinglossvalue = input(-5 , "Floating Loss" , tooltip = "Position Floating Loss to start firs DCA order")
num_orders = input(5 , "Number of all orders" , tooltip = " The number of orders is including the base order and the DCA orders the script will alculate every order qty based on the orders number So that the position size doubles with every order")
length = input(20, title="Length of relative volume" ,tooltip = " the length of relative volume indicator")
mult = input(2.0, title="Volume Multiplier" , tooltip = "you can adjust the relative volume multiplier to find best parameter")
tpmult = input.float(1, step=0.1 ,title = "Take Profit Multiplier" ,tooltip = " By default, the script is set to take profits based on the same median drop percent you can adjust it as you like")
// Pivot Calculation
p = ta.pivotlow(low, swing, swing)
v = ta.valuewhen(p, low[swing], 0)
// Variables
var float[] lows = array.new_float()
var float chn = na
// Calculate drops
if v < v[1]
chn := (v[1] - v) / v[1] * 100
if array.size(lows) < 4000
array.push(lows, chn)
else
array.shift(lows)
array.push(lows, chn)
mediandrop = array.avg(lows)
maxdrop = array.max(lows)
mindrop = array.min(lows)
// Table display
textcolor = color.white
// tabl = table.new(position=position.top_right, columns=4, rows=4)
// table.cell(table_id=tabl, column=1, row=1, text="Avg Drop %", width=15, text_color=textcolor)
// table.cell(table_id=tabl, column=2, row=1, text="Min Drop %", width=15, text_color=textcolor)
// table.cell(table_id=tabl, column=3, row=1, text="Max Drop %", width=15, text_color=textcolor)
// table.cell(table_id=tabl, column=1, row=2, text=str.tostring(mediandrop), width=10, text_color=textcolor)
// table.cell(table_id=tabl, column=2, row=2, text=str.tostring(mindrop), width=10, text_color=textcolor)
// table.cell(table_id=tabl, column=3, row=2, text=str.tostring(maxdrop), width=10, text_color=textcolor)
// Plot support
t = fixnan(ta.pivotlow(low, swing, swing))
plot(t, color=ta.change(t) ? na : #03f590b6, linewidth=3, offset=-(swing), title="Support")
// Calculate relative volume
avgVolume = ta.sma(volume, length)
relVolume = volume / avgVolume
// Base Activation
var bool baseisactive = na
if not na(p)
baseisactive := true
// Buy Signal Calculation
buyprice = v * (1 - (mediandrop / 100) * mediandropmult)
signal = close <= buyprice and relVolume > mult and baseisactive
// Take Profit Calculation
tpsl = (mediandrop / 100)
tp = (strategy.position_avg_price * (1 + (tpsl * tpmult)))
// Position Sizing
capital_per_order(num_orders, equity) =>
equity / math.pow(2, (num_orders - 1))
equity_per_order = capital_per_order(num_orders, strategy.equity)
qty_per_order(equity_per_order, order_number) =>
equity_per_order * order_number / close
// Calculate floating loss
floatingLoss = ((close - strategy.position_avg_price) / strategy.position_avg_price) * 100
// Strategy Entries
if signal and strategy.opentrades == 0
strategy.entry("Buy", strategy.long, qty=qty_per_order(equity_per_order, 1))
baseisactive := false
for i = 1 to num_orders -1
if signal and strategy.opentrades == i and floatingLoss <= floatinglossvalue
strategy.entry("Buy", strategy.long, qty=qty_per_order(equity_per_order, i), comment="DCA Order" + str.tostring(i))
baseisactive := false
// Strategy Exit
strategy.exit("exit", "Buy", limit=tp)
// Plot
plot(strategy.position_avg_price, color=color.rgb(238, 255, 0), style=plot.style_linebr, linewidth=2)