Search code examples
c++mql5

Initialise object in method - MQL5


I want to initialise an object inside a method.

My code:

void OnTick()
{
  CBullishTrend *Bullish=NULL;
  CalcBullish(Bullish);
}
void CalcBullish(CBullishTrend &pBullish)
{
  pBullish = new CBullishTrend(ColorForBullishTrend);
  // do calculations
}

I get this compile error:

'=' - object required

I can only pass objects by reference, so why am I getting this compile error?

Any help would be greatly appreciated.


Solution

  • i think what u are trying to do is pass reference to a pointer, like so:

    void CalcBullish(CBullishTrend *&pBullish)