आंतरिक मूल्य चैनलों पर आधारित लुक-अप और लुक-डाउन रणनीति

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

img

अवलोकन

यह रणनीति भविष्य के मूल्य रुझानों को निर्धारित करने के लिए आंतरिक मूल्य चैनलों का उपयोग करती है और प्रवृत्ति के बाद की रणनीतियों से संबंधित है। जब कीमतें आंतरिक मूल्य उतार-चढ़ाव चैनलों की एक निश्चित संख्या का गठन करती हैं, तो इसे लंबी या छोटी प्रविष्टियों के लिए प्रवृत्ति उलट सिग्नल के रूप में माना जाता है। यह मुनाफे में लॉक करने के लिए चलती औसत फ़िल्टरिंग और स्टॉप-लॉस / टेक-प्रॉफिट को भी शामिल करता है और एक अपेक्षाकृत आम मात्रात्मक ट्रेडिंग रणनीति है।

रणनीतिक सिद्धांत

रणनीति पिछले दो मोमबत्तियों के उच्चतम और निम्नतम मूल्य के बीच आकार संबंध के अनुसार आंतरिक चैनलों के गठन को निर्धारित करती है। जब मोमबत्तियों की एक निश्चित संख्या इस शर्त को पूरा करती है कि उच्चतम मूल्य पिछले मोमबत्तियों के उच्चतम मूल्य से कम है और सबसे कम मूल्य पिछले मोमबत्तियों के सबसे कम मूल्य से अधिक है, तो एक आंतरिक मूल्य चैनल की पहचान की जाती है।

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

झूठे संकेतों को फ़िल्टर करने के लिए, एक चलती औसत संकेतक भी पेश किया जाता है। वास्तविक ट्रेडिंग संकेत केवल तभी उत्पन्न होते हैं जब कीमत चलती औसत रेखा से ऊपर या नीचे होती है। इससे साइडवेज बाजारों में कुछ हद तक गलत ट्रेडों से बचा जा सकता है।

प्रवेश के बाद, उपयोगकर्ता की पसंद के अनुसार स्टॉप-लॉस और टेक-प्रॉफिट पॉइंट भी सेट किए जा सकते हैं। तीन उपलब्ध स्टॉप-लॉस विधियां हैंः फिक्स्ड-पॉइंट स्टॉप लॉस, एटीआर स्टॉप लॉस, पिछले उच्चतम/सबसे कम स्टॉप लॉस। टेक-प्रॉफिट को जोखिम/इनाम अनुपात के अनुसार सेट किया जाता है। यह कुछ हद तक लाभ में लॉक कर सकता है और जोखिमों को नियंत्रित कर सकता है।

लाभ विश्लेषण

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

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

अंत में, रणनीति में शुरू की गई चलती औसत फ़िल्टर और स्टॉप-लॉस/टेक-प्रॉफिट सेटिंग्स भी ट्रेडिंग जोखिमों को काफी कम करती हैं।

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

इस रणनीति का सबसे बड़ा जोखिम गलत रुझान निर्णयों की अपेक्षाकृत उच्च संभावना है। आंतरिक चैनल पूरी तरह से मूल्य उलट को निर्धारित नहीं कर सकते हैं, गलत निर्णय की एक निश्चित संभावना है। यदि निर्धारित मात्रा अपर्याप्त है, तो झूठे संकेत हो सकते हैं।

इसके अलावा, साइडवेज या अस्थिर बाजारों में रणनीति पूरी तरह से बेकार है। जब कीमतें एक प्रवृत्ति स्थापित किए बिना ऊपर और नीचे उतार-चढ़ाव करती हैं, तो रणनीति लगातार गलत संकेत उत्पन्न करेगी। यह रणनीति के तंत्र से निर्धारित होता है।

अंत में, यदि स्टॉप लॉस को बहुत रूढ़िवादी तरीके से सेट किया जाता है, तो रणनीति प्रमुख रुझानों में मुनाफे को पकड़ने के लिए पर्याप्त समय तक पदों को रखने में सक्षम नहीं हो सकती है। इससे उपयोगकर्ताओं को खुद से संतुलन बनाने की आवश्यकता होती है।

अनुकूलन दिशाएँ

