
এই কৌশলটি LazyBear এর Z দূরত্ব VWAP সূচকের উপর ভিত্তি করে তৈরি করা হয়েছে, যা মূল্যের সাথে VWAP এর Z দূরত্বের উপর ভিত্তি করে ওভারব্রেড এবং ওভারসোল্ডের সিদ্ধান্ত নেওয়ার জন্য ব্যবহার করা হয়। এই কৌশলটি ইএমএ গড় এবং Z দূরত্বের রিটার্ন 0 অক্ষের সিদ্ধান্তের সাথে যুক্ত করে, কিছু গোলমাল সংকেতগুলি ফিল্টার করতে পারে।
মূল ফাংশনঃ
সমাধানঃ
এই কৌশলটি Z দূরত্বের সাথে মূল্য নির্ধারণের সাথে VWAP এর সম্পর্ক ব্যবহার করে, EMA ফিল্টারিং শব্দ সংকেতগুলির সাথে মিলিত হয়ে ট্রেন্ডের সুযোগগুলি ক্যাপচার করে। কৌশলটি ট্রেন্ড ট্র্যাকিংয়ের জন্য পজিশনিংয়ের অনুমতি দেয় এবং স্টপ লস কন্ট্রোল ঝুঁকি সেট করে। প্যারামিটার অপ্টিমাইজেশন এবং অন্যান্য সূচক যুক্ত করে কৌশলটির স্থিতিশীলতা বাড়ানো যায়। তবে Z দূরত্বের সূচকটি পিছিয়ে রয়েছে, অপ্টিমাইজেশনের সময় বিবেচনা করা দরকার। সামগ্রিকভাবে, এই কৌশলটি সহজ এবং পরিষ্কার যুক্তি দিয়ে ট্রেন্ড ক্যাপচার করে, পর্যাপ্ত অপ্টিমাইজেশনের পরে এটি একটি উচ্চ কার্যকর ট্রেন্ড ট্র্যাকিং কৌশল হতে পারে।
/*backtest
start: 2022-11-03 00:00:00
end: 2023-11-09 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mohanee
//@version=4
//This is based on Z distance from VWAP by Lazybear
strategy(title="ZVWAP[LB] strategy", overlay=false,pyramiding=2, default_qty_type=strategy.fixed, default_qty_value=3, initial_capital=10000, currency=currency.USD)
length=input(13,"length")
calc_zvwap(pds, source1) =>
mean = sum(volume*source1,pds)/sum(volume,pds)
vwapsd = sqrt(sma(pow(source1-mean, 2), pds) )
(close-mean)/vwapsd
upperTop=2.5 //input(2.5)
upperBottom=2.0 //input(2.0)
lowerTop=-0.5 //input(-0.5)
lowerBottom=-2.0 //input(-2.0)
buyLine=input(-0.5, title="OverSold Line",minval=-2, maxval=3)
sellLine=input(2.0, title="OverBought Line",minval=-2, maxval=3)
fastEma=input(13, title="Fast EMA",minval=1, maxval=50)
slowEma=input(55, title="Slow EMA",minval=10, maxval=200)
stopLoss =input(5, title="Stop Loss",minval=1)
hline(0, title="Middle Line", linestyle=hline.style_dotted, color=color.green)
ul1=plot(upperTop, "OB High")
ul2=plot(upperBottom, "OB Low")
fill(ul1,ul2, color=color.red)
ll1=plot(lowerTop, "OS High")
ll2=plot(lowerBottom, "OS Low")
fill(ll1,ll2, color=color.green)
zvwapVal=calc_zvwap(length,close)
plot(zvwapVal,title="ZVWAP",color=color.purple, linewidth=2)
longEmaVal=ema(close,slowEma)
shortEmaVal=ema(close,fastEma)
vwapVal=vwap(hlc3)
zvwapDipped=false
for i = 1 to 10
zvwapDipped := zvwapDipped or zvwapVal[i]<=buyLine
longCondition= shortEmaVal > longEmaVal and zvwapDipped and crossover(zvwapVal,0)
barcolor(longCondition ? color.yellow: na)
strategy.entry(id="ZVWAPLE", long=true, when= longCondition and strategy.position_size<1)
//Add
strategy.entry(id="ZVWAPLE", comment="Add", long=true, when= strategy.position_size>1 and close<strategy.position_avg_price and crossover(zvwapVal,0))
//calculate stop Loss
stopLossVal = strategy.position_avg_price - (strategy.position_avg_price*stopLoss*0.01)
strategy.close(id="ZVWAPLE",comment="SL Exit", when=close<stopLossVal) //close all on stop loss
strategy.close(id="ZVWAPLE",comment="TPExitAll", qty=strategy.position_size , when= crossunder(zvwapVal,sellLine)) //close all zvwapVal>sellLine