icustom in my EA with estimated parameters

 

Hello everyone,


I'm stuck with an issue and i'd appreciate your help.


Usually in a normal way here it's how i'd define and read a new indicator in an EA (and that's worked fine):

1. Define the handle in OnInit() part (My Handle is an array of int because of the specific currency i):

Handle[i]=iCustom(symbolNames,PERIOD_H1,IndicatorName,Param1,Param2,Param3,Param4);

2. CopyBuffer to retrieve values in OnTick() part

CopyBuffer(Handle[i],Index,0,10,MyBuffer);

That's ok.


But now want redefine during my EA a specific handle with estimated parameters.

As you imagine there is a lot of possible combination because Param1, Param2, Param3 and Param4 are integers between 1 and 30.

If my estimation is for example as follow :  Param1=5,  Param2=10,  Param3=8 and  Param4=29,

I want to define :

1. A new handle ( so in the OnTick())part :

Handle[i]=iCustom(symbolNames,PERIOD_H1,IndicatorName,Param1,Param2,Param3,Param4);

2. CopyBuffer to retrieve values in OnTick() :

CopyBuffer(Handle[i],Index,0,10,MyBuffer);

=> But if i Print my MyBuffer values that's not work fine and seems not updated at all. I see values with others handle parameters.

Any suggestion ?


Thank you in advance

 

A partial answer is to initialize all differents handle with a loop contained all combination in OnInit()

But :

1. it's very dirty to do that

2. The strategy tester is very very slow

3. And it's very weird :

- The strategy tester with graphical mode activated works

- The strategy tester without graphical mode (quicker) doesn't works ! The handlers seems not initialized correctly

 
You could put the initialisation parts that you wanted to call again later in an external function after the Main functions. You can call it from OnInit and also from OnTick under the conditions of your choice. Are you familiar with function calling already?