FFCal indicator into mt4 EA

 

Hi,

I have FFCal.mql4 indicator (file attached) and I would like to use it into a mt4 EA to filter open trade from impact high and medium news economic.

To use this indicator into EA it is necesary to put this code below into EA code:

// EA Setting variables
extern int MinsBeforeNews = 120; // mins before an event to stay out of trading
extern int MinsafterNews  = 120; // mins after  an event to stay out of trading

// Global variable at top of file
bool NewsTime;

// Function to check if it is news time
void NewsHandling()
{
    static int PrevMinute = -1;
    if (Minute() != PrevMinute)
    {
        PrevMinute = Minute();
        int minutesSincePrevEvent = iCustom(NULL, 0, "FFCal", true, true, false, true, true, 1, 0);
        int minutesUntilNextEvent = iCustom(NULL, 0, "FFCal", true, true, false, true, true, 1, 1);
        NewsTime = false;
        if ((minutesUntilNextEvent <= MinsBeforeNews) || (minutesSincePrevEvent <= MinsAfterNews))
        {
            NewsTime = true;
        }

   Comment("\nNewsTime => ",NewsTime,
   "\nminutesSincePrevEvent => ",minutesSincePrevEvent,
   "\nminutesUntilNextEvent => ",minutesUntilNextEvent);

    }
}

It works nice but the minutes return by minutesSincePrevEvent and minutesUntilNextEvent are not correct, for example if the last impact medium news is 1 hour, the minutesSincePrevEvent return 930. Please see sceenshot. What is wrong into FFCal.mql4 code?

Thank you for your answer.

Files:
FFCal-mql4.jpg  138 kb
FFCal.mq4  88 kb
Reason: