Previous Next

GSupportAndResistance.GetAllPrices()

Returns a double array of the prices of the selected support and resistance levels.

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

Parameter

&array[]

[out]  The array to be filled with data.

get

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

timeFrame

[in]  Time frame of desired prices. -1 Outputs the data of all active timeframes.

Return Value

In case of success, the given array is filled with the elements and the array is shortened to the number of elements. In case of 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. Due to incomplete historical data passed from the terminal to Glib, there may be occasional errors in the output.


Example:

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

//--- Creating 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)
{
   //--- When closing, free memory
   delete supportAndResistance; }


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

      //--- Fill array
      supportAndResistance.GetAllPrices(array);

      //--- Check and output the values
      if (ArraySize(array)  > 0)
      {
         ArrayPrint(array, _Digits, " -- ");
      }
   }
}


See also

GSupportAndResistance.GetAll, GSupportAndResistance.GetPivots