[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 188

 
But I don't know how to delete a pending order if the pentamino was less than 30 pips.
 
hoz:

Yes, so what?

There are a number of limitations when working in visualisation mode
 

What did I do wrong!!!!

I came up with this solution to my problem

int start()
  {
     double Price=Ask+300*Point;    
     double SL=Price-300*Point;    
     double TP=Price+150*Point;
     bool New_Bar;
                          
     if (Time[0])                                                                           //   если образовался новый бар               
         int Ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Price,3,SL,TP ); //   выставить отложенный ордер
     return ;
     Fun_New_Bar();                                                                      
     if ( New_Bar==true)                                                // если образовался следующий бар
        OrderDelete(Ticket);                                          // удалить отложенный ордер
  
//+------------------------------------------------------------------+
     void  Fun_New_Bar();                            //НО ПО ОТНОШЕНИЮ К ЭТОЙ СТРОКЕ КОМПИЛЯТОР ПИШЕТ ОШИБКУ       '(' - function definition unexpected  
       {                                                                           
          static datetime New_Time=0;
          New_Bar=false;
                                
         if( New_Time!==Time[0])                       
            New_Time=Time[0];                         
         New_Bar=true;                             
      }

/* sorry, I've changed the post slightly - so that the Vinin is readable */

 
Thank you for your concern. Which button do I press to get the code in this format?
 
solnce600:

What did I do wrong!!!!

I came up with this solution to my problem

/* sorry, changed the post a bit - to make the Vinin readable */

This line
 if (Time[0])

means: "if the time of the last bar is not zero". So it is always not equal to zero.

Further, the variable

bool New_Bar;

is defined inside the start() function, so it won't be visible inside other functions. In addition, the Fun_New_Bar() you tried to define inside the start() body, you cannot do so in MQL, all functions must be declared at the global module level. The declaration of New_Bar should be placed there, too.

 

Besides, during one execution of start() function (if it is not looped), you cannot define formation of bar and then wait for formation of next bar: start() by definition is called and terminates on every tick (with nuances, but in general it is so).

I advise to reread the help and eliminate gaps in MQL program execution, and see an example of writing a looped program, non-looped too.

 
solnce600:
Thanks for your thoughtfulness. Which button do I press to get the code in this format?

SRC----------------------------\|/

--------------------------------------- V

 
He has the right.
 
alsu:
This line
 if (Time[0])

means: "if the time of the last bar is not equal to zero". So it is always not equal to zero.


Thank you. But I don't understand where the "NOT" is in this line. Not equal is indicated by the symbol !==.

What I meant was, as soon as the time of opening of a new bar appears, i.e. a new bar appears, the order is opened.

And this is indeed the code that opens an order at the opening of each five bars

 int start()

  {
 double Price=Open[0]+300*Point;	
 double SL=Price-300*Point;	
 double TP=Price+150*Point;
 if (Time[0])                         
 int Ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Price,3,SL,TP );
  

 
 }


 

I decided to take what I thought was a simpler route.

Not to delete the pending order - but to place a pending order only if a five-minute candle has not finished

That is, the pending order should be placed only when two conditions are met. If the first condition is met

 if (Time[0])

- I checked it, the order is set.

How should I set the second condition, i.e., set a pending order only if 5 minutes have not yet passed. if (---------- && ?????????)

int start()

  {
 double Price=Open[0]+300*Point;    
 double SL=Price-300*Point;     
 double TP=Price+150*Point;
 
  
 
 
                          
   if (Time[0]&& ?????????  )                         
 int Ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Price,3,SL,TP );
 return(0);
 
  }
Reason: