Can anyone help for iCustom for indicator? - page 2

 
kajironpu:

Unada san

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

You mean if BUY signal, it return 0.0?

Is this what you mention?

Yes, that's right.

"EMPTY_VALUE" is not 0.0.

 
kajironpu:
 

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?

I think (in this case) is much better not to use iCustom() because the indicator logic is very simple. In this case is better to use the logic in your EA (see code bellow). BTW pay attention that the original indicator code has a bug in my opinion because it is asymmetric (a different rule for UP and DOWN).

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

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

int start() {

    bool UP =  High[0]>High[1]&& Low[0]>Low[1]&& (High[0]-Low[0])>(High[1]-Low[1])&& (High[0]-Close[0])>(High[1]-Close[1]);
    
    // This line is in the original code but it is asymmetric.
    //bool DOWN  = High[0]<High[1]&& Low[0]< Low[1]&& (High[0]-Low[0])>(High[1]-Low[1])&& (Low[0]-Close[0])>(Low[1]-Close[1]);
    // I think it should be like this line.
    bool DOWN  = High[0]<High[1]&& Low[0]< Low[1]&& (High[0]-Low[0])>(High[1]-Low[1])&& (Close[0]-Low[0])>(Close[1]-Low[1]);
 
if( cbars!=Bars && UP  )
  {
   RefreshRates();
     OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"buy",magic,0,Blue);  
  }

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

I think (in this case) is much better not to use iCustom() because the indicator logic is very simple. In this case is better to use the logic in your EA (see code bellow). BTW pay attention that the original indicator code has a bug in my opinion because it is asymmetric (a different rule for UP and DOWN).

Petr, Thank you for taking time for me.

It is a good idea to copy main code to EA and I have just compile your code and run EA.

However it did not work...

You have skip the followings;

 if (Bars <= 100) return(0);
   int ExtCountedBars = IndicatorCounted();
   if (ExtCountedBars < 0) return(-1);
   if (ExtCountedBars > 0) ExtCountedBars--;
   for (int i=Bars-ExtCountedBars-1; i>=0; i--)

I wonder if it is a  reason for not working? Maybe no?  Another reason?


I have just added to check UP/DOWN signal.

 
 Print("UP="+UP);
 Print("DOWN="+DOWN);

And the result is as follows.  It has no output..


Files:
 
Petr Nosek:

I think (in this case) is much better not to use iCustom() because the indicator logic is very simple. In this case is better to use the logic in your EA (see code bellow). BTW pay attention that the original indicator code has a bug in my opinion because it is asymmetric (a different rule for UP and DOWN).

Petr san

I have tried to modify and finally get signals!

I made a success in the following;

 bool UP =  High[0]>High[1]&& Low[0]>Low[1] && (High[0]-Low[0])>(High[1]-Low[1])&& (High[0]-Close[0])>(High[1]-Close[1]);
    
  
 bool DOWN= High[0]<High[1]&& Low[0]< Low[1] &&(High[0]-Low[0])<(High[1]-Low[1])&& (Close[0]-Low[0])<(Close[1]-Low[1]);

I don't know if this logic is correct but I could made it!