Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1410
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
There is a confusion with using the standard library.
How to get a ticket after opening an order using the standard library?
Can I be sure that the server response is already received here? The terminal hangs while waiting for a response from the server? It is not clear.
In MQ4 everything was simple:
How to get a ticket after opening an order using the standard library?
Can I be sure that the server response is already received here? The terminal hangs while waiting for a response from the server? I don't understand.
In MQ4 everything was simple:
It is better to use OnTradeTransaction() event handling
It is better to use the OnTradeTransaction() event handler
Thanks! Then I'll have to redo a couple of functions.
Maybe somewhere you have seen a function for calculating slippage on mql5?
Thank you! I'll have to redo a couple of functions then.
Have you seen somewhere a function for calculating slippage on mql5?
Why look for it? In OnTradeTransaction you catch the event of order placement, read the order price, then catch the trade, read the trade price and get the difference of these prices.
You can also create a variable at the global level, write the price into it at the time of sending the order, and in OnTradeTransaction get the price of the deal...
Alexey Viktorov #:
You can also create a variable at the global level, write the price into it when the order is sent, and get the price of the transaction in OnTradeTransaction....
This option is definitely out. What do I need a price without a ticket if I send many orders, how will OnTradeTransaction deal with it?
This option is definitely out. What do I price without a ticket if I send many orders, how will OnTradeTransaction deal with it?
By position ID it will be sorted out without any problems.
You get a trade, get position ID from it, pull orders and trades from the history by this ID and read order and trade prices IN.
Read the documentation. You can find a lot of interesting things there.
Alexey Viktorov #:
You get a trade, get the position ID from it, pull orders and trades from the history by this ID and read the order and trade prices IN.
It is clear! But the second option with the saved price, while sending an order, at the global level and then in OnTradeTransaction get the price of the transaction...this is not clear to me. Why save a price that is not tied (to the order) while sending the order?
In short, I'll do it this way - get the trade, then pull everything else out of it.
The essence of the problem: I can't get the real values of the price on the indicator lines for the specified bar, because for some reason the same price value is written to different buffers of the indicator, which also does not correspond to the real values of any of the lines on this bar. And as a result, some unknown price value is written to different buffers (at different requests), which nullifies the whole further work of the function.
Moreover, using exactly the same method as in this function, I was able to get indicators from any other indicators, but here it doesn't work....
Bolinger is SMA +- N*standard_deviations.
There are their own indicators about standard deviation and SMA. But it's all calculated without them - take a reference book and here's a formula. From it you find the "average distance in points between the lines", which is equal to 4 sigma at the moment according to default values.
And the average (for which period?), do you bother to calculate it?
You de facto want to know the average of the standard deviation.
This is clear! But the second option of saving the price while sending the order, at the global level and then in OnTradeTransaction to get the price of the transaction...this is not clear to me. Why save a price that is not tied (to the order) while sending the order?
In short, I'll do it this way - get the trade, then pull everything else out of it.
This was said about calm trading, when everything will be in time... Without taking this into account
Forum on trading, automated trading systems and testing trading strategies
Questions from beginners MQL5 MT5 MetaTrader 5
Nauris Zukas, 2022.06.11 17:49
This option is definitely out. What is the price for me without a ticket if I send many orders, how will OnTradeTransaction deal with it?
It was said about quiet trading when everything will be in time... Without taking that into account
The morning is wiser in the evening! Why should I try to implement some logic from mql4 and use OnTradeTransaction to calculate slippage? mql5 allows me to calculate slippage from histories, I will go through the histories at a certain moment and collect all the information.
Anyway, thanks for your help!