Hello. I'm new to using the OnTradeTransaction Event.
I'm using it to detect pending orders that I place manually from a different terminal.
The pending orders should trigger the EA to start a trading session based on the pending order parameters.
That's working very well.
But now I want to delete the pending order as soon as I extract what I need. I used Ctrade OrderDelete to cancel the order but I'm getting invalid request error.
Sometimes it goes through.
Most Times, it is an invalid request error. Of the 20+ plus times I tried, only a couple went through
I printed the logs in the screenshots.
Is there something I'm missing? Thanks
Print the trading error code instead of the generic last error which is useless here.
Print("OnTradeTransaction Error: ", Trade.ResultCode());
When you delete the order onTradeTransaction is invoked once again. This time the order is already deleted and cannot be deleted again. I guess that is the problem.
Hello
I'm only looking for a new active order. That is what I'm checking first.
if(trans.type == TRADE_TRANSACTION_ORDER_ADD)
The block won't run again unless another pending order is added. I send only one order at a time, for now.
When I get the error, the order isn't deleted.
You are trying to delete an order BEFORE it's fully placed.
See this article for detailed explanation.
- www.mql5.com
You are trying to delete an order BEFORE it's fully placed.
See this article for detailed explanation.
Thank you very much.
I realized that the order wasn't placed state until after some moments, sometimes even a whole second. Behavior is different in different brokers and symbols.
Since I need to grab the information very early, I modified the Chaser class to handle the cancelation of the order on its method that runs OnTick.
So, I will pass the ticket and try to delete it on the next tick, or when it is available.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello. I'm new to using the OnTradeTransaction Event.
I'm using it to detect pending orders that I place manually from a different terminal.
The pending orders should trigger the EA to start a trading session based on the pending order parameters.
That's working very well.
But now I want to delete the pending order as soon as I extract what I need. I used Ctrade OrderDelete to cancel the order but I'm getting invalid request error.
Sometimes it goes through.
Most Times, it is an invalid request error. Of the 20+ plus times I tried, only a couple went through
I printed the logs in the screenshots.
Is there something I'm missing? Thanks