Hello, I’m working on a custom made indicator that works a bit like the zigzag one. This means that its value on the last bar may be recalculated later when new data comes in. The backtester will look into the future as it doesn’t recalculate the indicator on each bar.
I know I can rework my code to wait for the “last leg” to stabilize before making a transaction.
But I still want to evaluate my strategy as I think it could give interesting results. For this I would need the backtester to behave like the bar replay feature. (I know I’ll get some false signals). Is this possible ? Can it work with the custom back tester?
Many thanks in advance
There is no need to re-invent the wheel.
If you searched the forum prior to posting you will find this: Zigzag through connecting highs and lows?
and ready to use Zigzag formula that solves last leg problem
And there is no need to reinvent bar replay. Just use bar replay.
Using bar replay I can’t do optimizations or WFA, as far I know
is it not possible to perform them without adopting “last leg” stabilization tecniques?
It’s clear that using the backtest in a “bar replay mode” there would be a drop on optimization speed but I have no other ideas now
No, Bar replay function does not decrease optimization speed.
But frankly I just don't get it what you want to do. Without "last leg" stabilization ZigZag is WORTHLESS. It will give you amazingly good results on paper but this is total BS. It is absolutely bad idea to use ZigZag without waiting for last leg to stabilize.
Want to live in fantasy land? Really zig zag without waiting is not any wiser than writing this:
// ABSURD "maximum profit" code
Buy = Sell = 1;
BuyPrice = Low;
SellPrice = High;
Many thanks for your answers and the links Tomasz. As a matter of fact I took some time to read different articles before posting this topic, including the second one you mentioned.
I apologize in advance for what can be newbie remarks or questions. I’ll try to elaborate:
- I totally get that zigzag (without leg stabilization) in the back tester gives inaccurate and fantasy land results.
- I guess that in the backtester all arrays are calculated for the whole backtesting period, then the signals are generated based on those arrays
- In the code I’m working on, I’m trying to do some basic predictions based on the last available data and use that to generate signals. I know that those signals might be invalidated after a few days, when new data comes in.
- I know that waiting for the last leg to stabilize is the only way to get an accurate result, however I would like to simulate what happens if I use a prediction (before stabilisation) with the only available data on a specific day. AFAIK this is not possible with the backtester as it will calculate the arrays with the data of the whole testing period: it will look into the future instead of recalculating the arrays and generating signals on each new day. I’m wondering if my predictions, even if sometimes inaccurate, may generate opportunities more interesting than waiting for the last leg to stabilize (which creates lag)
- I’ve been using the replay bar feature (or just scrolling through my curves), and so far it’s showing me that my signals are 1 day late ( compared to the ‘final’ arrays, when new data validates or invalidates my predictions). The problem is that it’s not very practical as I have to pause the program, write down when the signal happened, etc… Eventually I can then create a .afl with ‘hardcoded’ buy and sell dates to have a full report (entries, exits, gains, Monte Carlo, etc…) It would be more practical that the backtester had an option to recalculate the arrays for each new day, ignoring the “future data”.
I had hoped that custom backtester features would help me with that, I’ll investigate this a bit more. Or perhaps this approach doesn’t make sense at all and I’m just wasting my time…
Just to follow up on this: I explored this some time ago and as Thomasz said, it didn't make any sense.