Download MetaTrader 5
To add comments, please log in or register
Trade with MetaTarder 5. Download it right now!
Toast
220
Toast 2014.03.04 00:16 

I have a need to retrieve the last 5 ZigZag swing prices & times for multiple iterations of ZigZag Depth.

With an eye to efficiency, what is the best mode of attack for this?

1. iCustom call

2. Incorporate ZigZag into the indicator as a function

3. Makes no difference between 1 and 2

4. Something else entirely

Any thoughts greatly appreciated!

Keith Watford
Moderator
7958
Keith Watford 2014.03.04 04:03  
toast:

I have a need to retrieve the last 5 ZigZag swing prices & times for multiple iterations of ZigZag Depth.

With an eye to efficiency, what is the best mode of attack for this?

1. iCustom call

2. Incorporate ZigZag into the indicator as a function

3. Makes no difference between 1 and 2

4. Something else entirely

Any thoughts greatly appreciated!


I believe that WHRoeder posted some code re getting the last 2 zigzag values in recent days.

It can probably be adapted to retrieve 5

Just look through recent topics with zigzag in the title

qjol
3243
qjol 2014.03.04 04:30  
GumRai:


I believe that WHRoeder posted some code re getting the last 2 zigzag values in recent days.

It can probably be adapted to retrieve 5

Just look through recent topics with zigzag in the title


& here it is
Toast
220
Toast 2014.03.04 09:36  

Many thanks for the replies.

I can loop ZigZag from iCustom, but I'm more wondering about efficiency.

Every time I call iCustom (x10 times) is iCustom having to recalculate all values from scratch? I only need the last 5 values... so that seems like a lot of wasted effort. But then the EA Journal show iCustom being loaded only once (for each iteration) during the course of the EA running.

Which is why I'm wondering if there is a better way to approach this, such as incorporating a function into the indicator which is a modified version of ZigZag that can utilize prev_calculated to speed things up... but I'd really rather not re-invent the wheel if it is totally unnecessary!

Louis Stoltz
644
Louis Stoltz 2014.03.04 19:20  
   //Zigzag Code shift can = zero
   double P0 = 0, P1 = 0, P2 = 0, P3 = 0, P4 = 0, P5 = 0;
   int T0, T1, T2, T3, T4, T5;   
   
   int x=0, t = shift;
   while(x<6)
   {
     if( P0>0 ) { P5=P4; P4=P3; P3=P2; P2=P1; P1=P0; T5=T4; T4=T3; T3=T2; T2=T1; T1=T0; }
     P0=iCustom(Symbol(),Period(),"ZigZag",5,5,3,0,t);
     T0=t;
     ObjectDelete(GetName("s",T0));
     ObjectCreate(GetName("s",T0), OBJ_TEXT, 0, Time[T0], P0);
     ObjectSetText(GetName("s",T0), P0, 8, "Times New Roman", Color_Text);

     if(P0>0) {x++;}
     t++;
   }
szgy74
266
szgy74 2014.03.04 19:51  

Once I worked on this. One call of ZigZag calculates the whole buffer array, you can add a function at the end

of the main loop of ZigZag which finds the elements you need in the array. You can then pass on the values with say GVs.

Toast
220
Toast 2014.03.04 23:31  
Thanks for the replies!
/
To add comments, please log in or register