• Overview
  • Reviews (6)
  • Comments (50)
  • What's new

EA Protection Filter

I am tranferring my business to another EA developer. Please see the new product page (sold with a discount for the transition period).

EA Protection Filter provides a news filter as well as a stock market crash filter, which can be used in combination with other EAs. Therefore, it serves as an additional protective layer for other EAs that do provide such filters. 

During backtest analysis of my own night scalpers, which already use a stock market crash filter, I noticed that the historic drawdown,  especially during stock market crash phases like 2007-2008, was reduced significantly by using such a filter. 

This type filter usually only makes sense in combination with scalpers that want to avoid fast markets, so don't use it on impulse/price action strategies! 

Also, there is no guarantee that using this filter will be more profitable compared to the normal trading. 


How it works:


In MT4 an EA is not allowed to modify other EAs for safety reasons. However, it is possible to close and re-open charts, which can be used to turn on/off other EAs. 

The EA will also be able to close existing open positions or pending orders based on the given magic numbers or comments you provide as input. 


Important notes:

- Please test the filter on DEMO account first!

- Open an M1 chart for the stock market symbol (for example US500) before starting the filter to force MT4 to load the historic data. 

- First arrange all charts and EAs that you want to use in combination with this protection filter. Then save the profile in case something goes wrong: File -> Profile -> Save As...

- Please allow requests to http://fxdata.cc and http://backup.fxdata.cc.

- Attach this EA to a new chart of any symbol after (!) all other EAs are loaded.

- Before you close the MT4 or remove the EA press the button on the chart "Turn filter OFF (opens all charts)" to re-open all charts. Else it will not remember closed charts. 

- It cannot be guaranteed that the other EAs are compatible with this filter. Make sure that the EAs are ok with being removed and initialized possibly multiple times a day ( best ask the developer). 

- Charts can only be filtered by symbol/timeframe, but open trades only by magic/comment. So you have to find a combination that makes sense for your EAs. 


Parameters:

  • includeTimeFrames  - a comma separated list of time frames that should be monitored. For example, if you have non-scalpers on H1 that should not be closed, delete H1 from this list. 
  • excludeSymbols -a  comma separated list of symbols that should be excluded (if you have other EAs that should not use this filter)
  • magicNumbersToCloseOpenPositions - a comma separated list of magic numbers, for which positions should be closed
  • commentsToClosePositionsExact - a comma separated list of comments, for which positions should be closed (exact match)
  • commentsToClosePositionsIncluding - same as the last parameter, but here the comment only has to be included, not an exact match
  • sleepSecondsBetweenChartOpen - to avoid terminal overload
  • filePrefix - name for the saved template files
  • debugMode - more information in Expert log

  • signalSymbol - symbol for the SP500 on your broker
  • maxPercentageChange - the maximum allowed percentage change for the stock filter to trigger
  • minimumKeepClosedMinutesStockFilter - minimum time to keep the chart closed after stock market filter triggered

  • filterCentralBankEvents - to filter central bank events
  • filterSpeechesAndTestimonies - to filter speeches
  • filterHighImpact - to filter other high impact events
  • closeMinutesBeforeEvents - minutes before events when charts and positions will be closed
  • pauseMinutesAfter... - minutes after events for which the charts will be kept closed
  • minimumKeepClosedMinutesNews - minimum time to keep the chart closed after news filter triggered
  • useBreakingNewsFilterSignals - If you have the breaking news filter, its signals can be used. It works only within start/end hour of the normal news filter!

  • startHourGMTwinter - start hour for the stock market filter. In summer all times will be automatically shifted 1 hour. 
  • endHourGMTwinter - end hour for the stock market filter
  • startHourGMTwinterNews - start hour for the news filter
  • endHourGMTwinterNews - end hour for the news filter









Tarek Tabchi
629
Tarek Tabchi 2020.03.16 16:15 
 

State of the art product, a must have tool for all serious traders! If you have this running during the current pandemic crisis, you know it already saved you a lot of losses! It's worth much more than the current price.

Huge respect to the author who keeps tweaking it and adding safety features, i hope the upgrades keep coming!

Guilai Zhang
1056
Guilai Zhang 2020.01.26 11:57 
 

This is a very good EA,I used it in my scalper EAs and got very good result.

ysl2001
53
ysl2001 2019.11.20 06:16 
 

Excellent! Using this EA protection filter successfully avoided a large loss!

