Help with calling a custom indicator within EA

 

Hi All

I am attaching a custom indicator I downloaded from Article section. I tried connecting to the indicator from OnTick() function within my EA. But it is displaying 0 values.

The indicator has 6 values for Stop Line, Start Line and for Target Lines from 1 to 4. You can find this in Price[0] to Price[5] within Oncalculate.

The code I am using to retrieve the values in my Ontick() is below, but it's not working as expected. Please have a look and let me know what i am doing wrong here.


 double strtLine[],stpLine[],tLine1[],tLine2[],tLine3[],tLine4[];

      

      ArraySetAsSeries(strtLine,true);

      ArraySetAsSeries(stpLine,true);

      ArraySetAsSeries(tLine1,true);

      ArraySetAsSeries(tLine2,true);

      ArraySetAsSeries(tLine3,true);

      ArraySetAsSeries(tLine4,true);

      

      

      int DiNap = iCustom(_Symbol,_Period,"DiNapoli_Levels");

      

      

      

      CopyBuffer(DiNap,0,0,3,strtLine);

      CopyBuffer(DiNap,1,0,3,stpLine);

      CopyBuffer(DiNap,2,0,3,tLine1);

      CopyBuffer(DiNap,3,0,3,tLine2);

      CopyBuffer(DiNap,4,0,3,tLine3);

      CopyBuffer(DiNap,5,0,3,tLine4);

      

      

      double startLine = NormalizeDouble(strtLine[0],4);

      double stopLine = NormalizeDouble(stpLine[0],4);

      double tarLine_1 = NormalizeDouble(tLine1[0],4);

      double tarLine_2 = NormalizeDouble(tLine2[0],4);

      double tarLine_3 = NormalizeDouble(tLine3[0],4);

      double tarLine_4 = NormalizeDouble(tLine4[0],4);

      

Comment ("Close Price :", closePrice, "Start Line :", startLine, "Stop Line :", stopLine, "Tar1 :", tarLine_1,"Tar2 :", tarLine_2, "Tar3 :", tarLine_3, "Tar4 :", tarLine_4 );

Files:
 

algo7134:

Hi All

I am attaching a custom indicator I downloaded from Article section. I tried connecting to the indicator from OnTick() function within my EA. But it is displaying 0 values.

The indicator has 6 values for Stop Line, Start Line and for Target Lines from 1 to 4. You can find this in Price[0] to Price[5] within Oncalculate.

The code I am using to retrieve the values in my Ontick() is below, but it's not working as expected. Please have a look and let me know what i am doing wrong here.


 double strtLine[],stpLine[],tLine1[],tLine2[],tLine3[],tLine4[];

      

      ArraySetAsSeries(strtLine,true);

      ArraySetAsSeries(stpLine,true);

      ArraySetAsSeries(tLine1,true);

      ArraySetAsSeries(tLine2,true);

      ArraySetAsSeries(tLine3,true);

      ArraySetAsSeries(tLine4,true);

      

      

      int DiNap = iCustom(_Symbol,_Period,"DiNapoli_Levels");

      

      

      

      CopyBuffer(DiNap,0,0,3,strtLine);

      CopyBuffer(DiNap,1,0,3,stpLine);

      CopyBuffer(DiNap,2,0,3,tLine1);

      CopyBuffer(DiNap,3,0,3,tLine2);

      CopyBuffer(DiNap,4,0,3,tLine3);

      CopyBuffer(DiNap,5,0,3,tLine4);

      

      

      double startLine = NormalizeDouble(strtLine[0],4);

      double stopLine = NormalizeDouble(stpLine[0],4);

      double tarLine_1 = NormalizeDouble(tLine1[0],4);

      double tarLine_2 = NormalizeDouble(tLine2[0],4);

      double tarLine_3 = NormalizeDouble(tLine3[0],4);

      double tarLine_4 = NormalizeDouble(tLine4[0],4);

      

Comment ("Close Price :", closePrice, "Start Line :", startLine, "Stop Line :", stopLine, "Tar1 :", tarLine_1,"Tar2 :", tarLine_2, "Tar3 :", tarLine_3, "Tar4 :", tarLine_4 );


There are no buffers 3,4 and 5 in that indicator ...

 
Mladen Rakic:

There are no buffers 3,4 and 5 in that indicator ...


Oh ok, but in that case, atleast buffer 0 to 2 should work right. That is minimum start line and stop line should have value.. but that is also not working for me..

and please suggest me how to add other price levels to the buffer.. 


When i drag the indicator to the char i can see all the lines with corresponding prices drawn..

 
algo7134:

Oh ok, but in that case, atleast buffer 0 to 2 should work right. That is minimum start line and stop line should have value.. but that is also not working for me..

and please suggest me how to add other price levels to the buffer.. 


When i drag the indicator to the char i can see all the lines with corresponding prices drawn..

Everything is as expected with that code (I used this for testing :

int OnInit(void) { return(INIT_SUCCEEDED); }
void OnDeinit(const int reason) {}
void OnTick() 
{ 

   double strtLine[],stpLine[],tLine1[];

      ArraySetAsSeries(strtLine,true);
      ArraySetAsSeries(stpLine,true);
      ArraySetAsSeries(tLine1,true);

         int DiNap = iCustom(_Symbol,_Period,"DiNapoli_Levels");
         if (DiNap != INVALID_HANDLE)
         {
            CopyBuffer(DiNap,0,0,3,strtLine);
            CopyBuffer(DiNap,1,0,3,stpLine);
            CopyBuffer(DiNap,2,0,3,tLine1);

            double startLine = NormalizeDouble(strtLine[0],4);
            double stopLine  = NormalizeDouble(stpLine[0],4);
            double tarLine_1 = NormalizeDouble(tLine1[0],4);
            Comment ("Start Line :", startLine, "Stop Line :", stopLine, "Tar1 :", tarLine_1);
         }
}

Check in data window what values you have in DiNapoly levels indicator buffers (if you can not check that from the code of the indicator) and see when are you going to have some value there - a value different from 0

 
Mladen Rakic:

Everything is as expected with that code (I used this for testing :

Check in data window what values you have in DiNapoly levels indicator (if you can not check that from the code of the indicator) and see when are you going to have some value there - a value different from 0


Hi Mladen


This is strange!.. I am using the exact code that you have but it's not working at all. I am trying this since yesterday but no progress or luck. It would be great if you help me here. I am attaching my code. May be somewhere it's wrong I don't know. May be it works on your PC..

Can you please have a look at let me know where I went wrong. I have added the OnInit and OnDeinit which u have used and i have also put the INVALID HANDLER check into my code. I am from python background and MQL5 is very different to work one.

Any help on this is much appreciated..


Thanks

Files:
Strategy0.4.mq5  11 kb
 
algo7134:

Hi Mladen


This is strange!.. I am using the exact code that you have but it's not working at all. I am trying this since yesterday but no progress or luck. It would be great if you help me here. I am attaching my code. May be somewhere it's wrong I don't know. May be it works on your PC..

Can you please have a look at let me know where I went wrong. I have added the OnInit and OnDeinit which u have used and i have also put the INVALID HANDLER check into my code. I am from python background and MQL5 is very different to work one.

Any help on this is much appreciated..


Thanks

Seems that you are mixing buffers and lines (graphical objects)

Lines displayed by that indicator can not be checked using copy buffer via iCustom() call. In buffers, that indicator has very rarely values different from 0. Please check the data in the data window

 
Mladen Rakic:

Seems that you are mixing buffers and lines (graphical objects)

Lines displayed by that indicator can not be checked using copy buffer via iCustom() call. In buffers, that indicator has very rarely values different from 0. Please check the data in the data window


But seem to use the same code. How it works for you and not mine..

 
algo7134:

But seem to use the same code. How it works for you and not mine..

Please read my posts again ...

Please check the data window and see what you can expect in BUFFERS - not LINES (objects) that are drawn on the chart

 
Mladen Rakic:

Please read my posts again ...

Please check the data window and see what you can expect in BUFFERS - not LINES (objects) that are drawn on the chart


Hi

I am not seeing any values against DiNapoli in the Data Window.