इस रणनीति का अनुकूलन स्थान अभी भी काफी बड़ा है। कुछ संभावित अनुकूलन दिशाओं में शामिल हैंः

  1. आंतरिक चैनलों की मात्रा और पैटर्न को अनुकूलित करें। विभिन्न मात्राओं या विभिन्न संयोजन व्यवस्थाओं के तहत व्यापार प्रभावों का परीक्षण करें।

  2. प्रवृत्ति दिशा को बेहतर ढंग से निर्धारित करने के लिए चलती औसत के चक्र पैरामीटर को अनुकूलित करें। वर्तमान डिफ़ॉल्ट चक्र सभी उत्पादों के लिए उपयुक्त नहीं हो सकता है।

  3. अन्य संकेतक फ़िल्टर जोड़ें. उदाहरण के लिए, बोलिंगर बैंड का परिचय दें और केवल तब ही ट्रेडिंग सिग्नल उत्पन्न करें जब कीमतें बैंड के ऊपरी या निचले रेलों को तोड़ दें.

  4. स्टॉप लॉस/टेक प्रॉफिट मापदंडों को अनुकूलित करें ताकि रणनीति को अधिक समय तक पदों को बनाए रखने की अनुमति मिल सके। इस प्रकार सुपर ट्रेंड्स में मुनाफे को कैप्चर किया जा सके।

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

निष्कर्ष

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


