Ultimate Trailing Stop EA: Importing and Backtesting/Optimizing Signal History

Ultimate Trailing Stop EA: Importing and Backtesting/Optimizing Signal History

19 November 2022, 04:24
BLAKE STEVEN RODGER
0
589

Continued from main description blog of Ultimate Trailing Stop EAhttps://www.mql5.com/en/blogs/post/738506

Description

Because Ultimate Trailing Stop EA (UTS) is great at managing one's exits with 16 trailing stop methods, it can also be extremely useful to apply any of these methods to a subscribed signal, in order to enhance it. 

To this end, we built an advanced signal analysis tool within UTS so that you can import, backtest and optimize any trailing stop configuration on historical signal data, so long as it is in csv format (ex: MQL5 or Myfxbook signals).

This feature presents a more objective way to determine the ideal settings for the system you are interested in enhancing with your trailing stop.

You just need to download the CSV signal history, drop it into the Tester > Files directory, and configure the inputs below. 


Inputs

 

  • Report CSV files    You need to indicate the name of the history file that you have dropped into DataFolder > Tester > Files folder.
    For example, Report CSV Files=HeroSP500.csv

  • Code Page (Dropdown)   ANSI | UTF7 | UTF8

    Code Page Dropdown

    Different signalhistory.csv may be downloaded in different csv formats, and Code Page allows you to correct for each peculiar csv format. 

  • Data separator  You need to indicate the primary separator format of the signalname.csv file.

    For MQL5 signalhistory.csv, use ; (semi-colon), so that Data Separator=; 
    For Myfxbook signalhistory.csv, use . (period), so that Data Separator=.

  • Hour adjustment   You need to make the hourly adjustment if your broker is different from history file broker.  For example, if signalname.csv is derived from a broker with GMT= +1, and your broker had a GMT= +3, you indicate Hour Adjustment=2

  • Date format  — You need to indicate the date format of the signalhistory.csv file.

    For MQL5 signalhistory.csv, use yyyy/mm/dd, so that Date format=yyyy/mm/dd
    For Myfxbook signalhistory.csv, use mm/dd/yyyy, so that Date format=mm/dd/yyyy

  • Date Separator   You need to indicate the date separator of the csv file.

    For MQL5 signalhistory.csv, use . (period), so that Date separator=.
    For Myfxbook signalhistory.csv, use / (forward slash), so that Date separator=/

  • Symbol to use  You need to indicate the symbol to perform the test upon. For example, Symbol to use=SPX500

Steps to Import MQL5 Signal History in Strategy Tester. 

  1. On selected MQL5 signal, click on Trade History tab.  
                  MQL5 Signal Trade History Tab


  2. Scroll down to the bottom of the trade history and left click on Export to CSV: History 
                  MQL5 Signal History

  3. Signalhistory.csv will download to your computer with something like 7digits.history.csv (ex.1731202.history.csv). You might want to right click and rename this file to signalname.csv (ex. HeroSP500.csv)

  4. Copy and paste the signalname.csv file into your Terminal > Common > Files folder.
    To get to this folder:

    a) click on File > Open Data Folder

    b) Double click on Terminal Folder
    Click on Terminal

    c) double click on Common Folder
    Click on Common
    d) Double click on Files Folder

    Click on Files Folder
                 

  5. In Strategy Tester (View > Strategy Tester or Ctr+R), load Ultimate Trailing Stop EA and open up UTS inputs, and scroll down to the last input section.

  6. In Report CSV Files input, you indicate the exact name of the file (ex. Report CSV Files=HeroSP500.csv)

  7. Keep Code Page=ANSI

  8. You DO NOT need to adjust the following defaults (as they already work with MQL5 signals): 

    Data Separator=; 
    Date Format=yyyy/mm/dd
    Date Separator=/

     
  9.  You can adjust the hour adjustment to match your broker GMT time, if different from file broker. For example, if signalname.csv is derived from a broker with GMT= +1, and your broker had a GMT= +3, you indicate Hour Adjustment=2

  10. You can indicate Symbol to Use with the symbol you are using. In my case, I will implement Symbol to Use=SPX500

  11. You can keep or remove the defaults to Preserve Original SL/TP/Close:

    Preserve Original SL=true
    Preserve Original TP=true
    Preserve Original Close=true

Backtesting Signal History

After configuring your signalhistory.csv file within the inputs of UTS in Strategy Tester, it is time to backtest the signal history without any trailing stop configurations. 

Here are the steps I take: 

1. Make sure you have downloaded enough 1 minute data for your selected symbol. 

For instance, I am wanting to backtest HeroSP500.csv on SPX500 (Darwinex S&P500 symbol). Since the signal has trade history from March-1-2022 till Nov-17-2022, I want to make sure I have at least that much data loaded in MT4. To do so, I use a tool like Quant Data Manager (free with ads or $49 lifetime) to download 1 minute S&P500 data from Dukascopy.

You can also use the free, built in History Center (Tools > History Center or F2) to download historical data on most forex symbols. 

3. Because I'm using Quant Data Manager's 1 minute data, I then use Period Converter.mq4 script to turn that 1 minute data into M5, M15, M30 and H1. If using History Center to download historical data, all the relevant timeframes get auto-downloaded, so no need to use the Period Converter.mq4 script. 

4. I then prepare Strategy Tester settings.

Expert Advisor: Ultimate Trailing Stop EA

Symbol: The symbol you want to test for. In my case, it is SPX500.

