Grid Code Request

 
int start()
{      
   for(int i = 1; i <= gridlines; i++)
   {
   if((Bid == gridstart + i*step))
   {
   int buy = OrderSend(Symbol(),OP_BUY,lot,Ask,0,0,Ask+step,Comments,MagicNumeber,0);
   int sell = OrderSend(Symbol(),OP_SELL,lot,Bid,0,0,Bid+step,Comments,MagicNumeber,0);
   }
   }
   return(0);
}

Hello traders and mql4 coders,

Can anyone help me in this; I've coded a very simple code to open trades in both directions (Buy/Sell) when the price hits the grid level which is predefined in the EA, however, the EA opens orders each time the price hits the grid line.

The question is: How to make the EA opens trade one time only when the price hits the gridline (if there's no trade open in the same gridline)?

Thanks

 

Aladdin Abdulkareem:

Can anyone help me in this;

The question is: How to make the EA opens trade one time only when the price hits the gridline (if there's no trade open in the same gridline)?

  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help
              urgent help.

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum

  2. The answer is: Check for open orders near your gridline first.

  3. if((Bid == gridstart + i*step))
    Doubles are rarely equal. Understand the links in:
              The == operand. - MQL4 programming forum

  4. OrderSend(Symbol(),OP_BUY,lot,Ask,0,0,Ask+step,Comments,MagicNumeber,0);
    Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.