दोहरी चलती औसत रेखा कैप्चर रणनीति

लेखक:चाओझांग, दिनांकः 2023-12-13 15:28:50
टैगः

img

अवलोकन

यह रणनीति बाजार की प्रवृत्ति की दिशा निर्धारित करने के लिए बोलिंगर बैंड्स के साथ संयुक्त दोहरी चलती औसत रेखाओं का उपयोग करती है, ताकि लाभ लेने के लिए कम खरीदने और उच्च बेचने के लिए ओवरबॉट और ओवरसोल्ड स्थितियों की पहचान की जा सके।

रणनीति तर्क

यह रणनीति बाजार की समग्र दिशा का पता लगाने के लिए दोहरी चलती औसत का उपयोग करती है, जबकि विशिष्ट प्रवेश संकेतों के लिए बोलिंगर बैंड पर निर्भर करती है।

दोहरी चलती औसत नियम एक अल्पकालिक और एक दीर्घकालिक घातीय चलती औसत रेखा की गणना करने के लिए निर्धारित करता है, जिसमें लंबी अवधि की रेखा को ऊपर की ओर पार करने वाली अल्पकालिक रेखा एक खरीद संकेत का संकेत देती है; लंबी अवधि के माध्यम से नीचे की ओर पार करने वाली अल्पकालिक रेखा एक बिक्री संकेत का गठन करती है।

बोलिंगर बैंड्स सूचक यह निर्धारित करता है कि क्या कीमतें ओवरबॉट या ओवरसोल्ड हैं। बोलिंगर बैंड्स का मध्य बैंड n-अवधि के समापन मूल्य की चलती औसत रेखा है, जबकि बैंड की चौड़ाई पिछले n अवधियों में चलती औसत के मानक विचलन का प्रतिनिधित्व करती है। ऊपरी बैंड के करीब आने वाली कीमतें एक ओवरबोल्ड स्थिति को इंगित करती हैं और निचले बैंड के करीब आने वाली कीमतें ओवरसोल्ड स्थिति का गठन करती हैं।

रणनीतिक नियम इस प्रकार परिभाषित किए गए हैंः जब छोटी औसत रेखा लंबी औसत रेखा से ऊपर की ओर पार करती है और बंद होने की कीमत बोलिंगर के ऊपरी बैंड से ऊपर प्रवेश करती है, तो लंबी हो जाती है। जब छोटी रेखा लंबी रेखा से नीचे की ओर पार करती है और बंद होने की कीमत बोलिंगर के निचले बैंड से नीचे गिरती है, तो छोटी हो जाती है।

लंबे समय के बाद स्टॉप लॉस पिछले n दिनों के दौरान सबसे कम कम पर सेट किया जाता है, जबकि लाभ लेने के लिए प्रवेश मूल्य का 1.6 गुना रखा जाता है। एक छोटी बिक्री के बाद स्टॉप लॉस पिछले n दिनों के दौरान उच्चतम उच्च पर बंधा होता है, जिसमें प्रवेश मूल्य का 0.6 गुना लाभ होता है।

इसके अतिरिक्त, रणनीति में ट्रेंड रिवर्स से बचने के लिए ईएमए ट्रेंड इंडेक्स पर विचार किया गया है।

लाभ विश्लेषण

  1. समग्र दिशा निर्धारित करने के लिए दोहरी चलती औसत का उपयोग करना और विशिष्ट प्रवेश बिंदुओं को उजागर करने के लिए बोलिंगर बैंड का उपयोग करना एक समझदार संकेतक मिश्रण का प्रतिनिधित्व करता है;
  2. लॉन्ग के लिए सबसे कम निचले स्तर को और शॉर्ट के लिए स्टॉप लॉस के रूप में उच्चतम उच्च स्तर को अपनाने से स्टॉप की संभावना कम होती है।
  3. प्रवेश मूल्य का 1.6 गुना लाभ लक्ष्य निर्धारित करने से पर्याप्त लाभ प्राप्त करना आसान हो जाता है।
  4. ईएमए प्रवृत्ति सूचकांक को ध्यान में रखते हुए प्रमुख प्रवृत्ति के खिलाफ ट्रेडों से बचने में मदद मिलती है, जिससे सिस्टम के नुकसान में कमी आती है।

