Discussion of article "Library for easy and quick development of MetaTrader programs (part XXIV): Base trading class - auto correction of invalid parameters"
Can you tell me how to get information about a losing order? Such as the amount of loss, order number, order quantity, opening time, etc.. Thank you!
hsyhsy863 :
Can you tell me how to get information about a losing order? Such as the amount of loss, order number, order quantity, opening time, etc.. Thank you!
Here you can ask your questions.
Can you tell me how to get information about a losing order? Such as the amount of loss, order number, order quantity, opening time, etc.. Thank you!
Artyom Trishkin:
Here you can ask your questions.
My question is, when designing an automated trading programme using your program, I need to close a losing order, how can I get the order number of the losing order?
Here you can ask your questions.
hsyhsy863 :
My question is when designing an automated trading programme using your program, I need to close a losing order, how do I get the order number of the losing order?
My question is when designing an automated trading programme using your program, I need to close a losing order, how do I get the order number of the losing order?
In the adviser.
//--- Get a list of all open positions CArrayObj* list=engine.GetListMarketPosition(); //--- Sort the list by profit, taking into the commission and swap list.Sort(SORT_BY_ORDER_PROFIT_FULL); //--- Get the index of the position with the lowest profit (largest loss) int index=CSelect::FindOrderMin(list,ORDER_PROP_PROFIT_FULL); if(index>WRONG_VALUE) { //--- Get the position object with the largest loss and close the position by ticket COrder* position=list.At(index); if(position!=NULL) engine.ClosePosition(position.Ticket()); }
The library should be connected in accordance with the expert example attached to this article.
Artyom Trishkin:
The library should be connected in accordance with the expert example attached to this article!
In the adviser.
The library should be connected in accordance with the expert example attached to this article.
Hello, when I was designing the auto-trading, I found that when OP_BUYSTOP and OP_SELLSTOP are placed at the same time, only OP_SELLSTOP is placed but not OP_BUYSTOP. The statement fully meets the conditions of the pending order but it can't be pending.
hsyhsy863 :
Hello, when I was designing the auto-trading, I found that when OP_BUYSTOP and OP_SELLSTOP are placed at the same time, only OP_SELLSTOP is placed but not OP_BUYSTOP. The statement fully meets the conditions for pending orders, but the orders cannot be pending.
Provide an example to reproduce this error.
Hello, when I was designing the auto-trading, I found that when OP_BUYSTOP and OP_SELLSTOP are placed at the same time, only OP_SELLSTOP is placed but not OP_BUYSTOP. The statement fully meets the conditions for pending orders, but the orders cannot be pending.
Artyom Trishkin:
Provide an example to reproduce this error.
Provide an example to reproduce this error.
if(datetimeN5!=iTime(NULL,0,0))
if(datetimeN5!=iTime(NULL,0,0))
if(ASWER(Close Position, "Upper Pending Bid")==0) { if(datetimeN5!=iTime(NULL,0,0))
{
Pending Buy(0.382,Closed); {
datetimeN5 = iTime(NULL, 0, 0);
}}
if(datetimeN6!=iTime(NULL,0,0))
{
if(ASWER(Close Position, "Down Pending Sell Count") == 0)
{
Pending Sell(0.382,Close Position);
datetimeN6 = iTime(NULL, 0, 0);
}}
This is the source code for my pending buy and pending sell, there should logically be two pending orders at the same time, but in reality there is only the pending sell order.
Sorry, problem solved, my mistake!!!!
hsyhsy863:
Sorry, problem solved, my mistake!!!!
OK
Sorry, problem solved, my mistake!!!!

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
New article Library for easy and quick development of MetaTrader programs (part XXIV): Base trading class - auto correction of invalid parameters has been published:
In this article, we will have a look at the handler of invalid trading order parameters and improve the trading event class. Now all trading events (both single ones and the ones occurred simultaneously within one tick) will be defined in programs correctly.
Generally, the EA should be able to act according to the circumstances while following the user-defined logic of handling errors in trading orders. Thus, we may give the following instructions to the EA when a trading order error is detected:
Handling errors in trading order parameters may lead to one of several outcomes:
In this article, we are going to develop the trading order error handler that will check errors and their sources, as well as return the error handling method:
Author: Artyom Trishkin