Historical data

 

Hi,

two questions on history data: 

 

1) I would like to get all available history data and highest bar prices for the selected symbol. For this I want to use the functions CopyRates and CopyHigh. However, as I don't know how many data is available I don't know how to specify the "count" parameter in these functions:

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   int              start_pos,         // start position
   int              count,             // data count to copy
   MqlRates         rates_array[]      // target array to copy
   );

 and 

int  CopyHigh(
   string           symbol_name,      // symbol name
   ENUM_TIMEFRAMES  timeframe,        // period
   int              start_pos,        // start position
   int              count,            // data count to copy
   double           high_array[]      // target array to copy
   );

"0" as value doesn't also seem to work.

 

2) In many indicators you find the function:

int OnCalculate(const int rates_total,    // amount of history in bars at the current tick
                const int prev_calculated,// amount of history in bars at the previous tick
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {...}

 How is this function invoked from the event handler, e.g. which values are passed in particular for "rates_total" and the array "high" (and what size does high has?) ?

 

Regards,

Chris 

Documentation on MQL5: Market Info / SymbolSelect
Documentation on MQL5: Market Info / SymbolSelect
  • www.mql5.com
Market Info / SymbolSelect - Documentation on MQL5
 
Your point 2. is an answer to your question 1. If you choose an indicator to get history data, rates_total gives you the count of bar in the current chart, and high[] returns the high of each of these bars.
 
angevoyageur:
Your point 2. is an answer to your question 1. If you choose an indicator to get history data, rates_total gives you the count of bar in the current chart, and high[] returns the high of each of these bars.

I want to program a screener which does not use the OnCalculate function since I want to go through all entries in the market watch list and evaluate each symbol individually. 

 

For this evaluation I need all available data for high[] and rates_array[]. However I don't know how to get all data hence my idea was to check how OnCalculate does it.

Documentation on MQL5: Language Basics / Functions / Event Handling Functions
Documentation on MQL5: Language Basics / Functions / Event Handling Functions
  • www.mql5.com
Language Basics / Functions / Event Handling Functions - Documentation on MQL5
 
zubr:

I want to program a screener which does not use the OnCalculate function since I want to go through all entries in the market watch list and evaluate each symbol individually. 

 

For this evaluation I need all available data for high[] and rates_array[]. However I don't know how to get all data hence my idea was to check how OnCalculate does it.

Did you read this page of documentation ? There is an example to load data on the second part.