Hello everyone !
Here is a very interesting code and ready to debate.
In fact, I thought I had developed a “perfect” code.
And for good reason : on the GBP/CHF, it transforms (in 16.5 years), 10,000 € in 1.800.000.000 € in H1 charts, and in 1,000,000 € on H4 charts !
The problem is that I forgot the spread.
With a spread of 5 points, it falls to € 243,000 in H4 graphs while the performance is bad in H1 graphs !
Fortunately, in H4 graph the progress of capital curve is very smooth, and with a leverage of 1.5 we go to 1.5 million € of gains, with a drawdown from 16 to 25%, still acceptable.
And we can run this strategy automatically.
Curiously, it is far less profitable than my own algorithms that are set in DAILY graphs ; the spread kills everything, I begin to understand why some professional traders say that they only trade on Daily charts…
So here is the code.
It plays with rebounds in trend, defined by a moving averages channel, and MACD.
The code is optimized for the graphs in H4.
It works on almost all pairs of forex, but need to adjust depending on the timeframe (variable at the entry and exit points).
It required a lot of work from myself, I thought using automatic… but I will stay on my strategies in “Daily », which are finally far more efficient.
Even the “Breakout CAC40” is more efficient from 2008 to 2016.
Too bad, because the strategy seems very reliable and logical.
DEFPARAM CumulateOrders = false
// TAILLE DES POSITIONS
REINV = 1 // Mettre "0" pour ne pas avoir de réinvestissement des gains
levier = 1.5
IF REINV = 0 THEN
n = levier // pas de réinvestissement
IF REINV = 1 THEN // réinvestissement
capital = 10000 + strategyprofit
n = (capital / 10000) *levier
// DEFINITION DES INDICATEURS
MM3LOW = Average(low)
MM3HIGH = Average(high)
IndicMACD = MACD[10,18,6](close)
// Conditions pour ouvrir une position acheteuse
c1a = (IndicMACD > 0)
NivOuverturePasse = Open
IF c1a AND NivOuverturePasse < MM3LOW THEN
BUY n SHARES AT (MM3LOW-0.001) limit
// Conditions pour fermer une position acheteuse
SELL AT (MM3HIGH+0.001) limit
// VENTE A DECOUVERT
// Conditions pour vendre à découvert
c1v = (IndicMACD < 0)
NivOuverturePasse2 = Open
IF c1v AND NivOuverturePasse2 > MM3HIGH THEN
sellshort n SHARES AT (MM3HIGH+0.0005) limit
// Conditions pour fermer une position vendeuse
exitshort AT (MM3LOW+0.0005) limit
// STOP LOSS : NON
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :