INVITE-ONLY SCRIPT

CRR Micro Breakout Scalping / Swing

26
//version=6
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

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.