Need help in fixing my grid system.

 
I have a grid system which takes Buy trades whenever market hit lower Bollinger line. and then it keeps on trading after every -200 points and then my ea calculates the average price and set take profit of all running trades to 250 points. 

the problem is that right now my system is working on single grid system. 

i want my ea to open multiple grid trades whenever market hit lower Bollinger line and then calculate average price and take profit for each individual grid.. 

i have this confusion : how to identify how many trades are running in Grid 1, grid 2 and so on. and then execute average price and take profit function to each grid separately.  
 

Coders (any coder) are coding for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members of this forum.

----------------

and Freelance section of the forum should be used in most of the cases.

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

Coders (any coder) are coding for free:

  • if it is interesting for them personally, or
  • if it is interesting for many members of this forum.

----------------

and Freelance section of the forum should be used in most of the cases.

i am learning so i want someone to just give me hint so i can do on my own i cant afford to hire someone

 
Sunny DP #:

i am learning so i want someone to just give me hint so i can do on my own i cant afford to hire someone

You can upload your code, and the users may correct it.
 
Sunny DP:
I have a grid system which takes Buy trades whenever market hit lower Bollinger line. and then it keeps on trading after every -200 points and then my ea calculates the average price and set take profit of all running trades to 250 points. 

the problem is that right now my system is working on single grid system. 

i want my ea to open multiple grid trades whenever market hit lower Bollinger line and then calculate average price and take profit for each individual grid.. 

i have this confusion : how to identify how many trades are running in Grid 1, grid 2 and so on. and then execute average price and take profit function to each grid separately.  
What you need is a data storage system for each grid you are running.

I suggest using a struct/class to do that.

In each struct/class you have to store the ticket numbers of the currently running positions to that grid.

You should also take measures to save/load that struct/class in a file or some other permanent storage, so that you can recover the state, if the EA/terminal crashes for some reason.

You should have some familiarity with structs and classes as well as file handling to implement this reliable.

Since you are currently more a beginner, I do suggest reading the book that has been published lately, and especially focus on data handling.


 
Dominik Egert #:
What you need is a data storage system for each grid you are running.

I suggest using a struct/class to do that.

In each struct/class you have to store the ticket numbers of the currently running positions to that grid.

You should also take measures to save/load that struct/class in a file or some other permanent storage, so that you can recover the state, if the EA/terminal crashes for some reason.

You should have some familiarity with structs and classes as well as file handling to implement this reliable.

Since you are currently more a beginner, I do suggest reading the book that has been published lately, and especially focus on data handling.


i have everything ready thats why my single grid function is working accurately. 

now i just need to fix on thing. how to identify which trades are from grid 1 and which trades are from grid 2 so i can run my already made average price and modify take profit functions on each individual grid 

 
Sunny DP #:

i have everything ready thats why my single grid function is working accurately. 

now i just need to fix on thing. how to identify which trades are from grid 1 and which trades are from grid 2 so i can run my already made average price and modify take profit functions on each individual grid 

I repeat, you need a storage class for each grid in such way, that you can instantiate each grid individually. Then you store each newly opened positions ticket in the storage class of the corresponding grid.

This is not very difficult to do, actually. - It is in fact more or less a refactoring of your current code. - You should be able to do it, or you share the code here, and maybe someone wants to help you with your task.

Everything has been said on this thread so far for you to act now. - Its not on us to provide further support without action on your side, as far it concerns me.

 
void Sell_Trade()
{      
   // Declare a two-dimensional array to store position information
   double SellArrayInfo[500][5];
   
   if (IsNewBar())
   {
      Sellreset = 0;
      Ssigma = s();
      BidPrice = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);

      if ( (Ssigma == 2) && (Sellreset==0) )  
      {
         // Print("Sell"); 
         
         double SellSL = NormalizeDouble((StopLoss == 0 ? 0 : BidPrice + StopLoss * _Point),_Digits);
         double SellTP = NormalizeDouble((BidPrice - TakeProfit * _Point),_Digits);
      
         if(trade.Sell(LotSize,_Symbol,BidPrice,SellSL,SellTP))
         { 
            Sellreset=1;
         }
      }   
   }        
   for (int i = 0; i <= SellTradeCount() -1; i++)
   {
      ulong Sellticket = PositionGetTicket(SellTradeCount() - 1);
            
      if (PositionSelectByTicket(Sellticket)) // Select the position by its ticket
      {
         if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
         {
                   Sellticket           = PositionGetInteger(POSITION_TICKET);
            double SelltradeLotSize     = PositionGetDouble(POSITION_VOLUME);
                   SellOpenPrice        = PositionGetDouble(POSITION_PRICE_OPEN);
            double SelltradeIfTraded    = 0; // 0 for false, 1 for true
                   SelltradeOpenPrice   = NormalizeDouble((SellOpenPrice + Points_to_Wait * _Point),_Digits); 
            double SelltradePriceType   = 1; // 0 for buy & 1 for sell 
         
            SellArrayInfo[i][0] = (double)Sellticket;
            SellArrayInfo[i][1] = SelltradeLotSize;
            SellArrayInfo[i][2] = SellOpenPrice;
            SellArrayInfo[i][3] = SelltradeIfTraded;
            SellArrayInfo[i][4] = SelltradeOpenPrice;
            
            if  (BidPrice >= SelltradeOpenPrice) //&& (trading_allowed==true) ) 
            {    
               double SellSL = NormalizeDouble((StopLoss == 0 ? 0 : BidPrice + StopLoss * _Point),_Digits);
               double SellTP = NormalizeDouble((BidPrice - TakeProfit * _Point),_Digits);
      
               if (trade.Sell(LotSize,_Symbol,BidPrice,SellSL,SellTP) )
               {
                  Sell_UpdateAverageInfo();
                  ModifySell();
               }
            }
         }
      }   
   }
}

thats my code please can anyone help now ?

 
Sunny DP #:

thats my code please can anyone help now ?


Does not compile...

If that is all involved code, then you have no idea about coding an EA. There is nothing I can do for you...

Edit:

Don't get this wrong, I am willing to help, but you are not supporting my efforts.
Reason: