Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1097
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
After execution of a trade order, a POSITION appears, not an ORDER!
There are servers where you can reproduce such a situation
I.e. we have the following order in the terminal at the same time
and the same position from it
So first describe in words what you are doing and what you want to get. Use "BUY trade order" and "SELL trade order" instead of ORDER. The result is a "BUY position" or a "SELL position".
OK, let's simplify our discussion to examples in code. Here is the code written in MQL4 - I'm interested in tester version, i.e. minimum checks, etc:
The essence of TS: when you open a Buy order at first start and remember the ticket of the order (work on the ticket), then check if the order is closed - see what type of order was and put the opposite order and remember the ticket and so on round
I need a similar example to be reproduced in MQL5 using SB CTrade
OK, let's simplify our discussion to examples in the code, here is the code written in MQL4 - I am interested in the version for tester, i.e. minimum checks, etc:
The essence of TS: when you open a Buy order at first start and remember the ticket of the order (work on the ticket), then check whether the order is closed - see what type of order and put the opposite order and remember the ticket and so on round
I need a similar example to be reproduced in MQL5 using SB CTrade
Now the little drummer will tell you what he thinks of you))))
let it speak, but we need to know if the ticket number is open or closed, if it is closed, we need to know what typeof trade order the closed position had
(in bold - it is an order anyway! - because in the TC header account)
OK, let's simplify our discussion to examples in code. I wrote a code in MQL4 - I'm interested in Tester version, i.e. minimum of checks, etc:
I need a similar example to be reproduced in MQL5 using CTrade SB
I need a similar example to be reproduced in MQL5 using CTrade SB.
So, the basics are thePOSITION_IDENTIFIER, but not the position ticket. This is important precisely because of the netting:
POSITION_IDENTIFIER
The position identifier is a unique number, which is assigned to each newly opened position and does not change throughout its lifetime. It corresponds to the ticket of the order with which the position was opened.
The position identifier is specified in each order (ORDER_POSITION_ID) and each trade (DEAL_POSITION_ID) which opened, changed or closed it. Use this property to search for orders and trades related to the position.
When a position is reversed in netting mode (a single in/out trade), the POSITION_IDENTIFIER identifier of the position is not changed. However, POSITION_TICKET is changed to the order ticket which resulted in the reversal. In the hedging mode there is no position reversal.
long
So, we have to keep track of the position identifier (POSITION_IDENTIFIER).
Now, a more accurate task: at first run, we open a BUY POSITION and memorize it (WARNING: we should memorize the position ID, not the ticket). If the position has been closed, we open an opposite position: e.g. once upon a time there was a BUY position, then it was closed, which means that we open a SELL position right away.
Now it will be much easier to solve the problem.
Now it will be much easier to solve the problem.
When writing the example, look a little ahead.
The second OrderSend contains an error. I don't need normalization. On the forum (and not only) it's easier to read the code when it's shorter.
Yes, I see, I wrote the code on the fly - ran it in the tester - it works, copied it to the forum
You'll have to try a bit harder.
That's why I asked for help on the forum! - I decided to estimate capabilities of SB CTrade - I took an elementary task as an example and so far the result has been negative!
Now it will become much easier to solve the problem.
I know you as an active member of the forum. Could you reproduce my, or rather the correctedfxsaber code, using CTrade Server under MQL5?
Yes, I see, I wrote the code on the fly - ran it in the tester - it works, copied it to the forum
When I start writing an EA, I always start with a blank page (I recommend it). Probably most often start with a header with On-functions.
That's why I asked for help on the forum! - I decided to assess CTrade's capabilities - I took an elementary task as an example and so far the result has been negative!
There is an even shorter example.
forum on trading, automated trading systems and trading strategies testing
Features of mql5 language, intricacies and tricks
fxsaber, 2018.02.15 11:48
It's hard to deal with in MT5 if not in the tester.