Paulus Verhoogt
1362
Paulus Verhoogt 2019.09.12 17:14 
 

You need some time to understand it, but it is one of the best and useful tools in the market!

In order to make it function well, make sure your CPU load is not too high (preferably 1 virtual CPU on your VPS)

Lucy
171
Lucy 2019.03.03 09:13 
 

Very useful tool :D This can be used for not only managing your EA but also other ways with flexible settings. For instance, I planned to halt some EAs prior to important news at first, but now I use this to prevent to be ordered manually by mobile app, once order is opened with magic #0, it is closed automatically quickly. So, probably you could do what you want with this tool.

Xu Yaji
324
Xu Yaji 2018.12.17 09:31 
 

ea很好用

Version 5.3 2020.05.08
Added a parameter fridayHourGMTadd48HoursToCrashEndTime.
If the stock crash filter triggers after this hour on a Friday, the crash end time will be increased by 48. This way the charts should stay closed until Monday morning (depending on your minimumKeepClosedHoursStockFilter setting).
If you don't want this logic to be used, just set a high value of 24 or higher.
Version 5.2 2020.05.03
Added parameter updateMinutesFile. If useCustomEventsFile=true, this will determine how often the filter updates its new data from file.
If you use the news data from my server (useCustomEventsFile=false), this parameter has no effect.
Version 5.1 2020.05.03
In case the chart closing function returned an error, the filter will now try to to close all charts with the same symbol and time frame.
Also, if an error occurs during chart opening, it will try to get back the initial setup by closing all charts with the same symbol and time frame and re-opening them again.
Version 5.0 2020.04.24
Fixed a bug, which could lead to charts being opened after the stock filter triggered.
Version 4.9 2020.04.19
- Added parameters combinedNewsCurrences1/2 and combinedBreakingNewsCurrences1/2. If combinedNewsCurrences1="USD,JPY,CHF" the filter would filter all three currencies on news for any of them.
combinedNewsCurrences2 does the same and was added so that you can use two different groups.
combinedBreakingNewsCurrences1/2 does the same, but only with regards to breaking news if you also use the Breaking News Filter on the account.

- Changed the stock filter parameters so that it is possible to define different values for up/down movement as well as for two different lookback duration (lookbackHours/lookbackHoursShort).
The new parameters are percentageDown, percentageUp, percentageUpShort and percentageDownShort.

- Added parameters close/openChartsHourGMTwinter. If they are set, the filter should close all charts during a given time period each day.

- Added parameter sendPushNotifications. If true, it will send push notifications when the stock market filter triggers (if push notifications are set up correctly on the MT4 terminal). It will send max once every 5 hours.
Version 4.8 2020.02.27
- The filter will now add a new internal M1 bar even if the stock market symbol is not open for trading. This should be more consistent if your broker has a trading pause during the night, but keeps sending quotes.
- Removed the paramter liveGMToffset, which did not have any function anymore after changing to the new GMT offset solution.
Version 4.7 2020.02.03
With version 4.7 the filter will not wait for a new bar of the stock market symbol anymore because it might not be updated if the chart is not open. Instead it just add an internal M1 on every new minute if MODE_TRADEALLOWED is true (market is open).
Version 4.6 2020.01.20
- Updated the news format so that it reflects the changes made on my news server.
- The EA now uses the auto GMT solution similar to my EAs which should be more exact with regards to filtering the news during the week. However, it partly still uses MT4 TimeGMT() function so that it can modify charts during the weekend. TimeGMT() relies on the correct Windows time, so it should still be set correctly. If not the EA will give an Alert during initialization.
Version 4.5 2019.11.04
- Corrected a bug when ChartClose() function returns false.
- Added parameter checkPositionsEvenWithoutCharts. If true, the filter will check open position for news even if there is no chart closed at the time. Will use more CPU since it checks every tick.
- For Japanese holidays on Monday open you can now define a list of currencies that should be filtered. Default is filterMondayOpenJapaneseHolidays="JPY,CHF".
Version 4.4 2019.10.01
- A bug was fixed that prevented usage of breaking news if useBreakingNewsFilterSignals=true.
- Added an option dontCloseSymbolsWithOpenOrders. If it is set to true, then charts will only be closed if there is no open position for the same symbol.
- It is now possible to load events from a custom file. This way you can use the EA without being dependent on the news server. New parameters:

useCustomEventsFile - whether to use the custom file. Then ONLY the events in the file will be used and no other data from the server. Every event in the file will be used without additional filters.

customEventFile - The name of the file you want the EA to read. It should be placed in the common file directory (...\MetaQuotes\Terminal\Common\Files) and should have exactly the following format "date time, currency, name", so for example like this:

2018.05.02 18:00, USD, Rate Decision
Version 4.3 2019.09.13
- Added an option to ignore events between given hours startHourGMTwinterIgnoreNews and endHourGMTwinterIgnoreNews.
- Added the possibility to define a custom pause interval for currencies (pauseCurrencies, pauseBeginMonth, pauseBeginDay, pauseEndMonth, pauseEndDay).
- The filter can now use signals from the breaking news filter with parameter useBreakingNewsFilterSignals (if the breaking news filter is puchased separately).
Version 4.2 2019.04.30
A few parameters have been added:

- filterMediumImpact: If true the EA will also filter medium impact events.

- closeMinutesBeforeBankEvents, closeMinutesBeforeSpeeches and closeMinutesBeforeOtherEvents can now be used to set different time intervals when the positions should be closed before coming news.
Version 4.1 2019.03.20
Correct a visual bug that would show "stock market filter deactivated" while it was active.
Version 3.8 2019.01.11
Added parameter closePositionsBeforeChartsOnMaxPL. If true it will lead to faster close when max open loss/profit is reached (for example during a flash crash), but it could also lead to interactions with still active charts/EAs.

Also changed trading pause so that it will only close after the same hour as the Friday close on the day given by stopTradingMonth and stopTradingDay.
Version 3.7 2019.01.11
- Added handleOpenProfitLossLikeCrashTrigger. If true the EA will close all position when the loss of open positions is larger than maxOpenLoss or when the proft of open positions is larger than maxOpenProfit. If those values are 0 it will not be used. It will handle it the same way as the stock market crash trigger, which means it will open charts again after the given time.
The open Profit/Loss and the number of monitored positions will be shown on the chart as visual feedback.

- Added stopTradingMonth ,stopTradingDay, startTradingMonth and startTradingDay so that users can define a trading pause where all monitored charts and positions will be closed.
Version 3.6 2018.12.29
Changed variable useStockFilterSundayNight to useStockFilterSundayNightAndDec25Jan1. If false, it will now also allow to not use the stock filter on the night of the 25th Dec and 1st Jan (GMT time). It is useful in case a user prefers to always trade the market open even if there was a stock market crash trigger before the weekend/holiday.
Version 3.5 2018.12.23
-Added a parameter handle24and31DecemberLikeFriday to automatically close on Christmas and New Year's Eve similar to Friday close.
Version 3.4 2018.12.08
The last version was a bit inconsistent in the case there the stock market filter triggered Friday (and therefore also Saturday/Sunday). The new version has a new variable useStockFilterSundayNight.
If true it will always use the Friday close time (+ 48 hours + minimumKeepClosedHoursStockFilter hours) as time to open charts again (Monday morning).
If false it will open charts again on Saturday and don't check stock filter until after Monday morning. So it will always allow Sunday night's trading even if there is a gap in stock markets.
Version 3.3 2018.12.06
Added the lengthy variable onlyTryPositionCloseOnceAfterChartCloseError, which needs a bit of explaining.
The problem is if there is an error after trying to close a chart multiple times, then it might be that the chart and other EA is still active. Therefore, we don't want to get into a situation where the other EA opens positions and the filter directly closes them again multiple times. If you have onlyTryPositionCloseOnceAfterChartCloseError=true it will only try to close the position once in case there was an error (only for the symbols that had an error).
However, if the symbol has already closed charts and the position close is not successful the first time, it could then lead to unmonitored positions. But the probability should be small.
Version 3.2 2018.12.04
Changed the stock filter to only add a new bar if the bar time changed to prevent adding the same bar multiple times during holidays.
Version 3.1 2018.11.30
The filter will now use MT4 GMT time to also be able to check for news during the weekend. This means that it is important that your server data is correct. But the filter will give a warning if it detects a difference between my server's GMT time and MT4 GMT time.
Version 3.0 2018.11.30
- The filter will now set global variables for all symbols in market watch. So if the other EA is able to use those for opening and closing of positions, there is no need to add it to the monitored charts.
But if it only check for opening and you also want the positions to be closed, you should include the magic in the filter input and also have at least one chart with the given symbol open.
- The filter will now also close charts during the weekend to prevent trading on market open in case there was a news release before.
Version 2.9 2018.11.24
Added an additional check to retry closing a chart if it did not work on the first attempt.
Version 2.8 2018.11.20
Added a parameter:
waitMinutesBetweenClosePositionAttempts - When news or stock filter triggers the EA will close all positions depending on the given settings. It will then wait at least waitMinutesBetweenClosePositionAttempts minutes until again checking to close positions.
Version 2.7 2018.11.17
Small fix for Friday close issue.
Version 2.6 2018.11.17
Fixed an issue where it would not open charts automatically on Saturday after they were closed on Friday.
Version 2.5 2018.11.15
Changed closeFridaySymbols to closeFridayCurrencies because it requires less input. For example, just set closeFridayCurrencies=GBP to close all charts of symbols containing GBP at the given FridayCloseHourGMTwinter and FridayCloseMinute.
Version 2.4 2018.11.15
Added a parameter closeFridaySymbols, where the user can insert a list of symbols for which charts should be closed on Friday at the given FridayCloseHourGMTwinter and FridayCloseMinute. If the list is empty, no charts will be closed on Friday.
Version 2.3 2018.11.14
- Added sleepSecondsBetweenChartClose to prevent MT4 terminal overload when closing many charts at the same time.