Model: It is advised to use Model=EveryTick. However, it can be much faster to test on Model=Open prices only if your strategy uses open prices. 

Use Date: Adjust date to the range of the signalhistory.csv. In my case, it is from March 1, 2022 to Nov 18, 2022. 

Period: Your preferred timeframe period. I prefer something low, like M1 or M5 or M15, to get more accurate results. 



4. Very important. Disable the trailing stops of UTS by putting threshold out of reach, such as Threshold in Pips or ATR=1000. At this point, you want to conduct a backtest that matches your downloaded signal history, in order to establish a baseline performance. When you have the baseline performance, you can then put threshold back in reach and optimize different trailing stops in the Optimization stage. 

5. Run Strategy Tester by pressing Start Button. 

6. Verify that the Results more or less match your signal results. Below is my Hero SP500 signal results: 



In my case, the above results approximately match my trade signal history for the last 9 months for Hero SP500



As noted in the backtest, my signal's baseline performance is: 

Baseline (No Trailing Stop Configurations):

$781, 1.31 PF (176 trades), -435 DD, 4.44 Payoff. 


This baseline performance is good, but I want better.

I know my signal currently works with a 30 full-point S&P500 stop loss and a 65 full-point take profit. I want to see if it can benefit from adding a trailing stop. 

My goal is to see if I can increase returns and reduce draw downs. 

With this baseline performance on hand, I can see if adding an optimized trailing stop to my signal will increase its baseline performance. 

Optimizing Signal History: Example: Period/Multiplier of Chandelier Exit and Threshold in ATR

Ideally, one ought to test out all 16 trailing stops of Ultimate Trailing Stop EA to see which one improves the baseline performance. 

In my case, I have tried every one and discovered that Chandelier Exit has the most promise. 

After selecting Trailing Stop Method=Chandelier Exit, I am going to optimize three parameters in two steps:

  1. Chandelier ATR Period and Chandelier Multiplier.
  2. Threshold in ATR. 


Optimization#1:

The key to any optimization is to figure out what parameters have the most impact.

Knowing enough about Chandelier Exit, I think that the most impact comes from Chandelier ATR Period and Multiplier. I will preserve the defaults for Chandelier Range (7), Shift (1), and Show Channel (true).

I will also revert the global input, Threshold in Pips or ATR, back to its default, Threshold in Pips or ATR=0 (0=no threshold), for now. I will play with threshold in Optimization#2. 

I will optimize:

Chandelier ATR Period from 10 to 40, in step of 5

AND

Chandelier Multiplier from 3 to 6, in step of 0.5





When I click on Optimize button, I get the following result: 




As you can see, I discovered that Chandelier Period=30 and Chandelier ATR Multiplier=5.5 show the best result. 

If I apply this optimization result, my signal has increased in performance from:

Baseline (No Trailing Stop Configurations):

$781, 1.31 PF (176 trades), -435 DD, 4.44 Payoff. 

⬇️

Best Outcome of Optimization#1 (Chandelier Period=30 and Chandelier ATR Exit=5.5): 

$855, 1.45 PF (176 trades), -283 DD, 4.86 Payoff. 🚀🚀


Optimization#1 improves return by 9.5% and draw down by 35%. 



I make sure to input these newly optimized values into these two parameters. I then deselect the optimization checkmarks for these two parameters and proceed to the next optimization. 



Optimization#2:

The next optimization I will conduct is on threshold.

Since I am using a CFD contract, I know I will get the most impact of out of Threshold in ATR than Threshold in pips. 

Once I indicate Threshold in pips or ATR=ATR, I will optimize: 

Threshold in ATR from 0 to 5, in step of 0.5




When I click Optimize, I get the following result: 



As you can see, the best outcome is Threshold in ATR=2.

If I apply both optimizations, my signal has increased in performance from: 

Baseline (No Trailing Stop Configurations):

$781, 1.31 PF (176 trades), -435 DD, 4.44 Payoff 

⬇️

Best Outcome of Optimization#1 (Chandelier Period=30 and Chandelier ATR Exit=5.5):

$855, 1.45 PF (176 trades), -283 DD, 4.86 Payoff 🚀🚀

⬇️

Best Outcome of Optimization#2 (Threshold in ATR=2.0):  

$1224, 1.59 PF (176 trades), -312 DD, 6.96 Payoff 🚀🚀🚀


Compared to baseline, optimization#2 (which builds on optimization#1) improves return by 56% and decreases draw down by 28%. This is very promising. 

Here is the results in Strategy Tester: 



Now I can apply Ultimate Trailing Stop EA with the new .set file to my Darwinex MT4.


I'm confident that I elevated my EA/Signal by this optimized Chandelier Exit trailing stop facelift. 😃😃


Now you can do the same for any of your subscribed signals, or any signals you are considering.  




✅ Links

    🌐 Ultimate Trailing Stop EA >>  https://www.mql5.com/en/market/product/52283

    🌐 Ultimate Trailing Stop EA >>  https://www.mql5.com/en/market/product/73983

    🌐 Ultimate Trailing Stop EA Free (15-day Trial) >> Download

    🌐 Ultimate Trailing Stop EA Demo (restricted to AUDJPY, USDJPY, USDCAD, NZDUSD) >> https://www.mql5.com/en/market/product/52434

    🌐 Ultimate Trailing Stop EA MT5 Free (15-day Trial) >>  Download

    You can ask any questions about the work of the program in private messages on mql5 website or in Telegram or on my Telegram Group


    Share it with friends: