top of page

Gold swing with ATR and RSI

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




182 views0 comments

Recent Posts

See All
bottom of page