ZigZagOnArray (problem with DRAW_SECTION) SOLVED

pennyhunter
705

I have done a ZigZagOnSMA and ZigZagOnRSI, on one hand for practice, on the other hand maybe it will be useful at some point for correcting input values when the stats are bad with the current inputs and the turning point are too far away and don't get hit.

Anyways but I am now making a ZigZagOnBuffer.mqh that I can put in every Indicator or Expert to check stuff if I have to or generate certain levels, whatever... it is also attached.

ZZOnBuffer

(compare ZigZigOnRSI and ZigZagOnBuffer with RSI as source buffer in above picture. Points are the same coordinates. They are both attached.)

I have some issue with the DRAW_SECTION thing. 

As you can see in the pic above I got it to work in ZigZagOnRSI. I am not sure why it does that because It has got the right numbers in the ZZ buffer.

int ZZOnBuffer(const int rates, const int calculated, const double &src[], double &dst[], const int &depth, const int &deviation, const int &backstep) 

{
// ...  ZigZag-code on the basis of Examples/ZigZag.mq5, (I know it is not the best though...)
}

What can I try to make it work? Because I realised before that sometimes the order of SetIndexBuffers or Plots seems to play a roll but there aren't many possibilities and as we say in German: I am at the end of my Latin.


So the question is actually why does it work in one example and not in the other one, even if the buffers and plots are in the same order?


If you want to try it you have to create a folder "ThingsOnArray" in your include folder and put the ZigZagOnBuffer.mqh in there.

pennyhunter
705
pennyhunter  

Okay so this was it:

int OnInit()
  {
//--- indicator buffers mapping
   
   SetIndexBuffer(1,ExtRSIBuffer,INDICATOR_DATA);
   SetIndexBuffer(0,ExtZZBuffer,INDICATOR_DATA);
   
   RSIHandle=iRSI(_Symbol,_Period,InpPeriodRSI,InpAppliedPrice);
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);

//---
   return(INIT_SUCCEEDED);
  }

Turns out you need that for DRAW_SECTION, because it sets all the zeros in the data buffer (plot buffer) to EMPTY_VALUE. And the first parameter of PlotIndexSetDouble is the buffer index you apply it on which is not well translated in the documentarah..

I will have to see how to implement this part in an mqh, this could be difficult. On the other hand it is a part of plot settings anyway which has to be handled by the user... okay so here is the ZigZagOnBuffer...

solved