Download MetaTrader 5
To add comments, please log in or register
Enable MQL5 Storage to store your source codes. It is free!
LouK
143
LouK 2014.05.04 15:52 

I want to be sure I understand how MT4 handles the forex servers.

I’ve been working with the assumption that there are market data servers which tick the EA and a broker server which I need to query separately for account information. I started cleaning up an EA to stop it from checking OrdersTotal() every tick, thinking that reduces server queries and lightens my communication load. But maybe this is not the case?

So my question is: Does each tick download account, as well as market, info? Is a check of OrdersTotal() for example, a local, and not a remote, check?



Thanks for your help.

whroeder1
13596
whroeder1 2014.05.04 16:52  
LouK: So my question is: Does each tick download account, as well as market, info? Is a check of OrdersTotal() for example, a local, and not a remote, check?
  1. Connection established Account history and current orders list sent
  2. Chart is opened, history refresh is requested. This is why after a disconnect/connect IndicatorCounted returns nonzero for a few ticks and then zero. History refresh arrives.
  3. Market change, update is sent and OnTick is called if not active.
  4. Order status changes, update is sent. OrdersTotal() is local but may change while in OnTick. This is why you must count down when: Loops and Closing or Deleting Orders - MQL4 forum
LouK
143
LouK 2014.05.04 22:19  
WHRoeder:
  1. Connection established Account history and current orders list sent
  2. Chart is opened, history refresh is requested. This is why after a disconnect/connect IndicatorCounted returns nonzero for a few ticks and then zero. History refresh arrives.
  3. Market change, update is sent and OnTick is called if not active.
  4. Order status changes, update is sent. OrdersTotal() is local but may change while in OnTick. This is why you must count down when: Loops and Closing or Deleting Orders - MQL4 forum


Thanks for the help!

I understand that the value of OrdersTotal() can change intra tick. I just want to be clear about #4:

Then a line like "int numTickets=OrdersTotal();" DOES NOT constitute an additional server query, it just retrieves the value of a local variable "OrdersTotal()", which was refreshed to the value which existed at the instant of the tick, correct?

Thanks again!

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.05.05 01:09  
OrdersTotal() value doesn't change if there is no change in trade orders.
whroeder1
13596
whroeder1 2014.05.05 11:49  
LouK: retrieves the value of a local variable "OrdersTotal()", which was refreshed to the value which existed at the instant of the tick, correct?

It retrieves the last value saved from the last update received. If an update is received while your OnTick is busy (server calls takes time seconds/minutes) the value changes between calls.

It is not the value at the beginning of the tick, it is the current value.

/
To add comments, please log in or register