Dear All,
Here is a simple strategy, a slight improvement of my “End of Day USD/JPY“.
The timeframe is M15.
The strategy is so simple that it doesn’t need explanations (see in the code).
You can adapt the parameters, so that you can use it on USD/JPY (the best), AUD/JPY, EUR/JPY, GBP/JPY.
Regards,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
// END OF DAY - YEN // www.doctrading.fr Defparam cumulateorders = false // TAILLE DES POSITIONS n = 1 // PARAMETRES // high ratio = few positions // AUD/JPY : ratio = 0.5 / SL = 0.8 / TP = 1.2 / Period = 12 // EUR/JPY : ratio = 0.6 / SL = 1 / TP = 0.8 / Period = 8 // GBP/JPY : ratio = 0.5 / SL = 0.6 / TP = 1 / Period = 8 // USD/JPY : ratio = 0.5 / SL = 1 / TP = 0.8 / Period = 12 ratio = 0.5 // HORAIRES startTime = 210000 endTime = 231500 exitLongTime = 210000 exitShortTime = 80000 // STOP LOSS & TAKE PROFIT (%) SL = 1 TP = 0.8 Period = 12 // BOUGIE REFERENCE à StartTime if time = startTime THEN amplitude = highest[Period](high) - lowest[Period](low) ouverture = close endif // LONGS & SHORTS : every day except Fridays // entre StartTime et EndTime if time >= startTime and time <= endTime and dayOfWeek <> 5 then buy n shares at ouverture - amplitude*ratio limit sellshort n shares at ouverture + amplitude*ratio limit endif // Stop Loss & Take Profit set stop %loss SL set target %profit TP // Exit Time if time = exitLongTime then sell at market endif if time = exitShortTime then exitshort at market endif |
Share this
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 :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Here is a improvement with MOMENTUM.
For M15 TIMEFRAME
Thanks to a friend, “Calvin”.
The performance is better :
Ciao doctrading, grazie per il tuo contributo. Volevo chiederti se hai tenuto in osservazione il tuo sistema (sono passati 3 anni …). Ho provato a ritestare FINE GIORNATA ed attualmente ho riscontrato risultati molto interessanti anche con timeframe a 1 minuto anche introducendo il bel programma KAMA di Roberto Gozzi per gestire la posizione. Vorrei, se vuoi, proporre il codice.
// END OF DAY – YEN
// http://www.doctrading.fr
// + MOMENTUM (Calvin)
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMÈTRES
// Plus le “ratio” monte, moins il y a de positions
// USD/JPY : ratio = 0.4 / SL = 1 / TP = 0.8 / Period = 10
ratio = 0.4
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// INDICATEUR MOMENTUM
OTa = Momentum[26]
c1a = OTa > OTa[11]
MLTa = Momentum[280]
c2a = MLTa > MLTa[20]
OTv = Momentum[4]
c1v = OTv < OTv[5]
MLTv = Momentum[180]
c2v = MLTv = startTime and time <= endTime and dayOfWeek 5 and CONDBUY then
buy n shares at ouverture – amplitude*ratio limit
ENDIF
if time >= startTime and time <= endTime and dayOfWeek 5 and CONDSELL THEN
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
set stop %loss SL
set target %profit TP
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
Peut-être un poil sur-optimisé ? Une idée de la performance OOS ?
Hello,
Problème de copié collé ici : c2v = MLTv = startTime
Si je comprend bien on devrait pluto avoir c2v = MLTv > OTv ?
Hello doctrading.
Thank you for you sharing.
I try this strategy “+MOMENTUM “ver.
There is something I don’t understand.
It is written as ”CONDBUY” and “CONDSELL”and”s2v”, what should I define?
Also, please tell me the time zone you set.
In “dayofweek 5” where other errors occurred, “” (difference operator) was missing.
I can’t use it well except Japanese, so I’m sorry if it’s strange English.
Waiting for your answer.
Thank You for sharing.
PRT v10.3 says : Syntax error line 34 char 58, it’s pointig at the 5 [dayOfWeek 5].
Am I doing something wrong or is v11 needed ?
Cheers!
Bonjour et merci pour le partage,
Je n’arrive pas à exécuter le code avec le Momentum. J’ai une erreur de syntaxe. could y help 🙂 Thx
Avec plaisir ! 😉
Qu’entendez-vous par performance OOS Nicolas ?
Hors échantillon, puisqu’il me semble que la stratégie a été optimisée sur tout l’historique ? Voir les vidéos sur l’optimisation avec walk forward dans le blog.
Ah je n’utilise jamais le Walk Forward c’est pour ça.
Attention à la suroptimisation dans ce cas ! Si c’était aussi simple.. 😉 Tu devrais regarder les vidéos du blog sur le walk forward, toujours vérifier la robustesse d’une stratégie, c’est la base, à minima sur 30% de données post optimisation ( hors échantillon ou Out Of Sample en anglais).
bonjour Calvin,
merci pour votre contribution, sur quel critère avez-vous définis les valeurs du momuntum.
je souhaite l’adapter à mes stratégies, peut-on en discuter sur un forum ?
Bonjour pjanin972, c’est de l’optimisation.
C’est ces paramètres qui ont le mieux marché durant le backtest.
Hi all
Just a little optimization for USD/JPY M15.
Nice performance since 2018, you can do what you want with it (as is it a little bit “optimized”)
Profit factor > 3,5.
Regards,
//———————————————-
// Code principal : End Of Day – USD/JPY M15
// http://www.doctrading.fr
//———————————————-
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMÈTRES
// Plus le “ratio” monte, moins il y a de positions
ratio = 0.64
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// INDICATEUR MOMENTUM
OTa = Momentum[26]
c1a = OTa > OTa[11]
MLTa = Momentum[280]
c2a = MLTa > MLTa[20]
OTv = Momentum[4]
c1v = OTv < OTv[5]
MLTv = Momentum[180]
c2v = MLTv = startTime and time = startTime and time <= endTime and dayOfWeek 5 and dayOfWeek 0 and CONDSELL then
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
set stop %loss SL
set target %profit TP
//set stop loss amplitude * ratioSL
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
Hi Doctrading, Thanks for your code and there is error as follow! could you fix it?
c2v = MLTv = startTime and time <= endTime and dayOfWeek 5 and CONDBUY then
Hello guys, thanks for the code !
Hello guys, thanks !
bonsoir ,
@nicolas
j’ai mis le TP = 100 et la un gros bug .
il affiche gagnant alors quand on regarde de prêt il est perdant et il touche le TP .
position buy et le TP est en dessous de entrée
j’ai fait quelques test sur d’autres parités de devises et sour d’autres timeframes en prenant la strategie d’origine qui me semble assez optiminée,
Hi Doctrading, thanks for this nice and simple strategy. I really would like to backtest the strategy based on the momentum conditions. Is it possible for you to provide this?
AU account losses in AU time zone, spread 2pips, so set set platform hours to Europe +2 “Paris”
ON USDJPY mini, I’v back tested through the similar date rang from current period in 15mn TF 100000 units, “100000 is all you get here in Australia!”
Just trades some inefficient gains and losses and then the account to zero in an nose dive!
Not going to be running this with out a safety net, or ever. Altough some gains in lower tf, however i have not enough data to prove robustness.
Which brings on my question.
### Quit Function ###
If we have a whole or chasm is a strategy. Can we lock in gains with using the Quit function ?
So far i’m only able to use Quit function to close the strategy in a negative situation, or after gains, it quit’s still negative after all the hard work!
which is something like,
If StrategyProfit <-130 then
QUIT
Ouch, little bug with the code display…
Here it is :
//———————————————-
// Code principal : End Of Day – USD/JPY M15
// http://www.doctrading.fr
//———————————————-
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMÈTRES
// Plus le “ratio” monte, moins il y a de positions
ratio = 0.64
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// INDICATEUR MOMENTUM
OTa = Momentum[26]
c1a = OTa > OTa[11]
MLTa = Momentum[280]
c2a = MLTa > MLTa[20]
OTv = Momentum[4]
c1v = OTv < OTv[5]
MLTv = Momentum[180]
c2v = MLTv = startTime and time <= endTime and dayOfWeek 5 and dayOfWeek 0 and CONDBUY then
buy n shares at ouverture – amplitude*ratio limit
endif
if time >= startTime and time <= endTime and dayOfWeek 5 and dayOfWeek 0 and CONDSELL then
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
set stop %loss SL
set target %profit TP
//set stop loss amplitude * ratioSL
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
Hi Doctrading
Thanks for sharing a correction but the error is the same
PRT v10.3 says : Syntax error line 29 char 58, it’s pointig at the 5 [dayOfWeek 5].
Am I doing something wrong or is v11 needed ?
Cheers!
Hi, you need to insert “5”, in order to not trade on Fridays.
Bonjour
J’ai essayé ça ne fonctionne pas
J’ai une position perdante -21 800 yen.
Comment faites vous
Hi, there seems to be a copy/paste error at the end of the Momentum section. Also, the first “if” to enter market seems to have a copy/paste error, wouldit be possible to have a look look? Thanks!
je n’arrive pas non plus avec le dernier code
Syntax error line 29 char 58, it’s pointig at the 5 [dayOfWeek 5].
Bonjour.
Le problème est que mon copier coller de dayofweek 5 supprime le “”.
Désolé.
Il faut remettre ces “” après “dayofweek”.
Cordialement
Essayez donc cette version :
//———————————————-
// End Of Day – USD/JPY M15
// http://www.doctrading.fr
//———————————————-
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMÈTRES
// Plus le “ratio” monte, moins il y a de positions
ratio = 0.64
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// INDICATEUR MOMENTUM
OTa = Momentum[26]
c1a = OTa > OTa[11]
MLTa = Momentum[280]
c2a = MLTa > MLTa[20]
OTv = Momentum[4]
c1v = OTv < OTv[5]
MLTv = Momentum[180]
c2v = MLTv = startTime and time <= endTime and dayOfWeek 5 and dayofweek 0 and CONDBUY then
buy n shares at ouverture – amplitude*ratio limit
endif
if time >= startTime and time <= endTime and dayOfWeek 5 and dayofweek 0 and CONDSELL then
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
set stop %loss SL
set target %profit TP
//set stop loss amplitude * ratioSL
// Exit Time
if time = exitLongTime then
sell at market
endif
if time = exitShortTime then
exitshort at market
endif
Thanks for the strategy Doctrading! The updated version you have posted is really inconsistent though. Parameters are not defined, conditions are not defined, defined parameters are never used, if-statements that end but never started and so on. Would you mind taking a better look at it?
Still doesnt work for me. error line 29, character 58. Anyone know what to do?
Account goes emptied in 2 trades.
Non of the 3 versions you posted are valid code. Thanks to explain what the code should do with days. dayOfWeek seems messed up.
Bonjour Doctrading, avez-vous un programme qui tourne en réel depuis plus d’un an et comparer les résultats avec un backtest au jour J ? Sont_ils approchant ? Merci , cordialement.
Thanks Doctrading, I have modified the ratio, number of periods, close trade time slightly and it works well in backtest…particularly new trades on Sun, Mon and Tue only, across different pairs. I have also started real trading with just £1 per point, just to see how it goes. It is positive so far…BUT…any idea why the actual trades entered are much fewer than in backtest on some days? As below, overnight 6/7 June ACTUAL generated 1 trade whereas BACKTEST generated 6 trades. This is similar across different pairs and timeframes. 3/4 June and 2/3 June were fine. Am I missing something? Thanks
Backtest
Entry date Exit date Type Nbr Bars Abs Perf
06/06/2021 23:00 07/06/2021 04:30 Short 22 -£4.00
06/06/2021 22:45 06/06/2021 23:00 Long 1 £3.80
06/06/2021 22:30 06/06/2021 22:45 Short 1 £3.80
06/06/2021 22:00 06/06/2021 22:30 Long 2 £3.80
06/06/2021 21:45 06/06/2021 22:00 Short 1 £3.80
06/06/2021 21:30 06/06/2021 21:45 Long 1 £3.80
03/06/2021 21:00 04/06/2021 04:30 Short 30 £7.90
02/06/2021 21:30 03/06/2021 04:30 Short 28 -£10.70
01/06/2021 22:15 02/06/2021 04:30 Long 25 £16.90
Actual
Entry date Exit date Type Nbr Bars Abs Perf
06/06/2021 21:59 07/06/2021 04:30 Short 29 £0.30
03/06/2021 21:00 04/06/2021 04:30 Short 32 £8.50
02/06/2021 21:35 03/06/2021 04:30 Short 30 -£10.20
01/06/2021 22:24 02/06/2021 04:30 Long 27 £18.00
Buongiorno doctradinge buongiorno a tutti.
Vorrei riportare all’attenzione questo sistema postato tre anni fa perchè le performance sono ancora interessanti.
In particolare con USD/JPY i backtest sono ottimi negli ultimi 4 mesi, soprattutto con un timeframe di 1 minuto.
Se qualche membro della community ha la possibilità e la pazienza di effettuare backtest più lunghi sarebbe utile per capire se questo sistema è veramente ottimo.
Di seguito propongo una mia versione aggiornata in cui ho inserito la gestione della posizione tramite il sistema KAMA & SMA proposto da Roberto tempo fa, con uno stop fisso a 30.
Defparam cumulateorders = false
// TAILLE DES POSITIONS
n = 1
// PARAMETRES
// high ratio = few positions
// AUD/JPY : ratio = 0.5 / SL = 0.8 / TP = 1.2 / Period = 12
// EUR/JPY : ratio = 0.6 / SL = 1 / TP = 0.8 / Period = 8
// GBP/JPY : ratio = 0.5 / SL = 0.6 / TP = 1 / Period = 8
// USD/JPY : ratio = 0.5 / SL = 1 / TP = 0.8 / Period = 12
ratio = 0.6
period = 8
// HORAIRES
startTime = 210000
endTime = 231500
exitLongTime = 210000
exitShortTime = 80000
// BOUGIE REFERENCE à StartTime
if time = startTime THEN
amplitude = highest[Period](high) – lowest[Period](low)
ouverture = close
endif
// LONGS & SHORTS : every day except Fridays
// entre StartTime et EndTime
if time >= startTime and time <= endTime and dayOfWeek <> 5 then
buy n shares at ouverture – amplitude*ratio limit
sellshort n shares at ouverture + amplitude*ratio limit
endif
// Stop Loss & Take Profit
// Stop e target
//SET STOP PLOSS 25
//SET TARGET PPROFIT 13 //395
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Trailing Stop
//————————————————————————————
IF Not OnMarket THEN
TrailStart = 10 //10 Start trailing profits from this point
BasePerCent = 0.100 //10.0% Profit to keep
StepSize = 6 //6 Pips chunks to increase Percentage
PerCentInc = 0.100 //10.0% PerCent increment after each StepSize chunk
RoundTO = -0.5 //-0.5 rounds to Lower integer, +0.4 rounds to Higher integer
PriceDistance = 7 * pipsize//8.9 minimun distance from current price
y1 = 0
y2 = 0
ProfitPerCent = BasePerCent
ELSIF LongOnMarket AND close > (TradePrice + (y1 * pipsize)) THEN //LONG
x1 = (close – tradeprice) / pipsize //convert price to pips
IF x1 >= TrailStart THEN //go ahead only if N+ pips
Diff1 = abs(TrailStart – x1)
Chunks1 = max(0,round((Diff1 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks1 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y1 = max(x1 * ProfitPerCent, y1) //y = % of max profit
ENDIF
ELSIF ShortOnMarket AND close < (TradePrice – (y2 * pipsize)) THEN//SHORT
x2 = (tradeprice – close) / pipsize //convert price to pips
IF x2 >= TrailStart THEN //go ahead only if N+ pips
Diff2 = abs(TrailStart – x2)
Chunks2 = max(0,round((Diff2 / StepSize) + RoundTO))
ProfitPerCent = BasePerCent + (BasePerCent * (Chunks2 * PerCentInc))
ProfitPerCent = max(ProfitPerCent[1],min(100,ProfitPerCent))
y2 = max(x2 * ProfitPerCent, y2) //y = % of max profit
ENDIF
ENDIF
IF y1 THEN //Place pending STOP order when y>0
SellPrice = Tradeprice + (y1 * pipsize) //convert pips to price
IF abs(close – SellPrice) > PriceDistance THEN
IF close >= SellPrice THEN
SELL AT SellPrice STOP
ELSE
SELL AT SellPrice LIMIT
ENDIF
ELSE
SELL AT Market
ENDIF
ENDIF
IF y2 THEN //Place pending STOP order when y>0
ExitPrice = Tradeprice – (y2 * pipsize) //convert pips to price
IF abs(close – ExitPrice) > PriceDistance THEN
IF close <= ExitPrice THEN
EXITSHORT AT ExitPrice STOP
ELSE
EXITSHORT AT ExitPrice LIMIT
ENDIF
ELSE
EXITSHORT AT Market
ENDIF
ENDIF
set stop ploss 30
Hi,
Yes I am monitoring all the strategies posted on this site and I confirm that the strategy is a winner.
However I have just turned it OFF as it iseems to have entered a less favorable market configuration;
I will tell here when the Strategy can be lauched again according to my indicators.
I will also check your algo; thanks for sharing ^^