open range strategy code – lot of success
Forums › ProRealTime English forum › ProOrder support › open range strategy code – lot of success
- This topic has 38 replies, 10 voices, and was last updated 6 years ago by dillongr.
-
-
10/08/2017 at 10:17 PM #4867410/08/2017 at 10:45 PM #4867610/09/2017 at 5:21 AM #4869510/09/2017 at 5:42 AM #48696
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.
10/09/2017 at 6:17 AM #48698I have made a few changes, still not the results I expect. On SAF 40 it is looking better, but no trades happening in september
123456789101112131415161718192021222324252627282930313233343536defparam cumulateorders=falsetradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000 and time <173000MAL=ExponentialAverage[5](close) > RangeTopMAS=ExponentialAverage[5](close) < RangeBottomonce tc=0if time=90000 thenRangeTop=highest[11](high[1])RangeBottom=lowest[11](low[1])endifif intradaybarindex=0 thentc=0endifCL=close>RangeTopCS=close<RangeBottombox=RangeTop-RangeBottomif not onmarket and not tc and tradingtime thenif CL and MAl thenbuy 1 contract at markettc=1elsif CS and MAS thensellshort 1 contract at markettc=1endifset target pprofit boxendifif longonmarket thensell at (RangeBottom*.6) stopelsif shortonmarket thenexitshort at (RangeTop*.6) stopendif1 user thanked author for this post.
10/09/2017 at 7:05 AM #48701I 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?
1234if longonmarket set target pprofit box*1.61elsif shortonmarket set target pprofit box*0.61endifendif10/09/2017 at 9:30 AM #4871210/09/2017 at 10:53 AM #4874610/09/2017 at 1:50 PM #48778year is the ORB indicator code. Is there a way to only show the lines on the current day during trading hours?
1234567891011if time =090000 thenRangeTop=highest[6](high[1])RangeBottom=lowest[6](low[1])therange= rangetop-rangebottomtenentrylong=((therange*.3820)+rangetop)tenentryshort=(rangebottom-(therange*.3820))takeprofitlong=((therange*1.618)+rangetop)takeprofitshort=(rangebottom-(therange*1.618))endifreturn 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"10/09/2017 at 2:22 PM #48782Like this?
1234567891011if dayofweek=currentdayofweek and time =090000 thenRangeTop=highest[6](high[1])RangeBottom=lowest[6](low[1])therange= rangetop-rangebottomtenentrylong=((therange*.3820)+rangetop)tenentryshort=(rangebottom-(therange*.3820))takeprofitlong=((therange*1.618)+rangetop)takeprofitshort=(rangebottom-(therange*1.618))endifreturn 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"10/09/2017 at 2:57 PM #4878410/09/2017 at 3:00 PM #4878510/10/2017 at 7:22 AM #48852I played around last night, with some interesting results, running it in demo now
1234567891011121314151617181920212223242526272829303132333435363738394041424344defparam cumulateorders=falsetradingtime=dayofweek>=1 and dayofweek<=5 and time>=090500 and time <170000MAL=ExponentialAverage[5](close) > close[1]MAS=ExponentialAverage[5](close) < close[1]//once tc=0if time=090500 thenRangeTop=highest[6](high[1])RangeBottom=lowest[6](low[1])endif//if intradaybarindex=0 then//tc=0//endif//CL=close>RangeTop//CS=close<RangeBottombox=RangeTop-RangeBottomentryl=close>=(rangetop+(box*.15))entrys=close<=(rangebottom-(box*.15))//trendlong=rangetop<ExponentialAverage[5](close)//trendshort=rangebottom>entrysif not onmarket and tradingtime thenif entryl and mal thenbuy 2 contract at market//tc=1elsif entrys and mas thensellshort 2 contract at market//tc=1endifset target pprofit box*2.5endifif longonmarket thensell at ExponentialAverage[5](close)> ExponentialAverage[15](close)stopelsif shortonmarket thenexitshort at ExponentialAverage[5](close)<ExponentialAverage[15](close) stop//elsif//endifendif//set stop loss 10010/10/2017 at 8:34 AM #48867This is the best I could get on Dax. The backtest on the last 30000 candles looks good.
Open Range Dax M1 Spread 11234567891011121314151617181920212223242526272829303132333435363738defparam cumulateorders=falsedefparam flatafter=173000tradingtime=dayofweek>=1 and dayofweek<=5 and time>=90000MA=ExponentialAverage[10](close) //15once tc=0if time=90000 thenRangeTop=highest[11](high[1])RangeBottom=lowest[11](low[1])Box=RangeTop-RangeBottomendifif intradaybarindex=0 thentc=0endifCL=close>RangeTop and close[1]>RangeTopCS=close<RangeBottom and close[1]<RangeBottombox=RangeTop-RangeBottomif not onmarket and not tc and tradingtime thenif CL and close>MA thenbuy 1 contract at markettc=1elsif CS and close<MA thensellshort 1 contract at markettc=1endifset target pprofit box*0.618endif// Stop Lossif longonmarket thensell at RangeBottom-box*1.618 stopelsif shortonmarket thenexitshort at RangeTop+box*1.618 stopendif10/10/2017 at 10:22 AM #48887There 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).
-
AuthorPosts
Find exclusive trading pro-tools on