iCustom Problem

 

Hello everyone. In the past I have used custom indicators with the iCustom feature for MT4 trading EAs. But I can't do it on MT5.

(In my account the code works fine, there is no problem).

The error I get is this, but I can't figure out what I'm doing wrong:


test on EURUSD,H1 (netting) expert file MQL5\Example.ex5 open error [2] expert file MQL5\Indicators\Example.ex5 open error [2] CS 0 09:30:40.938 Core 1 V5=··············································· program file Example.ex5 read error program file Indicators\Example.ex5 read error loading of Example EURUSD,M15 failed [557] 2019.04.01 00:00:00 cannot load custom indicator 'Example' [4802] 2019.04.01 00:00:00 indicator create error OnInit critical error tester stopped because OnInit failed disconnected there are no trading operations


This is the outline of my code regarding this indicator:

#property strict
#property tester_indicator "Example"
#resource "\\Indicators\\Example.ex5"


int Example_handle;
double Example[];
double Example_1[];


int OnInit()
  {
   Example_handle = iCustom(_Symbol, _Period, "Example");
   if(Example_handle < 0)
     {
      Print("The creation of Example has failed: Example_handle=", INVALID_HANDLE);
      Print("Runtime error = ", GetLastError());
      return(INIT_FAILED);
     }
   return(INIT_SUCCEEDED);
  }


void OnTick()
  {
   if(CopyBuffer(Example_handle, 0, 0, 200, Example) >= 0)
      return;
   ArraySetAsSeries(Example, true);
   
   if(CopyBuffer(Example_handle, 1, 0, 200, Example_1) <= 0)
      return;
   ArraySetAsSeries(Example_1, true);

 
 if (Example[1])   SendBuyOrder;
 if (Example_1[1]) SendSellOrder;

  }
 


Please. Someone might take me a cable? Thank you very much in advance

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 

I think you are referencing the resource incorrectly. It should be ...

...
#resource "\\Indicators\\Example.ex5"
...
Example_handle = iCustom(_Symbol, _Period, "::Indicators\\Example");
...
Documentation on MQL5: MQL5 programs / Resources
Documentation on MQL5: MQL5 programs / Resources
  • www.mql5.com
Resources - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

I think you are referencing the resource incorrectly. It should be ...

Fernando, you are the best! Indeed, here was the mistake that I was committing.

And now I have received this error, which I can't understand


test on EURUSD,H1 (netting)

CS 0 12:34:18.971 Core 1 V5=························································· ········

strategy tester report 969 total trades

 
 
Enrique Enguix #: Fernando, you are the best! Indeed, here was the mistake that I was committing. And now I have received this error, which I can't understand ... 

You are welcome!

Is that an error or just a normal status? Can you show more of the log entries?

 
Fernando Carreiro #:

You are welcome!

Is that an error or just a normal status? Can you show more of the log entries?

It's strange, it announces an error, but I don't understand what error it refers to. This is the log:

Files:
 
   if(CopyBuffer(Example_handle, 0, 0, 200, Example) >= 0)
      return;
Read in two hundred values. If it succeeds, exit.  If it fails, try to access the nonexistent elements and crash.
 
Enrique Enguix #:It's strange, it announces an error, but I don't understand what error it refers to. This is the log:

Where does it say it is an error?

Is that the full log output?

Where does the log come from — the agent log or the Strategy Tester Journal log?

 
Fernando Carreiro #:

Where does it say it is an error?

Is that the full log output?

Where does the log come from — the agent log or the Strategy Tester Journal log?

It is a commercial EA, the error appears when trying to upload it to the market, it is an update
 
William Roeder #:
Read in two hundred values. If it succeeds, exit.  If it fails, try to access the nonexistent elements and crash.
It happens when loading even less values, how could it be solved then?
 
Enrique Enguix #: It is a commercial EA, the error appears when trying to upload it to the market, it is an update

Without access to the source code it will difficult to say. You will probably have to try to recreate the issue on your own environment in order to debug it.

It could also be a problem on the MetaQuotes side as their verification process sometimes malfunctions. Try it again on another day to see if it works then.

 
Fernando Carreiro #:

Without access to the source code it will difficult to say. You will probably have to try to recreate the issue on your own environment in order to debug it.

It could also be a problem on the MetaQuotes side as their verification process sometimes malfunctions. Try it again on another day to see if it works then.


Yes, I understand, although it's a bit frustrating, since I don't understand what the error is. No error appears on my pc, neither when compiling the code, nor when doing backtest, nor in a live account. Thanks also