'CopyRates' Error

 

Greetings to you all

can any one please help me i have been bugged by this error for quite some time now: 'CopyRates' - no one of the overloads can be applied to the function call

here is the code:

MqlRates oneHourCandleAgo;
        
 if(CopyRates(_Symbol, onehourtf, 0, 1, oneHourCandleAgo, oneHourAgo) != -1)
even if i use ArrayReSize() function i'm still getting the same error right at the copyrates line
 
Hlomohang John Borotho: 'CopyRates' - no one of the overloads can be applied to the function call

Did you take the time to verify the documentation regarding the CopyRates function?

Your use (6 parameters) ...

CopyRates(_Symbol, onehourtf, 0, 1, oneHourCandleAgo, oneHourAgo)

Documentation (5 parameters) ...

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   int              start_pos,         // start position
   int              count,             // data count to copy
   MqlRates         rates_array[]      // target array to copy
   );

Do you see the issue?

 
Fernando Carreiro #:

Did you take the time to verify the documentation regarding the CopyRates function?

Your use (6 parameters) ...

Documentation (5 parameters) ...

Do you see the issue?

Yes but even though if I put 5 parameters I still get an error e.g if whether I put oneHourCandleAgo or OneHourAgo I still get the error

 
Hlomohang John Borotho #Yes but even though if I put 5 parameters I still get an error e.g if whether I put oneHourCandleAgo or OneHourAgo I still get the error

You did not declare the variable "oneHourCandleAgo" as an array.

MqlRates oneHourCandleAgo[];
 
Fernando Carreiro #:

You did not declare the variable "oneHourCandleAgo" as an array.

I didn't delcare it as an array because I am trying to check if I have bullsh one hour candle that is made up by "60/5" 5minutes candles and I'm using oneHourCandleAgo.close and .open once I start declaring as an array [ ] I will get more errors like 'close' is not a member of array
 
Hlomohang John Borotho #: I didn't delcare it as an array because I am trying to check if I have bullsh one hour candle that is made up by "60/5" 5minutes candles and I'm using oneHourCandleAgo.close and .open once I start declaring as an array [ ] I will get more errors like 'close' is not a member of array

The documentation clearly states that you need to use an array, even if you just copy one element ...

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   int              start_pos,         // start position
   int              count,             // data count to copy
   MqlRates         rates_array[]      // target array to copy
   );


 
Fernando Carreiro #: The documentation clearly states that you need to use an array, even if you just copy one element ...

Alright lemme try working on it and see where it takes me

Anyways do you know a different approach of checking if a candle is bullish apart from what I have already stated above, without having to use . close and .open in order to avoid a member array error 
 
Hlomohang John Borotho #: Anyways do you know a different approach of checking if a candle is bullish apart from what I have already stated above, without having to use . close and .open in order to avoid a member array error 

The error is because you are misunderstanding how CopyRates works.

You can also use iClose and iOpen, but I think that CopyRates may be more efficient.

 
Fernando Carreiro #:

The error is because you are misunderstanding how CopyRates works.

You can also use iClose and iOpen, but I think that CopyRates may be more efficient.

alright thanks lemme implement it and see where it takes me.

Reason: