Previous Next

GSupportAndResistance.GetAll()

Fills a GStructSupportAndResistanceDetails object array with the values of the extremal points.

void  GSupportAndResistance.GetAll(
   GStructSupportAndResistanceDetails  &array[],        // Array for data output
   ENUM_SUPPORTANDRESISTANCE           get = SAR_ALL,   // Output data: SAR_ALL, SAR_SUPPORT or SAR_RESISTANCE
   ENUM_TIMEFRAMES                     timeFrame = -1   // Timeframe of the desired values
   );

Parameter

&array[]

[out]  The array to be filled with data. Due to a bug of the MT5 terminal, the array must be resized with ArrayResize() before it is passed to the function.

get

[in]  The data to be read. Allowed are SAR_ALL, SAR_SUPPORT or SAR_RESISTANCE. See ENUM_SUPPORTANDRESISTANCE.

timeFrame

[in]  Timeframe of the values. -1 outputs the data of all active timeframes.

Return value

In case of success, the array passed to the function is filled with the elements and the array is shortened to the number of elements. In case of an error, the size of the array is 0 (zero) and a message is output.

Note

The array should always be checked for content after filling.


Example:

//--- Include the Glib classes
#include <Glib.mqh>

//--- Creation of a pointer to an empty class object
GSupportAndResistance *supportAndResistance;


int OnInit ()
{
   //--- Assign the class to the empty class object
   supportAndResistance = gSupportAndResistance();

   //--- Initialize the class data
   supportAndResistance.Init();

   return(INIT_SUCCEEDED);
}

void OnDeinit (const int reason)
{
   //--- Free up memory on exit
   delete supportAndResistance;
}


void OnTick ()
{
   if ( supportAndResistance.Ready() ) //--- Will only be executed when all data is ready
   {
      //--- Create structure array
      GStructSupportAndResistanceDetails array[];

      //--- Allocate memory
      ArrayResize(array, 256);

      //--- Fill the array
      supportAndResistance.GetAll(array);

      //--- Check and output of the touches of a line
      if (ArraySize(array)  >= 3)
      {
         Print(array[2].touches);
      }
   }
}


See also

GSupportAndResistance.GetAllPrices, GSupportAndResistance.GetPivots