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
Yes, good advice...
Repeat
We have to checkResults.order.
If the order is placed, it does not mean that the deal has already been done.
Besides, we should also check the status of the order and whether it has already appeared in the history or not.
The exchange does not work with positions, only orders.
I recently raised a topic on reopening orders. Thought I had solved the problem, as everything was working very smoothly for a week. But today I have encountered a similar problem only when opening.
A lot of orders opened on Finam, and 9 on Otkritie...although only one order should have opened in all cases.
Here is a code snippet from the EA
i.e. we can see from the code that if the operation is successful, the variableOpenOrders increases, which initially equals 0
If it is higher than 0, there should be no further opening of the order, but the entire pile of orders is opened with the comment Order1.
I check if there is a positive response in the function opening the order and if the order ticket has been received, but for some reason this function returns false, even though the order is actually set.
Explain what is wrong, how to solve this problem?
Tell me, for which market are you writing this code?
For the stockbroker.
Repeat
Apart from that you should also check the status of the order and whether it has already appeared in the history or not.
The exchange does not deal with positions, only orders.
Well Sergei, see....this is from the documentation of the query result
Deal
A ticket deal, if it has been executed. This is reported during a trade transactionTRADE_ACTION_DEAL
order
Ticket order, if a ticket has been placed. Notified during a trade operationTRADE_ACTION_PENDING
I don't have a pending order, I useTRADE_ACTION_DEAL
You must be working with limiters, then everything is correct.... and here is the entry from the market at the current price.Well Sergei, see....this is from the documentation of the query result
deal
Ticket deal, if any. To be reported on a tradeTRADE_ACTION_DEAL
order
Ticket order, if a ticket has been placed. Notified during a trade operationTRADE_ACTION_PENDING
I do not have a pending order, I useTRADE_ACTION_DEAL
You must be working with limiters, then everything is correct.... and here you are entering from the market at the current price.SetTypeFilling
SetTypeFilling
Sets order type by filling
You set what you see fit.
By the way, just checked the results of sending the order with the prints
so the ticket gives 0 in all cases
res=OrderSend(Request,Results);
if(res)
{
Print(_Symbol+" Test True order "+(string)Results.deal);
if(Results.deal>0) return(true);
else return(false);
}
Print(_Symbol+" Test False order "+(string)Results.deal);
return(false);
By the way, just checked the results of sending an order with the prints
Ticket shows 0 in all cases
Progress has been made ... ))
By the way, I just checked with the printers the results of sending the order
so the ticket gives 0 in all cases
res=OrderSend(Request,Results);
if(res)
{
Print(_Symbol+" Test True order "+(string)Results.deal);
if(Results.deal>0) return(true);
else return(false);
}
Print(_Symbol+" Test False order "+(string)Results.deal);
return(false);
Where are the return codes? How do I know if there was an error or not?
I gave you an example: double protection and the output of the ticket and return code.
I couldn't find an example. Let me put it this way.
When you send an order through the market the order should execute or be rejected (since you have a FOK fill).
So you do not need to wait for a ticket, you need to get a TICKET.
Once you receive a ticket, you "go" to OnTradeTransaction() with the ticket
you listen to TRADE_TRANSACTION_HISTORY_ADD because market orders always get to the history
and look at the ticket to see what happened to the order.