Grid system help

 

                   Hello coders I need help in correcting the code below. I want a situation whereby after the buy order has been activated the grid will open buy orders after every increase of 50 pips and when sell order has been activated the grid will open trades after a decrease of 50 pips. I've tried to correct the code but it's not working according to the conditions.

void Grid()   {       static double NextBuyPrice;       static double NextSellPrice;       string signal = "";       if(OrdersTotal() == 0)       NextBuyPrice = 0;              if(Ask >= NextBuyPrice )         {             signal = BUYSIGNAL;             int buy = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,EA_Comment,Magic,0,clrBlue);             NextBuyPrice = Ask + Griddistance * _Point;                      }                if(OrdersTotal() == 0)       NextSellPrice = 0;       if(Bid <=  NextSellPrice)         {            signal = SELLSIGNAL;            int sell = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0 ,EA_Comment,Magic,0,clrRed);            NextSellPrice = Bid -  Griddistance * _Point;                    }                  }
 
Ernest Akoyi:

I have deleted two other threads like this one (2023.03.22 and 2023.03.23). Please be patient.

 
Miguel Angel Vico Alba #:

I have deleted two other threads like this one (2023.03.22 and 2023.03.23). Please be patient.

I'll appreciate your help

 
Ernest Akoyi #:

 Hello coders I need help in correcting the code below. I want a situation whereby after the buy order has been activated the grid will open buy orders after every increase of 50 pips and when sell order has been activated the grid will open trades after a decrease of 50 pips. I've tried to correct the code but it's not working according to the conditions.

NextBuyPrice = OrderOpenPrice() + Griddistance * _Point;

NextSellPrice = OrderOpenPrice() - Griddistance * _Point; 

You should consider hiring somebody.

https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.03.24
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
meta_trader2352345 #:

You should consider hiring somebody.

https://www.mql5.com/en/job

Thank you for the help. What if I want it to buy after a decrease of 50 pips in current price and sell after price moves up by 50 pips

 
Ernest Akoyi:

                   Hello coders I need help in correcting the code below. I want a situation whereby after the buy order has been activated the grid will open buy orders after every increase of 50 pips and when sell order has been activated the grid will open trades after a decrease of 50 pips. I've tried to correct the code but it's not working according to the conditions.

Ask> NexTbuyprice—- this will always be true
Bid<nextsellprice  — this will never be true. 

You should make a condition for Buy or Sell, and from that OpenPrice() add gridgap for next orders in the grid 
 
Daniel Cioca #:
Ask> NexTbuyprice—- this will always be true
Bid<nextsellprice  — this will never be true. 

You should make a condition for Buy or Sell, and from that OpenPrice() add gridgap for next orders in the grid 

Thank you

Reason: