Wront Parameter Count for constructor, but I have the same number of parameters

 

I'm trying to just make a basic Object, but I'm getting an error saying the parameter count is wrong, but it seems the number of parameters in the object creation are the same as in the constructor, so I don't know why I'm getting this error


//+------------------------------------------------------------------+
//|                                                         MBFX.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);

   
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---

   if(Bid > 1){
      SellOrder sell = new SellOrder(3,3,3);
   }
   
  }
//+------------------------------------------------------------------+

class SellOrder{   
   public:
      int magicNumber;
      double lots;
      double stopLoss;
      double takeProfit;
      
      SellOrder(int theStopLoss, int theTakeProfit, int theMagicNumber){
         lots = .1;
         stopLoss = Bid + Point*10;
         takeProfit = Bid - Point*theTakeProfit*10;
         magicNumber = theMagicNumber;
      }
     
       void execute(){
            OrderSend(NULL,OP_SELL,lots,Ask,Bid,stopLoss,takeProfit,NULL,0,0,clrNONE);
      };
   };
 
Drew Clayman:t I'm getting an error saying the parameter count is wrong,
      SellOrder sell = new SellOrder(3,3,3);

You are trying to initialize a SellOrder (sell) with a pointer.

 
Drew Clayman:

I'm trying to just make a basic Object, but I'm getting an error saying the parameter count is wrong, but it seems the number of parameters in the object creation are the same as in the constructor, so I don't know why I'm getting this error


Use either :

      SellOrder sell(3,3,3);   // an object 

or

      SellOrder *sell = new SellOrder(3,3,3);   // a pointer
But not a mix of both.
 

If I add SellOrder() as a default constructor, it works fine. But what is really going on here?

What is the answer for the question?

Why does it get "Wrong Parameter Count" here?

class SellOrder{   
   public:
      int magicNumber;
      double lots;
      double stopLoss;
      double takeProfit;

      SellOrder(){}
      SellOrder(int theStopLoss, int theTakeProfit, int theMagicNumber){
         lots = .1;
         stopLoss = Bid + Point*10;
         takeProfit = Bid - Point*theTakeProfit*10;
         magicNumber = theMagicNumber;
      }
     
       void execute(){
            OrderSend(NULL,OP_SELL,lots,Ask,Bid,stopLoss,takeProfit,NULL,0,0,clrNONE);
      };
   };
Reason: