Hi !
This is my first code. Very simple code I use manually.
It works on eurusd in M5 but maybe in other forex/indices
For now results on my demo account are the same as the backtest.
Sorry for bad english 🙂
Have a nice day.
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 170000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions pour ouvrir une position acheteuse
indicator1 = BollingerDown[20](close)
c1 = (close < indicator1)
indicator2 = Average[50](close)
c2 = (close > indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions pour fermer une position acheteuse
indicator3 = Average[20](close)
c3 = (close CROSSES OVER indicator3)
IF c3 THEN
SELL AT MARKET
ENDIF
// Conditions pour ouvrir une position en vente à découvert
indicator4 = BollingerUp[20](close)
c4 = (close > indicator4)
indicator5 = Average[50](close)
c5 = (close < indicator5)
IF (c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions pour fermer une position en vente à découvert
indicator6 = Average[20](close)
c6 = (close CROSSES UNDER indicator6)
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops et objectifs
SET STOP pLOSS 30
Thanks for sharing your automated strategy code. It seems to be not performing so well on a 200k bars backtest, that’s why I moved your post from the posts pending review list to the forum instead. However, the strategy is not bad, like many others based on mean reverting price behavior with triggers on Bollinger Bands. The fact that the moving average periods are not optimized is also encouraging.
MazParticipant
Veteran
@Nicolas any chance you can post the 200k bar curve? This will give clues on curve fitting etc
Hi! We have discussed this type of strategy under the topic below. @theaccountant – have a look, it might give you some new ideas.
Scalping EURUSD
Btw try to change the starting time for the strategy. Starting this kind of strategy later in the day when the London open is over can improve the result.
hello !
Yep i tried with different time but i think 9 to 17h gives me the best results 🙂
I have improved the eurusd version since:
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 170000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions pour ouvrir une position acheteuse
indicator1 = BollingerDown[20](close)
c1 = (close < indicator1)
indicator2 = Average[80](close)
c2 = (close > indicator2)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 5 CONTRACT AT MARKET
ENDIF
// Conditions pour fermer une position acheteuse
indicator3 = Average[35](close)
c3 = (close CROSSES OVER indicator3)
IF c3 THEN
SELL AT MARKET
ENDIF
// Conditions pour ouvrir une position en vente à découvert
indicator4 = BollingerUp[20](close)
c4 = (close > indicator4)
indicator5 = Average[80](close)
c5 = (close < indicator5)
IF (c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
SELLSHORT 5 CONTRACT AT MARKET
ENDIF
// Conditions pour fermer une position en vente à découvert
indicator6 = Average[35](close)
c6 = (close CROSSES UNDER indicator6)
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops et objectifs
SET STOP pLOSS 30
for now, result on demo account and backtest are the same.