Custom Indicator

 

Hello! I have a problem with getting the values for an indicator  into a script.

It is about ZigZag indicator, I am only getting the values for the default inputs as setted in the indicator.

If I change the input in my iCustom function it will not have any efect.



This is how I get the indicator values:

#define  ZigZagindicator "Indicators\\ZigZag.ex4"
#resource "\\" + ZigZagindicator


double GetLastZigZag(int _timeframe,int InpDepth,int InpDeviation,int InpBackstep,int Buf_High1Low2)
  {
  
   double val=0;

   for(int i=4; i<300; i++)
     {

      val=iCustom(_Symbol,_timeframe,"::"+ZigZagindicator,InpDepth,InpDeviation,InpBackstep,Buf_High1Low2,i);
      if(val!=0)
         break;
     }

   return(val);
  }

I acces function like this:

void OnStart()
  {

double high=GetLastZigZag(_Period,6,3,1);
double low=GetLastZigZag(_Period,6,3,2);
Print("high=",high);
Print("low=",low);

  }

it wont matter what input values I put, because I am still getting the result for the default inputs.


Kindly advice!

The ZigZag Indicator: Fresh Approach and New Solutions
The ZigZag Indicator: Fresh Approach and New Solutions
  • www.mql5.com
The article examines the possibility of creating an advanced ZigZag indicator. The idea of identifying nodes is based on the use of the Envelopes indicator. We assume that we can find a certain combination of input parameters for a series of Envelopes, whereby all ZigZag nodes lie within the confines of the Envelopes bands. Consequently, we can try to predict the coordinates of the new node.
 
Daniel Cioca: it wont matter what input values I put, because I am still getting the result for the default inputs.

#property indicator_chart_window
#property indicator_buffers 1 
#property indicator_color1  Red
//---- indicator parameters
input int InpDepth=12;     // Depth
input int InpDeviation=5;  // Deviation
input int InpBackstep=3;   // Backstep

ZZ only has one visible buffer (index zero)

 
William Roeder #:

ZZ only has one visible buffer (index zero)

Thanks!

My version has 3 buffers, but is only showing one. The other two are for calculation:

int OnInit()
  {
   if(InpBackstep>=InpDepth)
     {
      Print("Backstep cannot be greater or equal to Depth");
      return(INIT_FAILED);
     }
//--- 2 additional buffers
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_SECTION);
//---- indicator buffers
   SetIndexBuffer(0,ExtZigzagBuffer);
   SetIndexBuffer(1,ExtHighBuffer);
   SetIndexBuffer(2,ExtLowBuffer);
   SetIndexEmptyValue(0,0.0);
//---- indicator short name
   IndicatorShortName("ZigZag("+string(InpDepth)+","+string(InpDeviation)+","+string(InpBackstep)+")");
//---- initialization done
   return(INIT_SUCCEEDED);
  }

Anyway, I have tried using only Buffer 0 as sugested, but still it will show the same value, regardless of what inputs I use

Reason: