iCustom not working - page 2

 
William Roeder #:
You were asked (twice) to post the error code. You didn't. You can't know the problem until you do.

Apologies for the oversight. The error in the Journal and in the Log:

 
Conor Mcnamara #:
Check if there are any errors in the journal when running the indicator. Sometimes an indicator works but is still error prone. If there is any error, iCustom will refuse to work. I have a working example of iCustom in one of my simple code publications..but I don't think it will help. It's likely a problem with the indicator 

Thanks for the reply Conor.

 
CobusSteyn0105 #:

Apologies for the oversight. The error in the Journal and in the Log:

Make sure you are providing the correct path to the custom indicator file. In your case, it seems the custom indicator file is located in the \Indicators folder. When using iCustom() , you need to provide the relative path from the terminal's MQL4/Indicators folder.

If your indicator is indeed located in \Indicators , then the correct path would be "Bollinger_bands_1b.ex5" .

Ensure you're using the correct file extension. For MT4, custom indicators typically have the .ex4 extension. If your indicator is compiled for MT5 ( .ex5 ), it won't work in MT4. Make sure you have the correct version of the indicator for your platform.

The issue with your code lies in how you're referencing the custom indicator file and its parameters.

Ensure that the path you're providing to iCustom() is correct. If your indicator file is located in the \Indicators folder, you need to reference it properly. In MQL4, you usually reference indicators relative to the MQL4\Indicators directory. Therefore, you should use "Bollinger_bands_1b.ex5" as the path if the indicator is in the \Indicators folder.

Then,  make sure that the parameters you're passing to iCustom() match the expected parameters of the custom indicator exactly. Any discrepancies in parameter names or values can lead to INVALID_HANDLE being returned.


Here's a way  how you can adjust the initialization function to address these issues:


int OnInit()
{
   //--- indicator buffers mapping
   SetIndexBuffer(0, DrawBuffer, INDICATOR_DATA);

   // Call iCustom with correct path and parameters
   hCustom = iCustom(_Symbol, PERIOD_CURRENT, "Bollinger_bands_1b", BBPeriod, BBShift, StdDeviation, appliedprc);
   
   if (hCustom == INVALID_HANDLE) 
      Print("Invalid handle");

   //---
   return INIT_SUCCEEDED;
}

If the error persists, check the log for error codes and post it here so we can help further.

 
CobusSteyn0105 #:

Thank you very much!

Here is the indicator file. Can't remember where I got it from.

Both pieces of code work fine no issues for me, I located both in the Indicators file.

The error log you posted does not show the whole line detail so I cannot see how long the path is for your file name sometime long paths can cause problems.

Have you done this as a project? if so try it not as a project issues have been reported there.

Have you recompiled both files in order, the indicator and then the calling indicator?

 
Paul Anscombe #:

Both pieces of code work fine no issues for me, I located both in the Indicators file.

The error log you posted does not show the whole line detail so I cannot see how long the path is for your file name sometime long paths can cause problems.

Have you done this as a project? if so try it not as a project issues have been reported there.

Have you recompiled both files in order, the indicator and then the calling indicator?

High Paul thank you for the response.

I got it to work!

The path was correct all along - BUT then I saw the source code file (mq5) was not in the Indicators folder, and thus not listed in the Navigator. It was still in the Downloads folder. So although the ex5 was in the Indicators folder, it eems that the mq5 file must be there as well - or at least listed in the Navigator?

It is peculiar because you only need access to the ex5 file right? But the moment I copied the mq5 file to the same folder as the ex5 file (in my case the Indicators folder), it worked.

It doesn't need the .ex5 extension, nor the price parameter right at the end, and the full path gives an error.

This is not in a project file.



int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,DrawBuffer,INDICATOR_DATA);
   path=TerminalInfoString(TERMINAL_DATA_PATH);
   hCustom = iCustom(_Symbol,PERIOD_CURRENT,"Bollinger_bands_1b",p,s,d,PRICE_CLOSE); THE PATH IS CORRECT
   Print(TerminalInfoString(TERMINAL_DATA_PATH));
   Print(GetLastError());
   if (hCustom==INVALID_HANDLE) Print("Invalid handle"); else Print("Handle success");
   
   
//---
   return(INIT_SUCCEEDED);
  }

Anyway hope this struggle helps someone some day!


Thanks once again!