so far so good

 

new to mql4. writing so code to try out all aspects of mql4.
wrote simple buy/sell code that work of last candle open and close. just have one problem as soon as trade is close buy stop loss or profit limit it opens up new trade; how do i code so it only open trade again on next candle.

 
   if (MathCeil(CurTime()/60/Period())!=MathCeil(TradeTime/60/Period()))
      {
       // do trade
       ...
       if (ticket>0) TradeTime=CurTime(); // only if trade operation done
      }


Something like this should help you to trade once a period.