Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1098
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
Hmm, strange situation, like the activity in the topic I raised, I had a question, from my point of view specific, but instead of an answer so far I got "why do you need it?
I want to do it with SB CTrade, here is an example (compiled from 2 my examples): We open everynew bar at 9 TF by one order, we memorize the ticket and determine the direction of a closed order by the ticket number.
In MQL4, the code for the tester would look like this
we need a code for the tester, i.e. the minimum number of checks and the fastest possible work in the optimizer.
how to write this code in MQL5 with SB CTrade ?
Hmm, strange situation, like the activity in the topic I raised, I had a question, from my point of view specific, but instead of an answer so far I got "why do you need it?
I want to do it with SB CTrade, here is an example (compiled from 2 my examples): We open every new bar at 9 TF by one order, we memorize the ticket and determine the direction of a closed order by the ticket number.
In MQL4, the code for the tester would look like this
how to write this code in MQL5 using SB CTrade ?
Forum on trading, automated trading systems & strategy testing
FAQ from Beginners MQL5 MT5 MetaTrader 5
Vladimir Karputov, 2019.07.21 12:56
So, the basis is thePOSITION_IDENTIFIER, but not the position ticket. It's important just 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.
i.e. CTrade does not know how to independently detect if an order is open or closed, what was the type of the last closed order?
which library should I use for this purpose?
i.e. does CTrade does not know how to independently detect if an order is open or closed? what was the type of the last closed order?
Which library should we use for this purpose?
I've told you a hundred times already, so please remove the word "order" from your vocabulary. Until you do so, you won't be able to move on. Anyway, I probably won't be able to help you. That's too bad.
Well, I've told you a hundred times - get the word 'warrant' out of your vocabulary. Until you do that, you can't move on. Anyway, I probably can't help you. That's too bad.
Well, tell me what you mean by that:
Well, I've told you a hundred times - get the word 'warrant' out of your vocabulary. Until you do that, you can't move on. Anyway, I probably can't help you. That's too bad.
OK? Let me rephrase the question:
How do you use a remembered ticket with CTrade::ResultOrder()
to find out:
1. whether the position is closed?
2. what type of deal did the closed position have?
3. we need to simultaneously handle 9 positions, orders or tickets, or ... OnAnyTerminology on a hedge account
in this formulation is my question unambiguous? (reproducible example under MQl4 posted above)
ZS: I can't forget the word order, unfortunately this word is used in the help along with other terms:https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade/ctraderequestorder
Hm, it's a strange situation, I seemed to have raised the topic, my question was specific from my point of view, but instead of an answer I got "why do you need it?
The reason is the incompetence of so responders. It took me five minutes to write it and one attempt to check it.
MT4
Forum on trading, automated trading systems and strategy tester
Questions from beginners MQL5 MT5 MetaTrader 5
fxsaber, 2019.07.21 12:54
MT5
You don't need to be a strong proficient to write this, you only need to know the basics of MT5.
ZS On netting there is a little nuance in determining the type of closed position. But it doesn't play a role here.
You don't need to be strong to write this, you just need to know the basics of MT5.
Thank you!
Yes, I was looking for a solution if I could not write it in five lines with SB
But how much I understood, that one SB CTrade will not be able to solve my problem? And I had to use CPositionInfo as well? - If I want to accompany 9 positions by several TFs at the same time?
ZS: I'm sitting in the MQL5 help with smart TV - quite well described trade functions, the use of SatB is under a question .... i think it makes sense to use SB for primitive strategies, a bit more complicated - the functionality is insufficient or not obvious use, maybe i need more practice - i will try to "twist" the SB
Thanks again!
The reason is incompetence so answered. It took me five minutes to write and one attempt to check.
MT4
MT5
You don't need to be a strong proficient to write this, you only need to know the basics of MT5.
You do not need to know the basics, you only need to know the basic MT5 basics. But it doesn't matter here.
This is where
there is a potential mistake.
In the historical list the warrants are not arranged in the order in which they appear in that list. Stumbled across this when developing the library. I relied on it. But it turned out to be not so simple. Try to set limit and stop orders in turn in the following order: limit -> stop -> limit -> stop -> limit -> stop and delete each in any order and see which order is the last one recorded in the history list. You will be surprised.
This is where
there is a potential error.
In the history list, the orders are not arranged in the order in which they appear in the list. I encountered this when developing the library. I relied on it. But it turned out to be not so simple. Try to set limit and stop orders in turn in the following order: limit -> stop -> limit -> stop -> limit -> stop and delete each in any order and see which order is the last one recorded in the history list. You will be surprised.
There is no error there, as the list is generated through HistorySelectByPosition.