study(title="Elders Force Index", shorttitle="EFI", format=format.
volume,
resolution="")
length = input(13, minval=1)
efi = ema(change(close) * volume, length)
plot(efi, color=#D66654, title="Elders Force Index")
hline(0, color=#606060, title="Zero")
entryprice = 0.0
delta = 0.0
direction = 0
entryprice := entryprice[1]
delta := delta[1]
direction := direction[1]
atr = 0.0
atr := atr[1]
atr := rma(tr(true), 14)
var x = 0
var y = 0
if ((direction == 1) and (high >= (entryprice + delta)))
strategy.close("buy", comment = "win1" )
x := x + 1
direction := 0
if ((direction == 1) and ((entryprice - (1.5 * delta)) >= low))
strategy.close("buy", comment = "loss1")
y := y + 1
direction := 0
if ((direction == -1) and ((entryprice - delta) >= low))
strategy.close("sell", comment = "win2")
x := x + 1
direction := 0
if ((direction == -1) and ((entryprice + (1.5*delta)) <= high))
strategy.close("sell", comment = "loss2")
y := y + 1
direction := 0
if (crossover(pmo, signal) and (not (direction == 1)))
if (time >= timestamp(2015 , 1 , 1))
strategy.close("sell")
strategy.entry("buy", strategy.long , qty = 1000)
entryprice := close
delta := atr
direction := 1
if crossunder(pmo, signal) and (not (direction == -1))
if (time >= timestamp(2015 , 1 , 1))
strategy.close("buy")
strategy.entry("sell", strategy.short , qty = 1000)
entryprice := close
delta := atr
direction := -1
plot ( x , title='wins' , color=color.lime )
plot (y , color=color.red)