CRR Micro Breakout Scalping / Swing

strategy(
"CRR Micro Breakout Option-3 Strategy",
overlay = true,
initial_capital = 100000,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 100,
commission_type = strategy.commission.percent,
commission_value = 0.02
)
// © CRR
//================ PARAMETERS =================
lookback = 4
maxBars = 100
flatPoints = 10
flatMinutes = 5
stATRlen = 10
stMult = 3.0
//================ RANGE ======================
rangeHigh = ta.highest(high, lookback)
rangeLow = ta.lowest(low, lookback)
//================ FILTERS ====================
ema59 = ta.ema(close, 59)
[stLine, stDir] = ta.supertrend(stMult, stATRlen)
//================ SIDEWAYS BLOCK =============
emaSlope = math.abs(ema59 - ema59[1])
priceNearEMA = math.abs(close - ema59) <= flatPoints
var int flatStartTime = na
if emaSlope < 0.15 and priceNearEMA
flatStartTime := na(flatStartTime) ? time : flatStartTime
else
flatStartTime := na
flatBlocked = not na(flatStartTime) and (time - flatStartTime >= flatMinutes * 60000)
//================ ENTRY CONDITIONS ===========
buyCond = close > rangeHigh[1] and close > ema59 and stDir == 1 and not flatBlocked
sellCond = close < rangeLow[1] and close < ema59 and stDir == -1 and not flatBlocked
//================ ENTRIES ====================
if buyCond and strategy.position_size <= 0
strategy.entry("BUY", strategy.long)
if sellCond and strategy.position_size >= 0
strategy.entry("SELL", strategy.short)
//================ TIME EXIT ==================
var int barsInTrade = 0
if strategy.position_size != 0
barsInTrade += 1
else
barsInTrade := 0
if barsInTrade >= maxBars
strategy.close_all()
barsInTrade := 0
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact rajesswarrav directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.
Author's instructions
Disclaimer
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact rajesswarrav directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.