Hi Folks,
During backtesting of my EA, frequently the opened Sell-limit and Buy-limit orders get closed due to expiration. I dont know why, since i do have the expiration time defined in the code:
I use the EA only on M15 PERIOD. I've tried several other expiration time, but i always get sometimes expiration closes.
What are you asking?
If you set an expiration time, why are you surprised when it is activated?
What are you asking?
If you set an expiration time, why are you surprised when it is activated?
It is either always or sometimes, it cannot be both.No thats not what i mean. Lets see the following pictures: Although the order is opened correctly and the price is below the tp-line, the order is not closed. If o choose short expiration times, the order gets closed quickly, otherwise the order is then closed by expiration, until the price reaches the next limit level (price). You can see the problem in the attached pictures:
Expiration does not close orders. It only deletes pending orders. If the order has been triggered before expiration, it will no longer close due to expiration.
Plus, you have to consider weekends. If the expiration ends after the close of the week, it will only be deleted when the week opens again.
EDIT: Also, you should always check for error 147 (ERR_TRADE_EXPIRATION_DENIED), in case the broker or account does not support expiration.
Expiration does not close orders. It only deletes pending orders. If the order has been triggered before expiration, it will no longer close due to expiration.
Plus, you have to consider weekends. If the expiration ends after the close of the week, it will only be deleted when the week opens again.
EDIT: Also, you should always check for error 147 (ERR_TRADE_EXPIRATION_DENIED), in case the broker or account does not support expiration.
I do not get error147. It has somehow to do if the price get below the tp-line in the same candle. But i cannot figure out why.
No thats not what i mean. Lets see the following pictures: Although the order is opened correctly and the price is below the tp-line, the order is not closed. If o choose short expiration times, the order gets closed quickly, otherwise the order is then closed by expiration, until the price reaches the next limit level (price). You can see the problem in the attached pictures:
Why do you want a sell limit to be close if the price is below the TP ? You should read and understand how limit orders are working.
To trigger a SL/TP the sell limit should be triggered in first place and become a SELL.
- www.metatrader4.com
Why do you want a sell limit to be close if the price is below the TP ? You should read and understand how limit orders are working.
To trigger a SL/TP the sell limit should be triggered in first place and become a SELL.
Thats correct. I know what the sell buy limit order is. in my EA the buy/sell limit normally are transformed into SELL or BUY orders but sometimes they just dont. I dont see why.
Your topic was about expiration, now you say the problem is "sometimes" limit orders are not triggered. Make your mind please.
I don't see any problem in what you posted.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Folks,
During backtesting of my EA, frequently the opened Sell-limit and Buy-limit orders get closed due to expiration. I dont know why, since i do have the expiration time defined in the code:
Ticket = OrderSend (Symbol(), OP_SELLLIMIT, Lotlimit, Bid+(Pips*Point), 3, Bid+(Pips*Point) + (StopLosslimit*Point),Bid+(Pips*Point)-(TakeProfitlimit*Point),NULL, Magic, TimeCurrent() + 3600, Red);
LastOrder = 0;
if ( Ask<(tun+big_limit*Point) && Ask>(tun+small_limit*Point) && tuo!=empty && tdo==empty&& LastOrder != 1 ) { // LastOrder!= 1 prevent script from making a lot of same buystop orders
Ticket = OrderSend ( Symbol(), OP_BUYLIMIT, Lotlimit, Ask- (Pips*Point), Slippage, Ask- (Pips*Point)-(StopLosslimit*Point),Ask-(Pips*Point)+(TakeProfitlimit*Point), NULL, Magic, TimeCurrent() + 3600), Green);
LastOrder = 1; // It prevent script from making a lot of same buy orders
}
I use the EA only on M15 PERIOD. I've tried several other expiration time, but i always get sometimes expiration closes.
Any tips ?
Cheers
akuh