You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would separate the problem into two layers:
If you mix both in one rule, the indicator usually becomes noisy or starts repainting. A confirmed swing needs right-side bars, so it will always have some delay. Internal points can be detected earlier, but they should be treated as lower-confidence structure until price confirms them.
A simple confirmed swing high/low function can start like this:
bool IsSwingHigh(const int i,const double &high[],int depth) { for(int k=1;k<=depth;k++) { if(high[i] <= high[i-k]) return false; if(high[i] <= high[i+k]) return false; } return true; } bool IsSwingLow(const int i,const double &low[],int depth) { for(int k=1;k<=depth;k++) { if(low[i] >= low[i-k]) return false; if(low[i] >= low[i+k]) return false; } return true; }
After that, I would not classify HH/HL/LL/LH from every candle. Store only accepted pivots first, then compare the last accepted pivot with the previous pivot of the same type.
For internal structure, use a smaller depth and add validation rules, for example:
You can keep the data in a small structure:
The important part is to decide what you want from the indicator. If you want non-repainting structure, accept the delay. If you want earlier internal points, mark them as provisional and update them until confirmation. Trying to make them early and final at the same time is usually where the logic becomes unstable.
I've done both...I've made a zigzag which records every candidate swing (accepting repaint), and made a zigzag that only draws markers on confirmed swings. If the trading system works on historical swings for support and resistance...then use the confirmed swings of course. If the trading system looks for entry signals, then you use the extremum candidate with confirmation on moving averages or momentum.