এই কৌশলটি নাদরায়-ওয়াটসন নিউক্লিয়ার রিগ্রেশন পদ্ধতির উপর ভিত্তি করে একটি গতিশীল অস্থিরতার পরিবেষ্টিত বেন্ড তৈরি করে এবং দাম এবং পরিবেষ্টিত বেন্ডের ক্রসগুলি অনুসরণ করে একটি কম বা উচ্চ বিক্রয়ের ট্রেডিং সংকেত দেয়। কৌশলটি গাণিতিক বিশ্লেষণের ভিত্তিতে গঠিত এবং বাজারের পরিবর্তনের সাথে খাপ খাইয়ে নিতে সক্ষম।
কৌশলটির মূল বিষয় হল দামের গতিশীল ঘেরের পরিমাপ করা। প্রথমত, কাস্টমাইজড রিভিউ পিরিয়ডের উপর ভিত্তি করে, দামের একটি নাদারায়েয়া-ওয়াটসন নিউক্লিয়ার রিটার্ন কার্ভ গঠন করা হয় (খুব কাছাকাছি, সর্বোচ্চ, সর্বনিম্ন) এবং একটি মসৃণ মূল্য অনুমান করা হয়। তারপরে কাস্টমাইজড এটিআর দৈর্ঘ্যের উপর ভিত্তি করে এটিআর সূচকটি গণনা করা হয়, নিকটবর্তী ফ্যাক্টর এবং দূরবর্তী ফ্যাক্টরগুলির সমন্বয় করে, উপরের এবং নীচের ঘেরের পরিসীমা পাওয়া যায়। যখন দাম নীচের ঘেরের নীচে থেকে ঘেরের ভিতরে প্রবেশ করে, একটি কেনার সংকেত উত্পন্ন হয়; যখন দাম উপরের ঘের থেকে বেরিয়ে আসে, তখন একটি বিক্রয় সংকেত উত্পন্ন হয়। কৌশলটি মূল্যের ওঠানির সাথে সম্পর্কিত পরিসংখ্যানের মাধ্যমে গতিশীলভাবে লেনদানের সিদ্ধান্ত গ্রহণ করে।
এই ঝুঁকিগুলি এড়ানো এবং হ্রাস করা মূলত প্যারামিটারগুলি অনুকূলিতকরণ, ভালভাবে পুনর্নির্মাণ, প্রভাবিত কারণগুলি বোঝা এবং সতর্কতার সাথে চালিত।
এই কৌশলটি পরিসংখ্যানগত বিশ্লেষণ এবং প্রযুক্তিগত সূচক বিশ্লেষণকে একত্রিত করে, দাম এবং ওঠানামা গতিশীলভাবে ট্র্যাক করে, কম বা উচ্চ বিক্রয় ট্রেডিং সংকেত অর্জন করে। প্যারামিটারগুলি বাজার এবং নিজস্ব পরিস্থিতির উপর নির্ভর করে সামঞ্জস্য করা যেতে পারে। সামগ্রিকভাবে, কৌশলটির তাত্ত্বিক ভিত্তি শক্ত, বাস্তব পারফরম্যান্স আরও যাচাই করা দরকার। সতর্কতা অবলম্বন করা দরকার, সাবধানতা অবলম্বন করা দরকার।
/*backtest
start: 2022-12-04 00:00:00
end: 2023-12-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// © Julien_Eche
//@version=5
strategy("Nadaraya-Watson Envelope Strategy", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=20)
// Helper Functions
getEnvelopeBounds(_atr, _nearFactor, _farFactor, _envelope) =>
_upperFar = _envelope + _farFactor*_atr
_upperNear = _envelope + _nearFactor*_atr
_lowerNear = _envelope - _nearFactor*_atr
_lowerFar = _envelope - _farFactor*_atr
_upperAvg = (_upperFar + _upperNear) / 2
_lowerAvg = (_lowerFar + _lowerNear) / 2
[_upperNear, _upperFar, _upperAvg, _lowerNear, _lowerFar, _lowerAvg]
customATR(length, _high, _low, _close) =>
trueRange = na(_high[1])? math.log(_high)-math.log(_low) : math.max(math.max(math.log(_high) - math.log(_low), math.abs(math.log(_high) - math.log(_close[1]))), math.abs(math.log(_low) - math.log(_close[1])))
ta.rma(trueRange, length)
customKernel(x, h, alpha, x_0) =>
sumWeights = 0.0
sumXWeights = 0.0
for i = 0 to h
weight = math.pow(1 + (math.pow((x_0 - i), 2) / (2 * alpha * h * h)), -alpha)
sumWeights := sumWeights + weight
sumXWeights := sumXWeights + weight * x[i]
sumXWeights / sumWeights
// Custom Settings
customLookbackWindow = input.int(8, 'Lookback Window (Custom)', group='Custom Settings')
customRelativeWeighting = input.float(8., 'Relative Weighting (Custom)', step=0.25, group='Custom Settings')
customStartRegressionBar = input.int(25, "Start Regression at Bar (Custom)", group='Custom Settings')
// Envelope Calculations
customEnvelopeClose = math.exp(customKernel(math.log(close), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelopeHigh = math.exp(customKernel(math.log(high), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelopeLow = math.exp(customKernel(math.log(low), customLookbackWindow, customRelativeWeighting, customStartRegressionBar))
customEnvelope = customEnvelopeClose
customATRLength = input.int(60, 'ATR Length (Custom)', minval=1, group='Custom Settings')
customATR = customATR(customATRLength, customEnvelopeHigh, customEnvelopeLow, customEnvelopeClose)
customNearATRFactor = input.float(1.5, 'Near ATR Factor (Custom)', minval=0.5, step=0.25, group='Custom Settings')
customFarATRFactor = input.float(2.0, 'Far ATR Factor (Custom)', minval=1.0, step=0.25, group='Custom Settings')
[customUpperNear, customUpperFar, customUpperAvg, customLowerNear, customLowerFar, customLowerAvg] = getEnvelopeBounds(customATR, customNearATRFactor, customFarATRFactor, math.log(customEnvelopeClose))
// Colors
customUpperBoundaryColorFar = color.new(color.red, 60)
customUpperBoundaryColorNear = color.new(color.red, 80)
customBullishEstimatorColor = color.new(color.teal, 50)
customBearishEstimatorColor = color.new(color.red, 50)
customLowerBoundaryColorNear = color.new(color.teal, 80)
customLowerBoundaryColorFar = color.new(color.teal, 60)
// Plots
customUpperBoundaryFar = plot(math.exp(customUpperFar), color=customUpperBoundaryColorFar, title='Upper Boundary: Far (Custom)')
customUpperBoundaryAvg = plot(math.exp(customUpperAvg), color=customUpperBoundaryColorNear, title='Upper Boundary: Average (Custom)')
customUpperBoundaryNear = plot(math.exp(customUpperNear), color=customUpperBoundaryColorNear, title='Upper Boundary: Near (Custom)')
customEstimationPlot = plot(customEnvelopeClose, color=customEnvelope > customEnvelope[1] ? customBullishEstimatorColor : customBearishEstimatorColor, linewidth=2, title='Custom Estimation')
customLowerBoundaryNear = plot(math.exp(customLowerNear), color=customLowerBoundaryColorNear, title='Lower Boundary: Near (Custom)')
customLowerBoundaryAvg = plot(math.exp(customLowerAvg), color=customLowerBoundaryColorNear, title='Lower Boundary: Average (Custom)')
customLowerBoundaryFar = plot(math.exp(customLowerFar), color=customLowerBoundaryColorFar, title='Lower Boundary: Far (Custom)')
// Fills
fill(customUpperBoundaryFar, customUpperBoundaryAvg, color=customUpperBoundaryColorFar, title='Upper Boundary: Farmost Region (Custom)')
fill(customUpperBoundaryNear, customUpperBoundaryAvg, color=customUpperBoundaryColorNear, title='Upper Boundary: Nearmost Region (Custom)')
fill(customLowerBoundaryNear, customLowerBoundaryAvg, color=customLowerBoundaryColorNear, title='Lower Boundary: Nearmost Region (Custom)')
fill(customLowerBoundaryFar, customLowerBoundaryAvg, color=customLowerBoundaryColorFar, title='Lower Boundary: Farmost Region (Custom)')
longCondition = ta.crossover(close, customEnvelopeLow)
if (longCondition)
strategy.entry("Buy", strategy.long)
exitLongCondition = ta.crossover(customEnvelopeHigh, close)
if (exitLongCondition)
strategy.close("Buy")