EA can't reopen orders

 

Hi all,

 At first, ea is working fine, but once an order is closed but trailingstop the ea do not start to open an order.

As it is, once price is greater than the OpenDistance the ea open an order and if price goes back more than the OppositeDistance an opposite orders is open and the last one is closed. After that when price is greater than MinimumProfit the TrailingStop starts to run and if price bounce back the order is closed and this is fine. Problem comes now, once the trailing stop closes the order the ea should start again, but from here the ea do not start to open any order.

Follow. in attach is the code. Is that possible to get from you any support here ? 

Thank you in advance 

Luis 

 
luisneves: At first, ea is working fine, but once an order is closed but trailingstop the ea do not start to open an order.
   if(OTCurrentTick == 0)
      {
       BuyAllowed  = true;
       SellAllowed = true;
 
  //+----------------------------------------------------------------------------+
         //Buy Order Condition to Open

   if(Ask > BuyTrigger && BuyAllowed)
     {//5
     while(BuyTicket<=0)

Of course no more open. The first time BuyTicket = 0 and you enter the loop and open an order. After that the while loop never executes, because BuyTicket is still above zero.
Put Print statements inside your IFs and loops, with variable values so you find out what is happening.

 
WHRoeder:

Of course no more open. The first time BuyTicket = 0 and you enter the loop and open an order. After that the while loop never executes, because BuyTicket is still above zero.
Put Print statements inside your IFs and loops, with variable values so you find out what is happening.


Hi WHRoeder,

Thank you for your support.

Best regards

Luis 

 

Hi again,

 Thanks to you for show me where I was wrong now the ea is working.

Nevertheless, The reason why I want to make use of a Retry is to surpass issues like requotes, off quotes and so on. So my question is how could one do retries till the moment that our order is accepted without to get an information that ticket is different from 0 ?

Thank you in advance for any clarification.

Luis 

 
BuyAllowed  = true;
SellAllowed = true;
BuyAllowed  = true; BuyTicket  = 0;
SellAllowed = true; SellTicket = 0;
When in doubt, think!