Expert Advisors: MQL5 Wizard - Trade Signals Based on Crossover of Two EMA with intraday time filter
MQL5 Wizard - Trade Signals Based on Crossover of Two EMA with intraday time filter:
Author: MetaQuotes Software Corp.
Good article but i beg some explanations:
**** to open positions only from 0:00 till 5:59. It can be done by setting the value of BadHoursOfDay=16777152=111111111111111111000000b. All other trade hours are "bad", so it's better to prohibit the opening of new positions from 6:00 till end of the day. ****
Some details here are needed:
- how to calculate/define this value of " 16777152", how to define it for an other "opening/closing" or only "opening" time ?
- how to take decisions on multiple ITFs , for examples: TOKYO/LONDON/NY opening times ?
Some details here are needed:
- how to calculate/define this value of " 16777152", how to define it for an other "opening/closing" or only "opening" time ?
In this example the filter on new position opening is implemented. (It's assumed that they will be closed by SL/TP).
The binary representation of 16777152 is:
In our case we used the filter by hours, the "bad" hours have marked with corresponding bits=1. The same can be done with BadMinutesOfHour.
You can use calc.exe to convert binary values:
- how to take decisions on multiple ITFs , for examples: TOKYO/LONDON/NY opening times ?
If you want to use 3 separate filters (TOKYO,LONDON,NY), you can add additional instances of CSignalITF class (in our case there is an only one m_time_filter) into your signals class.
How would you optimize the time filter in strategy tester?
The best time filter can be found using the optimization of the BadHoursOfDay input parameter in Strategy Tester. You can specify starting and ending values of the parameters and it will find the best hours, because of the use of the genetic optimization algorithm it doen't need much time, as it seems.
The second way is to check the time of loss deals manually and "mark" them in bits of BadHoursOfDay parameter.
In fact, it allows to tune your stategy and take into account some "logical" reasons of trade idea. For example, the oscillators works better when flat, the reason of flat may be the absence of news, the session/currency pair properties, etc.
In this example the filter on new position opening is implemented. (It's assumed that they will be closed by SL/TP).
The binary representation of 16777152 is:
In our case we used the filter by hours, the "bad" hours have marked with corresponding bits=1. The same can be done with BadMinutesOfHour.
You can use calc.exe to convert binary values:
If you want to use 3 separate filters (TOKYO,LONDON,NY), you can add additional instances of CSignalITF class (in our case there is an only one m_time_filter) into your signals class.
Thanks for this howto, but what a headache :( Cant we simply use something more user friendly like StartHour/EndHour/StartMinute/EndMinute as we can do with MT4 ? Why using this so complicated binary mode ?
The binary representation of parameters has some significant advantages. For example, you can explore the parameter space in Strategy Tester (start from 0, end 16777215, step 1). Try it.
After finding the best hours you can explore the days. But note, that time filters are effective for lower timeframes (H1 and lower).
If you need more "friendly" way, you can write your own class of trade signals (see MQL5 Wizard: How to Create a Module of Trading Signals).
The binary representation of parameters has some significant advantages. For example, you can explore the parameter space in Strategy Tester (start from 0, end 16777215, step 1). Try it.
After finding the best hours you can explore the days. But note, that time filters are effective for lower timeframes (H1 and lower).
If you need more "friendly" way, you can write your own class of trade signals (see MQL5 Wizard: How to Create a Module of Trading Signals).
The best time filter can be found using the optimization of the BadHoursOfDay input parameter in Strategy Tester. You can specify starting and ending values of the parameters and it will find the best hours, because of the use of the genetic optimization algorithm it doen't need much time, as it seems.
The second way is to check the time of loss deals manually and "mark" them in bits of BadHoursOfDay parameter.
In fact, it allows to tune your stategy and take into account some "logical" reasons of trade idea. For example, the oscillators works better when flat, the reason of flat may be the absence of news, the session/currency pair properties, etc.
Okay please correct me if am wrong but supposing I want to filter bad minutes does this mean I need to sift through 1152921504606846975 options?
Moderator's note
This is an English language forum.
Please only post in English.
Use the site's translation tool if necessary.
Your post has been deleted
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
MQL5 Wizard - Trade Signals Based on Crossover of Two EMA with intraday time filter:
MQL5 Wizard allows to create the code of Expert Advisors automatically. See Creating Ready-Made Expert Advisors in MQL5 Wizard for the details.
The trading signals of the strategy, based on two moving averages are considered in MQL5 Wizard - Trade Signals Based on Crossover of Two Exponentially Smoothed Moving Averages. The moving averages are effective when trend, in other cases they provide many false signals. One of the ways to improve the strategy is the use of the time filters (for example, open new positions when European session of FOREX).
Here we will consider the strategy based on crossover of two exponentially smoothed Moving Averages (fast EMA and slow EMA) with intraday time filter. The strategy called "Signals based on crossover of two EMA with intraday time filter" (when creating EA automatically in MQL5 Wizard).
Trade signals:
This strategy is implemented in CSignal2EMA_ITF class of the Trading Strategy classes of MQL5 Standard Library (located in MQL5\Include\Expert\Signal\Signal2EMA-ITF.mqh).
The trading system is based on pending orders, the price levels are calculated depending on values of moving average, the ATR units (Average True Range) are used.
Author: MetaQuotes Software Corp.