Self-Optimising MACD (Experimental)

Hi guys, just thought I'd share a small part of an idea i've been working on.

One of the biggest problems with algo trading is optimisation and finding a way to constantly adapt to the market conditions as time unfolds.

First of all... You should NEVER EVER trade just using a MACD , including this study, and I only produced this script in a small amount of time, so make sure you backtest it properly before using it. When backtesting, it is my advice that your sample size should be at least 5000 trades, but I recommend 10000 in order to get sufficient statistical significance.

Also, I am not a financial advisor, and any trading based decisions are your sole responsibility.


This script is simple... it simply uses 4 different MACD's and tracks their profit/loss and automatically uses the one with the most historical profit at any given time to execute a trade. The type of MACD will obviously change as market states fluctuate.

Included are : Hull MACD , Ema MACD , Sma MACD and VWMA Macd .

You can adjust all four of their settings to your desire.

The trade execution is simple and definitely flawed... it simply tracks the MACD when it has a crossover for long, and then the opposite for short.

The green line represents the performance of the top MACD for Longs at any given time. This line refreshes once a year, and where it is in relation to price, reflects how profitable it has been I.e - the higher it is the better.

The Red line represents the performance on the Short side, and again, it reflects profit/loss, but this time the LOWER the line is in relation to price the better.

There is no exit strategy in place! This is why I do NOT recommend trading off this script alone, but to use it as a tool to help optimise your choice of MACD .

However, your exit strategy could change your optimal choice of MACD , so keep that in mind.

The lookback period represents how far the script will track the performance at any given time. This will change your results. The longer the period, the more it will show long term success and vice versa.

This optimisation process could be done with different indicators, moving averages, or even multiple strategies to find the most statistically viable option at any given time... if you wish to have this process coded into your strategies or indicators, message me.

เอกสารเผยแพร่: *Smallupdate
สคริปต์นี้เผยแพร่แบบปิดและคุณสามารถใช้มันได้อย่างอิสระ คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้แต่คุณจะไม่สามารถดูหรือแก้ไขซอร์สโค้ดได้