0% found this document useful (0 votes)
244 views1 page

Elder Force Index Strategy

This document contains the code for a trading strategy. It calculates technical indicators like the Elders Force Index and averages true range. It enters long or short positions based on crossovers of a momentum oscillator and sets entry prices and stop losses relative to the average true range. It plots the strategy's performance by counting wins and losses.

Uploaded by

shehab gouda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
244 views1 page

Elder Force Index Strategy

This document contains the code for a trading strategy. It calculates technical indicators like the Elders Force Index and averages true range. It enters long or short positions based on crossovers of a momentum oscillator and sets entry prices and stop losses relative to the average true range. It plots the strategy's performance by counting wins and losses.

Uploaded by

shehab gouda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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)

You might also like