Can anyone help for iCustom for indicator?

 

Hi, I am having a trouble to use iCustom to get signal from an indicator.

The indicator is "called2candles 1 pilot331"   and it is MQL4 file.

You can download from here.

https://forex-station.com/download/file.php?id=3324510

I want to get arrow up /down signal from the indicator by using iCustom and use in my EA.

 double buy  = iCustom(NULL,0,"called2candles 1 pilot331",0,0);
 double sell = iCustom(NULL,0,"called2candles 1 pilot331",1,0);  

However, I can not get any signals.

It looks like arrowup is buffer0(index0) and arrowdown is buffer1(index2).

indi signal


Can anyone help to point out what the problem is.

What is the wrong code for my iCustom use?


Thanks!

 

kajironpu:

   double buy  = iCustom(NULL,0,"called2candles 1 pilot331",0,0);

   double sell = iCustom(NULL,0,"called2candles 1 pilot331",1,0); 

However, I can not get any signals.

It looks like arrowup is buffer0(index0) and arrowdown is buffer1(index2).

SetIndexBuffer(0,buf_1);  //Arrow Up
SetIndexBuffer(1,buf_2);  //Arrow Down

It seems there is no mistake.

Is there any mistake in other places?


PS: Certainly the file name is different as the person below says.

 

kajironpu: The indicator is "called2candles 1 pilot331"   and it is MQL4 file.

double buy  = iCustom(NULL,0,"called2candles 1 pilot331",0,0);
double sell = iCustom(NULL,0,"called2candles 1 pilot331",1,0); 
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. When I download your link I get a file named "2··candles·1·pilot331.mq4" (No "called," plus leading "2" with two spaces.) Verify your filename. Verify you compiled it.

  3. You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum
 

HI, Thank you for your reply and sorry for my mistake. I have just edit my post.  I made a mistake for the file name.

so, I have changed the file name for indicator and code also.

But the result was the same. I still can not get any signals from the indicator.....

So I have just coded simply to see if I can get indicator signal by using iCustom.

//+------------------------------------------------------------------+
//| icustom test EA
//+------------------------------------------------------------------+

     
int start() {


  // icustom indicator reading
    double buy  = iCustom(NULL,0,"indicator",0,0);
    double sell = iCustom(NULL,0,"indicator",1,0);  
  

if(  buy!= EMPTY_VALUE )
  {
        Print("Arrow up"+buy); 
  }

if(  sell!= EMPTY_VALUE )
  {
        Print("Arrow down"+sell);
  }

 return(0);
 
}

If the EA catch the buffer0 and buffer1 signal from the indicator,  it should make output in the terminal (MT4) but it did not...

I have no ideas what the problem is. It is very strange. I have used iCustom in other original EAs and they worked perfect! 

Can anyone give me any advices? I will attach the indicator file and EA .

Thanks!



Files:
iCustom.ex4  6 kb
iCustom.mq4  1 kb
indicator.ex4  16 kb
indicator.mq4  11 kb
 
kajironpu:

HI, Thank you for your reply and sorry for my mistake. I have just edit my post.  I made a mistake for the file name.

so, I have changed the file name for indicator and code also.

But the result was the same. I still can not get any signals from the indicator.....

So I have just coded simply to see if I can get indicator signal by using iCustom.

If the EA catch the buffer0 and buffer1 signal from the indicator,  it should make output in the terminal (MT4) but it did not...

I have no ideas what the problem is. It is very strange. I have used iCustom in other original EAs and they worked perfect! 

Can anyone give me any advices? I will attach the indicator file and EA .

Thanks!



The reason your code isn't working is both due to file name and you aren't satisfying the args requirement for the indicator. If you look at the indicators code you will see that you have missed four args in your iCustom call. Here is how it should look.

void OnStart()
{
   printf(
      "Up= %d | Dn = %d",
      get_last_signal(0),
      get_last_signal(1)
   );
}
//+------------------------------------------------------------------+
int get_last_signal(int buffer)
{
   for(int i=0;i<Bars;i++)
   {
      if(
         iCustom(_Symbol,
                 _Period,
                 "2_candles_1_pilot331", //name with underscores instead of spaces - RENAME YOUR INDICATOR IN THE SAME WAY
                 false, // needs to satisfy args for all extern/input vars
                 false, // input
                 false, // input
                 false, // input
                 buffer,// buffer number
                 i      // shift
         ) != 0.0 // not empty-value (as set by programmer in this indicator)
      ){
         return i;
      }
   }
   return -1;
}
 
Emma Schwatson:

The reason your code isn't working is both due to file name and you aren't satisfying the args requirement for the indicator. If you look at the indicators code you will see that you have missed four args in your iCustom call. Here is how it should look.

 If the values of input parameters are not specified, the default values will be used. In this case, these args are not required.

 

kajironpu:

But the result was the same. I still can not get any signals from the indicator.....


I tried it with my sample indicator, and I confirmed it works perfectly.

Maybe you couldn't get signals on your timing, ie there was no signal on the buffer number 0. 

Files:
Sample_4.mq4  6 kb
 

Thank you so much for many advices.

I guess  the input parameters is not necessary in this case??

It seems like I got signals from the indicator!!

However,  I got some problems. The EA open trade (buy /sell) in every single bar!!!



In terminal it says signal is not on every single bar but I don't know why EA open trade all bars!?




I will attach the code and appreciate for your advices.

This is just for test. I just want to check to see if the EA receive the indicator signal correctly and open orders!

Can anyone know what the problems?

//+------------------------------------------------------------------+
//| indicator.mq4   icustom EA
//+------------------------------------------------------------------+

extern double lots=0.01;
int cbars=0;
extern int magic=8338;

int start() {

  // icustom data read
    double buy  = iCustom(NULL,0,"indicator",0,0);
    double sell = iCustom(NULL,0,"indicator",1,0);  
 
if( cbars!=Bars&& buy!=EMPTY_VALUE  )
  {
   RefreshRates();
     OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"buy",magic,0,Blue);  
  }

if( cbars!=Bars&& sell!=EMPTY_VALUE  )
  {
     RefreshRates();
   OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"sell",magic,0,Magenta);
 
  }
 
 
  cbars=Bars;
 return(0);
}
 


 

It returns 0.0, not EMPTY_VALUE.

I think you don't need put the "RefreshRates();".

 
kajironpu:

Thank you so much for many advices.

I guess  the input parameters is not necessary in this case??

It seems like I got signals from the indicator!!

However,  I got some problems. The EA open trade (buy /sell) in every single bar!!!



In terminal it says signal is not on every single bar but I don't know why EA open trade all bars!?




I will attach the code and appreciate for your advices.

This is just for test. I just want to check to see if the EA receive the indicator signal correctly and open orders!

Can anyone know what the problems?

 
Naguisa Unada:

It returns 0.0, not EMPTY_VALUE.

I think you don't need put the "RefreshRates();".

Unada san

Thank you.What do you mean "It return 0.0" ?

You mean if BUY signal, it return 0.0?

if( cbars!=Bars&& buy==0.0  )

Is this what you mention?