How to extract only the bottoms turnaround points extracted by the zigzag indicator? - page 3

 
jackprobe:
Thank you deVries. will try it ...


and if you put something like

this inside your code ....

 
ubzen:

Here's what i came up with. I haven't checked deVries results above [was doing this when he posted].


hello, ubzen, I just see your code as below:

I don't know what is meaning of these two lines codes: if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];

I find that it almost change nothing when I delete these two lines' codes, so I don't know why you add this two lines.

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_width1 1
#property indicator_color2 Yellow
#property indicator_width2 1

double Bottoms[];
double Toppers[];

int init()
{

   IndicatorBuffers(2);

   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,Bottoms);
   SetIndexEmptyValue(0,0.0);

   SetIndexStyle(1,DRAW_SECTION);
   SetIndexBuffer(1,Toppers);
   SetIndexEmptyValue(1,0.0);

  IndicatorShortName("zz show top & bottom");
  return(0);
}

int deinit()
{
  return(0);
}

int start()
{
  int counted_bars=IndicatorCounted();
  int limit=0;
  limit = Bars-counted_bars;
  
  for(int shift=limit-1;shift>=0;shift--)
  {
    int ExtDepth=12; int ExtDeviation=5; int ExtBackstep=3;
    int ZigzagBuffer=0; int HighMapBuffer=1; int LowMapBuffer=2;
    
    Bottoms[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        LowMapBuffer, shift
    );
    
    Toppers[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        HighMapBuffer, shift
    );
    
    if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift];
    if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];
  }
  
  return(0);
}
 
vx0532:


hello, ubzen, I just see your code as below:

I don't know what is meaning of these two lines codes: if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];

I find that it almost change nothing when I delete these two lines' codes, so I don't know why you add this two lines.


Zigzag with line at lows and line at highs
 


I write these below codes as below in EA

but when I test it in history data, "print" shows all 0, why?

for(int shift=99;shift>=0;shift--)
  {
    int ExtDepth=12; int ExtDeviation=5; int ExtBackstep=3;
    int ZigzagBuffer=0; int HighMapBuffer=1; int LowMapBuffer=2;
    
    Bottoms[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        LowMapBuffer, shift
    );
    
    Toppers[shift]=iCustom(
        Symbol(),0,"ZigZag",
        ExtDepth, ExtDeviation, ExtBackstep,
        HighMapBuffer, shift
    );
    if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift];
    if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];
 }
 
 shift=0;
 while(shift<100)
 {
 Print("Bottoms,Toppers:",Bottoms[shift]," , ",Toppers[shift]);
 shift++;
 }
 

read my posting 1 page back

deVries 2013.10.19 12:13 #

https://www.mql5.com/en/forum/144092/page2#854926


//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

//---- input parameters  ZigZag
extern int ExtDepth=12;
extern int ExtDeviation=5;
 
deVries:

thanks deVries, I have know this matter after review your post .

So I get the conclusion we can use double array and variable to receive iCustom()'s return value in Indicator's codes; but we just can use variable to receive iCustom()'s return value in EA's codes.

your explain is that:"that are the wrong buffers and you have to find value of i at what bar the top or bottom will be"

my understanding is that in EA, when we use array x[i] to receive iCustom(), assignment is ok, but the bar of the assignment is uncertain.

so iCustom() not only return a value simply but other things, yes?

but I still don't understand the significance of the code: " if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];"

 
vx0532:

thanks deVries, I have know this matter after review your post .

So I get the conclusion we can use double array and variable to receive iCustom()'s return value in Indicator's codes; but we just can use variable to receive iCustom()'s return value in EA's codes.

your explain is that:"that are the wrong buffers and you have to find value of i at what bar the top or bottom will be"

my understanding is that in EA, when we use array x[i] to receive iCustom(), assignment is ok, but the bar of the assignment is uncertain.

so iCustom() not only return a value simply but other things, yes?

but I still don't understand the significance of the code: " if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];"


you're still strugling to get data from ZigZag indicator

why do you want me to explain what is not inside my code ??

why don't you research the code of

//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

//---- input parameters  ZigZag
extern int ExtDepth=12;
extern int ExtDeviation=5;

the whole code you can find one page back.... https://www.mql5.com/en/forum/144092/page2#854926

if you understand working of that code then it is simply using same method in EA's

 
  1. deVries: the whole code you can find one page back....
    Don't say one page back, post the link to the exact post. It's the # sign right of your name (right click, copy link) one page back
  2. vx0532: but I still don't understand the significance of the code: " if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];"
    What do you think the significance of "if(x>0.1) x=x;" means? Nothing! The corrected code later says:
        if(ZigZag[shift]>0.1 && Low[shift]==ZigZag[shift]) Bottoms[shift]=ZigZag[shift];
        if(ZigZag[shift]>0.1 && High[shift]==ZigZag[shift]) Toppers[shift]=ZigZag[shift];
    
 
WHRoeder:
  1. deVries: the whole code you can find one page back....
    Don't say one page back, post the link to the exact post. It's the # sign right of your name (right click, copy link) one page back
  2. vx0532: but I still don't understand the significance of the code: " if(Bottoms[shift]>0.1) Bottoms[shift]=Bottoms[shift]; if(Toppers[shift]>0.1) Toppers[shift]=Toppers[shift];"
    What do you think the significance of "if(x>0.1) x=x;" means? Nothing! The corrected code later says:

done https://www.mql5.com/en/forum/144092/page2#854926
 

Dear All,

thanks for this wonderful discussion on the ZigZag and the codes. I would add a new spin to the discussion
For me it would be of great value if I could extract the high/low values calculated by the ZigZag
indicator (with a given, specific set of parameters) together with their times of occurrence to a text or csv file,
something like this: 

- Day, Time, High-Value, High(Boolean)
- Day, Time, Low-Value, Low(Boolean)

I would like to extract these values for further analysis in MS Excel in order to identify probabilities of
occurrence of time-periods and amplitudes in a chart. In the end, histograms will be created from
this data, indicating the "signature" of the value in the chart by identifying intrinsic time periods and
and intrinsic swing amplitudes.  

Maybe I am trying to reinvent the wheel here and there is code out there that does want I want to
do. If not, it would be worthwhile to develop such code. I am doing this type of analysis manually
with tons of charts every day, and I can clearly state that knowing the intrinsic signature of a value
vastly improves the chance to predict a change of direction. In my opinion, this process could be
easily automatized ... but I would need some help from people with programming experience. The
result would either be a handy-dandy indicator, or even an automatic MT4 EA (Expert Adviser)  
that trades at significant turning points.  

Would be nice to find someone here who is interested in a collaborative effort. But a few hints
on how to extract the data from the ZigZag indicator would also help. Many thanks! 

- spjuliman  

Reason: