juanj

Stochastic Gold Trader

Category: Strategies By: juanj Created: August 14, 2020, 8:53 AM
August 14, 2020, 8:53 AM
Strategies
29 Comments
Stochastic Gold Trader

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)

Download
Filename: Stochastic-Gold-Trader.itf
Downloads: 1864
juanj
juanj Master
My name is Juan Jacobs and I am an algorithmic trader and trading coach. After 7 years of corporate work as a Systems Analyst, I have decided to pursue my passion of trading on a full-time basis. My current focus area is that of 'smart' strategies based on 'Machine Learning'. You can find me at www.FXautomate.com or visit my PRC Marketplace Store here: https://market.prorealcode.com/store/fxautomate/
Author’s Profile

Comments

Jiankyr82
5 years ago
#

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.

superfalcio
5 years ago
#

Hello, on the 2h timeframe I got a better performance in terms of win% and profit factor. I just optimized some parameters of stochastic.

juanj
5 years ago
#

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.

jissey
5 years ago
#

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

jissey
5 years ago
#

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

CLAUDIOZ8
6 years ago
#

Hi Juanj, thank's. good work.

LaurentBZH35
6 years ago
#

It certainly need an other filter to run less time than 90% on market. Any suggestion ?

Jan
Jan
6 years ago
#

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.

annepfw
6 years ago
#

Hello Jan, i like to have your little programm of stoploss. thank

philnunn14
6 years ago
#

hi! Can you confirm which gold market, Minutes and units? On pro real time?

bibiyanki
6 years ago
#

doesn't work , not start

jebus89
6 years ago
#

heres a pic of 200K bars: https://imgur.com/JNKCJ6u

juanj
6 years ago
#

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,

Jan
Jan
6 years ago
#

This strategy is more than 90% in the market, do you reckon overnight interest costs in your strategy ?

Anonymous
6 years ago
#

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!

Lespa212
5 years ago
#

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.

delynot
6 years ago
#

Superbe stratégie, elle marche plutôt bien en H1 et H4. Merci ;)

juanj
6 years ago
#

Just be careful, this strategy has not been tested live

Gaspare
6 years ago
#

ho inserito una loss di -25 e un profit di +50 per cui dopo l'ottimizzazione i parametri dello stocastico sono 22 5 4

Gaspare
6 years ago
#

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

pranik
6 years ago
#

If stoch -1 then is equivalent to if stoch -1 <> 0 then

Poiloulou
6 years ago
#

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.

pranik
6 years ago
#

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

bertrandpinoy
6 years ago
#

hi Juanj, thank you. TF 1 h?

juanj
6 years ago
#

The '=' sign probably got lost during the copy/paste. It is always better to rather import the ITF file to avoid these formatting issues.

juanj
6 years ago
#

@Pranik that is exactly what I did? Line 39 looks at stoch = -1 and line 45 looks at stoch = 1

pranik
6 years ago
#

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

Gaspare
6 years ago
#

Ottimo TS grazie Juanj Si puo' adattare anche agli indici? Magari ci puoi suggerire qualche dritta per il mini SP500? Grazie

Anonymous
6 years ago
#

Hi Juanj, Thank you very much for sharing, at first glance this looks great. I look forward to testing further! Thanks

ProRealCode ProRealCode
Loading...