0
Views
0
Downloads
0
Favorites
3FoldTradingFilterforEA
//+------------------------------------------------------------------+
//| 3FoldTradingFilterForEA.mq4 |
//| cubesteak |
//| http://www.cubesteak.net |
//+------------------------------------------------------------------+
//| HourlyFilter |
//| |
//| This function filters execution by three separate hourly |
//| timeframes. If the time is within the configured time, it |
//| it returns true. If HourlyFilter is disabled, it will also |
//| return true, effectively nullifying its call. |
//+------------------------------------------------------------------+
//+<< Hourly Restrictions on Trade >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
extern string HourlyRetrict_Parameters = "*** Hourly Restrictions ***";
extern bool UseHourTrade = true;
extern bool UseHourTrade1 = true;
extern string FromHour1 = "0:00"; //from
extern string UntilHour1 = "23:59"; //Until
extern bool UseHourTrade2 = false;
extern string FromHour2 = "0:00"; //from
extern string UntilHour2 = "23:59"; //until
extern bool UseHourTrade3 = false;
extern string FromHour3 = "0:00"; //from
extern string UntilHour3 = "23:59"; //until
bool HourlyFilter()
{
int HFa,HFb,HFc;
if (UseHourTrade)
{
datetime FromHourTrade1 = StrToTime(FromHour1);
datetime ToHourTrade1 = StrToTime(UntilHour1);
datetime FromHourTrade2 = StrToTime(FromHour2);
datetime ToHourTrade2 = StrToTime(UntilHour2);
datetime FromHourTrade3 = StrToTime(FromHour3);
datetime ToHourTrade3 = StrToTime(UntilHour3);
string s_now = StringConcatenate(Hour(),":",Minute());
int now = StrToTime(s_now);
if (
( UseHourTrade1 ) &&
( (now>=FromHourTrade1) ) &&
( (now<=ToHourTrade1) )
) HFa=1;
if (
( UseHourTrade2 ) &&
( (now>=FromHourTrade2) ) &&
( (now<=ToHourTrade2) )
) HFb=1;
if (
( UseHourTrade3 ) &&
( (now>=FromHourTrade3) ) &&
( (now<=ToHourTrade3) )
) HFc=1;
if (
(HFa!=1) &&
(HFb!=1) &&
(HFc!=1)
)
{
Comment(
"\n"," ^^^^^^^^^^^^^^^^^^^^",
"\n"," * NON-TRADING HOURS * ",
"\n"," ^^^^^^^^^^^^^^^^^^^^");
return (false);
}
else
{
Comment(
"\n"," ^^^^^^^^^^^^^^^^",
"\n"," * TRADING HOURS * ",
"\n"," ^^^^^^^^^^^^^^^^");
return (true);
}
}
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---