PVT indicator not matching

 

Hi

Writing my first EA, steep learning curve but managed to get so far with it using various online sources to sort through most issues.

Come across a few issues when using the PVT indicator that I can't explain or find the answers to. EA is running ok but results are not correct and what I have discovered are

1) When I backtest the scale and values for the same point in time from the PVT windows appear to differ in the STV window versus the chart window.

E.g.

STV: 51.87

Chart: -341.08

2) I've also noticed that the amount of trades differ between STV and Chart, I've seen trades in the Chart that are not in the STV graph. Suspect its related to the above issue.

Hoping someone can point me in the right direction.

 

This may help you and will increase the steepness of your learning curve:

If the code can be compiled without any error but it doesn't do what you expect use the debugger to find out why - it is exactly made for this.
Code debugging:  https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5:  https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272

Code debugging - Developing programs - MetaEditor Help
  • www.metatrader5.com
MetaEditor has a built-in debugger allowing you to check a program execution step by step (by individual functions). Place breakpoints in the code...
 
Carl Schreiber #:

This may help you and will increase the steepness of your learning curve:

If the code can be compiled without any error but it doesn't do what you expect use the debugger to find out why - it is exactly made for this.
Code debugging:  https://www.metatrader5.com/en/metaeditor/help/development/debug
Error Handling and Logging in MQL5:  https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272

Thanks for this, not used it before, really useful. The debugging tool did not solve the custom PVT indicator scaling issue described above, but has helped me detect another issue I've been trying to understand for a while.

I've been wondering why the code appeared to be triggering at the wrong signal level, hence buying at a higher value resulting often with being stopped out, as entry is too late.

For example, if my buy was set to trigger at value of 25, the debugger and the charts were showing buy at 38 and bypassed the correct entry level four bars back. The journal shows its triggering at the correct level just above 25. Then I looked at the time stamp of the buy in the journal versus that of the corresponding buy entry level in the chart (and SVT). Journal time for the correct level(25) entry signal was 16:45, the chart hit the corresponding(25) trigger level at 15:45, exactly an hour earlier. This is either something to do with daylight saving time or local time, which needs adjustment in the code. While I'm writing the code I'm using my PC, but when its ready I'll run it on my VPS.

Hopefully, someone can point me in the right direction, nothing I've read so far makes much sense.

 

Sorry, to be more clear, I'm using the ADX indicator to trigger a buy when it reached 25.

I've now tested a few other indicators along side it, what I observe is that their corresponding values match between the journal and chart for a given time. While the ADX entry for the same time in the journal is showing the value from an hour before, when I look at the chart.

Hence, does not sound like server synchronisation issue, appears related to the ADX.

 

Setting ArraySetAsSeries on the custom ADX indicator resolved this issue. Found the reference in ADX_Trend by Scriptor.

https://www.mql5.com/en/code/22592

ADX_Trend
ADX_Trend
  • www.mql5.com
ADX Trend indicator
 
False alarm, ignore previous post, it did not fix the issue, it reverses the data in the array.
Reason: