FXCM and the internal variable "Point". - page 2

 

Dear Paul,


this is a very good advice to implement initRiskmanagement() as a singleton pattern which is run onTick()(*) instead of init(). This is very helpful. Thank you very much for the hint.

You're saying that on a newly created chart a Pair(X) does take the wrong parameters of Point/Digit from a previously created chart of Pair(y)? This has not been the case here.

The only thing which changed during the restart on March 6th was an archival of the logfiles as they grew a bit over the years and a downscaling of the number of history bars in "Extra/Settings/Charts" from "2147483647" to "256000" and the number of active bars from "256000" to "65000" as MT4.

MT4 got a bit sluggish over the time and as I do no backtesting on the real account any longer I assumed that such a change would be free of side effects.

Is there a slight possibility that MT4 provided the wrong parameters to the EAs while pruning the history and chart files? This would explain the scarcity of the bug.


(*) I personally like the term onTick() more than start() - but technically we're meaning the same.

 
WHRoeder:

Your code ASSSUMED a 5 digit broker. Have your EA auto adjust.

Either the broker changed, or you changed servers. Some brokers provide both.

You're absolutely right when you say that this code assumes the point arithmetics of a 5 digit broker. And during testing on the demo account and from march 1st until march 6th those arithmetics worked fine and demo was always consistent with the real account.

Only on this mistrade on March 8th there were suddenly differences in the contents of "Point" which endured until I restarted the MT4 on the real account.

The broker has been the same between 6th and 7th and there has been definitely no change on my side of the connection information of the servers. 

On the disputed trade you can see that this trade had been opened with a 5-digit precision. This also does not fit to the assumption that there is a 4 digit broker all of a sudden.

00:29:28 MyEA EURUSD,M1: orderSendReliable(EURUSD,OP_BUY,1.38000000,1.31061000,10,1.30300000,1.31950000,DayTrading,16384,0,16711680)
00:29:29 MyEA EURUSD,M1: open #XXXXXXXXX buy 1.38 EURUSD at 1.31061 sl: 1.30300 tp: 1.31950 ok
00:29:29 MyEA EURUSD,M1: orderSendReliable(): Success! Ticket: XXXXXXXX
 

Maybe your symbols.sel/.raw changed with your "update", too, and MT4 got wrong values from there, correcting them later with the 1st tick, leaving you with wrong values from your init routine. MT4 especially behaves funny at restarting/initialization. Suddenly all kind of bugs/side effects appear. Indicator buffers are not initialized (ArraySize(iBuffer) returns 0 in onTick), charts have "no bars" (Bars = 0 in onTick), Digits and Point are messed up, MarketInfo() returns wrong values if called too early, etc etc. You simply have to check all and everything if it makes sense. Not talking about hard to trace connection issues, ie. order functions return nonsense if a re-connect occures during the call.

 
It seems internally Digits is always initialized with 5, no matter what the symbol is, somewhen later it's updated with the correct value. Quick proof: Open any offline chart for a JPY pair. It's a new window and in init() Digits is set to 5.
 

Of course.

In init, there is NO CHART YET. No history, no values, no buffers, nothing. Only when the first tick comes in is anything ready. You should not be looking at Bars or your buffer sizes. Init must return in 2 seconds. Do the minimum and get out. Everything else should be done in start().

It should be setting Digits from the symbols.raw table in init() that came from the broker. That is why you download from the broker, not from MQ. But in an off line chart, Digits is undefined. It has no meaning, the chart could be anything the generator creates. Only for a real pair is Digits valid, same for every other market info.

Digits and Point are messed up, MarketInfo() returns wrong values if called too early
I've never see that (at least in the tester) But I've never used offline charts.
 

Just read again. I was talking about messed up indicator buffer/Bar values in start(), not in init(). And here is an example for wrong Digits and Point values. 1st and 2nd call.

 

btw: the posted picture shows an online chart.

WHRoeder: ...MQ. But in an off line chart, Digits is undefined. It has no meaning, the chart could be anything the generator creates.

Sorry, but you are wrong, again. Please look at the file specification for history files. In case you want to argue, MT4 ignores the specifications, it doesn't. Create a synthetic instrument and watch MT4 reading/using the specified informations without any informations about that instrument from the broker.

The observed Digits and Point bug comes into play only if a new window is created, no matter if it's an online or offline chart.

 

To me there's only 2 possibilites: Some careless handling of config parameters on the brokers end or a really really scary and rare bug in MT4.

Regarding the changes I've done on the MT4 side on March 6th and some other related issues I'm thinking of the latter.

Lessons learned for today:

  • Constants aren't - at least one should not take them for granted. :-)
  • As a called function: Check results twice before passing them back to the caller. AccountFreeMarginCheck() is a friend for the reconciliation.
  • As a caller: Always distrust the results from the called function.
  • Some Marketinfo() results are probably not correctly initialized when queried from the init() procedure. Better init them in the start() resp. onTick().
  • There is no such a thing like to much logging. :-)

Thanks to you guys I was pretty busy to implement those recommended changes today after grasping the consequences.

Reason: