Issue passing pair string input for indicator via EA

 

Hi all,

So i'm having issues passing the pair string input for an indicator im trying to use within EA. When using the indicator directly on a chart and entering the required symbols as inputs I have no issues and the indicator displays as expected, however when calling the indicator via iCustom the exact same symbols cannot be found. The indicator does contain a check to ensure the symbols are available using SymbolSelect which is currently returning false only when used in an EA, otherwise works fine when just using the indicator.


I have tried a few different ways and even hard coded the symbols just to see if that helps but still no success. My indicator inputs:

sinput   string         Pair1       ="EURUSD";  //Pair #1
sinput   string         Pair2       ="EURJPY";  //Pair #2
input    int            MAperiod    =8;         //MA period
input    ENUM_MA_METHOD MAmethod    =MODE_SMA;  //MA method
input    double         DEVperiod   =2.0;       //StDev level
input    int            CorD        =100;       //Corelation depth (bars)

my inputs defined in the EA:

sinput string a1="============ Indicator settings ============";//============ Indicator settings ============
sinput string Pair1 ="EURUSD";  //Pair #1
sinput string Pair2 ="EURJPY";  //Pair #2
input int MAperiod    =8;         //MA period
input int MAmethod =5;  //MA method
input double DEVperiod =1.5;       //StDev level
input int CorD =100;       //Corelation depth (bars)

the icustom call in my EA using the above inputs:

cor_c=iCustom(Symbol(),PERIOD_CURRENT,"iSJCFX_1",Pair1,Pair2,MAperiod,MAmethod,DEVperiod,CorD,0,1);//correlation  
   cor_c_check=iCustom(Symbol(),PERIOD_CURRENT,"iSJCFX_1",Pair1,Pair2,MAperiod,MAmethod,DEVperiod,CorD,0,2);//correlation

Any guidance on the matter would be much appreciated, thank you in advance

 
SJCFX:

Hi all,

So i'm having issues passing the pair string input for an indicator im trying to use within EA. When using the indicator directly on a chart and entering the required symbols as inputs I have no issues and the indicator displays as expected, however when calling the indicator via iCustom the exact same symbols cannot be found. The indicator does contain a check to ensure the symbols are available using SymbolSelect which is currently returning false only when used in an EA, otherwise works fine when just using the indicator.


I have tried a few different ways and even hard coded the symbols just to see if that helps but still no success. My indicator inputs:

my inputs defined in the EA:

the icustom call in my EA using the above inputs:

Any guidance on the matter would be much appreciated, thank you in advance

You should post the relevant code. If your problem is "symbols cannot be found"...show the code with SymbolSelect().

Probably not related but why the MAmethod parameter which is ENUM_MA_METHOD becomes an int in the EA ?

 
William Roeder:
Your iCustom is wrong.
Indicator
iCustom

From what he posted it's the reverse, the "a1" parameter is in the EA.
 
input int MAmethod =5;  //MA method
What MA are you using?

ID

Value

Description

MODE_SMA

0

Simple averaging

MODE_EMA

1

Exponential averaging

MODE_SMMA

2

Smoothed averaging

MODE_LWMA

3

Linear-weighted averaging


          Smoothing Methods - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
 

hi guys,

absolutely right, typo on my part for the mamethod of 5, should be 0.

re the point of 'No Symbol Found', below is the code in the indicator causing this message when trying to use within my EA.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
sinput   string         Pair1       ="EURUSD";  //Pair #1
sinput   string         Pair2       ="EURJPY";  //Pair #2
input    int            MAperiod    =8;         //MA period
input    ENUM_MA_METHOD MAmethod    =MODE_SMA;  //MA method
input    double         DEVperiod   =2.0;       //StDev level
input    int            CorD        =100;       //Corelation depth (bars)
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double   point;
double   Cor[],MA[],Up[],Dn[],Pr1[],Pr2[];
double   Dev[];
double   P1[],P2[];
//---
#include <MovingAverages.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Comment("");
   if(!LicenseValidation())
      return(INIT_FAILED);
   if(!SymbolSelect(Pair1,true) || !SymbolSelect(Pair2,true))
     {
      Comment("Symbol is Not Found!");
      return(INIT_FAILED);
     }
 
SJCFX:

hi guys,

absolutely right, typo on my part for the mamethod of 5, should be 0.

re the point of 'No Symbol Found', below is the code in the indicator causing this message when trying to use within my EA.

Change your comment to print "Pair1" and "Pair2", to check they are correct.
 
Alain Verleyen:
Change your comment to print "Pair1" and "Pair2", to check they are correct.
 
SJCFX:

values seem to look ok

 
SJCFX:
SymbolSelect() doesn't work in the Strategy Tester. Check the error returned with GetLastError() and you will see it returns error 4014 (according to my memory as I didn't check).
 
Alain Verleyen:
SymbolSelect() doesn't work in the Strategy Tester. Check the error returned with GetLastError() and you will see it returns error 4014 (according to my memory as I didn't check).

of course, i will have to remove SymbolSelect() for the purpose of back testing. Thank you for your help