Problem of data storage and return!

 

Hello,

I try to do an EA which calculate a value on the OnCalculate() part of my code in a loop for each new [i] (IndBuffer[i]=CalculateValue).

I would like to store /save this value in an handle in order to return it in the OnTick() part of my code in order to use it but I don't know how...

Somebody could help me please???....

Thank you.

 

Antoine

double IndBuffer[];

//...

int OnCalculate()
  {
   //...
   for (i = 0;i<rates_total;i++)
     {
      //...
      IndBuffer[i]=CalculateValue;
     }
   return(rates_total);
  }

//...

void OnTick()
  {
   //...
   if(IndBuffer[1]<IndBuffer[2])
     {
      //...
     }
  return;
  }
 

See Program Running:

NewTick

The NewTick event is generated if there are new quotes, it is processed by OnTick() of Expert Advisors attached. In case when OnTick function for the previous quote is being processed when a new quote is received, the new quote will be ignored by an Expert Advisor, because the corresponding event will not enqueued.


Calculate

The Calculate event is generated only for indicators right after the Init event is sent and at any change of price data. It is processed by the OnCalculate function.

So it's impossible to use both function in one mql5-program.
 

Thank you Sir, but how can I do so???

Do I have to create an indicator and after to call it with an iCustom() or can I do something else???

I already tried to create but i met some difficulties... 

Reason: