top of page

Gold swing with ATR and RSI

Writer: ProRealAlgosProRealAlgos

Updated: Jun 15, 2023

18 lines of AI-generated code for swing trading Gold on the daily timeframe


The code


threshold = 10
atr = AverageTrueRange[14]

If (currentMonth >= 6) And (currentMonth <= 9) And (atr > threshold) And (rsi < 30) Then
// It's summer, ATR is above the threshold, and RSI is oversold, so we enter a long trade
Buy 1 contract at market
ElsIf (currentMonth >= 12) Or (currentMonth <= 3) And (atr > threshold) And (rsi > 70) Then
// It's winter, ATR is above the threshold, and RSI is overbought, so we enter a short trade
Sell 1 contract at market
EndIf

If (longOnMarket) And (rsi > 70) then
//The position is long, and RSI is overbought, so we exit the trade
sell at market
ElsIf (shortOnMarket) And (rsi < 30) Then
// The position is short, and RSI is oversold, so we exit the trade
exitshort at market
EndIf




Comments


Try the products free for 7 days

Easy setup • full version • get-started support

ProRealTime made easy

CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. On average 76% of retail investor accounts lose money when trading CFDs. Past performance is no guarantee of future results. You should consider whether you understand how CFDs work before starting.

Read full terms and conditions

ProRealTime™ is a trademark registered by the third-party entity ProRealTime SAS

We have no link with the ProRealTime™ entity that offers the ProRealTime™ trading software

Copyright ProRealAlgos 580648-4231
Harju maakond, Tallinn, Kesklinna linnaosa, Pille 13, 10173

bottom of page