wrong paramater counts on Trailing Stops

 

hi guys can anyone help me out on this one am getting wrong paramater counts … am sorry about that guys 

void BuyTrailingStop(string Symbol, double TrailingStop, double MinProfit, int MagicNumber, double MaxStopLoss)
   { 
     for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++) 
       { 
         if(OrderSelect(Counter,SELECT_BY_POS))
        // Calculate Max Stop and Min Profit 
           
        MaxStopLoss = MarketInfo(Symbol(),MODE_BID) - (TrailingStop * PipPoint(Symbol()));
               MaxStopLoss = NormalizeDouble(MaxStopLoss,MarketInfo(OrderSymbol(),MODE_DIGITS));
        double CurrentStop = NormalizeDouble(OrderStopLoss(),MarketInfo(OrderSymbol(),MODE_DIGITS));
        double PipsProfit = MarketInfo(Symbol(),MODE_BID) - OrderOpenPrice(); 
         MinProfit = MinProfit * PipPoint(Symbol());

       // Modify Stop 
       if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && OrderType() == OP_BUY && CurrentStop < MaxStopLoss && PipsProfit >= MinProfit) 
         { 
           bool Trailed = OrderModify(OrderTicket(),OrderOpenPrice(),MaxStopLoss, OrderTakeProfit(),0);
       // Error Handling 
           if(Trailed == false) 
             { 
               int ErrorCode = GetLastError(); 
               string ErrDesc = "ErrorDescription(ErrorCode)";
               string ErrAlert = StringConcatenate("Buy Trailing Stop – Error ",ErrorCode,": ",ErrDesc); 
                 Alert(ErrAlert);
               string ErrLog = StringConcatenate("Bid: ", MarketInfo(Symbol(),MODE_BID)," Ticket: ",OrderTicket()," Stop: ", OrderStopLoss()," Trail: ",MaxStopLoss); 
                 Print(ErrLog);
             }
          }
        }
   }
















and the sell trailing stop function


void SellTrailingStop(string Symbol, double TrailingStop, double MinProfit, int MagicNumber, double MaxStopLoss ) 
   { 
     for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++) 
       { 
         if(OrderSelect(Counter,SELECT_BY_POS))
      // Calculate Max Stop and Min Profit 
         MaxStopLoss = MarketInfo(Symbol(),MODE_ASK) + (TrailingStop * PipPoint(Symbol()));
               MaxStopLoss = NormalizeDouble(MaxStopLoss,MarketInfo(OrderSymbol(),MODE_DIGITS));
        double CurrentStop = NormalizeDouble(OrderStopLoss(),MarketInfo(OrderSymbol(),MODE_DIGITS));
        double PipsProfit = OrderOpenPrice() - MarketInfo(Symbol(),MODE_ASK); 
              MinProfit = MinProfit * PipPoint(Symbol());
        
     // Modify Stop 
        if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol() && OrderType() == OP_SELL && (CurrentStop > MaxStopLoss || CurrentStop == 0) && PipsProfit >= MinProfit) 
           { 
             bool Trailed = OrderModify(OrderTicket(),OrderOpenPrice(),MaxStopLoss, OrderTakeProfit(),0);
     // Error Handling 
             if(Trailed == false) 
               { 
                 int ErrorCode = GetLastError(); 
                 string ErrDesc = "ErrorDescription(ErrorCode)";
                 string ErrAlert = StringConcatenate("Sell Trailing Stop - Error ", ErrorCode,": ",ErrDesc); 
                    Alert(ErrAlert);
                 string ErrLog = StringConcatenate("Ask: ", MarketInfo(Symbol(),MODE_ASK)," Ticket: ",OrderTicket()," Stop: ", OrderStopLoss()," Trail: ",MaxStopLoss); 
                    Print(ErrLog);
               }
             }
         }
   }


// Adjust trailing stops
  if(BuyMarketCount(Symbol(),MagicNumber) > 0 && TrailingStop > 0)
    {
      BuyTrailingStop(Symbol(),TrailingStop,MinimumProfit,MagicNumber);      //HERE
    }
  if(SellMarketCount(Symbol(),MagicNumber) > 0 && TrailingStop > 0)
    {
     SellTrailingStop(Symbol(),TrailingStop,MinimumProfit,MagicNumber);      //AND HERE
    }
  return(0);
}

 

your TrailingStop function is a custom function, check its defination, you must have missed some parameters it requires

 
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2017.07.19

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. We have no idea what your custom function are.

    Always post all relevant code.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

 
steve.lee:

your TrailingStop function is a custom function, check its defination, you must have missed some parameters it requires

okay let me double check it
 
William Roeder:
  1. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2017.07.19

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. We have no idea what your custom function are.

    Always post all relevant code.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

okay i am sorry about that let me do all that
 
Themba Mkhize:
okay lemme double check it
Themba Mkhize:
okay am sorry about that lemme do all that

Please use English in the forum. "Lemme" is not a word.

 
void BuyTrailingStop(string Symbol, double TrailingStop, double MinProfit, int MagicNumber, double MaxStopLoss)
void SellTrailingStop(string Symbol, double TrailingStop, double MinProfit, int MagicNumber, double MaxStopLoss ) 

Both functions have 5 parameters

     BuyTrailingStop(Symbol(),TrailingStop,MinimumProfit,MagicNumber);      //HERE

     SellTrailingStop(Symbol(),TrailingStop,MinimumProfit,MagicNumber);      //AND HERE

Your function calls only have 4!

 
Keith Watford:

Both functions have 5 parameters

Your function calls only have 4!

thank you very much,i really appreciate it
Reason: