Download MetaTrader 5

Possible dangerous BUG in offline charts

To add comments, please log in or register
What are the latest MQL5.community news? The Wall section will tell you!
Mt Fan
490
Mt Fan 2015.12.18 20:09 

Hello to everyone.

I'm experiencing an issue on EA made by myself that works on Renko (using offline charts).

Inside the routine OnInit() I've calculated PipValue of the pair in this way:


double PipValue;

int OnInit()
{
   double LotSize = 1;
   PipValue =(((MarketInfo(Symbol(),MODE_TICKVALUE)*point)/MarketInfo(Symbol(),MODE_TICKSIZE))*LotSize);

.....


as you can see PipValue is a "public" Double variable defined before the OnInit() routine.

The issue that I have is that PipValue variable assumes ZERO value after the EA takes a trade!!   So inside the  OnTick()  event I was forced to calculate it again to use it in my calculations...

The first question is: why variable goes to ZERO? 

Second question is: why JUST that variable goes to zero?  I have many other variables calculated on the OnInit() .... and all work nice...


Any idea?!!   Thanks in advance.

Carl Schreiber
6580
Carl Schreiber 2015.12.18 21:55  
You mast have a valid connection to your broker for some time otherwise you'll get false values like 0.0!
Mt Fan
490
Mt Fan 2015.12.19 17:23  

Issue is not related to Broker connection: I'm forward testing this EA on many platforms (Demo & Real on different brokers) and issue happens in the same way on ALL the platforms!!

That variable is calculated ONCE (during init) and it's calculated correctly....  the mistery is that during EA execution that variable goes to Zero (this happens right after a new trade).

I've checked the source code and that variable is assigned ONLY in the Init event .... in the remaining code it is just read, not assigned.

I've spent sleepless nights and the reason behind this issue remains a big mistery.  I suspect there's a Bug in the Platform and for this reason I've explained my issue here.....


Thanks to everyone could help.



Alain Verleyen
Moderator
30712
Alain Verleyen 2015.12.19 18:26  
mt4fan:

Issue is not related to Broker connection: I'm forward testing this EA on many platforms (Demo & Real on different brokers) and issue happens in the same way on ALL the platforms!!

That variable is calculated ONCE (during init) and it's calculated correctly....  the mistery is that during EA execution that variable goes to Zero (this happens right after a new trade).

I've checked the source code and that variable is assigned ONLY in the Init event .... in the remaining code it is just read, not assigned.

I've spent sleepless nights and the reason behind this issue remains a big mistery.  I suspect there's a Bug in the Platform and for this reason I've explained my issue here.....


Thanks to everyone could help.



Either it's in your code, either it's zero from the start (init). We don't see your code, and MarketInfo data can be zero in some circumstances.

Which MT4 build are you using ?

Mt Fan
490
Mt Fan 2015.12.19 18:34  

Build of terminal is 920 and 940.

Value of the variable is displayed on chart by the EA (at each tick): so I know for sure that PipValue variable has the correct value .... until the execution of a new trade!!

Alain Verleyen
Moderator
30712
Alain Verleyen 2015.12.19 18:37  
mt4fan:

Build of terminal is 920 and 940.

Value of the variable is displayed on chart by the EA (at each tick): so I know for sure that PipValue variable has the correct value .... until the execution of a new trade!!

So your code is changing the value.
To add comments, please log in or register