- Added parameters FridayCloseHourGMTwinter and FridayCloseMinute. The EA will close all charts at the given time and close open position to avoid holding positions over the weekend. However, some EAs are specifically designed to trade during the weekend. Set FridayCloseHourGMTwinter=-1 if you want to disable this function.
Version 2.2 2018.11.10
Small fix to make delaySecondsOnInitialization work properly during weekends.
Version 2.1 2018.11.09
Added parameters startHourGMTwinterNewsCharts and endHourGMTwinterNewsCharts.
They allow to set different windows for the news filter:
Between startHourGMTwinterNews and endHourGMTwinterNews the news filter will be active and close positions (but not charts).
Between startHourGMTwinterNewsCharts and endHourGMTwinterNewsCharts the news filter will also close charts (only if also within the normal news filter time window).

Also added a parameter delaySecondsOnInitialization. It will cause the EA to wait a few seconds on normal initialization. For example, after you restart MT4 it makes sure that the EA will read the charts after all EAs on other charts have been initialized. After pressing F7 to change settings it will not cause a delay.
Version 2.0 2018.11.05
Resolved an issue that could prevent loading a template on some MT4 terminals.
Version 1.9 2018.11.05
The new version will not open all charts on pressing F7. Use the chart button "Turn filter OFF" to do that before modifying the EA settings.
Version 1.8 2018.11.05
Added parameter add48hoursIfTriggerWasFriday in case you want to also prevent Sunday/Monday morning trading if there was a stock market crash on Friday. The EA will then automatically add 48 hours to the minimumKeepClosedHoursStockFilter value.

It will also now show the reference time to which the percentage change of SP500 will be calculated. Be aware that on first initialization it will load X bars, so it might be that the reference time has not the same minute compared to the current time.
Version 1.7 2018.11.04
Smal fix for the OnTimer() function so that it will not update during the weekend.
Version 1.6 2018.11.03
Small fix for lookback period.
Version 1.5 2018.11.03
- News is now only checked every minute and the chart also only updates every minute to reduce CPU and memory usage.
- There ois now a parameter onlyCheckStockPriceEveryMinute in case the user also only wants to check stock prices every minute.
Version 1.4 2018.11.03
The stock filter now uses M5 bars for more exact 8h period.
Version 1.3 2018.11.02
- There was a small bug that has been solved now.
- The charts list will now use multiple rows if more than 8 charts are monitored.
Version 1.2 2018.11.02
I decided to again delete openAllChartsAndTurnOffFilter. It is now replaced by a visible button on the chart "Turn filter OFF (opens all charts)", which you should press in case you have closed charts and want to remove the EA without losing those charts.
Version 1.1 2018.11.02
Added a parameter openAllChartsSlowlyAndTurnOffFilter.

MT4 ignores the sleep() function when removing an EA, which means that if you have many closed charts, it will try to open all at once without time in between. This can cause CPU overload and errors in opening the charts.

So if you have many closed charts, first press F7, set openAllChartsAndTurnOffFilter=true and wait until all charts are open. Then the filter will be turned off and you can remove it from the chart.