Hi,
I have had a lot of success with an open range break strategy and I am trying to see if I can automate the strategy, but my limited knowledge of coding is proving to be a challenge
I am trying to define the opening range on the 5 min, for a set period of time. using the dax as an example:
- open range is high and low of 5 min candles between 8am and close of the 8:55 five min candle.
- entry is 2nd 5 min close above /below the range
- exit is a Fibonacci expansion of, 261.8
very simple and reliable in my intraday trading on SAF40, Dax, Dow, FTSE and US500.
Does anyone know how you define the range?
EricParticipant
Master
Hi dillongr
try something like this for high (hh) you can also use it as an indicator by “return hh” to see that the time are in right place
starttime = 080000
endtime = 085959
if intradaybarindex=0 then
hh = 0
endif
if time>=starttime and time<=endtime then
if high>hh then
hh = high
endif
endif
EricParticipant
Master
and low (ll)
starttime = 080000
endtime = 085959
if intradaybarindex=0 then
ll = 0
endif
if time>=starttime and time<=endtime then
if low<ll or ll=0 then
ll = low
endif
endif
Where is your stop loss for this strategy?
thanks Eric!
SL is normally at the top or bottom of the range depending if you are long or short. Price normally comes to test the 50% Fibonacci of the range before continuing on the breakout. I also use a 15ema to confirm trend direction
If you have a long breakout you take the bottom of the range as SL and for short the top? Sounds funny. I will program this.
Entry condition you write the second close outside the range. Shall this two closes be consecutive?
And tagte is the 261.8% fibs expansion. So if the range is 100 points wider you have a take profit of 261.8 points above the range top? This is far away!
I coded this here with a profit target at the 161.8% fibo extension (that was already bad enough) and at least for the dax the result was not very promising.
Here is the code if you want to play with it:
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000
MA=ExponentialAverage[15](close)
once tc=0
if time=90000 then
RangeTop=highest[11](high[1])
RangeBottom=lowest[11](low[1])
endif
if intradaybarindex=0 then
tc=0
endif
CL=close>RangeTop and close[1]>RangeTop
CS=close<RangeBottom and close[1]<RangeBottom
box=RangeTop-RangeBottom
if not onmarket and not tc and tradingtime then
if CL and close>MA then
buy 1 contract at market
tc=1
elsif CS and close>MA then
sellshort 1 contract at market
tc=1
endif
set target pprofit box*1.618
endif
if longonmarket then
sell at RangeBottom stop
elsif shortonmarket then
exitshort at RangeTop stop
endif
Same code as Despairs but without EMA15 and a time end for buy at 09:16, tested with 1 WF at 60% resulted in fib 1,5 on OMX 30.
Andy
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>085900 and time<091600
once tc=0
if time=090000 then
RangeTop=highest[11](high[1])
RangeBottom=lowest[11](low[1])
endif
if intradaybarindex=0 then
tc=0
endif
fib=fib
CL=close>RangeTop and close[1]>RangeTop
CS=close<RangeBottom and close[1]<RangeBottom
box=RangeTop-RangeBottom
if not onmarket and not tc and tradingtime then
if CL then
buy 1 contract at market
tc=1
elsif CS then
sellshort 1 contract at market
tc=1
endif
set target pprofit box*fib
endif
if longonmarket then
sell at RangeBottom stop
elsif shortonmarket then
exitshort at RangeTop stop
endif
Ooops, attached 3 times 🙂
EricParticipant
Master
dont forget spread and slippage (sweden30)
Spread was 0,9 should be ok I think, what do you mean with slippage Eric?
EricParticipant
Master
about slippage on sweden30, i mean if you get a bad fill on market order or stop around the open of cash market
but run it on demo it may not be a problem after all?
Andy
On my computer it looks like this.?
Strange.