Hi everyone,
I have this quite simple EA, that after signal is generated and price goes one pip in the favor of the signal opens trade.
My problem is that I do not know how to make EA give up on this signal if it can not be filled in the following bar and just wait for another signal.
I am using:
void OpenBuy()
{
double lLot, lStop, lTake;
string lComm;
lLot = GetLotSize();
lStop = GetStopLoss("BUY");
lTake = GetTakeProfit("BUY");
lComm = GetCommentForOrder();
OrderSend(Symbol(), OP_BUYSTOP, lLot, BuyPrice, Slippage, lStop, lTake, lComm, MAGIC, 0, clOpenBuy);
This BUY STOP is opened until infinite time, and i only need it opened in the next bar ...
I am sure this is not a hard task for someone proficient in MQL ...
Thanks in advance,
m83
/// EA attached
Hello,
I think you have to program a loop reading all your pending orders and for each check the open time with the close time of the bar you want to be the limit, close the order when its lifetime is over (your order is no more a pending order when OrderType() == OP_BUY || OrderType()== OP_SELL)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 everyone,
I have this quite simple EA, that after signal is generated and price goes one pip in the favor of the signal opens trade.
My problem is that I do not know how to make EA give up on this signal if it can not be filled in the following bar and just wait for another signal.
I am using:
void OpenBuy()
{
double lLot, lStop, lTake;
string lComm;
lLot = GetLotSize();
lStop = GetStopLoss("BUY");
lTake = GetTakeProfit("BUY");
lComm = GetCommentForOrder();
OrderSend(Symbol(), OP_BUYSTOP, lLot, BuyPrice, Slippage, lStop, lTake, lComm, MAGIC, 0, clOpenBuy);
This BUY STOP is opened until infinite time, and i only need it opened in the next bar ...
I am sure this is not a hard task for someone proficient in MQL ...
Thanks in advance,
m83
/// EA attached