Pro order different from probacktest
Forums › ProRealTime English forum › ProOrder support › Pro order different from probacktest
- This topic has 41 replies, 5 voices, and was last updated 3 years ago by
PeterSt.
-
-
03/02/2022 at 1:41 PM #189194
hello, I have a discrepancy between pro backtest and pro order. They mostly seem synchronised but only on the loosing trades. the live code took a few loosing trades that the backtest didn’t take. And the live code hardly took any of the winning trades that the backtest did take which which reduces a 45% accurate backtest down to 2% accurate on live. I overcompensated for the spread on the backtest to account for a bit of slippage here and there.
The code is exactly the same I run a backtest and then from there prepare for automated trading and run them side by side to compare the difference.
Is there anything I can do to resolve this? or are these codes not able to replicate a backtest on live money?
I found it funny how the discrepancy was the live code only took loosing trades and not one winning trade and not the other way round. is there anything behind this or is it just bad luck?
03/02/2022 at 3:29 PM #189197Hi, you have ticked by tick mode
03/02/2022 at 6:02 PM #18920703/02/2022 at 7:16 PM #18920903/02/2022 at 10:35 PM #189214Thanks for your reply. Yes, i have checked the minimum trade size for the asset and set it to that. and i have backtested the code with a larger spread than it will be on live so if anything it should be better.
The majority of the issue seems to be on execution, the live is taking all of the loosing trades the backtest takes but doesn’t get into the trades that win. Also the live code got stopped out of a few winning trades before they went on to win whereas the backtest code didn’t get stopped out and went on to win. The spread is higher on my backtest than on the live to make sure i am testing for the wort possible case scenario.
03/02/2022 at 11:16 PM #189215You’ve not said what is the Instrument?
If it’s Forex then you may be getting a lot of flash (few milliseconds) widening of the spread and that is hitting your stop, whereas no such flash spread occurs in backtest. Add the Indicator – Bid Ask band to yuor chart and you can see the flash wideing of the spread!
If you post your code on here then I would run it on my platform and see if I come up with anything?
But also the coding wizards on here would take a look at your code and advise any oddities likely to cause issues.
03/03/2022 at 4:39 AM #189216Is there anything I can do to resolve this? or are these codes not able to replicate a backtest on live money?
Hi there Jos,
Please take it from me that a backtest can be equal to live for, say 95 out of the 100 trades. Thus, 95 out of 100 will be equal to the penny.
BUT
Those 5 not equal will create a completely different flow/sequence of the further trades. And this is the first you did not see through yet (with respect of course).
Try this, in order to see what I mean : Start a Live system with little money, and start a Backtest with the same money and code. Take care that the first trade is synchronised in both (fiddle with the start time of the backtest in order to get there). The backtest will now run in “forward test” mode. Thus, just let it be and see what it does. Now, according to yourself you *will* see that a next order (starting with the exit and otherwise a next entry) will not be synchronised any more in both Live and Forward-Backtest). This is the point where I want you to be, because from that point on you will see that all your arguments for “not the same result” are moot.All even includes you highering the spread in the backtest and expecting less profit from there. Eh, no; instead, all will be apples and oranges because the trade sequence is going to be different, and actually it is close to 50% whether you will make more or less money with the higher spread (on the very long term less for sure indeed).
If you, as GraHal asked, would show us the code in full, you can bet that we will be working on it to give you the hints on what the culprits and pitfalls could theoretically be (we won’t be executing your code in Live). Also hand the timeframe of the chart and indeed the instrument you run it on.
An almost infinite reasons exist allowing your backtest results to be be different from Live and this is mostly related to our perception of how markets are and react. You will undoubtedly see responses like “yea, no wonder, because you challenge for …” etc. (it is useless to give real examples at this moment). But … I am afraid that you will also see that whatever it exactly is that’s going off, mostly can’t be tackled by you. This is related to the enormous amount of time involved to get it right on one hand, and the required creativity and coding skills on the other. And we can’t demand from anyone that he can spend this time and has all the skills. And for example, possibly all people reading about my said “95 out of 100” will say, “yea sure !” (not believing that at all).
As far as I can tell myself, there’s at least one area where the backtesting will be off compared to reality : accumulated orders. PRT’s backtesting engine lacks the proper features for maintaining the gain accurately so much so, that I can’t get it to “synchronise” with even a single trade (a first does not end up equal, therefore does not end up equally in time, and therefore the sequence hence trades are not the same from the start). Once could also attest that now my own creativity etc. has its limits, or I just did not find the way.
Apologies for all the blathering, but I think it’s all good things to know for everyone, especially the mere beginners with AutoTrading.
Regards,
Peter1 user thanked author for this post.
03/03/2022 at 10:57 AM #189230You always have to start the backtest with the same day and time as when you put in Live, only in this way you are able to evaluate if there are any problems.
So for example, if you start the live on March 9, 2022 at 10.00 also the backtest you have to do everything the same.
Hello
Mauro03/03/2022 at 2:01 PM #189252Thankyou all for your replies I really appreciate the help. I paid for this code to be done so that I can turn on and off different indicators and change parameters over multiple timeframes so that I can easily tailor the code to different assets using a range of tools. So I will explain clearly on here what exactly this is supposed to be doing so that you can ignore the rest and hone in on the parts being used.
Timeframe 3 minutes
buy trade to be taken when:
EMA 3 > EMA6 [by 2 pips]
EMA6 > EMA9 [by 8 pips]
Price crosses over upper bollingerband [period 5] [standard dev 1.0]
sell trade to be taken
EMA 3 < EMA6 [by 2 pips]
EMA6 < EMA9 [by 8 pips]
Price crosses under lower bollingerband [period 5] [standard dev 1.0]
Stop loss – 9
Trailing stop – 7
Risk-reward – 10 [the strategy is to get taken out by the trailing stop]
If the signal is larger than 20pips take trade on 50% retracement of next candle [only]
It doesn’t actually take the trades exactly how I want it to, even on the backtest so I think something is wrong on there somewhere, however I figured if it produces good results then it will be good to use anyway.
The idea behind the strategy is for the code to detect short term buying and selling pressure and take an entry around where price is pushing hence the use of the bollinger band or 1 or 2 period EMA also works. And I want the code to execute the trade as it’s pushing with a tight trailing stop loss. And choosing an asset such as the NASDAQ that moves a long way allows to make a larger pip gain with short moves than say a forex pair. also the Spread for the NASDAQ is 1-2 pips the majority of the time.
The code doesn’t actually seem to be taking the trades I feel that it should be taking when I’m looking at the charts. I thought maybe the “signal larger than” parameter what causing the issue I have tried it without and it’s still not right. If you could take a look for me that would be great and please ask any further questions you might have.
Thanks
03/03/2022 at 3:44 PM #1892651This is better as then the coding wizards do not have to import to their platforms etc
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889//v1.1 - the 2 RSi strategies and stochastic strategy to include the MA conditionsdefparam cumulateorders=false//timeframe(15 minutes,updateonclose)sma50d = exponentialaverage[5]sma90d = exponentialaverage[8]sma200d = exponentialaverage[13]ema90d = exponentialaverage[90]ema200d = exponentialaverage[200]dailybuyc = sma50d-sma90d>dailyMA50MA90Distance*pointsize and sma90d-sma200d>dailyMA90MA200Distance*pointsizedailysellc = sma90d-sma50d>dailyMA50MA90Distance*pointsize and sma200d-sma90d>dailyMA90MA200Distance*pointsize//timeframe(3 minutes,updateonclose)sma50h4 = exponentialaverage[3]sma90h4 = exponentialaverage[6]sma200h4 = exponentialaverage[9]ema90h4 = exponentialaverage[55]ema200h4 = exponentialaverage[89]h4buyc = sma50h4<sma90h4 and sma90h4<sma200h4h4sellc = sma50h4>sma90h4 and sma90h4>sma200h4//timeframe(3 minutes,updateonclose)sma50m15 = exponentialaverage[3]sma90m15 = exponentialaverage[6]sma200m15 = exponentialaverage[9]ema90m15 = exponentialaverage[55]ema200m15 = exponentialaverage[89]m15buyc = sma50m15-sma90m15>m15MA50MA90Distance*pointsize and sma90m15-sma200m15>m15MA90MA200Distance*pointsizem15sellc = sma90m15-sma50m15>m15MA50MA90Distance*pointsize and sma200m15-sma90m15>m15MA90MA200Distance*pointsize//timeframe(default)if rsistrategy then //rsi jump trade entryirsi = rsi[rsiperiod]buyc1 = (dailybuyc and h4buyc and m15buyc) and ((irsi[1]<RSIcross1Level1 and irsi>RSIcross1Level2) OR (irsi[1]<RSIcross2Level1 and irsi>RSIcross2Level2) OR (irsi[1]<RSIcross3Level1 and irsi>RSIcross3Level2) OR (irsi[1]<RSIcross4Level1 and irsi>RSIcross4Level2) OR (irsi[1]<RSIcross5Level1 and irsi>RSIcross5Level2))sellc1 = (dailysellc and h4sellc) and ((irsi[1]>RSIcross1Level2 and irsi<RSIcross1Level1) OR (irsi[1]>RSIcross2Level2 and irsi<RSIcross2Level1) OR (irsi[1]>RSIcross3Level2 and irsi<RSIcross3Level1) OR (irsi[1]>RSIcross4Level2 and irsi<RSIcross4Level1) OR (irsi[1]>RSIcross5Level2 and irsi<RSIcross5Level1))endifif mastrategy then //moving average trade entryBB = 5 //20 periodsBBdev = 1.0 //2.0 standard deviationBBavg = average[BB,0](close) //BB mean (middle line)UPboll = BBavg + ((std[BB](close)) * BBdev) //BB Upper BandLOboll = BBavg - ((std[BB](close)) * BBdev) //BB Lower Bandmacrossbuy = open crosses over UPbollmacrosssell = open crosses under LObolLbuyc2 = m15buyc and macrossbuysellc2 = m15sellc and macrosssellendifif rsimultiplestrategy then //rsi multiple cross entryrsi1 = rsi[rsiper1]rsi2 = rsi[rsiper2]rsi3 = rsi[rsiper3]buyc3 = (dailybuyc and h4buyc) and ((rsi1 crosses over rsi1over1 and rsi2 crosses over rsi2over1 and rsi3 crosses over rsi3over1) or (rsi1 crosses over rsi1over2 and rsi2 crosses over rsi2over2 and rsi3 crosses over rsi3over2) or (rsi1 crosses over rsi1over3 and rsi2 crosses over rsi2over3 and rsi3 crosses over rsi3over3))sellc3 = (dailysellc and h4sellc) and ((rsi1 crosses under rsi1under1 and rsi2 crosses under rsi2under1 and rsi3 crosses under rsi3under1) or (rsi1 crosses under rsi1under2 and rsi2 crosses under rsi2under2 and rsi3 crosses under rsi3under2) or (rsi1 crosses under rsi1under3 and rsi2 crosses under rsi2under3 and rsi3 crosses under rsi3under3))endifif stochasticstrategy then //stochastic entrysto = Stochastic[stokperiod,stoksmoothing](close)buyc4 = (dailybuyc and h4buyc and m15buyc) and (sto crosses over stoover1 or sto crosses over stoover2 or sto crosses over stoover3)sellc4 = (dailysellc and h4sellc and m15sellc) and (sto crosses under stounder1 or sto crosses under stounder2 or sto crosses under stounder3)endif// --- orderslotsize = 1if not longonmarket and (buyc1 or buyc2 or buyc3 or buyc4) thenif range>SignalLargerThan*pointsize thenbuy lotsize contract at high-range*.5 stopelsebuy lotsize contract at marketendifendifif not shortonmarket and (sellc1 or sellc2 or sellc3 or sellc4) thenif range>SignalLargerThan*pointsize thensellshort lotsize contract at low+range*.5 stopelsesellshort lotsize contract at marketendifendif// --- tp & slif trailingstopenable thensl = trailingstopsizeset stop ptrailing slelsesl = stoplossdistanceset stop ploss slendifset target pprofit sl*RiskRewardRatio//graph (dailybuyc and h4buyc and m15buyc)1 user thanked author for this post.
03/03/2022 at 3:49 PM #189266I’m surpised it runs at all as lotsize, trailingstopsize and stoplossdistance (Lines 66 to 84) are not defined anywhere?
When I click on above in the code editor, the highllighter only shows the one instance of above (4 in the case of lotsize).
Am I missing a trick here?? 🙂
03/03/2022 at 4:07 PM #189268Note: I defined lotsize = 1 at Line 63.
This weirder and weirder … ‘google find’ says there are 13 mentions of lotsize on the page, I can see 8 and 3 of those are in my text. Google find is not highlighting the other 5 anywhere!?
Is above a new way of hiding code or should I have gone to specsavers!!?? 🙂
03/03/2022 at 4:18 PM #189269Is above a new way of hiding code
Yes it is GraHal … they are hidden in the optimiser as variables!! doh to me!!! 🙂
I’ve got so used to my variables names being Line numbers (A10, B26 … etc) I was blind to varables as names!
Specsavers, ring ring … appointment please!! 🙂
03/03/2022 at 8:31 PM #18928503/03/2022 at 9:03 PM #189286I have a discrepancy between pro backtest and pro order
It be good if you post your backtests results then we can start investigations from the same baseline?
-
AuthorPosts
Find exclusive trading pro-tools on