Short Trend Reversal
- Experts
- Tomasz Adrian Bialous
- Versione: 1.7
- Aggiornato: 25 dicembre 2025
- Attivazioni: 10
This EA is a part of my other EA Nash Equilibrium. If you activate this EA on a chart created from Nash Equilibrium, orders can be managed by Nash Equilibrium with Manage mode (External or Main&External). EAs are compatible.
With this EA you can build a good profitable system. The EA was created to test signals for the Nash Equilibrium EA, but when I saw the backtest results, I thought I would add a few lines and put it on the market. After adding over 1000 lines of code, here it is. It works on any classic currency pair /you just need to find the right settings/. It works on many other instruments, but you need to choose the right TakeProfit, StopLoss, min_dist, pending_dist. If you want to test other instruments, it is best to do large tests from methodology 2 with your own TP.
For EUR,USD,GBP,CHF,CAD,JPY,AUD,NZD between them crosses, pips calculated as for a 4-digit broker (inside multiplied by 10). The rest of the instruments as your broker has.
EA has the following Built-in settings: SAFE, MODERATE, AGGRESIVE, start by checking what it looks like with your broker /it was backtested with Vantage broker on STP account/.
I recommend turning EA on several charts of one currency, for example several crosses EUR or USD or ... or mixed, and several TFs, this way you will obtain indirect hedging.
Important: This EA should have StopLoss set to 0 while running. StopLoss is only used to create a statistical file in the tester folder during historical testing. There you will see useful information about the amounts of losing and profitable trades. Pips in this EA are calculated as for 4-digit-broker /FOR CURRENCIES ONLY/. The rest of the instruments as your broker has.
Rules and my backtest methodology:
- Disable the genetic algorithm if you want to use my statistics file
- Open prices only testing model. There is no need to test every tick because EA takes a position only on new candles
- set mine TP first: M15: TP=15, M30: TP=20, H1: TP=30, H4: TP=40 /change if you want, but try mine/
- EA not using StopLoss. Used only in method 1 for check signals quality
_________________________________________________________________________________________________________
method 1 /detailed/
step one:
- EA default values: and disable the final_optimisation parameter (enabled, averages trades, and we don't want that now), Built-in settings set to 'user'
- BarsRange1: range 5-50 with step 5 (pattern higher lower trades)
- BarsRange2: range 3-13 with step 2 (pattern higher lower trades)
- TakeProfit as above (unless you prefer otherwise, I recommend mine to start with)
- StopLoss you accept (100,150,200 it depends on the symbol and is only used to count bad signals)
Run optimisation with BarsRange1 and BarsRange2 selected. The results that the tester shows or does not show are not important. Important information is saved in the MT4/tester/files/ShortTrendReversal/*.txt file. The file is only created when StopLoss is greater than 0. Now open the created file. I recommend notepad++ for this because it reloads the file if it changes. Analyze the results.
Important: Once you have changed the optimisation parameters, you should clear the tester's cache, as the results will not appear in the html file. (when the tester finds results in the cache, it skips the calculations)
step two:
- narrow the ranges of BarsRange1 and 2
- min_dist: range 20-90 with step 10 /minimum distance from the previous order, 0 completely disables the limit/
- pending_dist: range 20-90 with step 10 /pending order distance, 0 disables pending orders/
- StopLoss set to 0
- enable final_optimisation
Run optimisation. Now choose what suits you. Additionally, once you have your optimisation results, you can set StopLoss as above call up the individual results. At this point /with StopLoss/ the result itself won't matter, but you can see and compare the new statistics in the file (MT4/tester/files/ShortTrendReversal/*.txt). Statistics will be different than before and will certainly be very helpful in making decisions. You can save selected results to a file with external parameters (MQL4/files/ShortTrendReversal/ReadFromFile.txt). Details can be found in the file.
My rules when backtesting Built-in settings: SAFE,MODERATE,AGGRESIVE
| SAFE: | BarsRange2 range 7-11 |
| MODERATE: | BarsRange2 range 5,7,9 |
| AGGRESIVE: | BarsRange2 range 3,5,7 |
_________________________________________________________________________________________________________
method 2 /fast and simple/ source code and optimisation sets: StrategyTester in pips
Everything as above in one go.
- from EA default settings: change Built-in settings to 'user'
- BarsRange1: range 5-50 with step 5 /pattern higher lower trades/
- BarsRange2: range 3-13 with step 2 /pattern higher lower trades/
- min_dist: range 20-90 with step 10 /minimum distance from the previous order, 0 completely disables the limit/
- pending_dist: range 20-90 with step 10 /pending order distance, 0 disables pending orders/
- TakeProfit set my TP first: M15: TP=15, M30: TP=20, H1: TP=30, H4: TP=40
- StopLoss set to 0
- enable final_optimisation
- enable StrategyTester in pips
- set filter rules
Run optimisation. When finished, open the HTML file from the tester directory, sort, select the good results, deselect the automatically selected ones if you want, and save to a CSV file in the 'csv_done' directory. Now deselect the previous optimisation parameters, enable 'test selected results' and select ONLY the 'stage1 results array' optimisation, e.g. in the range 1-200. Empty ones will be skipped. Now choose what suits you. If you test a single parameter setting, it will be displayed in the tester logs.
Important: Once you have changed the optimisation parameters, you should clear the tester's cache, as the results will not appear in the html file. (when the tester finds results in the cache, it skips the calculations)
Below is a .bat script for quick cleaning cache and delete last created file inside tester folders.
rem @echo off set mt4_path="full_path_to_metatrader4\tester\files\ShortTrendReversal" del %mt4_path%\..\..\caches\*.* /P del %mt4_path%\..\..\history\*.* /P for /F %%a in ('dir /B /O:-D /A:-D /T:C %mt4_path%\*.html') do del /P "%mt4_path%\%%a"&goto deldone :deldone for /F %%a in ('dir /B /O:-D /A:-D /T:C %mt4_path%\csv_done\*.html') do del /P "%mt4_path%\csv_done\%%a"&goto deldone :deldone pause
_________________________________________________________________________________________________________
Settings:
| BarsRange1 | main signal 1 /pattern higher lower trades/ |
| BarsRange2 | main signal 2 /pattern higher lower trades/ |
| min_dist | minimum distance from the previous order, 0 completely disables the limit |
| pending_dist | distance of pending order, 0 disables, negative value: distance from local maximums and minimums for pending orders |
| TakeProfit | M15: TP=15, M30: TP=20, H1: TP=30, H4: TP=40 |
| StopLoss | 100,150,200 /depends on the symbol/ |
| final_optimisation | enable/disable averaging |
| Built-in settings | user,SAFE,MODERATE,AGGRESIVE,ReadFromFile |
| TP,SL in %: | calculation in % for other instruments than currencies |
| Other trade settings: | |
| StartTrading: | set Start and Stop to 0:00, trading is active all the time, set Start and Stop to 9:9, trading is inactive all the time |
| StopTrading | end of trade, Start and Stop disabled for backtests |
| Lots | trade volume |
| dynamic_lots | each subsequent order is increased. modes: OFF, simple, fibo sequence, martingale. Max 10. |
| UseRiskManager | you know, risk manager |
| EntryRisk | %of capital per trade for leverage=100. the position size is always calculated the same as for leverage=100 (for secure) |
| MagicNumber | EA recognizes orders by number and _Period |
| Compatibility | leave default, use only with my Nash Equilibium EA |
| Graphics/Logs settings: | |
| GUI_enable | two graphical interface modes, simple GUI, also works in visual mode |
| Narrow/Fat font | Font family used: Arial Narrow, Arial Nova, Bahnschrift |
| UseSounds | on/off sounds |
| LogLvL | silent/MT4logs/alerts |
| ShowInitConfig | shows a window with parameters at startup |
| Advanced backtesting: | |
| StrategyTester in pips | (optimisation only), generates an HTML file in the tester directory. source code: StrategyTester in pips |
| MathAbs(AccLoss) < x * InitBalance | show if (optimisation only) |
| MathAbs(maxDD) < x * TotalProfit | show if (optimisation only) |
| MathAbs(maxDD) < x * Profit before maxDD | show if (optimisation only) |
| test selected results | only test settings saved in the .csv file (creates new HTML file in tester directory) |
| stage1 results array | in optimising, iterations of settings from a .csv file |
Built-in settings: user: all settings can be changed by the user for use or backtesting
SAFE,MODERATE,AGGRESIVE: all parameters from the first section are permanently set:
- BarsRange1, BarsRange2, min_dist, pending_dist are saved in arrays
- TakeProfit: M15: TP=15, M30: TP=20, H1: TP=30, H4: TP=40
- StopLoss is set to 0
- final_optimisation is enabled
ReadFromFile: During the first launch, EA will create a ReadFromFile.txt file in the folder MQL4/files/ShortTrendReversal/ with a saved SAFE table as an example of use. After backtesting, you can save the parameters there and you don't have to do anything else. This option not working on VPS.
Due to the fact that importing external DLL libraries is prohibited, I moved the window resize to the indicator. Source code below.
