need help with compiling error: parameter conversion not allowed

 

Hello,

I'm stuck on a compiling error.  Maybe something stupid but I can't see it or understand it.  Help greatly appreciated.

I've tried to only include relevant code to make this as easy as possible.

The problem is calling a function I've created.  The code works if I execute it directly in OnCalculate() instead of through a called function.  But the OnCalculate() runs the code several times and I'm attempting to refactor the code so I can iterate through multiple calls to the same code using different handles, buffers and timeframes.

The full error I'm getting when constructing it as a function call is:

'T1ThickBuffer' - parameter conversion not allowed

    void CalculateAllTimeframes(int,double,double,int,double,int) csb_MACD Status in Timeframes.mq5 1073 6

Here is the relevant code.  At the bottom you can see two different constructs of the function, both of which get the same compilation error:

//<...snip...>

input ENUM_TIMEFRAMES TF1=PERIOD_MN1;

int T1Handle;
int T1MACDCrossHandle;

double T1ThickBuffer[];         // not an indicator plot, just an array, not an index
double T1ThinBuffer[];          // not an indicator plot, just an array, not an index
double T1ChartHistStat[];       // this is an indicator plot, an index set with SetIndexBuffer() in OnInit()

string macdIndicatorToUse="csb_MACD.ex5";

//<...snip...>


OnInit()
   {
   SetIndexBuffer(0,T1ChartHistStat);
   ArraySetAsSeries(T1ChartHistStat,true);
   
   ArraySetAsSeries(T1ThickBuffer,true);
   ArraySetAsSeries(T1ThinBuffer,true);
   
   //<...snip...>
   
   /// the below 2 lines work with their constants - these two lines are verified
   T1Handle=iCustom(_Symbol,TF1,macdIndicatorToUse,12,26,9,PRICE_CLOSE);
   T1MACDCrossHandle=iCustom(_Symbol,TF1,macdIndicatorToUse,12,26,9,PRICE_CLOSE);

   //<...snip...>
   
   }


OnCalculate()
   {
   
   //<...snip...>
   
      int THandle = 0;
      THandle = T1Handle;
      CalculateAllTimeframes(THandle, T1ThickBuffer, T1ThinBuffer, T1MACDCrossHandle, T1ChartHistStat, TF1);

   //<...snip...>

   }

// CONSTRUCT TEST #1
// this construct has the compiling error
void CalculateAllTimeframes(int THandle, double TThickBuffer, double TThinBuffer, int TMACDCrossHandle, double TChartHistStat, int TF)
   {

   //<...snip...>

   }


// CONSTRUCT TEST #2
// this construct has the compiling error
void CalculateAllTimeframes(int THandle, double &TThickBuffer, double &TThinBuffer, int TMACDCrossHandle, double &TChartHistStat, int TF)
   {

   //<...snip...>

   }

I hope I've not missed anything relevant when snipping out excess code.  Again, all my code works great when in OnCalculate(), but I can't seem to encapsulate it in the new CalculateAllTimeframes() function without getting the compiling error.

Thank you so much for your time!!

 
double T1ThickBuffer[];         // not an indicator plot, just an array, not an index

CalculateAllTimeframes(THandle, T1ThickBuffer, T1ThinBuffer, T1MACDCrossHandle, T1ChartHistStat, TF1);

void CalculateAllTimeframes(int THandle, double TThickBuffer, double TThinBuffer, …

T1ThickBuffer is an array.
You pass it to the function.
The function takes a single double, not an array.
 
William Roeder #:
double T1ThickBuffer[];         // not an indicator plot, just an array, not an index

CalculateAllTimeframes(THandle, T1ThickBuffer, T1ThinBuffer, T1MACDCrossHandle, T1ChartHistStat, TF1);

void CalculateAllTimeframes(int THandle, double TThickBuffer, double TThinBuffer, …

T1ThickBuffer is an array.
You pass it to the function.
The function takes a single double, not an array.

OMG William thank you so much.  Really appreciate it.  Here obviously is what works:

void CalculateAllTimeframes(int THandle, double &TThickBuffer[], double &TThinBuffer[], int TMACDCrossHandle, double &TChartHistStat[], int TF)
Reason: