Discussion re Pure Renko strategy
Forums › ProRealTime English forum › ProOrder support › Discussion re Pure Renko strategy
- This topic has 345 replies, 24 voices, and was last updated 4 years ago by bertrandpinoy.
Tagged: renko
-
-
04/06/2020 at 5:34 PM #12491304/07/2020 at 1:00 AM #124943
I’ve been trying to apply ATR code to dynamically adjust the boxsize with little success. I tried optimising the strategy to 500 ticks (on the 10s version) and it prooved to be succesful in the short term with a very small box size.
So I tried to apply the Volatility Breakout Indicator (https://www.prorealcode.com/prorealtime-indicators/volatility-breakout-indicator/) to enter long only when it’s above the upper channel in timeframe 100seconds and vice verca for short conditions.
It seems to be that a small box size doesn’t work most of times as the price quickly retraces and gest stopped out, however from my backtest it looks like it could work when applying this indicator. Maybe this is a way to always use a small box size and having minimum drawdown? Although the % of winning trades are lower than 50% it seems that the losses are small (as momentum is no our side) and the gains are high.
I will test this on demo tomorrow – it would be amazing if we could have a set box size that worked all the time!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493//variation of renko strategy with volatility cycle indicator to filter. This allows for a smaller box size to be used with high accuracy.//————————————————————————-// Hoofd code : renko v3.2 dji 10 sec(V2)//————————————————————————-// see notes for spreaddefparam cumulateorders = falsedefparam preloadbars = 1000defparam flatbefore = 130000defparam flatafter = 211500timeframe (100 seconds)myupperchannel, mylowerchannel = CALL “PRC_Volatility Cycle Breakout”[18, 2, 10, 0.1]timeframe (default)once spreadmode = 1 // [1]dji;[2]us500;[3]us100;[4]dax;[5]saf;[6]ftse;[7]cac40once orderhandling = 1 // [0] default; [1] based on open v/d market orderonce orderoffset = 1 // % average slippage & spread points if above=[1]once trailingstoptype = 2 // [0]off [1]original [2]modified(faster)once positionsize = 1once tradetype = 1 // [1]long&short;[2]long;[3]shortonce closeonreversal = 1 // break renko other sideonce closeonbreak = 1 // close on breaking previous x high / lowonce periodr = 1 //0all;1day;2week;3month;4yearonce maxprofit = 100 //set high to make it useless, or to i.e. 2 %once maxloss = 100 //set high to make it useless, or to i.e. 2 %// boxsize settingsboxsize = 1.3once renkomax = round(close / boxsize) * boxsizeonce renkomin = renkomax – boxsizeif close > renkomax + boxsize and not (close < renkomin – boxsize) thenrenkomax = renkomax + boxsizerenkomin = renkomin + boxsizeendifif close < renkomin – boxsize and not (close > renkomax + boxsize) thenrenkomax = renkomax – boxsizerenkomin = renkomin – boxsizeendif//================================// limit losses & secure profitif periodr=0 thenif barindex=0 thenlongperf=0shortperf=0tradecounter=0tradecounterlong=0tradecountershort=0endifelsif periodr=1 thenif day<>day[1] thenlongperf=0shortperf=0tradecounter=0tradecounterlong=0tradecountershort=0endifelsif periodr=2 thenif dayofweek=0 thenlongperf=0shortperf=0tradecounter=0tradecounterlong=0tradecountershort=0endifelsif periodr=3 thenif month<>month[1] thenlongperf=0shortperf=0tradecounter=0tradecounterlong=0tradecountershort=0endifelsif periodr=4 thenif year<>year[1] thenlongperf=0shortperf=0tradecounter=0tradecounterlong=0tradecountershort=0endifendifif longonmarket[1] and (not onmarket or shortonmarket) thenif strategyprofit[1]>=strategyprofit[2] thenlongperf=longperf+positionperf(1)*100elselongperf=longperf-positionperf(1)*100endifendifif shortonmarket[1] and (not onmarket or longonmarket) thenif strategyprofit[1]>=strategyprofit[2] thenshortperf=shortperf+positionperf(1)*100elseshortperf=shortperf-positionperf(1)*100endifendifif longperf>maxprofit or longperf<-maxloss thentradelong=0elsetradelong=1endifif shortperf>maxprofit or shortperf<-maxloss thentradeshort=0elsetradeshort=1endif//=================================// strategyonce periodeb = 15once nbchandelierb = 30mmb = exponentialaverage[periodeb](totalprice)pente = (mmb-mmb[nbchandelierb]*pipsize) / nbchandelierb//buy conditionscondbuy = (pente > -0.5)//short conditionscondsell = (pente < -1)if range<>0 thenspreadOC=abs(open-close)coeff=spreadOC/highest[6](spreadOC)*100elsecoeff=0endif// conditionscondbuy=condbuy and high > (renkomax + boxsize)condbuy=condbuy and coeff<15condsell=condsell and low < (renkomin – boxsize)condsell=condsell and coeff<15// entryIf (tradetype=1 or tradetype=2) and tradelong and close > myupperchannel thenif condbuy and not longonmarket thenbuy positionsize contract at markettradecounter=tradecounter+1tradecounterlong=tradecounterlong+1endifendifif (tradetype=1 or tradetype=3) and tradeshort and close < mylowerchannel thenif condsell and not shortonmarket thensellshort positionsize contract at markettradecounter=tradecounter+1tradecountershort=tradecountershort+1endifendif// closeonreversalif closeonreversal thenif longonmarket thensell at (renkomin – boxsize) stopendifif shortonmarket thenexitshort at (renkomax + boxsize) stopendifendif// close on break previous high/lowif closeonbreak thenif longonmarket and (shortonmarket[1] or not onmarket[1]) thenbreakvaluelow=lowest[10](low)endifif longonmarket thensell at breakvaluelow stopendifif shortonmarket and (longonmarket[1] or not onmarket[1]) thenbreakvaluehigh=highest[10](high)endifif shortonmarket thenexitshort at breakvaluehigh stopendifendif// spread has to be set in the backtest-engine too// spreadif spreadmode=1 then // wallstreetif time > 090000 and time <= 153000 thenspread=2.4elsif time > 153000 and time <= 220000 thenspread=1.6elsif time > 221500 and time <= 223000 thenspread=9.8elsif time > 230000 and time <= 235959 thenspread=9.8elsif time = 000000 thenspread=9.8elsespread=3.8endifelsif spreadmode=2 then // us500if time > 090000 and time <= 220000 thenspread=0.4elsif time > 221500 and time <= 223000 thenspread=1.5elsif time > 223000 and time <= 235959 thenspread=1.5elsif time = 000000 thenspread=1.5elsespread=0.6endifelsif spreadmode=3 then // us100if time > 153000 and time <= 220000 thenspread=1elsif time > 221500 and time <= 223000 thenspread=5elsif time > 230000 and time <= 235959 thenspread=5elsif time = 000000 thenspread=5elsespread=2endifelsif spreadmode=4 then // daxif time > 090000 and time <= 173000 thenspread=1elsif time > 173000 and time <= 220000 thenspread=2elsif time > 220000 and time <= 235959 thenspread=7elsif time >= 000000 and time <= 080000 thenspread=7elsif time > 080000 and time <= 090000 thenspread=2endifelsif spreadmode=5 then // south african 40if time > 073000 and time <= 163000 thenspread=8elsespread=30endifelsif spreadmode=6 then // ftse100if time > 080000 and time <= 163000 thenspread=1elsif time > 163000 and time <= 210000 thenspread=2elsif time > 070000 and time <= 075000 thenspread=2elsespread=5endifelsif spreadmode=7 then // cac40if time > 090000 and time <= 173000 thenspread=1elsif time > 173000 and time <= 220000 thenspread=2elsif time > 220000 and time <= 235959 thenspread=5elsif time > 000000 and time <= 080000 thenspread=5elsif time > 080000 and time <= 090000 thenspread=2endifendifspread=spread/2// orderhandlingif orderhandling thenonce orderprice=close // prevent graph orderprice at 0 at start chartoffsetvalue=((close/10000)*orderoffset)*pointsize // adjustment spread & slippageif longonmarket and not longonmarket[1] thenorderprice=open+offsetvalue+spreadelsif shortonmarket and not shortonmarket[1] thenorderprice=open-offsetvalue-spreadendifif longonmarket thenpp=((close/orderprice)-1)*100elsif shortonmarket thenpp=((orderprice/close)-1)*100elsif not onmarket thenpp=0endifelseonce orderprice=close // prevent graph orderprice at 0 at start chartorderprice=tradeprice(1)if longonmarket thenpp=((close/orderprice)-1)*100elsif shortonmarket thenpp=((orderprice/close)-1)*100elsif not onmarket thenpp=0endifendifpp=pp // to use variable//graphonprice orderprice//graph spread// trailing atr stop//———————————————-if trailingstoptype=1 thenonce trailingstoplong = 2once trailingstopshort = 2once atrtrailingperiod = 14once minstop = 10atrtrail=averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000 //i.e. dow//atrtrail=averagetruerange[atrtrailingperiod]((close/1)*pipsize) //i.e. forextgl = round(atrtrail*trailingstoplong)tgs = round(atrtrail*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice = 0minprice = closenewsl = 0endifif longonmarket thenmaxprice = max(maxprice,close) // original “close”if maxprice-orderprice>=tgl*pointsize thenif maxprice-orderprice>=minstop thennewsl = maxprice-tgl*pointsizeelsenewsl = maxprice – minstop*pointsizeendifendifendifif shortonmarket thenminprice = min(minprice,close) // original “close”if orderprice-minprice>=tgs*pointsize thenif orderprice-minprice>=minstop thennewsl = minprice+tgs*pointsizeelsenewsl = minprice + minstop*pointsizeendifendifendifif longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifendif// trailing stop atr//———————————————-if trailingstoptype=2 thenonce steps=0.05 // set to 0 to ignore stepsonce minatrdist=1once atrtrailingperiod = 14 // atr parameter valueonce minstop = 10 // minimum trailing stop distanceif barindex=tradeindex thenonce trailingstoplong = 2 // trailing stop atr relative distanceonce trailingstopshort = 2 // trailing stop atr relative distanceelseif longonmarket thenif newsl>0 thenif trailingstoplong>minatrdist thenif newsl>newsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-stepsendifelsetrailingstoplong=minatrdistendifendifendifif shortonmarket thenif newsl>0 thenif trailingstopshort>minatrdist thenif newsl<newsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-stepsendifelsetrailingstopshort=minatrdistendifendifendifendif//atrtrail=averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000 //i.e. dow//atrtrail=averagetruerange[atrtrailingperiod]((close/1)*pipsize) //i.e. forex//tgl=round(atrtrail*trailingstoplong)tgs=round(atrtrail*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice=0minprice=closenewsl=0endif//if longonmarket thenmaxprice=max(maxprice,high)if maxprice-orderprice>=tgl*pointsize thenif maxprice-orderprice>=minstop thennewsl=maxprice-tgl*pointsizeelsenewsl=maxprice-minstop*pointsizeendifendifendif//if shortonmarket thenminprice=min(minprice,low)if orderprice-minprice>=tgs*pointsize thenif orderprice-minprice>=minstop thennewsl=minprice+tgs*pointsizeelsenewsl=minprice+minstop*pointsizeendifendifendif//if longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifif longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifendif//if onmarket thenonce sl=0.5once pt=0.5if longonmarket thenslvalue=orderprice-(sl*(orderprice/100))sell at slvalue stopendifif shortonmarket thenslvalue=orderprice+(sl*(orderprice/100))exitshort at slvalue stopendifif longonmarket thenptvalue=orderprice+(pt*(orderprice/100))sell at ptvalue limitendifif shortonmarket thenptvalue=orderprice-(pt*(orderprice/100))exitshort at ptvalue limitendifendifset stop %loss 1//set target %profit 0.25//graph longperf coloured(0,0,255,255) as “long performance”//graph shortperf coloured(255,0,0,255) as “short performance”//graphonprice renkomax + boxsize coloured(0,200,0) as “renkomax”//graphonprice renkomin – boxsize coloured(200,0,0) as “renkomin”//graphonprice newsl coloured(0,0,255,255) as “trailingstop atr”//graphonprice avg coloured(0,0,255,255) as “average renko”04/07/2020 at 1:01 AM #12494704/07/2020 at 1:41 AM #124949I tidied it up. Sometimes that happens.
04/07/2020 at 9:40 AM #124977I added hourly optimised renko boxsizes. Good idea?
hourly bs optimization123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657// boxsize settingsIF (CurrentHour = 08) THENboxsize = 11.5ENDIFIF (CurrentHour = 09) THENboxsize = 21.4ENDIFIF (CurrentHour = 10) THENboxsize = 25ENDIFIF (CurrentHour = 11) THENboxsize = 33.7ENDIFIF (CurrentHour = 12) THENboxsize = 12.5ENDIFIF (CurrentHour = 13) THENboxsize = 11.6ENDIFIF (CurrentHour = 14) THENboxsize = 2.8ENDIFIF (CurrentHour = 15) THENboxsize = 24.7ENDIFIF (CurrentHour = 16) THENboxsize = 27.8ENDIFIF (CurrentHour = 17) THENboxsize = 14.5ENDIFIF (CurrentHour = 18) THENboxsize = 25.8ENDIFIF (CurrentHour = 19) THENboxsize = 6.5ENDIFIF (CurrentHour = 20) THENboxsize = 12.5ENDIFIF (CurrentHour = 21) THENboxsize = 28.9ENDIF04/07/2020 at 9:48 AM #124979hourly optimised renko boxsizes. Good idea?
Only time will tell? 🙂
We need to Forward Test 2 Systems side by side … one with hourly box opti and one without … I’ve done just that! 🙂
Is box size that critical that we need the value after the decimal point? (curve fitting to the extreme?? 🙂 Also be easier and quicker for opti without decimal values?
04/07/2020 at 9:55 AM #124982@GraHal
Yes indeed! It’s probably over optimised. I wonder also if it’s better to optimise only from yesterdays price action or if it’s good to take a 4 day period. Whilst the maket is so volatile it might be better to optimise against a shorter period? What’s your thougths on this?
04/07/2020 at 9:58 AM #124985I reckon best to use maximum data available (4 days) but to optimise every day at 14:00 ish UK time (before DJI open) .
Then optimised values will be up with latest price action, but also will take into account the last 4 days price action
04/07/2020 at 10:39 AM #124990@eckaw interesting, curious how it performs today!
My focus is on less parameters.
I.e. below
Still it gave me parameters long and/or short and period. That period I use range*10 now.
Maybe it doesn’t make sense, but it can work for the dax too.
123456if barindex>1 and range>0 thenspread = max(abs(open - close), 0.000000001)coeff=spread/highest[range*10](spread)*100trendup = coeff<cftrenddown= coeff<cfendifOne thing for sure. No point optimising with 1.6/2.4 spread. If it’s gonna be profitable, it has to be at 6!
04/07/2020 at 2:24 PM #125059during the test with renko / TF 1s, i saw difference between backtest and demo this afternoon
do you have an idea about the huge difference in the numbers of late candles regarding the last exit ? orange cross/backtest , red cross/demo IG
thanks
04/07/2020 at 4:46 PM #12510604/07/2020 at 5:36 PM #12511804/07/2020 at 6:23 PM #12512804/08/2020 at 4:38 PM #125276here’s an inconsistency today.
short at the same time, backtest sells lower and gets out on trailing stop with small profit.
live demo short sells higher=better and no trailingstop is activated and results in a small loss.
Especially because the entryprice is better in the live demo makes it hard to understand why no ts is activated.
edit; Switched trailing-stops. Same results hopefully better consistency.
04/17/2020 at 9:43 AM #126489 -
AuthorPosts
Find exclusive trading pro-tools on