Questions from a "dummy" - page 275

 

Hello! How do I find a value in a two-dimensional array? You need to search in the first dimension. There seems to be no standard means. Thank you!

 
zhurkin:

Hello! How do I find a value in a two-dimensional array? You need to search in the first dimension. There seems to be no standard means. Thank you!

The old-fashioned way. Cycle. If it's equal, that's it.
 
ALXIMIKS:

I've started to study OOP.

I had a problem when writing a descendant of a base class, the compiler writes - "'ХХХХХХ' - wrong parameters count".

I searched for the reason for a long time, re-read articles and reference book,

but I found it - the base class has a constructor, it is one and parametric.

I've found a solution too - overloading of the constructor function with the default constructor,

but then I have to drag all the parameters of the parametric constructor of the base class to the descendant constructor for correct logic.

Are there any other ways?

Is there any way, when declaring a descendant class, to distribute to whom what? For example: these parameters to the constructor of the base class and these parameters so that the descendant doesn't get bored...

If a base class has a single parametric constructor, the descendant class cannot avoid calling it. However, the child class can have any number of parameters, including having no parameters at all. The main thing is that the constructor of the base class is called with all the parameters assigned to it. Example:

class CParent
{
   public:
      CParent(int myID, string myName, double myValue)
      {
         id = myID;
         name = myName;
         value = myValue;
      }
   private:
      int id;
      string name;
      double value;
};

class CChildOne : CParent
{
    public:
       CChildOne() : CParent(2, "CChildOne", 2.34){;}
};

class CChildTwo : CParent
{
    public:
       CChildOne(int myID, int param) : CParent(myID, "CHildTwo", 2.56)
       {
          xParam = param;
       }
    private:
       double xParam;
};

 

There was a discussion in the thread about


ENUM_POSITION_TYPE

two values. and what is returned if there are no open positions?

I use the PositionType() method from the standard library.

Ok, I got it, PositionSelect() returns false, and PositionType() returns the type of the last selected position.



it turns out that if there is no position opened, it always returns 0, i.e. as if a buy position is opened?

how do i get around this?


 
openlive:

There was a discussion in the thread about


ENUM_POSITION_TYPE

two values. and what is returned if there are no open positions?

I use the PositionType() method from the standard library.

Ok, I got it, PositionSelect() returns false, and PositionType() returns the type of the last selected position.



it turns out that if there is no position opened, it always returns 0, i.e. as if a buy position is opened?

how do i get around this?


PositionSelect() is selected if there is a position regardless of its type, 0 - no position, 1 - yes, and the type is defined as convenient.
 

There are two variants ofOnCalculate function definition:

1)int OnCalculate (const int rates_total, // size of array price[]

const int prev_calculated, // processed bars at previous call
const int begin, // where significant data starts from
const double& price[] // array for calculation
);

2)int OnCalculate (const int rates_total, // size of input timeseries

const int prev_calculated, // bars processed at previous call
const datetime& time[], // Time
const double& open[], // Open
const double& high[], // High
const double& low[], // Low
const double& close[], // Close
const long& tick_volume[], // Tick Volume
const long& volume[], // Real Volume
const int& spread[] // Spread
);

call the function 1)OnCalculate(), prefill all its parameters - OnCalculate(rates_total,0,0,_price);

QUESTION: could you please fill in the parameters for the second call toOnCalculate() in this case?

 
Piterrr:

There are two variants ofOnCalculate function definition:

1)int OnCalculate (const int rates_total, // size of array price[]

const int prev_calculated, // processed bars at previous call
const int begin, // where significant data starts from
const double& price[] // array for calculation
);

2)int OnCalculate (const int rates_total, // size of input timeseries

const int prev_calculated, // bars processed at previous call
const datetime& time[], // Time
const double& open[], // Open
const double& high[], // High
const double& low[], // Low
const double& close[], // Close
const long& tick_volume[], // Tick Volume
const long& volume[], // Real Volume
const int& spread[] // Spread
);

call the function 1)OnCalculate(), prefill all its parameters - OnCalculate(rates_total,0,0,_price);

QUESTION: could you please fill in the parameters for the second call toOnCalculate() in this case?

and nothing needs to be filled in either the first or second case.
 
zfs:
and nothing needs to be filled in the first or second case.
I need to call this function forcibly - how do I fill in the parameters in this case ?
 
Piterrr:
I need to call this function forcibly - how do I fill in the parameters in this case ?
Create your own, this one cannot.
 
zfs:
You can't create one of your own.
I create my own, inside of which I write theOnCalculate() function, but when filling it with parameters it generates errors - please send me an example.
Reason: