Trading the spread of multiple symbols

Avatar
  • updated
  • Under review

Hi, from my initial research I think it might work very well to define a custom price as

p1 - x * p2

where p1 is the price of e.g. EURUSD

and p2 is the price of EURGBP


Basically, we are trading the spread here.


The main advantage of this approach is that the spread is always reverting. So If situations like covid as in march 2020 occur, the spread reverts because all assets went down.


If you are new to this concept, I can recommend this book: https://b-ok.cc/book/667720/3ffe3a?dsource=recommend

Image 1694


When the EA triggers an order to the custom symbol, there must be some specific logic which implemntes:

Going long of 1 lot with the custom asset, means:

going long of 1 lot of EURUSD and 1.3 short of EURGBP.

Vice versa for closing a position.



Avatar
0
Andrey Khatimlianskyi
  • Under review

Hannes, have you tried to generate such symbol in MT5 and to backtest the EA on it?

Avatar
0
Hannes Waser
Quote from Andrey Khatimlianskyi

Hannes, have you tried to generate such symbol in MT5 and to backtest the EA on it?

Thanks Andrey, I will try to do so this weekend. Exciting! :)

Avatar
0
Andrey Khatimlianskyi
Quote from Hannes Waser

Thanks Andrey, I will try to do so this weekend. Exciting! :)

How it goes? Have you tried to test on synthetic symbol

Avatar
0
Hannes Waser
Quote from Andrey Khatimlianskyi

How it goes? Have you tried to test on synthetic symbol

all right,  finally found time to do it. With little success.

Here is the spread analyzed within jupyter:

Initial look on USDCHF and GBPCHF

When I however try to import the data to my custom symbol, the importis colored in read but I dont see any error message:

However, when I try to run a backtest on the new SUSDGBP symbol, I always get the error in the journal that the symbol has not data for that period:

Here is the csv file for reference:

spread USDCHF-GBPCHF

Would be great if anyone can provide further insights.


Thanks in advance!


Avatar
0
Hannes Waser

corrected pdf (less typos and fixed the sign on the position explanation).

Tutorial Spread Trading

Avatar
0
Hannes Waser

I did some more trials and this time I got the custom symbol data to work - at least partially.

- Creating a custom symbol worked after I added spaces into the formula: "GBPCHF - 1.38 * USDCHF" instead of "GBPUSD-1.38*USDCHF"

- The data is available as 1M candles after June. Dont know why I can't run the backtest on older data - even if use the "request" button inside the custom symbol properties...

- When running the backtest the position sizes are always super small. The final equity is not really changing. However I can at least generate some trades and see them on the chart.

Here is the set file I created to obtain the results:

statarb_v0.set

I am afraid I won't be of any further help here tuning the internals of MT5. Andrey, I hope these first insights are of some help for you.

In summary, The spread has much less power runs, which break the martingale EAs. Due to this property, the spread can already be traded with a very simple CP-configuration like the provided above using actually StochasticK + TrendFilter.

I think having the possibility within CP to trade symbol spreads or maybe one day also a symbol "package", would bring us here to a new robustness level where rather larger hedge funds operate.


Avatar
0
Andrey Khatimlianskyi
Quote from Hannes Waser

I did some more trials and this time I got the custom symbol data to work - at least partially.

- Creating a custom symbol worked after I added spaces into the formula: "GBPCHF - 1.38 * USDCHF" instead of "GBPUSD-1.38*USDCHF"

- The data is available as 1M candles after June. Dont know why I can't run the backtest on older data - even if use the "request" button inside the custom symbol properties...

- When running the backtest the position sizes are always super small. The final equity is not really changing. However I can at least generate some trades and see them on the chart.

Here is the set file I created to obtain the results:

statarb_v0.set

I am afraid I won't be of any further help here tuning the internals of MT5. Andrey, I hope these first insights are of some help for you.

In summary, The spread has much less power runs, which break the martingale EAs. Due to this property, the spread can already be traded with a very simple CP-configuration like the provided above using actually StochasticK + TrendFilter.

I think having the possibility within CP to trade symbol spreads or maybe one day also a symbol "package", would bring us here to a new robustness level where rather larger hedge funds operate.


Hannes, I have some success with custom symbol testing.

Try to import symbol settings from the attached JSON file - GBPUSD_CHF_config.json (Ctrl + U -> Create custom symbol -> Import)

Custom symbol name has sense too, don't change it.

Here is visual testing of CP on custom symbol:



If you want to have longer history of spread, you should use custom script to generate and upload history.

Please, try to find it on mql5.com


Everything is possible )

Avatar
0
Hannes Waser
Quote from Andrey Khatimlianskyi

Hannes, I have some success with custom symbol testing.

Try to import symbol settings from the attached JSON file - GBPUSD_CHF_config.json (Ctrl + U -> Create custom symbol -> Import)

Custom symbol name has sense too, don't change it.

Here is visual testing of CP on custom symbol:



If you want to have longer history of spread, you should use custom script to generate and upload history.

Please, try to find it on mql5.com


Everything is possible )

Awesome!

What happens in the background when 0.1 lot of GBPUSD_CHF is going long? 


Based on the uploaded pdf analysis (see above), which looks like the spread started a down-trend recently.


I started this week a manual test (opening a position of a short position of  1xGBPCHF - 1.4 USDCHF)

and this is the result sofar:

Really looking forward to test your json file @Andrey.


Avatar
0
Andrey Khatimlianskyi
Quote from Hannes Waser

Awesome!

What happens in the background when 0.1 lot of GBPUSD_CHF is going long? 


Based on the uploaded pdf analysis (see above), which looks like the spread started a down-trend recently.


I started this week a manual test (opening a position of a short position of  1xGBPCHF - 1.4 USDCHF)

and this is the result sofar:

Really looking forward to test your json file @Andrey.


You can check yourself.

Just disable all order-management functions (SL, TP, martingale, trailing-stop, etc) and open a trade using panel.

You will also like this indicator, I guess — https://www.mql5.com/ru/code/11859 (description in Russian only).

Avatar
0
Hannes Waser
Quote from Andrey Khatimlianskyi

You can check yourself.

Just disable all order-management functions (SL, TP, martingale, trailing-stop, etc) and open a trade using panel.

You will also like this indicator, I guess — https://www.mql5.com/ru/code/11859 (description in Russian only).

Nice! Looks like a good tool for the research of "good" portfolios before putting one into CP.