Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © askkuldeeprandhawa

//@version=4

strategy("KSR F2F Trading Strategy", overlay=true)


par1=input(21)
par2=input(55)
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)

ema100=ema(close,100)
ibuy=crossover(ema1,ema2)
iSell=crossunder(ema1,ema2)
//iSell=crossunder(close,ema1)
varp=tostring(close[1])

crossed =crossover(ema(close,par1), ema(close,par2))


if crossed
l = label.new(bar_index, na, tostring(close),
color=color.green,
textcolor=color.white,
style=label.style_labelup, yloc=yloc.belowbar)

crossed2 =crossunder(ema(close,par1), ema(close,par2))


if crossed2
l = label.new(bar_index, na, tostring(close),
color=color.red,
textcolor=color.white,
style=label.style_labeldown, yloc=yloc.abovebar)

plot(ema(close,par1),"EMA Short",color=color.blue)
plot(ema(close,par2),"EMA Long",color=color.orange)

longCondition = crossover(ema(close, par1), ema(close, par2))


if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)

shortCondition = crossunder(ema(close, par1), ema(close, par2))


if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)

You might also like