ICustom ZigZag returns zero value

 

i've been trying to get custom indicator (zigzag) value using this code...and get its signal


#define       PATH     "ZigZag"

void OnTick()
  {

//---
  double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  double zigzag_handler=iCustom(Symbol(),Period(),PATH,12,5,3);

//--    Then I wanted to get the signals using this code

  bool sSignal=false; bool bSignal=false; 
  double zigzag_value=zigzag_handler; 
//---
  if (zigzag_value!=0)
     {
      if (ask < zigzag_value)
       { sSignal=true; }
      if (bid > zigzag_value)
       { bSignal=true; }
   Print("Zig Zag Handler : ",zigzag_handler);
     } 
}

I realized that after commenting and printing the signal that the value is always Zero.

I have also tried adding mode and adjusting the shift but nothing seems to change

what am i doing wrong here ....

 
Omega J Msigwa:

i've been trying to get custom indicator (zigzag) value using this code...and get its signal


I realized that after commenting and printing the signal that the value is always Zero.

I have also tried adding mode and adjusting the shift but nothing seems to change

what am i doing wrong here ....


Read the iCustom documentation


double zigzag_handler=iCustom(Symbol(),Period(),PATH,12,5,3);  // Here you need to add two more parameters for index and shift

Last two parameters in iCustom call are buffer index and bar index for which you want indicator value.

In your code, iCustom uses 5 as number of indicator buffer, and 3 as bar number.

You need to add two more parameters to the iCustom call.

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iCustom - Technical Indicators - MQL4 Reference
Reason: