#Orders Calculations & Account Info's Updates - Open
( Once I asked - but I still need help )
I call my calculate functions by the OnTick() or Start(), and they depends on Chart Symbol Ticks. And I has been started to researching for how can I do my EA's calculation updates does not depends on Ticks and Symbols ( / Chart - Ticks, Symbols ). Just I am trying to do 'All Orders Calculations & Account Info's' will updates sync ( / real time ) with 'Terminal > Trade'.
Good comment, which one it helped me, thanks a lot. Now, I am using OnTick() and OnTimer(), both of that functions works good for me. ( I first time to use OnTimer() for EA's )
---
Also I would like to try Ticks. I just need only Ticks from which symbols ( Pairs ) on 'Terminal > Trade' and current chart symbol. Is this SymbolName() could help me? Please, help me or give me advice, so how can I do that?
Amazing example and really useful comment for me, thanks a lot man.
Is it possible Ticks comes from Trade Pairs / Symbols, please? Because almost all the time my Market Watch shows all symbols - specially I look for new good Pairs for Trades and that is only reason I am researching some ways for how can I get ' Terminal > Trade ' symbols / pairs, just currently opening trades ticks.
no but you can update price in OnTimer() function set to a low value for example 250 milliseconds will be equal to 4 ticks a second so why do you need it ?
Marco vd Heijden: no but you can update price in OnTimer() function set to a low value for example 250 milliseconds will be equal to 4 ticks a second so why do you need it ?
Thanks for your comment.
( subtopic - #Orders Calculations & Account Info's Updates - Open ) As I mentioned I use orders profit calculations and that is not running sync with ' Terminal > Trade ', that is only reason. So, sometimes volatility very low, Ticks comes least amounts, and I think functions could be running 4 times in a second, so that running for nothing ( / vain ).
If I cannot find the way which one it can give me ' Terminal > Trade ' ticks for Orders Profit Calculations and Account info ( / updates ) sync. I will use your very useful methods - which one you showed me that ways in your last comments, thanks a lot. ( I already tested and that way works me )
structMqlTick { datetime time; // Time of the last prices update double bid; // Current Bid price double ask; // Current Ask price double last; // Price of the last deal (Last) ulong volume; // Volume for the current Last price long time_msc; // Time of a price last update in milliseconds uint flags // Tick flags };
The Structure for Returning Current Prices (MqlTick)
This is a structure for storing the latest prices of the symbol. It is designed for fast retrieval of the most requested information about current prices.
The variable of the MqlTick type allows obtaining values of Ask, Bid, Last and Volume within a single call of the SymbolInfoTick() function.
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
So u can use it to check if there was a new tick for a specific symbol, but this will actually be one step more then directly reading the price levels directly so once more, why would you need it.
Standard Constants, Enumerations and Structures / Data Structures / Price Data Structure - Reference on algorithmic/automated trading language for MetaTrader 5
Well if your really into it you can use: ... So u can use it to check if there was a new tick for a specific symbol, but this will actually be one step more then directly reading the price levels directly so once more, why would you need it.
Thanks for your informative comment, much appreciate.
---
If I am right this part of sentence is a question.
... why would you need it. There is only one reason, I am trying to prevent irrelevant function loops / runs.
( I would like to mention today while I was testing my EA's Orders Profit calculation, calculation was continuously updates ( / loops for nothing ) I was test it on EURUSD chart, and while I was testing, I saw very low volume almost 20 ( no over ) a minute. And while I was testing, one more time I was know for sure, I could find a way which one it will give me only ' Terminal > Trade ' Ticks. I would like to say one more time, there is no any reason. Just I know that ways which can give me ticks OnTick() only ticks could comes from Chart Symbol. And others OnTimer() it could give me 4 ticks a second... and so on, which one I learned from your very useful and great comments, one more thanks a lot for that. )
And I need to describe my situation.
My Orders Profit Calculation could be sync with Terminal Trade panel while my EA's running on chart symbol which one ( eg: EURUSD ) if chart symbol equal to same as Order Symbol, but if I open new position for GBPUSD and then sync will interrupt with Terminal Trade panel. And If I have orders for EURUSD, but I try to look for new good pairs for trade on other chart symbol ( eg: GBPUSD, NZDUSD and so on. ) Orders Profit Calculation does not sync with ' Terminal > Trade ' panel. ( Do not forget I already know OnTimer(), which one you helped me how can I use it for 4 ticks a second. )
All of that concern comes from here.
Today, I open positions for short terms, if I open positions for long terms, I will not give attention to that sync with Terminal Trade.
Well if you really want to wait for each tick you will have to write a separate EA for every symbol and use the OnTick() function.
But i can tell you i also program micro controllers and they are in an endless while loop (forever) until a power failure, or interrupt occurs.
To check if a condition is true or false, uses the smallest Boolean data type and your processor already does that millions if not billions of times per second with all the processes running in the background and the graphics etc.
It's when you start doing heavy calculations involving larger data types, that this becomes an issue.
#Orders Calculations & Account Info's Updates - Open
( Once I asked - but I still need help )
I call my calculate functions by the OnTick() or Start(), and they depends on Chart Symbol Ticks.
And I has been started to researching for how can I do my EA's calculation updates does not depends on Ticks and Symbols ( / Chart - Ticks, Symbols ).
Just I am trying to do 'All Orders Calculations & Account Info's' will updates sync ( / real time ) with 'Terminal > Trade'.
Please help me, thanks.
Thanks in advance.
OnTimer()
https://www.mql5.com/en/docs/basis/function/events#ontimer
And SymbolName(x,1);And SymbolName(x,1);
Good comment, which one it helped me, thanks a lot.
Now, I am using OnTick() and OnTimer(), both of that functions works good for me. ( I first time to use OnTimer() for EA's )
---
Also I would like to try Ticks. I just need only Ticks from which symbols ( Pairs ) on 'Terminal > Trade' and current chart symbol. Is this SymbolName() could help me?
Please, help me or give me advice, so how can I do that?
All the best.
{
Print(i," Symbol: ",SymbolName(i,1)," Ask: ",MarketInfo(SymbolName(i,1),MODE_ASK)," Bid: ",MarketInfo(SymbolName(i,1),MODE_BID));
}
{
Print(i," Symbol: ",SymbolName(i,1)," Ask: ",MarketInfo(SymbolName(i,1),MODE_ASK)," Bid: ",MarketInfo(SymbolName(i,1),MODE_BID));
}
Amazing example and really useful comment for me, thanks a lot man.
Is it possible Ticks comes from Trade Pairs / Symbols, please?
Because almost all the time my Market Watch shows all symbols - specially I look for new good Pairs for Trades and that is only reason I am researching some ways for how can I get ' Terminal > Trade ' symbols / pairs, just currently opening trades ticks.
Thanks a lot in advance.
no but you can update price in OnTimer() function set to a low value for example 250 milliseconds will be equal to 4 ticks a second so why do you need it ?
Thanks for your comment.
( subtopic - #Orders Calculations & Account Info's Updates - Open ) As I mentioned I use orders profit calculations and that is not running sync with ' Terminal > Trade ', that is only reason.
So, sometimes volatility very low, Ticks comes least amounts, and I think functions could be running 4 times in a second, so that running for nothing ( / vain ).
If I cannot find the way which one it can give me ' Terminal > Trade ' ticks for Orders Profit Calculations and Account info ( / updates ) sync. I will use your very useful methods - which one you showed me that ways in your last comments, thanks a lot. ( I already tested and that way works me )
Thanks in advance.
Well if your really into it you can use:
{
datetime time; // Time of the last prices update
double bid; // Current Bid price
double ask; // Current Ask price
double last; // Price of the last deal (Last)
ulong volume; // Volume for the current Last price
long time_msc; // Time of a price last update in milliseconds
uint flags // Tick flags
};
The Structure for Returning Current Prices (MqlTick)
This is a structure for storing the latest prices of the symbol. It is designed for fast retrieval of the most requested information about current prices.
The variable of the MqlTick type allows obtaining values of Ask, Bid, Last and Volume within a single call of the SymbolInfoTick() function.
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:
Example:
{
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() failed, error = ",GetLastError());
//---
}
See also
https://www.mql5.com/en/docs/constants/structures/mqltick
Structures and Classes, CopyTicks(), SymbolInfoTick()
So u can use it to check if there was a new tick for a specific symbol, but this will actually be one step more then directly reading the price levels directly so once more, why would you need it.
Marco vd Heijden:
Well if your really into it you can use: ...
So u can use it to check if there was a new tick for a specific symbol, but this will actually be one step more then directly reading the price levels directly so once more, why would you need it.
Thanks for your informative comment, much appreciate.
---
If I am right this part of sentence is a question.
And I need to describe my situation.
All of that concern comes from here.
---
I hope you understand me now more clearly.
All the best.
Well if you really want to wait for each tick you will have to write a separate EA for every symbol and use the OnTick() function.
But i can tell you i also program micro controllers and they are in an endless while loop (forever) until a power failure, or interrupt occurs.
To check if a condition is true or false, uses the smallest Boolean data type and your processor already does that millions if not billions of times per second with all the processes running in the background and the graphics etc.
It's when you start doing heavy calculations involving larger data types, that this becomes an issue.