I have been trading Gold more than usual recently and made an interesting observation regarding the trend waves moving very much in sync with the stochastic. So this prickled my curiosity enough to quickly code-up a strategy based on my observation. And despite the fact that I purposefully fine tuned (aka curve fitted) the stochastic parameters I still think the result is rather promising considering there really isn’t that many essential moving parts outside of the stochastic settings. Also as a professional PRT developer I no longer have the liberty of sharing as many strategies to the community as before, so I sincerely hope there is something that someone here might find useful.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
Defparam cumulateorders = False possize = 1 StochUpperLimit = 90 StochLowerLimit = 10 StochConsolidationPeriod = 2 StochPeriods = 18 StochK = 2 StochD = 6 StochSignal = Stochastic[StochPeriods,StochK](close) StochMain = average[StochD](StochSignal) RSI2 = RSI[2](close) RSIUpperLimit = 95 RSILowerLimit = 5 RSILimit = 4 once Stoch = 0 once StochCounter = 0 once RSICounter = 0 once RSICounterAdj = 0 once LastRSI = 50 If Stoch = 0 and lowest[StochConsolidationPeriod](StochSignal) < StochLowerLimit and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then Stoch = -1 StochCounter = 0 ElsIf Stoch = 0 and highest[StochConsolidationPeriod](StochSignal) > StochUpperLimit and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then Stoch = 1 StochCounter = 0 EndIf StochCounter = StochCounter + 1 If onmarket = 0 and Stoch -1 and StochCounter > 1 and StochSignal[1] <= StochMain[1] and StochSignal > StochMain Then Buy possize contract at market StochCounter = 0 RSICounter = 0 RSICounterAdj = 0 LastRSI = 50 ElsIf onmarket = 0 and Stoch = 1 and StochCounter > 1 and StochSignal[1] >= StochMain[1] and StochSignal < StochMain Then Sellshort possize contract at market StochCounter = 0 RSICounter = 0 RSICounterAdj = 0 LastRSI = 50 EndIf If longonmarket and RSI2[1] >= RSIUpperLimit and RSI2 < RSIUpperLimit Then RSICounter = RSICounter + 1 If highest[8](RSI2) < LastRSI Then RSICounterAdj = RSICounterAdj + 1 EndIf LastRSI = highest[8](RSI2) ElsIf shortonmarket and RSI2[1] <= RSILowerLimit and RSI2 > RSILowerLimit Then RSICounter = RSICounter + 1 If lowest[8](RSI2) > LastRSI Then RSICounterAdj = RSICounterAdj + 1 EndIf LastRSI = lowest[8](RSI2) EndIf If longonmarket and RSI2[1] < RSIUpperLimit and RSI2 >= RSIUpperLimit and RSICounter >= RSILimit-RSICounterAdj Then sell at market Stoch = 0 ElsIf shortonmarket and RSI2[1] > RSILowerLimit and RSI2 <= RSILowerLimit and RSICounter >= RSILimit-RSICounterAdj Then exitshort at market Stoch = 0 EndIf //Graph RSICounter //Graph RSILimit coloured(255,0,0) //Graph RSICounterAdj coloured(0,255,0) |
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
Hi Juanj,
Thank you very much for sharing, at first glance this looks great. I look forward to testing further!
Thanks
Ottimo TS grazie Juanj
Si puo’ adattare anche agli indici? Magari ci puoi suggerire qualche dritta per il mini SP500?
Grazie
Hi juanj, I don’t undestand line 39 on the uploaded code. There is a stoch -1 on the if statement. Maybe you wanted to write stoch = -1.
Thanks
@Pranik that is exactly what I did? Line 39 looks at stoch = -1 and line 45 looks at stoch = 1
The ‘=’ sign probably got lost during the copy/paste. It is always better to rather import the ITF file to avoid these formatting issues.
hi Juanj, thank you. TF 1 h?
Hi @Juanj, I imported itf file and the ‘=’ sign is missing. If I put stoch = -1 as you suggest the results are very different from yours. If I remove ‘=’ sign the results are the same.
Thanks
The question is how the program understand “Stoch -1”. Because if we remove it, or if we put Stoch = -1 it is not working at all.
If stoch -1 then
is equivalent to
if stoch -1 <> 0 then
io l’ho messo live e qualcosa non va: apre posizioni short, in accordo con lo stocastico che punta al ribasso, mentre sul backtest apre posizioni long.
Per adesso sono posizioni positive
ho inserito una loss di -25 e un profit di +50 per cui dopo l’ottimizzazione i parametri dello stocastico sono 22 5 4
Just be careful, this strategy has not been tested live
Superbe stratégie, elle marche plutôt bien en H1 et H4. Merci 😉
Hi – I’ve had a lot of fun testing this out, and trying various iterations and tweaks. Thank you once again for sharing. A nice little strategy in an asset class I don’t currently trade. A useful stop loss mechanism is what I am currently looking to incorporate, along with the ability to exit the market if the direction changes to that of the current trade. Will share when I have something that works.
Thanks once again, and keep posting!
Hi Samsampop,
are you using this strategy? did you add a SL and an exit in case of a trend reversal? I will be happy to see any improved version of this nice starting point .
Thank you.
This strategy is more than 90% in the market, do you reckon overnight interest costs in your strategy ?
Hi Jan, I did not include swap fees for this strategy as it is primarily a ‘concept strategy’. I do not personally trade this strategy live neither do I intend to,
heres a pic of 200K bars: https://imgur.com/JNKCJ6u
doesn’t work , not start
hi!
Can you confirm which gold market, Minutes and units?
On pro real time?
Thanks for sharing ! I tested it on the hourly graph, it gives very good profits, but also huge drawndowns. I tried a percentage stoploss, that reduces losses per trade, but that also reduces overall profit and % winners significantly.
Hello Jan, i like to have your little programm of stoploss. thank
It certainly need an other filter to run less time than 90% on market.
Any suggestion ?
Hi Juanj, thank’s. good work.
Bonjour Juanj , avez-vous un programme qui tourne en réel depuis au moins une année et avez-vous fait un backtest pour comparer les résultats ? Pour moi, je trouve qu’il y a des différences entre un backtest et la démo et encore une différence entre la démo et le réel, avez-vous constaté cela? Merci pour votre réponse, cordialement, jc
bonjour Juanj , avez-vous un programme qui tourne en réel depuis plus d’un an et comprer les résultats avec un backtest ? Merci pour votre réponse, cordialement
Hi Jissey, your observation is correct. There are most certainly differences between the backtest, demo and live. Please see the screenshots attached to my 2 strategies listed in the marketplace. They contain live results. Sometimes I update strategies after a few months meaning it is rare that I run the same version unchanged for a year.
Hello, on the 2h timeframe I got a better performance in terms of win% and profit factor. I just optimized some parameters of stochastic.
Juan thanks for sharing, I had played with it few days, as also try to catch up on my pro-real-time coding skills. Your codes are always great training. The philosophy’ of this strategy for gold is impressive good- that I noticed is the strategy is very effective on upside gold waves when gold goes up while work terribly on downsize waves. That I try to add if a supper trend flag – till now tried couple. I believe even if the simple pro-real-time super trend(3-10) may work, if solve it I will share it with you.