जोखिम विश्लेषण

  1. बोलिंगर बैंड्स मापदंडों के अनुचित अनुकूलन के परिणामस्वरूप अत्यधिक बार-बार व्यापार या अपर्याप्त संकेत हो सकते हैं;
  2. अत्यधिक ढीले स्टॉप लॉस पॉइंट्स से बड़े नुकसान होते हैं।
  3. अत्यधिक सख्त लाभ लेने के प्रतिबंध से अधिक लाभ खो जाते हैं।

उपरोक्त जोखिमों से निपटने के लिए, बोलिंगर मापदंडों के संयोजनों को अनुकूलित करें और इष्टतम सेटिंग्स का चयन करने के लिए विभिन्न स्टॉप लॉस/प्रॉफिट कैप्चर सीमा स्तरों का परीक्षण करें।

अनुकूलन दिशा

  1. आदर्श संयोजनों का पता लगाने के लिए बोलिंगर बैंड्स इनपुट मापदंडों को अनुकूलित करें;
  2. स्टॉप लॉस की संभावनाओं को कम करने के लिए विभिन्न स्टॉप लॉस वृद्धि मापदंडों की जांच करें;
  3. अधिक से अधिक संभावित लाभ प्राप्त करने के लिए लाभ गुणक मानों का परीक्षण करें।

निष्कर्ष

इस रणनीति ने दोहरी चलती औसत का उपयोग करके समग्र प्रवृत्ति की पुष्टि करके और विशिष्ट प्रवेश संकेतों के लिए बोलिंगर बैंड पर भरोसा करके बैकटेस्ट में विश्वसनीय प्रदर्शन किया है। निरंतर पैरामीटर अनुकूलन और नियम संशोधनों के माध्यम से अतिरिक्त प्रदर्शन सुधार की उम्मीद की जा सकती है। स्टॉप लॉस / लाभ लेने की तंत्र को अनुकूलन के लिए अन्य प्रणालियों में भी स्थानांतरित किया जा सकता है।