/*backtest
start: 2023-12-03 00:00:00
end: 2023-12-10 00:00:00
period: 3m
basePeriod: 1m
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/

// From "Day Trading Cryptocurrency 
// Strategies, Tactics, Mindset, and Tools Required To Build Your 
// New Income Stream"
// by Phil C. Senior

// "Inside bars are a two -bar pattern. They can indicate either a continuation of the 
// existing move or a reversal. A continuation occurs when there is no significant 
// support or resistance level in sight, while a reversal occurs close to a strong sup- 
// port or resistance level...
// ...A lot of traders are aware of inside bars but few manage to make money with 
// them. Why is this so? It goes back to interpreting price action. A lot of traders look 
// to trade in geometric ways. What I mean is that they search for fancy shapes on a 
// chart and think that this is what represents true price action. 
// This is not the case. A shape is just a shape. The formation by itself means 
// nothing unless underlying order flow backs it up. This is why it’s extremely impor- 
// tant that you look for inside bars when a trend is already in place. The best place to 
// look for them is in the beginning of trends."

// © tweakerID

//@version=4
strategy("Inside Bar Strategy w/ SL", 
     overlay=true, 
     default_qty_type=strategy.percent_of_equity, 
     default_qty_value=100, 
     initial_capital=10000, 
     commission_value=0.04, 
     calc_on_every_tick=false, 
     slippage=0)

direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))

/////////////////////// STRATEGY INPUTS ////////////////////////////////////////
title1=input(true, "-----------------Strategy Inputs-------------------")  

i_NBars = input(defval=1, type=input.integer, title="# Of Inside Bars in pattern", options=[1, 2, 3, 4])
i_BarsDirection = input(false, title="Only trade using complete bullish or bearish patterns")
i_MAFilter = input(true, title="Use MA Trend Filter")
i_MALen = input(65, title="MA Length")

/////////////////////// BACKTESTER /////////////////////////////////////////////
title2=input(true, "-----------------General Inputs-------------------")  

// Backtester General Inputs
i_SL=input(true, title="Use Stop Loss and Take Profit")
i_SLType=input(defval="ATR Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])
i_SPL=input(defval=10, title="Swing Point Lookback")
i_PercIncrement=input(defval=1, step=.1, title="Swing Point SL Perc Increment")*0.01
i_ATR = input(14, title="ATR Length")
i_ATRMult = input(5, step=.1, title="ATR Multiple")
i_TPRRR = input(2, step=.1, title="Take Profit Risk Reward Ratio")
TS=input(false, title="Trailing Stop")

// Bought and Sold Boolean Signal
bought = strategy.position_size > strategy.position_size[1] 
 or strategy.position_size < strategy.position_size[1]

// Price Action Stop and Take Profit
LL=(lowest(i_SPL))*(1-i_PercIncrement)
HH=(highest(i_SPL))*(1+i_PercIncrement)
LL_price = valuewhen(bought, LL, 0)
HH_price = valuewhen(bought, HH, 0)
entry_LL_price = strategy.position_size > 0 ? LL_price : na 
entry_HH_price = strategy.position_size < 0 ? HH_price : na 
tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRR
stp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR

// ATR Stop
ATR=atr(i_ATR)*i_ATRMult
ATRLong = ohlc4 - ATR
ATRShort = ohlc4 + ATR
ATRLongStop = valuewhen(bought, ATRLong, 0)
ATRShortStop = valuewhen(bought, ATRShort, 0)
LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na 
ShortSL_ATR_price = strategy.position_size < 0 ? ATRShortStop : na 
ATRtp=strategy.position_avg_price + (strategy.position_avg_price - LongSL_ATR_price)*i_TPRRR
ATRstp=strategy.position_avg_price - (ShortSL_ATR_price - strategy.position_avg_price)*i_TPRRR


// Strategy Stop
float LongStop = valuewhen(bought,low[1],0)*(1-i_PercIncrement)
float ShortStop = valuewhen(bought,high[1],0)*(1+i_PercIncrement)
float StratTP = na
float StratSTP = na

/////////////////////// STRATEGY LOGIC /////////////////////////////////////////

MAFilter=close > sma(close, i_MALen)
plot(i_MAFilter ? sma(close, i_MALen) : na)
bullBar=close > open
bearBar=close < open
contbullBar=barssince(not bullBar) >= (i_NBars+1)
contbearBar=barssince(not bearBar) >= (i_NBars+1)

InsideBar(NBars) =>
    Inside1Bar=high < high[1] and low > low[1] 
    Inside2Bar=high < high[2] and low > low[2] and Inside1Bar
    Inside3Bar=high < high[3] and low > low[3] and Inside1Bar and Inside2Bar
    Inside4Bar=high < high[4] and low > low[4] and Inside1Bar and Inside2Bar and Inside3Bar
    if NBars == 1
        inside1Bar=Inside1Bar
        [inside1Bar]
    else if NBars == 2
        inside2Bar=Inside2Bar
        [inside2Bar]
    else if NBars == 3
        inside3Bar=Inside3Bar   
        [inside3Bar]
    else if NBars == 4
        inside4Bar=Inside4Bar
        [inside4Bar]
    else
        [na]
[insideBar] = InsideBar(i_NBars) 
    
bullInsideBar=bar_index > 40 and insideBar and bullBar 
     and (i_BarsDirection ? contbullBar : true) and (i_MAFilter ? MAFilter : true)
bearInsideBar=bar_index > 40 and insideBar and bearBar 
     and (i_BarsDirection ? contbearBar : true) and (i_MAFilter ? not MAFilter : true)

BUY = bullInsideBar
SELL = bearInsideBar

//Debugging Plots
plot(contbullBar ? 1:0, transp=100, title="contbullBar")
plot(contbearBar ? 1:0, transp=100, title="contbearBar")

//Trading Inputs
DPR=input(true, "Allow Direct Position Reverse")
reverse=input(false, "Reverse Trades")

// Entries
if reverse
    if not DPR
        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)
    else     
        strategy.entry("long", strategy.long, when=SELL)
        strategy.entry("short", strategy.short, when=BUY)
else
    if not DPR 
        strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)
    else
        strategy.entry("long", strategy.long, when=BUY)
        strategy.entry("short", strategy.short, when=SELL)

SL= i_SLType == "Swing Lo/Hi" ? entry_LL_price : i_SLType == "ATR Stop" ? LongSL_ATR_price : LongStop
SSL= i_SLType == "Swing Lo/Hi" ? entry_HH_price : i_SLType == "ATR Stop" ? ShortSL_ATR_price : ShortStop
TP= i_SLType == "Swing Lo/Hi" ? tp : i_SLType == "ATR Stop" ? ATRtp : StratTP
STP= i_SLType == "Swing Lo/Hi" ? stp : i_SLType == "ATR Stop" ? ATRstp : StratSTP

//TrailingStop
dif=(valuewhen(strategy.position_size>0 and strategy.position_size[1]<=0, high,0))
 -strategy.position_avg_price
trailOffset     = strategy.position_avg_price - SL
var tstop = float(na)
if strategy.position_size > 0
    tstop := high- trailOffset - dif
    if tstop<tstop[1]
        tstop:=tstop[1]
else
    tstop := na
StrailOffset     = SSL - strategy.position_avg_price
var Ststop = float(na)
Sdif=strategy.position_avg_price-(valuewhen(strategy.position_size<0 
 and strategy.position_size[1]>=0, low,0))
if strategy.position_size < 0
    Ststop := low+ StrailOffset + Sdif
    if Ststop>Ststop[1]
        Ststop:=Ststop[1]
else
    Ststop := na

strategy.exit("TP & SL", "long", limit=TP, stop=TS? tstop : SL, when=i_SL)
strategy.exit("TP & SL", "short", limit=STP, stop=TS? Ststop : SSL, when=i_SL)

/////////////////////// PLOTS //////////////////////////////////////////////////

plot(i_SL and strategy.position_size > 0 and not TS ? SL : i_SL and strategy.position_size > 0 and TS ? tstop : na , title='SL', style=plot.style_cross, color=color.red)
plot(i_SL and strategy.position_size < 0 and not TS ? SSL : i_SL and strategy.position_size < 0 and TS ? Ststop : na , title='SSL', style=plot.style_cross, color=color.red)
plot(i_SL and strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)
plot(i_SL and strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)
// Draw price action setup arrows
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar, 
 color=color.green, title="Bullish Setup", size=size.auto)
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar, 
 color=color.red, title="Bearish Setup", size=size.auto)
 



अधिक