calculating indicators on filtered price data...

 

hello all..

im new to coding with mql5.. the problem im facing is this.. i acquire a list of rates in the mqlrates structure.. then transform this data to remove the currency jumps that occur during the weekends.. now i need to calculate indicator outputs such as iAC, iADX or iATR on this data instead of the original rates.. how do i do that?

when i open the source code of an indicator.. i can see that the oncalculate function has a prototype that takes the rates as separate arrays.. how can i call an indicator so it uses user-defined rate arrays? or do i have a copy / paste / modify the indicator code so it works on my arrays?

thanks..

 asim 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / History Data Structure
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / History Data Structure - Documentation on MQL5
 
MqlRates g_oRates[];

int FillRates (string sTimeStart, string sTimeEnd, bool bRemoveSpikes)
{
        bool bFlag = ArraySetAsSeries (g_oRates, true);
        int iSize = CopyRates (_Symbol, PERIOD_CURRENT, StringToTime(sTimeStart), StringToTime(sTimeEnd) , g_oRates);
        
        if (bRemoveSpikes==true)
        {
                double dDelta = 0;
                ArraySetAsSeries (g_oRates, false);
                for (int i=1; i<iSize; ++i)
                {
                        dDelta = g_oRates[i].open - g_oRates[i-1].close;
                        g_oRates[i].close -= dDelta;
                        g_oRates[i].high -= dDelta;
                        g_oRates[i].low -= dDelta;
                        g_oRates[i].open -= dDelta;
                }
        }
        ArraySetAsSeries (g_oRates, bFlag);
        return iSize;
}

this is the code i use to fill and filter my g_oRates array.. i want the indicators like iATR to use these rates to calculate their values.. any help will be greatly appreciated..

thanks..

asim 

 
awesim:

this is the code i use to fill and filter my g_oRates array.. i want the indicators like iATR to use these rates to calculate their values.. any help will be greatly appreciated..

thanks..

asim 

Hi

You can calculate the g_oRates[] as a data buffer output from indicator, due to the fact that all the rates of g_oRates are equal

(ie g_oRates[].close = g_oRates[].open =  g_oRates[].low = g_oRates[].high) so you'll have one indicator that calculates that buffer. Then you'll call you're second indicator which is what you want at first place, with the input of the first indicator data (first_indicator_data). Read some about using one indicator with data from another.

 

Regards  

Reason: