Need some help/ideas on how to solve this ...

To add comments, please log in or register
Martel
5
Martel  

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

Files:
lg1sea.mq4 5 kb
jacques366
327
jacques366  
maran83 wrote >>

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)

To add comments, please log in or register