three question from IndicatorCreate()

 

1. do not support "[]&" grammar

In MQL5 Reference / Timeseries and Indicators Access / IndicatorCreate,
there is:

int  IndicatorCreate(
   string           symbol,                            // symbol name
   ENUM_TIMEFRAMES  period,                            // timeframe
   ENUM_INDICATOR   indicator_id,                      // indicator type from the enumeration ENUM_INDICATOR
   int              parameters_cnt=0,                  // number of parameters
   MqlParam[]&      parameters_array=NULL,             // array of parameters
   );

But when I write


bool CopyMqlParam(const int iNum, const MqlParam[]& rcaParam)

It cause compile error:


'[' - objects passed by reference only  testAlligator.mq5       54      43

I must write


bool CopyMqlParam(const int iNum, const MqlParam& rcaParam[])

So, please change the MQL5 implementation or document.

 

2. parameters_array should be const

Now (MetaEditor 5.00 build 247), if I give IndicatorCreate() a const MqlParam array as parameter,
It will cause compile error:

'cIndiParamALLIGATOR' - parameter conversion is not allowed     testAlligator.mq5       94      52

So I must make a function to copy the const MqlParam array to a non-const array.
It make an unnecessary move.

const MqlParam cIndiParamALLIGATOR[8] = { { TYPE_INT,13, 0.0, ""}, 
                                          { TYPE_INT, 8, 0.0, ""},
                                          { TYPE_INT, 8, 0.0, ""},
                                          { TYPE_INT, 5, 0.0, ""},
                                          { TYPE_INT, 5, 0.0, ""},
                                          { TYPE_INT, 3, 0.0, ""},
                                          { TYPE_INT, MODE_SMMA, 0.0, ""},
                                          { TYPE_INT, PRICE_MEDIAN, 0.0, ""} };
MqlParam m_IndiParam[8];

bool CopyMqlParam(const int iNum, const MqlParam& rcaParam[])
{
   if (iNum<=0)
      return(true);
   for(int i=0;i<iNum;i++)
   {
      m_IndiParam[i].type          = rcaParam[i].type;
      m_IndiParam[i].integer_value = rcaParam[i].integer_value;
      m_IndiParam[i].double_value  = rcaParam[i].double_value;
      m_IndiParam[i].string_value  = rcaParam[i].string_value;
   }
   return(true);
}
void OnInit()
  {
...
   CopyMqlParam(8, cIndiParamALLIGATOR);
   m_handle=IndicatorCreate(NULL,0,IND_ALLIGATOR,8,m_IndiParam);
...
  }
 

3. CopyBuffer() lost last value when get m_handle from
iAlligator() and IndicatorCreate(NULL,0,IND_ALLIGATOR,8,m_IndiParam)

Files:
 

4. And iGator(), I think it should fill all the data buffer, do not let user patch in indicator.

 

Files:
testgator.mq5  13 kb
 

4.----Perhaps I misunderstood. Forget it. Unless you have other ideas.

 

 

3. I add set empty value and ArrayInitialize()

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0);
      ArrayInitialize(ExtJaws,0.0);
      ArrayInitialize(ExtTeeth,0.0);
      ArrayInitialize(ExtLips,0.0);

But it still can not be drawn shift.
And it happen strange phenomena.

 


I just compiled it, did not do anything else.

Files:
 

1. Documentation will be fixed

2. You are right, parameters_array should be const, implementation fixed.