I'm very close to abandoning a practice conversion - page 2

 
Vladislav Boyko #:
I attached AutoScaleZZ2_fixed.mq5

Apparently, in AutoScaleZZ2_fixed.mq5 in MT5 the highlighted line does not work correctly. Because when moving a high point, the previous value of the point remains in the buffer (but must be cleared).

I don't know why this is happening. I couldn't figure out the reason quickly, I don't have enough free time to figure out the reason, sorry.

//+------------------------------------------------------------------+
//| Calculation High ZZ Point                                        |
//+------------------------------------------------------------------+
void HighZZPoint(const int index, const double &high[], const double &low[]){

double PriceHigh = high[index]; // Current maximum price value
double PriceLow = low[index]; // Current minimum price value

double EventHigh = False; // High point ZZ update event
double EventLow = False; // Low point ZZ update event

double R_Step = MathAbs((ArrayHighLast[index + 1] - PriceLow)/PriceLow) * 100.0; // Price range in percent
double StepDownLevel = PriceLow/SpecDivSymb/ZZScale; // Step to form a segment down

// Updating and redrawing the maximum extremum
if(PriceHigh > ArrayHighLast[index + 1]){

EventHigh = True;

ArrayTypeZZ[index] = 1;

ArrayHighZZ[(int)ArrayHighBarZZ[index + 1]] = 0.0;
 
Vladislav Boyko #:
Apparently, in AutoScaleZZ2_fixed.mq5 in MT5 the highlighted line does not work correctly. Because when moving a high point, the previous value of the point remains in the buffer (but must be cleared).

Here's a visual demonstration. See the data window - multiple values ​​in a row in the "High Point ZZ" buffer. That's why it's not displaying correctly.

 
that line you highlighted is indeed not working as it should, it caused an exception every time for me.  You can force it to work by insuring the previous bar index is always a positive number (and then clear the value of the buffer with that index), but even though this would work, it will cause the zigzag to look odd
 
Conor Mcnamara #:
that line you highlighted is indeed not working as it should, it caused an exception every time for me.  You can force it to work by insuring the previous bar index is always a positive number (and then clear the value of the buffer with that index), but even though this would work, it will cause the zigzag to look odd

Using 0.0 as an empty value of an indicator buffer is a bad idea if the indicator stores bar indexes in buffers. And storing bar indexes in buffers is also a bad idea. I would rather write from scratch instead of converting this (but I don't have time for that). Because it's someone else's complex code. Your own complex code will always be clearer and more debuggable than someone else's complex code.

 
Vladislav Boyko #:

Your own complex code will always be clearer and more debuggable than someone else's complex code.

Wise words. I removed the logic of 0.0 (which also means NULL in this framework), and went back to EMPTY_VALUE. I have things working correctly for MT5 now, I may not have it built in cross-platform, but I'm happy enough as long as there is both a working MT4 and MT5 implementation.

 

I have a correctly working series version now if you're interested. Indexing is more delicate, and a decremental loop is needed in the main calculation loop. 

(btw this zigzag is only built to work on currency pairs)

 
Conor Mcnamara #:
(btw this zigzag is only built to work on currency pairs)

Why? It's just a derivative of the price. You can build it even on a cardiogram

 
Vladislav Boyko #:

Why? It's just a derivative of the price. You can build it even on a cardiogram

Yea but the original only worked on currency pairs with normal scaling values. I don't fully understand the authors scaling calculation, so I don't know why this doesn't work on say...gold or bitcoin. I'm thinking because gold and bitcoin are on extremely different prices.