edit : new topic from https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/
According to IG Status Page … all trading platforms are now sorted!! See attached.
This Renko code is the only code I am still getting Rejects / Stoppages on (up to now anyway!?).
Only major difference I can see between this System and my others is the use of While, Wend? Maybe While. Wend has recently become a non-approved term anymore??
@Nonetheless would it be easy for you to re-code without While, Wend? I know the code is a DocTrading code so maybe it not easy for you either?
If one of our coding wizards might be able to help it would be much appreciated?
Below is the code of the System that is showing +£1.8K profit since October (see attached).
//-------------------------------------------------------------------------
// Main code : Nneless Renko DJI 1M v1
//-------------------------------------------------------------------------
//https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
//DEFPARAM FLATBEFORE = 143000
// Cancel all pending orders and close all positions at the "FLATAFTER" time
//DEFPARAM FLATAFTER = 210000
boxSize = 110 //50
once renkoMax = ROUND(close / boxSize) * boxSize
once renkoMin = renkoMax - boxSize
IF high > renkoMax + boxSize THEN
WHILE high > renkoMax + boxSize
renkoMax = renkoMax + boxSize
renkoMin = renkoMin + boxSize
WEND
ELSIF low < renkoMin - boxSize THEN
WHILE low < renkoMin - boxSize
renkoMax = renkoMax - boxSize
renkoMin = renkoMin - boxSize
WEND
ENDIF
buy 1 CONTRACT at renkoMax + boxSize stop
sellshort 1 CONTRACT at renkoMin - boxSize stop
// Stops and targets
SET STOP PLOSS 75
SET TARGET PPROFIT 150
PaulParticipant
Master
maybe this?
IF high > renkoMax + boxSize THEN
renkoMax = renkoMax + boxSize
renkoMin = renkoMin + boxSize
ELSIF low < renkoMin - boxSize THEN
renkoMax = renkoMax - boxSize
renkoMin = renkoMin - boxSize
ENDIF
Hahaha … nice one Paul!
Your change works (same profits etc) and System has NOT been rejected!
Feeling guilty now that I didn’t persevere with the code.
I had heard others on here mention While, Wend and the terms are on here under approved probuilder language documentation and so I doubted this would be the Issue, but seems it is!
Now I can try my other forks piling up ready to be Forward Tested!
Onward and Upward!
Thank You
Grahal
showing +£1.8K profit since October
That is not too shabby at all, thanks to DocTrading (and also to Paul!) who did the heavy lifting…
PaulParticipant
Master
now wondering if it could be used on a higher timeframe. Couldn’t resist! 100k tested so far on 15 min dow, spread 3.1
//-------------------------------------------------------------------------
// main code : nneless renko dji 1m v1
//-------------------------------------------------------------------------
//https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889
defparam cumulateorders = false
defparam preloadbars = 1000
timeframe (default)
boxsize = 100
once renkomax = round(close / boxsize) * boxsize
once renkomin = renkomax - boxsize
if high > renkomax + boxsize then
renkomax = renkomax + boxsize
renkomin = renkomin + boxsize
elsif low < renkomin - boxsize then
renkomax = renkomax - boxsize
renkomin = renkomin - boxsize
endif
ctime=hour>=4
if ctime then
buy 1 contract at renkomax + boxsize stop
sellshort 1 contract at renkomin - boxsize stop
else
exitshort 1 contract at renkomax + boxsize stop
sell 1 contract at renkomin - boxsize stop
endif
// trailingstop splitsed so it can run on higher timeframe
timeframe (15 minutes,updateonclose)
// trailing atr stop
once trailingstoptype = 1 // trailing stop - 0 off, 1 on
once trailingstoplong = 7 // trailing stop atr relative distance
once trailingstopshort = 4 // trailing stop atr relative distance
once atrtrailingperiod = 14 // atr parameter value
once minstop = 10 // minimum trailing stop distance
// trailingstop
//----------------------------------------------
atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstarts = round(atrtrail*trailingstopshort)
//
if trailingstoptype then
tgl =trailingstartl
tgs=trailingstarts
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
maxprice = 0
minprice = close
newsl = 0
endif
if longonmarket then
maxprice = max(maxprice,close)
if maxprice-tradeprice(1)>=tgl*pointsize then
if maxprice-tradeprice(1)>=minstop then
newsl = maxprice-tgl*pointsize
else
newsl = maxprice - minstop*pointsize
endif
endif
endif
if shortonmarket then
minprice = min(minprice,close)
if tradeprice(1)-minprice>=tgs*pointsize then
if tradeprice(1)-minprice>=minstop then
newsl = minprice+tgs*pointsize
else
newsl = minprice + minstop*pointsize
endif
endif
endif
endif
timeframe (default)
if trailingstoptype then
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
endif
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
endif
endif
// stops and targets
set stop %loss 2
set target %profit 2
graphonprice renkomax + boxsize
graphonprice renkomin - boxsize
it would make sense / logical to ask the Mods to change the name of this Topic to … Discussion re Pure Renko strategy
Yes, absolutely … how do I go about that? I’m waving my arms but guess they can’t see me.
wondering if it could be used on a higher timeframe
Hey, my thoughts exactly! The 1m TF always seemed wrong. Now it’s really starting to look interesting…
Make a statue to Paul thanks
how do I go about that?
@Vonasi or
@RobertoGozzi might check out all the action on this Topic and now – as OP – you are asking for the title to be changed, they may sort it for us?
Now Paul is onboard I can see us having all sorts Renko versions in this Topic so Mods please …
New Topic Required …
Renko Systems
PaulParticipant
Master
there’s a bug at monday 00.00.00 where there shouldn’t be an entry. With the bug the results are better though.
pics are with spread 100k & 200k
//-------------------------------------------------------------------------
// main code : nneless renko dji 15min v1
//-------------------------------------------------------------------------
//https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889
defparam cumulateorders = false
defparam preloadbars = 1000
timeframe (default)
once bugfix=0 // [1] activate bugfix monday time 00.00.00
once boxsize = 100
once renkomax = round(close / boxsize) * boxsize
once renkomin = renkomax - boxsize
if high > renkomax + boxsize then
renkomax = renkomax + boxsize
renkomin = renkomin + boxsize
elsif low < renkomin - boxsize then
renkomax = renkomax - boxsize
renkomin = renkomin - boxsize
endif
condbuy=1
condsell=1
ctime=hour>=3
if bugfix then
if dayofweek=5[1] and (hour[1]=22 or hour[1]=21) then
skipmondayfirsthour=0
else
skipmondayfirsthour=1
endif
else
skipmondayfirsthour=1
endif
if ctime then
if skipmondayfirsthour then
if condbuy then
buy 1 contract at renkomax + boxsize stop
endif
if condsell then
sellshort 1 contract at renkomin - boxsize stop
endif
endif
endif
// trailingstop splitsed so it can run on higher timeframe
timeframe (15 minutes,updateonclose)
// trailing atr stop
once trailingstoptype = 1 // trailing stop - 0 off, 1 on
once trailingstoplong = 7 // trailing stop atr relative distance
once trailingstopshort = 4 // trailing stop atr relative distance
once atrtrailingperiod = 14 // atr parameter value
once minstop = 10 // minimum trailing stop distance
// trailingstop
//----------------------------------------------
atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstarts = round(atrtrail*trailingstopshort)
//
if trailingstoptype then
tgl =trailingstartl
tgs=trailingstarts
if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
maxprice = 0
minprice = close
newsl = 0
endif
if longonmarket then
maxprice = max(maxprice,close)
if maxprice-tradeprice(1)>=tgl*pointsize then
if maxprice-tradeprice(1)>=minstop then
newsl = maxprice-tgl*pointsize
else
newsl = maxprice - minstop*pointsize
endif
endif
endif
if shortonmarket then
minprice = min(minprice,close)
if tradeprice(1)-minprice>=tgs*pointsize then
if tradeprice(1)-minprice>=minstop then
newsl = minprice+tgs*pointsize
else
newsl = minprice + minstop*pointsize
endif
endif
endif
endif
timeframe (default)
if trailingstoptype then
if longonmarket then
if newsl>0 then
sell at newsl stop
endif
endif
if shortonmarket then
if newsl>0 then
exitshort at newsl stop
endif
endif
endif
// stops and targets
set stop %loss 2
set target %profit 2
graphonprice renkomax + boxsize
graphonprice renkomin - boxsize
Sadly the robustness test is a bust for this one. Odd because I had thought that Renko bars were time independent and that it might perform better than most. 🤔
Would be worth putting a link to your post above on Vonasi Robustness Tester Topic … he might have some useful observation re Renko and Robustness tests?
Here’s an interesting development. Starting with the 1m version that @Grahal was running I added a trailing stop, tweaked the boxsize, stop and TP — ran it on daily TF for a 20 year back test.
Very low % win but the stop loss is just .1% so it works even with lots of small losses. WF is as good as it gets, robustness checks out…
Can you also do the 21 5 and the 20 5 in order to look at the total average?