Final KSR Strategy Code
Final KSR Strategy Code
Final KSR Strategy Code
0 at
https://mozilla.org/MPL/2.0/
// © askkuldeeprandhawa
//@version=4
//par1=input(10)
par1=input(title="Strategy EMA 1", type=input.integer, defval=11, minval=1,
maxval=200, step=1)
par2=input(title="Strategy EMA 2", type=input.integer, defval=37, minval=1,
maxval=200, step=1)
ema1=ema(close,par1)
ema2=ema(close,par2)
buy=ema1>ema2
sell=ema2>ema1
mycolor= iff(buy,color.green,iff(sell,color.blue,color.red))
barcolor(color=mycolor)
ibuy=crossover(ema1,ema2)
iSell=crossunder(ema1,ema2)
//iSell=crossunder(close,ema1)
varp=tostring(close[1])
//plotshape(ibuy, "Up Arrow", shape.triangleup, location.belowbar, color.green, 0,
0,"Buy" , color.green, true, size.tiny)
//plotshape(iSell, "Down Arrow", shape.triangledown, location.abovebar, color.red,
0, 0, "Sell", color.red, true, size.tiny)
plot(ema(close,par1),"EMA Short",color=color.white)
plot(ema(close,par2),"EMA Long",color=color.orange)
//plot(ema(close,50),"EMA 50",color=color.purple)
longCondition = crossover(ema(close, par1), ema(close, par2))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
o = ema(open, ma1_len)
c = ema(close, ma1_len)
h = ema(high, ma1_len)
l = ema(low, ma1_len)
tim1=input('D',"Short Time")
tim2=input('W',"Long Time")
ha_t1 = heikinashi(syminfo.tickerid)
ha_o1 = security(ha_t1, tim1, o)
ha_c1 = security(ha_t1, tim1, c)
ha_h1 = security(ha_t1, tim1, h)
ha_l1 = security(ha_t1, tim1, l)
o3 = ema(ha_o1, ma2_len)
c3 = ema(ha_c1, ma2_len)
h3 = ema(ha_h1, ma2_len)
l3 = ema(ha_l1, ma2_len)
ha_col1 = ha_c1 > ha_o1 ? color.red : color.green
//plotcandle(o2, o2, c2, c2, title="Heikin Ashi Smoothed", color=ha_col)
plotshape(true, style=shape.circle, color=ha_c1 > ha_o1 ? color.green : color.red,
location=location.top)