/*backtest
start: 2023-12-05 00:00:00
end: 2023-12-06 22:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This close code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AugustoErni

//@version=5
strategy('Bollinger Bands Modified (Stormer)', overlay=true)

bbL                   = input.int(20, title='BB Length/Comprimento da Banda de Bollinger', minval=1, step=1, tooltip='Calculate the length of bollinger bands./Calcula o comprimento das bandas de bollinger.')
mult                  = input.float(0.38, title='BB Standard Deviation/Desvio Padrão da Banda de Bollinger', minval=0.01, step=0.01, tooltip='Calculate the standard deviation of bollinger bands./Calcula o desvio padrão das bandas de bollinger.')
emaL                  = input.int(80, title='EMA Length/Comprimento da Média Móvel Exponencial', minval=1, step=1, tooltip='Calculate the length of EMA./Calcula o comprimento da EMA.')
highestHighL          = input.int(7, title='Highest High Length/Comprimento da Alta Maior', minval=1, step=1, tooltip='Fetches the highest high candle from length input. Use to set stop loss for short position./Obtém a vela de maior alta com base na medida fornecida. Usa para definir o stop loss para uma posição curta.')
lowestLowL            = input.int(7, title='Lowest Low Length/Comprimento da Baixa Menor', minval=1, step=1, tooltip='Fetches the lowest low candle from length input. Use to set stop loss for long position./Obter a vela de menor baixa com base na medida fornecida. Usa para definir o stop loss para uma posição longa.')
targetFactor          = input.float(1.6, title='Target Take Profit/Objetivo de Lucro Alvo', minval=0.1, step=0.1, tooltip='Calculate the take profit factor when entry position./Calcula o fator do alvo lucro ao entrar na posição.')
emaTrend              = input.bool(true, title='Check Trend EMA/Verificar Tendência da Média Móvel Exponencial', tooltip='Use EMA as trend verify for opening position./Usa a EMA como verificação de tendência para abrir posição.')
crossoverCheck        = input.bool(false, title='Add Another Crossover Check/Adicionar Mais uma Verificação de Cruzamento Superior', tooltip='This option is to add one more veryfication attempt to check if price is crossover upper bollinger band./Esta opção é para adicionar uma verificação adicional para avaliar se o preço cruza a banda superior da banda de bollinger.')
crossunderCheck       = input.bool(false, title='Add Another Crossunder Check/Adicionar Mais uma Verificação de Cruzamento Inferior', tooltip='This option is to add one more veryfication attempt to check if price is crossunder lower bollinger band./Esta opção é para adicionar uma verificação adicional para avaliar se o preço cruza a banda inferior da banda de bollinger.')
insideBarPatternCheck = input.bool(true, title='Show Inside Bar Pattern/Mostrar Padrão de Inside Bar', tooltip='This option is to show possible inside bar pattern./Esta opção é para mostrar um possível padrão de inside bar.')

[middle, upper, lower] = ta.bb(close, bbL, mult)
ema                    = ta.ema(close, emaL)
highestHigh            = ta.highest(high, highestHighL)
lowestLow              = ta.lowest(low, lowestLowL)
isCrossover            = ta.crossover(close, upper) ? 1 : 0
isCrossunder           = ta.crossunder(close, lower) ? 1 : 0

isPrevBarHighGreaterCurBarHigh = high[1] > high ? 1 : 0
isPrevBarLowLesserCurBarLow    = low[1] < low ? 1 : 0
isInsideBar                    = isPrevBarHighGreaterCurBarHigh and isPrevBarLowLesserCurBarLow ? 1 : 0

isBarLong  = ((close - open) > 0) ? 1 : 0
isBarShort = ((close - open) < 0) ? 1 : 0

isLongCross  = crossoverCheck ? ((isBarLong and not isBarShort) and (open < upper and close > upper)) ? 1 : 0 : isCrossover ? 1 : 0
isShortCross = crossunderCheck ? ((isBarShort and not isBarLong) and (close < lower and open > lower)) ? 1 : 0 : isCrossunder ? 1 : 0

isCandleAboveEma = close > ema ? 1 : 0
isCandleBelowEma = close < ema ? 1 : 0

isLongCondition  = emaTrend ? isLongCross and isCandleAboveEma ? 1 : 0 : isLongCross
isShortCondition = emaTrend ? isShortCross and isCandleBelowEma ? 1 : 0 : isShortCross

isPositionNone  = strategy.position_size == 0 ? 1 : 0
isPositionLong  = strategy.position_size > 0 ? 1 : 0
isPositionShort = strategy.position_size < 0 ? 1 : 0

var float enterLong     = 0.0
var float stopLossLong  = 0.0
var float targetLong    = 0.0
var float enterShort    = 0.0
var float stopLossShort = 0.0
var float targetShort   = 0.0
var bool isLongEntry    = false
var bool isShortEntry   = false

if (isPositionNone)
    isLongEntry   := false
    isShortEntry  := false
    enterLong     := 0.0
    stopLossLong  := 0.0
    targetLong    := 0.0
    enterShort    := 0.0
    stopLossShort := 0.0
    targetShort   := 0.0
if (isPositionShort or isPositionNone)
    isLongEntry  := false
    enterLong    := 0.0
    stopLossLong := 0.0
    targetLong   := 0.0
if (isPositionLong or isPositionNone)
    isShortEntry  := false
    enterShort    := 0.0
    stopLossShort := 0.0
    targetShort   := 0.0
if (isPositionLong and isLongEntry)
    isLongEntry   := true
    isShortEntry  := false
    enterShort    := 0.0
    stopLossShort := 0.0
    targetShort   := 0.0
if (isPositionShort and isShortEntry)
    isShortEntry := true
    isLongEntry  := false
    enterLong    := 0.0
    stopLossLong := 0.0
    targetLong   := 0.0

if (isLongCondition and not isLongEntry)
    isLongEntry  := true
    enterLong    := close
    stopLossLong := lowestLow
    targetLong   := (enterLong + (math.abs(enterLong - stopLossLong) * targetFactor))
    alertMessage = '{ "side/lado": "buy", "entry/entrada": ' + str.tostring(enterLong) + ', "stop": ' + str.tostring(stopLossLong) + ', "target/alvo": ' + str.tostring(targetLong) + ' }'
    alert(alertMessage)
    strategy.entry('Long', strategy.long)
    strategy.exit('Exit Long', 'Long', stop=stopLossLong, limit=targetLong)

if (isShortCondition and not isShortEntry)
    isShortEntry  := true
    enterShort    := close
    stopLossShort := highestHigh
    targetShort   := (enterShort - (math.abs(enterShort - stopLossShort) * targetFactor))
    alertMessage = '{ "side/lado": "sell", "entry/entrada": ' + str.tostring(enterShort) + ', "stop": ' + str.tostring(stopLossShort) + ', "target/alvo": ' + str.tostring(targetShort) + ' }'
    alert(alertMessage)
    strategy.entry('Short', strategy.short)
    strategy.exit('Exit Short', 'Short', stop=stopLossShort, limit=targetShort)

plot(upper, title='Upper Band', color=color.blue)
plot(middle, title='Middle Band', color=color.gray)
plot(lower, title='Lower Band', color=color.blue)
plot(ema, title='EMA', color=color.white)

barcolor(insideBarPatternCheck and isInsideBar and isBarLong ? color.lime : insideBarPatternCheck and isInsideBar and isBarShort ? color.maroon : na, title='Inside Bar Color in Long Bar Long and in Short Bar Short/Cor do Inside Bar em Barra Longa Longa e em Barra Curta Curta')

tablePosition    = position.bottom_right
tableColumns     = 2
tableRows        = 5
tableFrameWidth  = 1
tableBorderColor = color.gray
tableBorderWidth = 1

tableInfoTrade = table.new(position=tablePosition, columns=tableColumns, rows=tableRows, frame_width=tableFrameWidth, border_color=tableBorderColor, border_width=tableBorderWidth)

table.cell(table_id=tableInfoTrade, column=0, row=0)
table.cell(table_id=tableInfoTrade, column=1, row=0)

table.cell(table_id=tableInfoTrade, column=0, row=1, text='Entry Side/Lado da Entrada', text_color=color.white)
table.cell(table_id=tableInfoTrade, column=0, row=2, text=isLongEntry ? 'LONG' : isShortEntry ? 'SHORT' : 'NONE/NENHUM', text_color=color.yellow)

table.cell(table_id=tableInfoTrade, column=1, row=1, text='Entry Price/Preço da Entrada', text_color=color.white)
table.cell(table_id=tableInfoTrade, column=1, row=2, text=isLongEntry ? str.tostring(enterLong) : isShortEntry ? str.tostring(enterShort) : 'NONE/NENHUM', text_color=color.blue)

table.cell(table_id=tableInfoTrade, column=0, row=3, text='Take Profit Price/Preço Alvo Lucro', text_color=color.white)
table.cell(table_id=tableInfoTrade, column=0, row=4, text=isLongEntry ? str.tostring(targetLong) : isShortEntry ? str.tostring(targetShort) : 'NONE/NENHUM', text_color=color.green)

table.cell(table_id=tableInfoTrade, column=1, row=3, text='Stop Loss Price/Preço Stop Loss', text_color=color.white)
table.cell(table_id=tableInfoTrade, column=1, row=4, text=isLongEntry ? str.tostring(stopLossLong) : isShortEntry ? str.tostring(stopLossShort) : 'NONE/NENHUM', text_color=color.red)

अधिक