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.
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)
You must be logged in to post a comment.
Hello, on the 2h timeframe I got a better performance in terms of win% and profit factor. I just optimized some parameters of stochastic.
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.
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
It certainly need an other filter to run less time than 90% on market. Any suggestion ?
hi! Can you confirm which gold market, Minutes and units? On pro real time?
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 Juanj, thank you. TF 1 h?
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.