- Discussing the article: "How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 1): Indicator Signals based on ADX in combination with Parabolic SAR"
- M5 SMA-Cross scalping
- Summer holiday in forex market?
The EA avoids overtrading and stays inactive during low-volatility conditions.
Add a volume indicator as a filter:
or a volatility indicator as a filter:
Ryan L Johnson, 2025.11.08 14:29
A volatility filter based on 3 ATR's: a fast ATR, a middle ATR, and a slow ATRYou seem to have already diagnosed the problem with trading the holiday season--low liquidity and extraordinarily erratic price movements. Institutional traders generally thin out starting on the week of U.S. Thanksgiving and don't return until after New Year's Day. A time filter applied from Thanksgiving week through January 31st might do well in your case.
Accurate backtesting can generate a valuable Report that will show you the specific hours, days, and months that are winners versus losers.range = (highest - lowest)
if (range > threshold) signal()
I agree with adding a volume filter - don't allow a trade if the volume is below the average. Maybe you can also use trend strength filter instead of a volume filter. I don't know which is better.
Ryan L Johnson, 2025.04.29 19:52
This indicator calls 3 other subwindow indicators. All files go in your Indicators folder.So as not to leave the time filter implementation like a sea of question marks...
Forum on trading, automated trading systems and testing trading strategies
Issues with TimeHour Error when Coding EA
Ryan L Johnson, 2025.01.30 15:16
Inputs:
input group "---------------------------------------"; input group "Turn trading time filter on/off"; input bool UseTimer = true; input group "---------------------------------------"; input group "Use personal computer time to filter? ==> if false, broker time is used"; input bool UsePCtime = true; input group "---------------------------------------"; input group "Set time to enable trading ==> Intraday and overnight are supported"; input string StartTime = "21:00"; input group "---------------------------------------"; input group "Set time to disable trading"; input string StopTime = "16:00"; input group "---------------------------------------";
Variables on global scope:
datetime dLocalTime, dStartTime, dStopTime; ulong uLocalTime, uStartTime, uStopTime,
In OnTick():
dStartTime = StringToTime(StartTime); uStartTime = ulong(dStartTime); dStopTime = StringToTime(StopTime); uStopTime = ulong(dStopTime); if(UsePCtime == true) { dLocalTime = TimeLocal(); } else { dLocalTime = TimeCurrent(); } uLocalTime = ulong(dLocalTime); if(uStartTime < uStopTime) // intraday start trading time is earlier than intraday stop trading time { if(UseTimer == true) { if(uLocalTime >= uStartTime && uLocalTime < uStopTime) { runBot = true; if(timerPrinted != 1) { Print("Timer is ON. Current time is within set trading times. Bot is ON."); timerPrinted = 1; } } else { runBot = false; if(timerPrinted != 2) { Print("Timer is ON. Current time is outside of set trading times. Bot is OFF."); CancelOrder(); timerPrinted = 2; } } } } if(uStartTime > uStopTime) // intraday start trading time is later than intraday stop trading time { if(UseTimer == true) { if(uLocalTime >= uStopTime && uLocalTime < uStartTime) { runBot = false; if(timerPrinted != 2) { Print("Timer is ON. Current time is outside of set trading times. Bot is OFF."); timerPrinted = 2; } } else { runBot = true; if(timerPrinted != 1) { Print("Timer is ON. Current time is within set trading times. Bot is ON."); timerPrinted = 1; } } } } if(UseTimer == false) { runBot = true; if(timerPrinted != 3) { Print("Timer is OFF. Bot is ON."); timerPrinted = 3; } }
And then put your trading code inside:
if(runBot == true) { //all of your trading code }(I prefer to leave trade exits code outside of the time filter).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use