Download MetaTrader 5
To add comments, please log in or register
Use MQL5 Cloud Network. It is secure!
strontiumDog
263
strontiumDog 2013.09.25 20:04 

Hello

I grabbed myself a copy of Yurich's FastZZ zigzag indicator from https://www.mql5.com/en/code/1027

Looks good, but feeling responsible, before I rely on it, I need to fully understand the code.  I'm relatively new to indicators and had a little trouble understanding the way it carries on, so I changed some of the variable names to make more sense to me, and inserted print statements all over the place to help me trace exactly what it was doing.  I've attached the modified indicator.

 When I iCustomed this in to my EA with a Depth of 1100, I noticed that not all the print statements were outputting or in the right order.  Can anyone explain this?  I've had this in c before, but that's due to buffering which I can fix by flushing the print buffer.  Doesn't appear to be an equiv here (assuming I've got it right).

Run the mt5 backtest 2009-01-05 -> 2009-01-06 to get a small sample in. 262 candles on Build 842 / Win 7 VM on a MacBook Pro Dual Core i7.

Have a look at the screenshot of my journal.  Comparing to the code, a snippet of which is here:

int OnCalculate(const int priceArSize,
                const int candles,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick[],
                const long &real[],
                const int &spread[]) {
                
        if(candles == 0) {
                Print("Zero candles: ", candles);
                last = 0;
        }
        
        Print("49 for int i = candles (",candles,") > 0 ? candles -1:0; i<priceArSize (",priceArSize,") -1; i++");
        Print("i thus is: ", candles > 0 ? candles - 1 : 0);
        for(i = candles > 0 ? candles - 1 : 0; i < priceArSize - 1; i++) {
...

 You can see that as candles > 0 the first thing the indicator should do is output the first two print statements, but the log lists the first two blank lines I put in at the end of the indicator code. Why?  Worse, then 'Zero candles: 262' which I only put there to double check there were in fact 0 candles at some point.  Good job I did too, as the code was invoked (so candles should == 0), but then output there were 262!

1. Am I right in thinking that the print method does not actually always print when we expect it to, but when it can, which is difficult when there are many competing calls from the indicator?

2. Am I right in thinking that in addition to this, when the first if was evauated, there were 0 candles, but by the time it actually output the value, it had been instantiated to 262? 

3. Can someone reassure me that it is normal to have expected the first two Print statements ('49 for int...' and 'i thus is:...') first?

4. How to get all the print statements output properly? 

This is not the procedural response I expected from some computer software, especially this critical to my wallet.

Cheers 

Fast ZigZag
Fast ZigZag
  • votes: 11
  • 2012.10.30
  • Yury Kulikov
  • www.mql5.com
The easiest and fastest zigzag.
Alain Verleyen
Moderator
28524
Alain Verleyen 2013.09.25 20:19  
strontiumDog:

Hello

I grabbed myself a copy of Yurich's FastZZ zigzag indicator from https://www.mql5.com/en/code/1027

Looks good, but feeling responsible, before I rely on it, I need to fully understand the code.  I'm relatively new to indicators and had a little trouble understanding the way it carries on, so I changed some of the variable names to make more sense to me, and inserted print statements all over the place to help me trace exactly what it was doing.  I've attached the modified indicator.

 When I iCustomed this in to my EA with a Depth of 1100, I noticed that not all the print statments were outputting or in the right order.  Can anyone explain this?  I've had this in c before, but that's due to buffering which I can fix by flushing the print buffer.  Doesn't appear to be an equiv here (assuming I've got it right).

When there is too much output from Print statement, not all data are shown, as you noted, but they are always logged. You can use the viewer to analyse logs. You can also open the log an editor.

Also in Experts/Journal tab, data are in reverse order, most recent log is on top, though with the viewer the order is as usual (most recent data on the bottom).

strontiumDog
263
strontiumDog 2013.09.27 09:54  

Thanks for the tips.  The viewer is useful for forward testing, but if I'm back testing, the test window journal has no such context menu which is a shame.  I guess I could drag the EA onto a forward chart to see what is going on.  And I've just seen the tester notify me of the full log location.  Ace - cheers. 

Alain Verleyen
Moderator
28524
Alain Verleyen 2013.09.27 11:55  
strontiumDog:

Thanks for the tips.  The viewer is useful for forward testing, but if I'm back testing, the test window journal has no such context menu which is a shame.  I guess I could drag the EA onto a forward chart to see what is going on.  And I've just seen the tester notify me of the full log location.  Ace - cheers. 

The Strategy Tester journal tab has just the same behavior AND context menu (even with more options) that for forward test (toolbox window). Please check that properly.
/
To add comments, please log in or register