ProOrder / Indicator inconsistency
Forums › ProRealTime English forum › ProOrder support › ProOrder / Indicator inconsistency
- This topic has 11 replies, 4 voices, and was last updated 6 years ago by
robertogozzi.
-
-
09/27/2019 at 4:55 AM #108641
Dear forum members,
I have been back-testing a strategy I’ve been working on and I’ve used the exact same code for the ProOrder as I have in my indicator.
However, when I compare the trades with my indicator, I can clearly see inconsistencies here and there. They are not big, but they fail entries or create entries that should not have occured in my indicators. I can follow the problem by using Graph and comparing the outcome of the different parts of the back-test parameters with my indicators. As mentioned, they are identical in code.
I have set the DEFPARAMPRELOADBARS = 0
This is to make sure that the code in the backtest doesn’t preload any bars. I understand that the indicator shouldn’t preload either – at least it doesn’t look like it.
Any idea why I get this inconsistency?
Thanks
09/27/2019 at 8:32 AM #10864409/27/2019 at 8:38 AM #108646Its more or less impossible to help/answer without more context.
Please show code if possible so we can test it, or at least show indicator code and or photos of the failed/missed entries with more explanation.
99% of the time i experience this, its my own fault and after posting in this forum ive been corrected. Feelsgoodman.jpeg
09/27/2019 at 1:45 PM #108671Hi,
I looked at my code for hours till my eyes were bleeding early this morning. It’s a complex code that takes a lot of values at the first bars, and this affects everything, so I did a short test and found there IS A DIFFERENCE between indicators and back-testing. Namely – 1 bar difference.
I have intentionally put in PreloadBars = 0 as I thought this was messing with my code. No difference. So I put a conditional BarIndex entry and found the culprit.
Have a look:
__________________________________________________________________
SNAFU INDICATOR123456IF BarIndex > 14 THENATR = AverageTrueRange[14](CLOSE)ENDIFRETURN ATR__________________________________________________________________
FUBAR ProOrder123456789101112131415161718// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedDEFPARAM PRELOADBARS = 0IF BarIndex > 14 THENATR = AverageTrueRange[14](CLOSE)Trange = TR(CLOSE)ENDIFIF Trange > ATR THENBUY 1 CONTRACT AT MARKETENDIFIF Trange < ATR THENSELL AT MARKETENDIFGRAPH ATR__________________________________________________________________
Compare the SNAFU indicator with FUBAR graph output.
If I change the BarIndex > 13 in the Indicator SNAFU – then it all works out the same. But if I leave it at 14 on both, – I get one bar displacement. That means that my indicator would not show me the same exit / entry as I would expect in the ProOrder FUBAR at the early bars.
I take it that the 0(zero) bar in BarIndex for indicator SNAFU is differently accounted for when relating to ProOrder back-test and that puts the whole calculation of bars one step later in indicator.
Question is how this affects strategies relying on settings at the first bars? Everything will be skewed as the count of Bars is messed up. Maybe averages will even out over time, but for me counting close and open and relating to these, it is completely out of sync! I get totally different appearances on Indicator and ProOrder.
09/27/2019 at 2:02 PM #10867409/27/2019 at 2:15 PM #108675Hi,
I tried removing CLOSE command without success. I’m running on 10.3
09/27/2019 at 4:04 PM #108679I can confirm this is a discrepancy solely based on bars. BarIndex(0) is counted in the indicator as a bar, which it is not in Back-Testing as it is an incomplete bar I guess. So those are totally out of sync.
This makes back-testing very odd when analysing the outcome! Unfortunately I see this as a bug! Especially as they are time-lined so that you should be able to follow what happens in the back-test versus your price AND indicators. And if you use the same indicator as a trigger for the action – you would expect the same outcome, which is extremely perplexing when you define PRELOADBARS = 0. I’m coding a ZeroBarCorrection of + 1 in everything that could cause this problem for now. It solves the problem for now…
Surprised no one has reacted on this until now…
Not sure if it is fixed in version 11.
Regarding version 11…I can’t do back-testing as I have no IG connection… since it is not supported by IG… which… by the looks of it… won’t be happening for another… year???
09/27/2019 at 4:47 PM #108680Your code above:
1234IF BarIndex > 14 THENATR = AverageTrueRange[14](CLOSE)Trange = TR(CLOSE)ENDIFwill calculate ATR when BarIndex = 15 (or greater), so it will scan the last 14 bars (2 through 15) to make the calculations, while replacing 14 with 13 will calculate it on bars 1-14.
BarIndex starts from 0, so to calculate 14 bars starting from bars 0 you should replace > 14 with > 12.
09/27/2019 at 5:32 PM #108684Hi,
I see your point. However the snippet of code is not part of the indicator, it is merely to show the inconsistency. My first line is actually an equaliser formula to be able to use ONCE command for variables.
For simplicity, in my code I use ATRperiod as a value (14)
1234ATRperiod = 14IF BarIndex = ATRperiod THENATR = AverageTrueRange[ATRperiod](CLOSE)ENDIFAnd in the ProOrder I use
12345BarZeroCorrection = 1ATRperiod = 14IF BarIndex + BarZeroCorrection = ATRperiod THENATR = AverageTrueRange[ATRperiod](CLOSE)ENDIFI find this to be easier to address when reading the code as the problem is that BarIndex[0] that causes the problem!
09/27/2019 at 5:58 PM #108685Try not using ONCE in your indicator.
09/27/2019 at 6:01 PM #108686Well… this specific indicator requires it 🙂
09/27/2019 at 6:32 PM #108687Replace ONCE with:
123If barindex = 0 thenMyVariable = ...Endif -
AuthorPosts
Find exclusive trading pro-tools on