can someone assist me in making a function which trade only once per candle not at the start of candle but through out candle until condition is met.

 
bool Tradeallowed(){

      bool hastraded = false;
      
    for(int a =PositionsTotal()-1;a>=0;a--){
         
         string symbol1 = PositionGetSymbol(a);  
         
         if(Symbol() == symbol1){
                  
            ulong pticket1 = PositionGetTicket(a);
            double csl1 = PositionGetDouble(POSITION_SL);
            int posT = PositionGetInteger(POSITION_TYPE);
          
               if(posT == POSITION_TYPE_BUY){
            
                       hastraded = true;
                        
                  
                  }
                 
               
               
               if(posT == POSITION_TYPE_SELL){
            
                       hastraded = true;
                       
                  
                }
               
             }   
         }
          
     
     
     return hastraded;    

}
 

Don't double post! You already had another thread open.

          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017.07.19)