Download MetaTrader 5

Indicators: FFC - Forex Factory Calendar

To add comments, please log in or register
Automated-Trading
Admin
108435
Automated-Trading  

FFC - Forex Factory Calendar:

Modified version of FF Calendar Indicator with new features.

FFC 2

Author: awran5

Daniel Abitbol
214
Daniel Abitbol  

I want my EA to stop working for an hour when the level 3 Calendar item is visible;


Since it is not possible to backtest, would you agree that these lines would be correct?

    int rest = 60;

    int EventMinute = (int)iCustom(NULL,0,"FFC",0,0);
    int EventImpact = (int)iCustom(NULL,0,"FFC",1,0);

   if(EventMinute == 30 && EventImpact == 3 && Minute() < rest) return;  
// 30 minutes prior to the event and 30 minutes after the event

Thanks in advance

awran5
4342
awran5  
Daniel Abitbol:

I want my EA to stop working for an hour when the level 3 Calendar item is visible;


Since it is not possible to backtest, would you agree that these lines would be correct?

    int rest = 60;

    int EventMinute = (int)iCustom(NULL,0,"FFC",0,0);
    int EventImpact = (int)iCustom(NULL,0,"FFC",1,0);

   if(EventMinute == 30 && EventImpact == 3 && Minute() < rest) return;  
// 30 minutes prior to the event and 30 minutes after the event

Thanks in advance

Hello Daniel,

I think you need to modify the indicator code to make "after the event" condition work properly.

By default, the event will be removed/replaced after 10 minutes of its time and so the Buffer that holds the value.

Also, Please note that the simple call method will always return the default indicator parameters which means you will get all "High impact events" that may not be related to the current pair. If that is the case its fine, otherwise you need to use the advanced call method:

int EventMinute=(int)iCustom(NULL,0,"FFC",true,0,0);    // Event minute for active pair only

So first you need to increase (by code) the "EventDisplay" input to 30 minutes instead of 10 and maybe try something this: (Not tested due closed market)

int rest=30; // minutes
int EventMinute=(int)iCustom(NULL,0,"FFC",true,0,0);
bool HighImpact=(int)iCustom(NULL,0,"FFC",true,1,0)==3; // Event impact for active pair only
bool EventTime=EventMinute<rest && EventMinute+rest>0;  // 30 minutes before and 30 minutes after
   
if(EventTime && HighImpact) return; // return is like the EA is disabled, the rest of EA code will not executed
else { .... } // Your entry condition and the rest of your code

Hope this helps!

Daniel Abitbol
214
Daniel Abitbol  
Daniel Abitbol:

I want my EA to stop working for an hour when the level 3 Calendar item is visible;


Since it is not possible to backtest, would you agree that these lines would be correct?

    int rest = 60;

    int EventMinute = (int)iCustom(NULL,0,"FFC",0,0);
    int EventImpact = (int)iCustom(NULL,0,"FFC",1,0);

   if(EventMinute == 30 && EventImpact == 3 && Minute() < rest) return;  
// 30 minutes prior to the event and 30 minutes after the event

Thanks in advance

Hi awran5 and thanks for responding so quickly.

I will try you suggestion.

SInce I never worked with icustom indictaors before, I need to ask you another question. Does the indicator need to be placed on the chart of each currency pair that I use or will the call in my EA be enough?

Thanks

awran5
4342
awran5  
Daniel Abitbol:

Hi awran5 and thanks for responding so quickly.

I will try you suggestion.

SInce I never worked with icustom indictaors before, I need to ask you another question. Does the indicator need to be placed on the chart of each currency pair that I use or will the call in my EA be enough?

Thanks

Depending on how you’re going to call, the simple method uses no parameters so the iCustom function will returns the default indicator parameters values which has been set to report for all currency pairs (except CNY) by default. In that case only one chart would be enough.

But the advanced method is like to override the indicator parameters inputs with your own values and if you didn't specify any parameters, the default values will be used. These parameters should go after the name of the custom indicator separated by commas.

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   string       name,             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters separated by commas
   int          mode,             // line index
   int          shift             // shift
   );

As the example below, the fourth parameter "true" is refers to the first indicator parameter Report for active chart only

int EventMinute=(int)iCustom(NULL,0,"FFC",true,0,0); // Active chart only is enabled

If you use it that way, it will return the data form the chart that the indicator is attached to so the indicator need to be placed on each chart you like to use.

More examples:

Second indicator parameter is Include high, you can change it by:

int EventMinute=(int)iCustom(NULL,0,"FFC",true,false,0,0); // Active chart enabled - include high events is disabled 

Also you can access the events index by changing the Shift parameter

int EventMinute=(int)iCustom(NULL,0,"FFC",0,0); // very first event
int EventMinute=(int)iCustom(NULL,0,"FFC",0,1); // the up next event

And so on :)

iCustom - Technical Indicators - MQL4 Reference
iCustom - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iCustom - Technical Indicators - MQL4 Reference
Daniel Abitbol
214
Daniel Abitbol  
awran5:

Depending on how you’re going to call, the simple method uses no parameters so the iCustom function will returns the default indicator parameters values which has been set to report for all currency pairs (except CNY) by default. In that case only one chart would be enough.

But the advanced method is like to override the indicator parameters inputs with your own values and if you didn't specify any parameters, the default values will be used. These parameters should go after the name of the custom indicator separated by commas.

As the example below, the fourth parameter "true" is refers to the first indicator parameter Report for active chart only

If you use it that way, it will return the data form the chart that the indicator is attached to so the indicator need to be placed on each chart you like to use.

More examples:

Second indicator parameter is Include high, you can change it by:

Also you can access the events index by changing the Shift parameter

And so on :)

Hi awran5,

I modified the code of my EA as suggested and once restarted, the "call" worked and the indicator window and data appeared without problems on the chart without any problem.

Now all I hope is that when there is an event 3, that the EA stops working for the period of 30 min prior and 30 mins after.

Question: Would it be possible for the future, that you create for testing purpose only a dummy xml file with false data so that during testing, would send alerts when the EA stops and restarts after a dummy event?

Thanks for all the help so far. You have really been great!! 

awran5
4342
awran5  
Daniel Abitbol:

Hi awran5,

I modified the code of my EA as suggested and once restarted, the "call" worked and the indicator window and data appeared without problems on the chart without any problem.

Now all I hope is that when there is an event 3, that the EA stops working for the period of 30 min prior and 30 mins after.

Question: Would it be possible for the future, that you create for testing purpose only a dummy xml file with false data so that during testing, would send alerts when the EA stops and restarts after a dummy event?

Thanks for all the help so far. You have really been great!! 

You're welcome my friend.

Well, it's possible but it's kinda useless since all events based on time, you will have to change the time manually :)

But why don't you just filter out only the high impact events from the indicator settings then use the Alert based on the Event minutes left? You can see the event time left in minutes when you mouse hover on the event.

ffc mouse hover

Example: recent event time left is 582 minutes so set the first alert to 582 and so on.

Edit: I forgot to mention about the EA alerts.

You can use something like this:

   if(EventTime && HighImpact)
     {
      MessageBox("Stopping all trades due to possibility of High impact Event!"); // Alert() function does not work .. or
      SendNotification("Stopping all trades due to possibility of High impact Event!"); // or
      SendMail("EA Status","Stopping all trades due to possibility of High impact Event!");
      return;
     }

Just put your preferred Alert function under your filter condition.


Daniel Abitbol
214
Daniel Abitbol  

Hi awran5,

Just to let you know that the code worked to perfection without any issues.

Thanks for a great indicator and thanks for helping me set it up. 

awran5
4342
awran5  
Daniel Abitbol:

Hi awran5,

Just to let you know that the code worked to perfection without any issues.

Thanks for a great indicator and thanks for helping me set it up. 

Hello Daniel,

I'm really glad i could help and i really appreciate your feedback.

Actually, your idea about the "after event" is really useful and it could lower the risk .. I'll consider it.

Thank you very much.

Good luck :)

Daniel Abitbol
214
Daniel Abitbol  

Hi awran5,

I have another question for you, since there is a ""  in the indicator, I suppose that it is for reporting chosen keywords as found in the event title. So suppose that I am very worried that the nonfarm payrolls or the FOMC have  such a high impact, that I would consider to stop all trades for at least one hour after the event, contrarily to 30 minutes for most level 3 events.

So how do I tell the indicator that I want all level 3 events, but I that I also need to know when that event is the "Nonfarm Payrolls" or the "FOMC"?

Does the below code go in the right direction? 

1. All level 3 events;

   int EventMinute = (int)iCustom(NULL,0,"FFC",true,true,true,true,true,false,"","",true,1,0,0);

   int EventImpact = (int)iCustom(NULL,0,"FFC",true,true,true,true,true,false,"","",true,1,1,0);

if (EventMinute== 30 && EventImpact==3) // and so on 


2. Nonfarm Payrolls

   int EventMinuteNF = (int)iCustom(NULL,0,"FFC",true,true,true,true,true,false,"Nonfarm","",true,1,0,0);

   int EventImpactNF = (int)iCustom(NULL,0,"FFC",true,true,true,true,true,false,"Nonfarm","",true,1,1,0);

if (EventMinuteNF == 30 && EventImpactNF==3) // here I am not sure if it is a 3 or the keyword "Nonfarm".

I am unsure because the indicator calls for int and not for a string.


3. FOMC

same idea as per the "Nonfarm"


awran5
4342
awran5  
Daniel Abitbol:

Hi awran5,

I have another question for you, since there is a ""  in the indicator, I suppose that it is for reporting chosen keywords as found in the event title. So suppose that I am very worried that the nonfarm payrolls or the FOMC have  such a high impact, that I would consider to stop all trades for at least one hour after the event, contrarily to 30 minutes for most level 3 events.

So how do I tell the indicator that I want all level 3 events, but I that I also need to know when that event is the "Nonfarm Payrolls" or the "FOMC"?

Does the below code go in the right direction? 

Yes, it's good just a few notes:

  1. You need to write the word (or even 2 words) exactly as it shown in the calendar, i think it's "Non-Farm" not "Nonfarm"? it maybe easier if you just copy/past it.
  2. Just note that other currencies may contain the same word. i.e. EUR have "French Final Non-Farm Payrolls q/q"
  3. You don't have to write down all the custom parameters unless you want to change the "following" parameter.
  4. It's OK with the string call, the indicator uses StringFind() function which return an integer.
  5. about "3" or "keyword" .. it will rerun both :) , actually it will return the Buffer value:
  int EventFOMC=(int)iCustom(NULL,0,"FFC",true,true,true,true,true,false,"FOMC","",true,1,1,0); 
  /*
        Active chart only:     true  (watch this)
        Include High impact:   true 
        Include Medium impact: false (no need)
        Include Low impact:    false (no need)
        Include Speaks:        false (no need)
        Include Holidays:      false
        Find keyword:          FOMC
        Ignore keyword:        ""
        Allow Updates:         true
        Update every:          1 hour (4 is better)
        Buffer:                Impact
        shift:                 0
  */
   //--- if found, it will return either (1,2,3)
   if(EventFOMC > 0)  // All FOMC events
   if(EventFOMC == 3) // Only High impact FOMC events

Hint:

- You can just use a separate variables for each event.
- If you like to make the panel text selectable to copy/past it, comment out line 721
ObjectSet(name,OBJPROP_SELECTABLE,0);
To add comments, please log in or register