Trade Wait X Pips the last trade Open Price.

 

Hello Everyone. 

I would like a function to put before the sendorder, to prevent an expert from opening an order before the price of the previous one is greater than X Pips.

Example:

Distance = 30 Pips;

Open = BUY> Price: 1,001

Signal buy> Price 1.015> Dont open

New Signal Buy> Price 1,030> Open, because distance set for 30 pips distant the last open order.

I have one code for time, I want a code like this, though, that works with the Pips count.

extern bool TradeWaitTime  = 30; 

int TradeTime(){
   int wait=0;
   int total=OrdersTotal();

      for (int i = total - 1; i >= 0; i --)
      {
         OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
         if(OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
         {
            if(OrderOpenTime() + (TradeWaitTime*60) > TimeCurrent()) wait=1;
         }
      }
   return (wait);
}
 
?
Reason: