Error 4054

 

Hi All.

Problem:

- getting error 4054 on different symbols

- after start in visual mode, EA is unloading and reloading indicator HMA_1.mq4

- there is no error on 5m tf of the same symbols, only higher; 15m, 30m ....

Logs, indi and code attached.

EA code:

//----- HMA
     int hmaPer = 21;
     int hma0Periods = hmaPer;
     int hma0Array = PRICE_CLOSE;
     
     int hma1Periods = hmaPer;
     int hma1Array = PRICE_OPEN;
     
     double hma00 = iCustom(NULL,0,"HMA_1",hma0Periods,hma0Array,0,0);
     double hma01 = iCustom(NULL,0,"HMA_1",hma0Periods,hma0Array,0,1);
     double hma02 = iCustom(NULL,0,"HMA_1",hma0Periods,hma0Array,0,2);

     double hma10 = iCustom(NULL,0,"HMA_1",hma1Periods,hma1Array,0,0);
     double hma11 = iCustom(NULL,0,"HMA_1",hma1Periods,hma1Array,0,1);
     double hma12 = iCustom(NULL,0,"HMA_1",hma1Periods,hma1Array,0,2);
     

https://www.mql5.com/en/search?keyword=error+4054

there is not solution on this forum for this, so, do not tell me, please, to search better or learn articles.

please, give me clear and quick solution.

Files:
hma_1.mq4  3 kb
 

here are logs:

Greetings to All

Files:
20110821.zip  31 kb
 
int hmaPer = 21;
int hma0Periods = hmaPer;
int hma0Array = PRICE_CLOSE;
double hma00 = iCustom(NULL,0,"HMA_1",hma0Periods,hma0Array,0,0);
  1. The indicator contains
    extern int HMA_Period=20;
    extern int pSeries = 0;
    double     ind_buffer0[];
    double     ind_buffer1[];
    
    So in the EA you would use
    int hma0Periods = 21;
    int p0Series = PRICE_CLOSE;
    #define IND_BUFFER0 0
    #define IND_BUFFER1 1
    double hma00 = iCustom(NULL,0,"HMA_1",hma0Periods,p0Series,IND_BUFFER0,0);
    
    This is what you have but with different names.

  2. I see nothing wrong in the indicator. Did you compile the indicator after adding the extern pSeries ?
  3. Otherwise the problem is else where in the EA
 
Hi, WHRoeder.
WHRoeder

  1. I see nothing wrong in the indicator. Did you compile the indicator after adding the extern pSeries ?


Yes, I have compiled.

Thank you for quick reply.

I have found HMA wrote by WizardSerg, attached and coded this way:

//----- HMA 1
     int hmaMethod = MODE_LWMA;
     int hmaPer = 21;

     int hma0Periods = hmaPer;
     int hma0Array = PRICE_CLOSE;

     double hma00 = iCustom(NULL,0,"HMA_WS",hma0Periods,hmaMethod,hma0Array,0,0); 
     double hma01 = iCustom(NULL,0,"HMA_WS",hma0Periods,hmaMethod,hma0Array,0,1); 
     double hma02 = iCustom(NULL,0,"HMA_WS",hma0Periods,hmaMethod,hma0Array,0,2);

for now EA is working ;-)

Yet, thank you for replay.

Best.

Files:
hma_ws.mq4  3 kb
 
stywny:
Please, can you explain, brefily, what is the point using such definition?
Bands is a Bollenger Bands indicator that allows fractional deviation. If I code:
int    BandsPeriod=20;
int    BandsShift=0;
double BandsDeviations=2.0;
double v1 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, 0, shift);
double v2 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, 1, shift);
double v3 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, 2, shift);

What is the meaning of the 0, 1, 2? No cheating by looking at the indicator.

Instead if I code:

int    BandsPeriod=20;
int    BandsShift=0;
double BandsDeviations=2.0;
#define SMA     0
#define UPPER   1
#define LOWER   2
double v1 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, SMA,   shift);
double v2 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, UPPER, shift);
double v3 = iCustom("Bands", BandsPeriod, BandsShift, BandsDeviation, LOWER, shift);

Now you know.

 

so,

problem comes back

after "debugging" the code piece by piece conclusion is this:

out of start function, there was external function with Stochastic like this:

#define ARRAY_CLOSE 1 // as you wish 
#define ARRAY_HLOW 0


int StochPosition()
{
   int StochTF = PERIOD_M5;               // this line created problem in tester 
                                          // on TF > 5M, turning error 4054
                                          // "wrong array series"
                                          // corrected to:
                                          // int StochTF = 0; is working well
   int lineK   = 21;
   int lineD   =  4;
   int slow    =  3;
   
   double Stoch51 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,0);
   double Stoch52 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,1);
   double Stoch53 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,2);
   double Stoch54 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,3);
   double Stoch55 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,4);
   double Stoch56 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,5);
   double Stoch57 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,6);
   double Stoch58 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,7);
   double Stoch59 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,8);
   double Stoch50 = iStochastic(NULL,StochTF,lineK,lineD,slow,MODE_SMA,ARRAY_HLOW,MODE_SIGNAL,9);
   
   
   if(Stoch51 > 20 && Stoch52 < 20 && Stoch51 > Stoch52) return(1);
   if(Stoch51 > 20 && Stoch53 < 20 && Stoch51 > Stoch52) return(1);
   if(Stoch51 > 20 && Stoch54 < 20 && Stoch51 > Stoch52) return(1);
   if(Stoch51 > 20 && Stoch55 < 20 && Stoch51 > Stoch52) return(1);
   
   if(Stoch51 < 80 && Stoch52 > 80 && Stoch51 < Stoch52) return(-1);
   if(Stoch51 < 80 && Stoch53 > 80 && Stoch51 < Stoch52) return(-1);
   if(Stoch51 < 80 && Stoch54 > 80 && Stoch51 < Stoch52) return(-1);
   if(Stoch51 < 80 && Stoch55 > 80 && Stoch51 < Stoch52) return(-1);
   
   return(0);
   
}

now we know and have one solution to 4054.

Best.