@Stefanb, yes that´s strange, 1.5 instead of fib in “set target pprofit box*1.5″ and 0,9 in spread, that´s about it.
yes that is how I am running it. my entries are on the 2nd 5min close outside the range. Manually it works for for me, but then again manually you can react to price action on the fly
Thanks Despair.
That is the problem I am having. If you manually draw the range with fib extensions, you will see how often those targets are hit, but when we try code it, the results are not what I am seeing. For example the dow and S&P hit the 261.8 targets 4 times last week.
I have made a few changes, still not the results I expect. On SAF 40 it is looking better, but no trades happening in september
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000 and time <173000
MAL=ExponentialAverage[5](close) > RangeTop
MAS=ExponentialAverage[5](close) < RangeBottom
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
CS=close<RangeBottom
box=RangeTop-RangeBottom
if not onmarket and not tc and tradingtime then
if CL and MAl then
buy 1 contract at market
tc=1
elsif CS and MAS then
sellshort 1 contract at market
tc=1
endif
set target pprofit box
endif
if longonmarket then
sell at (RangeBottom*.6) stop
elsif shortonmarket then
exitshort at (RangeTop*.6) stop
endif
I notice that the short targets will not work as we are targeting the top of range, I am trying to add criteria that defines a 161.8 expansion but I get errors. Am I coding this correct?
if longonmarket set target pprofit box*1.61
elsif shortonmarket set target pprofit box*0.61
endif
endif
You should make an indicator of the box and its target/stop and applied it on price, better to get a real idea of what happened or not and what to expect from any possible scenario, just my 2 cents 🙂 Great job everyone!
good idea Nicolas! Notice that the dax has broken its open range and on its way to the -61.8 Fibonacci extension. It has already hit the height of the range target
year is the ORB indicator code. Is there a way to only show the lines on the current day during trading hours?
if time =090000 then
RangeTop=highest[6](high[1])
RangeBottom=lowest[6](low[1])
therange= rangetop-rangebottom
tenentrylong=((therange*.3820)+rangetop)
tenentryshort=(rangebottom-(therange*.3820))
takeprofitlong=((therange*1.618)+rangetop)
takeprofitshort=(rangebottom-(therange*1.618))
endif
return rangetop as "top of range", rangebottom as "bottom of range", tenentrylong as "anti fake out long",tenentryshort as "anti fake out short", takeprofitlong as"Long Profit Target", takeprofitshort as"Short Profit Target"
Like this?
if dayofweek=currentdayofweek and time =090000 then
RangeTop=highest[6](high[1])
RangeBottom=lowest[6](low[1])
therange= rangetop-rangebottom
tenentrylong=((therange*.3820)+rangetop)
tenentryshort=(rangebottom-(therange*.3820))
takeprofitlong=((therange*1.618)+rangetop)
takeprofitshort=(rangebottom-(therange*1.618))
endif
return rangetop as "top of range", rangebottom as "bottom of range", tenentrylong as "anti fake out long",tenentryshort as "anti fake out short", takeprofitlong as"Long Profit Target", takeprofitshort as"Short Profit Target"
S&P and Dow both hit their 61.8 open range targets
I played around last night, with some interesting results, running it in demo now
defparam cumulateorders=false
tradingtime=dayofweek>=1 and dayofweek<=5 and time>=090500 and time <170000
MAL=ExponentialAverage[5](close) > close[1]
MAS=ExponentialAverage[5](close) < close[1]
//once tc=0
if time=090500 then
RangeTop=highest[6](high[1])
RangeBottom=lowest[6](low[1])
endif
//if intradaybarindex=0 then
//tc=0
//endif
//CL=close>RangeTop
//CS=close<RangeBottom
box=RangeTop-RangeBottom
entryl=close>=(rangetop+(box*.15))
entrys=close<=(rangebottom-(box*.15))
//trendlong=rangetop<ExponentialAverage[5](close)
//trendshort=rangebottom>entrys
if not onmarket and tradingtime then
if entryl and mal then
buy 2 contract at market
//tc=1
elsif entrys and mas then
sellshort 2 contract at market
//tc=1
endif
set target pprofit box*2.5
endif
if longonmarket then
sell at ExponentialAverage[5](close)> ExponentialAverage[15](close)stop
elsif shortonmarket then
exitshort at ExponentialAverage[5](close)<ExponentialAverage[15](close) stop
//elsif
//endif
endif
//set stop loss 100
This is the best I could get on Dax. The backtest on the last 30000 candles looks good.
defparam cumulateorders=false
defparam flatafter=173000
tradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000
MA=ExponentialAverage[10](close) //15
once tc=0
if time=90000 then
RangeTop=highest[11](high[1])
RangeBottom=lowest[11](low[1])
Box=RangeTop-RangeBottom
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*0.618
endif
// Stop Loss
if longonmarket then
sell at RangeBottom-box*1.618 stop
elsif shortonmarket then
exitshort at RangeTop+box*1.618 stop
endif
@dillongr
There is something wrong with your exit conditions (pending orders) at lines 37 and 39. You are trying to put a stop order at 1 or 0 since you are using boolean conditions (is my first value is superior to my second one? TRUE=1 FALSE=0).