
इस रणनीति का उपयोग कीमतों के आंतरिक चैनल भविष्य की कीमतों के आंदोलन का आकलन करने के लिए, प्रवृत्ति का पालन करने की रणनीति है. जब कीमतों में एक निश्चित संख्या में आंतरिक कीमतों के उतार-चढ़ाव के चैनल का गठन किया जाता है, तो यह प्रवृत्ति मोड़ के संकेत के रूप में निर्णय लिया जाता है, खरीद या बेचने के लिए। साथ ही साथ चलती औसत फ़िल्टर और स्टॉप लॉस स्टॉप सेटिंग्स के साथ मिलकर मुनाफे को लॉक करने के लिए, यह एक अधिक सामान्य मात्रात्मक ट्रेडिंग रणनीति है।
यह रणनीति आंतरिक चैनल के गठन का न्याय करती है, जो कि पहले और बाद में दो K लाइनों के उच्चतम मूल्य और निम्नतम मूल्य के बीच के बड़े संबंधों के आधार पर निर्धारित की जाती है। कीमतों को आंतरिक चैनल के रूप में माना जाता है जब एक निश्चित संख्या में K लाइनें उच्चतम मूल्य से कम होती हैं और निम्नतम मूल्य से अधिक होती हैं।
मूल्य आंतरिक चैनल के गठन का न्याय करते हुए, रणनीति भी आंतरिक चैनल की दिशा का न्याय करती है। यदि यह एक bullish आंतरिक चैनल है, तो यह एक खरीद संकेत उत्पन्न करता है; यदि यह एक bearish आंतरिक चैनल है, तो यह एक बेचने का संकेत उत्पन्न करता है। इसलिए, यह रणनीति द्वि-दिशात्मक व्यापार रणनीति के अंतर्गत आती है।
झूठे संकेतों को फ़िल्टर करने के लिए, इस रणनीति में एक चलती औसत संकेतक भी शामिल किया गया है। वास्तविक ट्रेडिंग सिग्नल केवल तभी उत्पन्न होते हैं जब कीमत ऊपर या नीचे चलती औसत से ऊपर होती है। यह कुछ हद तक गलत ट्रेडों से बचने के लिए किया जाता है।
प्रवेश के बाद, रणनीति उपयोगकर्ता के चयन के आधार पर स्टॉप लॉस स्टॉप सेट करती है। तीन प्रकार के स्टॉप विकल्प हैंः फिक्स्ड पॉइंट स्टॉप, एटीआर स्टॉप, प्रीमियम हाई-लो-पॉइंट स्टॉप। स्टॉप लॉस सेटिंग्स रिस्क-रिटर्न अनुपात स्टॉप हैं। यह कुछ हद तक मुनाफे को लॉक कर सकता है, जोखिम को नियंत्रित कर सकता है।
इस रणनीति का सबसे बड़ा लाभ यह है कि यह प्रवृत्ति के मोड़ की पहचान करने की क्षमता में मजबूत है। जब कीमतों में एक निश्चित संख्या में आंतरिक चैनल बनते हैं, तो यह अक्सर एक बड़ी गिरावट का संकेत देता है। यह निर्णय पारंपरिक तकनीकी विश्लेषण सिद्धांतों के साथ अत्यधिक संगत है।
इसके अलावा, रणनीति स्वयं बहुत ही विन्यास योग्य है। उपयोगकर्ता आंतरिक चैनलों की संख्या, चलती औसत चक्र, स्टॉप लॉस स्टॉप मोड आदि जैसे मापदंडों को स्वतंत्र रूप से चुन सकते हैं। यह विभिन्न किस्मों और विभिन्न व्यापारिक शैलियों के लिए बहुत अधिक लचीलापन प्रदान करता है।
अंत में, चलती औसत फ़िल्टर और स्टॉप लॉस स्टॉप सेटिंग्स जो रणनीति में शामिल हैं, ट्रेडिंग जोखिम को काफी हद तक कम करते हैं। यह रणनीति को विभिन्न प्रकार के बाजार स्थितियों में व्यापार करने के लिए उपयुक्त बनाता है।
इस रणनीति का सबसे बड़ा जोखिम यह है कि प्रवृत्ति के निर्णय पर गलत होने की अधिक संभावना है। आंतरिक चैनल पूरी तरह से कीमतों के उलटफेर का निर्धारण नहीं कर सकते हैं, गलत निर्णय की एक निश्चित संभावना है। यदि निर्धारित संख्या कम है, तो झूठे संकेतों की स्थिति हो सकती है।
इसके अलावा, यह रणनीति पूरी तरह से संरेखित या अस्थिर बाजारों में लागू नहीं होती है। जब कीमतों में उतार-चढ़ाव होता है, लेकिन कोई प्रवृत्ति स्थापित नहीं की जाती है, तो यह रणनीति लगातार गलत संकेत देगी। यह रणनीति तंत्र के कारण निर्धारित है।
अंत में, स्टॉप लॉस सेटिंग्स जो बहुत रूढ़िवादी हैं, रणनीति को लंबे समय तक पकड़ने में असमर्थ बनाती हैं और बड़े रुझानों में लाभ को पकड़ने में असमर्थ बनाती हैं।
इस रणनीति के लिए अनुकूलन के लिए काफी जगह है. कुछ संभावित अनुकूलन दिशाओं में शामिल हैंः
आंतरिक चैनलों की संख्या और रूपों का अनुकूलन करें। विभिन्न संख्याओं या विभिन्न पदानुक्रम संयोजनों के तहत लेनदेन की प्रभावशीलता का परीक्षण करें।
एक चलती औसत के लिए आवधिक मापदंडों को अनुकूलित करें ताकि यह बेहतर ढंग से प्रवृत्ति की दिशा का आकलन कर सके। वर्तमान में डिफ़ॉल्ट चक्र सभी किस्मों के लिए उपयुक्त नहीं हो सकता है।
अन्य संकेतक फ़िल्टर जोड़ें। उदाहरण के लिए, ब्रिन बैंड की शुरूआत, केवल ट्रेडिंग सिग्नल उत्पन्न करता है जब कीमत ब्रिन बैंड को पार करती है या नीचे जाती है।
स्टॉप-लॉस और स्टॉप-स्टॉप पैरामीटर का अनुकूलन करें ताकि रणनीति अधिक समय तक स्थिति रख सके। सुपरट्रेंड में लाभ को पकड़ने के लिए।
कुल मिलाकर, यह रणनीति प्रवृत्ति के निर्णय की सटीकता के लिए मौजूद है। जब तक निर्णय की सटीकता की गारंटी दी जाती है, तब तक उचित जोखिम प्रबंधन सेटिंग्स के साथ, एक अच्छा एल्गोरिथ्म व्यापार किया जा सकता है।
इस रणनीति के लिए कुल मिलाकर भविष्य की कीमतों के रुझानों का आकलन करने के लिए कीमतों के आंतरिक चैनल पर आधारित एक मात्रात्मक ट्रेडिंग रणनीति है। यह ट्रेंड ट्रैकिंग और ट्रेंड रिवर्सिंग के दो आकलन विधियों को जोड़ती है, जिसमें कुछ फायदे हैं। लेकिन कुछ अनुकूलन योग्य स्थान भी हैं, निवेशक अपनी आवश्यकताओं के आधार पर तदनुसार समायोजित कर सकते हैं, जो विशिष्ट किस्मों और व्यापारिक वातावरण के अनुकूल है। पैरामीटर अनुकूलन के बाद, यह रणनीति बहुत ही आदर्श मात्रात्मक ट्रेडिंग रणनीतियों में से एक हो सकती है।
/*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)