La Struttura per il Ritorno dei Prezzi Correnti (MqlTick)
Questa è una struttura per memorizzare gli ultimi prezzi del simbolo. È progettata per il recupero rapido delle informazioni più richieste sui prezzi correnti.
struct MqlTick
{
datetime time; // Orario dell'aggiornamento dell'ultimo prezzo
double bid; // Il corrente prezzo Bid
double ask; // Il corrente prezzo Ask
double last; // Prezzo dell'ultimo affare (Last)
ulong volume; // Volume per il corrente prezzo Last
long time_msc; // Orario dell'ultimo aggiornamento di prezzo in millisecondi
uint flags; // Flag Ticks
double volume_real; // Volume con maggior accuratezza per il corrente presso Last
};
|
La variabile di tipo MqlTick permette di ottenere valori di Ask, Bid, Last e Volume entro una singola chiamata della funzione SymbolInfoTick().
The parameters of each tick are filled in regardless of whether there are changes compared to the previous tick. Thus, it is possible to find out a correct price for any moment in the past without the need to search for previous values at the tick history. For example, even if only a Bid price changes during a tick arrival, the structure still contains other parameters as well, including the previous Ask price, volume, etc.
You can analyze the tick flags to find out what data have been changed exactly:
- TICK_FLAG_BID – tick has changed a Bid price
- TICK_FLAG_ASK – a tick has changed an Ask price
- TICK_FLAG_LAST – a tick has changed the last deal price
- TICK_FLAG_VOLUME – a tick has changed a volume
- TICK_FLAG_BUY – a tick is a result of a buy deal
- TICK_FLAG_SELL – a tick is a result of a sell deal
Esempio:
void OnTick()
{
MqlTick last_tick;
//---
if(SymbolInfoTick(Symbol(),last_tick))
{
Print(last_tick.time,": Bid = ",last_tick.bid,
" Ask = ",last_tick.ask," Volume = ",last_tick.volume);
}
else Print("SymbolInfoTick() fallito, errore = ",GetLastError());
//---
}
|
Vedi anche