How to get the 2nd value of the ZigZag indicator for the stop loss in a buy trade?

 

Sir / Mam,

Get Value

I don't want to get the 1st and 3rd Values in the ZigZag indicator Because I want to get the 2nd Value for the stop loss in a buy trade.

How to get the 2nd Value of the ZigZag indicator for the stop loss in a buy trade?

Please solve this code 👇

// MQL5 Code
double Zig_Zag(int ZigZag_handle_param, double &ZigZag_Value_param[])
  {
   ArraySetAsSeries(ZigZag_Value_param, true);

   int Copy_Buffer =  CopyBuffer(ZigZag_handle_param, 0, 
2 , 100, ZigZag_Value_param);

   for(int j = 0; j < Copy_Buffer; j++)
     {
      if(ZigZag_Value_param[j] != 0)
        {
         return ZigZag_Value_param[j];
         break;
        }
     }
   return 0;
  }

OR

You can send me MQL5 code

 

Two frequently used methods of "getting" historic indicator data from within an EA are:

  1. Using iCustom() to call a separate indicator file from within an EA; and
  2. Embedding all of an indicator's source code calculations inside a custom function within an EA.

You're mixing both to some extent but implementing neither completely.

The easier method is the former where you use iCustom(), a handle, and CopyBuffer():


                                                              

 
Ryan L Johnson #:

Two frequently used methods of "getting" historic indicator data from within an EA are:

  1. Using iCustom() to call a separate indicator file from within an EA; and
  2. Embedding all of an indicator's source code calculations inside a custom function within an EA.

You're mixing both to some extent but implementing neither completely.

The easier method is the former where you use iCustom(), a handle, and CopyBuffer():


                                                              

Ok Sir