Occ
Occ
//
strategy(title = "Open Close Cross Strategy R5.1", shorttitle = "OCC Strategy R5.1", overlay = true,
pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 10,
calc_on_every_tick=false)
a1 = exp(-1.414*3.14159 / len)
b1 = 2*a1*cos(1.414*3.14159 / len)
c2 = b1
c3 = (-a1)*a1
c1 = 1 - c2 - c3
v12 = 0.0
v12 := c1*(src + nz(src[1])) / 2 + c2*nz(v12[1]) + c3*nz(v12[2])
type=="EMA"?v2 : type=="DEMA"?v3 : type=="TEMA"?v4 : type=="WMA"?v5 : type=="VWMA"?v6 :
type=="SMMA"?v7 : type=="HullMA"?v8 : type=="LSMA"?v9 : type=="ALMA"?v10 : type=="TMA"?v11:
type=="SSMA"?v12: v1
//
// === ALERT conditions
xlong = crossover(closeSeriesAlt, openSeriesAlt)
xshort = crossunder(closeSeriesAlt, openSeriesAlt)
longCond = xlong // alternative: longCond[1]? false : (xlong or xlong[1]) and close>closeSeriesAlt and
close>=open
shortCond = xshort // alternative: shortCond[1]? false : (xshort or xshort[1]) and close<closeSeriesAlt
and close<=open
// === /ALERT conditions.
// Make sure we are within the bar range, Set up entries and exit conditions
if ((ebar==0 or tdays<=ebar) and tradeType!="NONE")
strategy.entry("long", strategy.long, when=longCond==true and tradeType!="SHORT")
strategy.entry("short", strategy.short, when=shortCond==true and tradeType!="LONG")
strategy.close("long", when = shortCond==true and tradeType=="LONG")
strategy.close("short", when = longCond==true and tradeType=="SHORT")
strategy.exit("XL", from_entry = "long", profit = TP, loss = SL)
strategy.exit("XS", from_entry = "short", profit = TP, loss = SL)