Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1096

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
I have the time and price of points A and B
How do I know the time and price of point C? It's in the middle between A and B.
I can't find an example anywhere
I have the time and price of points A and B
How do I know the time and price of point C? It's in the middle between A and B.
I can't find an example anywhere.
Time C = Time B - ((Time B - Time A) / 2)
Price at Time C
Time C = Time B - ((Time B - Time A) / 2)
Price by Time C
Checked it out, sometimes I get a weekend)
Is there any way to find out the centre in the line itself?
Here is my line
how do you find out the ticket of the last order opened? it doesn't work that way:
What exactly do you want to know? We need to clearly distinguish between the terms ORDER, ORDER and POSITION.
Second: You have immediately caused confusion by naming the objects of the CTrade class "order_1" " "order_2". They used to call CTrade class objects "m_trade_1" and "m_trade_2". It doesn't affect the usability, but it adds a lot of confusion.
Third: thePositionClose method won't work only because you pass to it a position ticket equal to zero (and you initialize them with zero in OnInit() ) - Such ideal conditions, when the first position has a ticket "0", can only be obtained in the tester.
Fourth: TheBuy method
Note
Successful completion of the Buy(...) method does not always mean successful trade operation. One should check the result of the trade request (return code of the trade server) by callingResultRetcode() method as well asthe value returned byResultDeal() method.
ResultDeal() method
Gets the READ ticket.
What exactly do you want to know? You need to clearly distinguish between the terms ORDER, ORDER and POSITION.
Second, you have immediately caused confusion by naming objects of the CTrade class with the words "order_1" and "order_2". They used to call CTrade class objects "m_trade_1" and "m_trade_2". It doesn't affect the usability, but it adds a lot of confusion.
Third: thePositionClose method won't work only because you pass to it a position ticket equal to zero (and you initialize them with zero in OnInit() ) - Such ideal conditions, when the first position has a ticket "0", can only be obtained in the tester.
Fourth: TheBuy method
Note
Successful completion of the Buy(...) method does not always mean successful trade operation. One should check the result of the trade request execution ( return code of the trade server) by calling ResultRetcode() method as well asthe value returned byResultDeal() method.
ResultDeal() method
Gets the RECEIVED ticket.
Thank you! Figured it out already
in general, the problem was from the abundance of information, gossip and opportunities.... was sure that I wouldn't be able to catch a ticket in Result(), because the OnTradeTransaction() event is remembered every once in a while ... and it's on!
i am currently working on it with MT5 tester, i am just looking for reproducible examples, i am not talking about the functional code - just a tester for now
thanks again for your help!
this code can get the tickets of the last orders in the tester:
Thank you! Already figured it out.
in general the problem was from the abundance of information, gossip and possibilities.... was sure that I couldn't catch the ticket in Result(), because the OnTradeTransaction() event is remembered every once in a while ... and it's on!
i am currently working on it with MT5 tester, i am just looking for reproducible examples, i am not talking about the functional code - just a tester for now
thanks again for your help!
Such code can get the ticks of the last orders in the tester:
Yes using ResultOrder will get the order ticket.
Yes, with ResultOrder we can get a ticket for the order.
Ok, now I don't have any problems with it, but another problem has appeared when using CTrade: I have a memorized order ticket and I can close it using PositionClose(m_ticket)
In MQL4, it was very easy to find out if the order is closed or not. I selected it using OrderSelect() and checked if(OrderCloseTime()>0) - if the close time is not equal to 0, the order is closed
How do I know if an order is closed using SB CTrade ?
Ok, now I don't have any problems with it, but another problem has appeared when using CTrade: I have a memorized order ticket and I can close it using PositionClose(m_ticket)
In MQL4, it was very easy to find out if the order is closed or not. I selected it using OrderSelect() and checked if(OrderCloseTime()>0) - if the close time is not equal to 0, the order is closed
how do I know that the order is closed using SB CTrade ?
Forget about the order! There is a position!
I specifically asked what do you want: an ORDER, a TAKE OR a POSITION? Do not confuse the terminology. After the trade order is executed, the POSITION appears, not the ORDER!
Therefore, first describe in words what you are doing and what you want to obtain. Instead of an ORDER, use "BUY trade order" and "SELL trade order". This results in a "BUY" or "SELL" position.
OK, now I don't have any problems with it, but another problem has appeared when using CTrade: I have a memorized order ticket and I can close it using PositionClose(m_ticket)
In MQL4, it was quite simple: I selected the order via OrderSelect() and checked if(OrderCloseTime()>0) - if the close time is not equal to 0, the order is closed
How do I know if an order is closed using SB CTrade ?
Leaving aside the fact that a position ticket usually corresponds to an order ticket, but not absolutely always, it is possible to use the PositionSelectByTicket function without SB
Can I substitute my own calculation formula in this indicator calculation code?
For example open/2