CopyBuffer debugging issue: expression and value

 

Hi there, I try to search for a solution but still could not find it.

Please you have time, please do help me check this little issue.


I am trying to learn to write an EA and I am curious about this part.

input int MA_Period = 8; // Moving Average Period
int maHandle; // handle for our Moving Average indicator
double maVal[]; // Dynamic array to hold the values of Moving Average for each bars

int OnInit()
{
   //--- Get the handle for Moving Average indicator
   maHandle = iMA(_Symbol,_Period,MA_Period,0,MODE_EMA,PRICE_CLOSE);

   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
   //--- Release our Indicator handle
   IndicatorRelease(maHandle);
}

void OnTick()
{
   //--- The MA-8 values arrays
   ArraySetAsSeries(maVal,true);

   //--- Copy the new values of our indicator to buffer using the handle
   if(CopyBuffer(maHandle,0,0,3,maVal)<0)
   {
      Alert("Error copying Moving Average indicator buffer - error:",GetLastError());
      return;
   }
}

First, do you have any suggestion on improving this ? Or is it already good up to the standard.

Second, when I try to debug, the individual value of maVal[xxx] is not the same of the maVal dynamic array (as seen in the attached image). Can you help explain this part ?

For example maVal[0] == 0.0 but maVal with dropped down [0] == 1.211440250031675

Three, if later I use maVal[0] in the calculation, would it gives me 0.0 or 1.211440250031675 ?


Thank you so much for your time.

Files:
DD1234.png  11 kb
 
TeddyBear SADAMA:

For example maVal[0] == 0.0 but maVal with dropped down [0] == 1.211440250031675

 maVal with dropped down [0]

What does that mean?

For example maVal[0] == 0.0 

How do you know?

Show the code where you print the value.

 
Keith Watford:

 maVal with dropped down [0]

What does that mean?

For example maVal[0] == 0.0 

How do you know?

Show the code where you print the value.

Dear @Keith Watford,


Please check my newly attached image: DD1234.png

Files:
DD1234.png  11 kb
 
TeddyBear SADAMA :

Dear  @Keith Watford ,


Please check my newly attached image: DD1234.png

Build 2760 has been released. Check - the behavior of the calculator has been fixed.

 
Vladimir Karputov:

Build 2760 has been released. Check - the behavior of the calculator has been fixed.

You are saying this is due to bug and it will be resolved once I have updated the MT5 ?

Thankk you ^_^


edited

The issue is fixed ^______^

Thank you so much.

 
TeddyBear SADAMA :

You are saying this is due to bug and it will be resolved once I have updated the MT5 ?

Thankk you ^_^

Refresh the terminal. You must update the terminal.

Reason: