Golden Swing Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © in_pursuit

//@version=5
indicator(title = "Golden Swing Strategy",shorttitle = "GSS", overlay=true)

// RSI : Relative Strength Index
// Arguments : source (series int/float) Series of values to process.
// Argument : length (simple int) Number of bars (length).
// Returns : Relative strength index.
RSI = ta.rsi(source = close, length = 20)

//Stochastic
periodK = input.int(55, title="%K Length", minval=1)
smoothK = input.int(34, title="%K Smoothing", minval=1)
periodD = input.int(21, title="%D Smoothing", minval=1)
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

//supertrend
// Argument : factor (series int/float) The multiplier by which the ATR will get multiplied. 
// Argument : atrPeriod (simple int) Length of ATR.
// Returns : Tuple of two supertrend series: supertrend line and direction of trend. Possible values are 1 (up direction) and -1 (down direction).
[supertrend, direction] = ta.supertrend(factor = 2, atrPeriod = 10)

// Bollinger Bands.
//Arguments
// series (series int/float) Series of values to process.
// length (series int) Number of bars (length).
// mult (simple int/float) Standard deviation factor.
// Returns : Bollinger Bands.
[middle, upper, lower] = ta.bb(close, length = 20, mult = 2)

// Arguments : length (simple int) Length (number of bars back).
// Returns : Average true range.
// atr = ta.atr(length = 5)

// Check RSI >= 50
RSI_test_buy = RSI > 50
RSI_test_sell = RSI < 50

// Check Stochastic %K should be above %D
stoch_test_buy = k > d
stoch_test_sell = k < d

// Day Low/high Should be below/above SuperTrend
supertrend_low_test =  low < supertrend
supertrend_high_test = high > supertrend

// Day close Should be above SuperTrend
supertrend_close_test =  close > supertrend

// SuperTrend should remain green/red before & EOD
supertrend_green_test = direction == -1
supertrend_red_test = direction == 1

// SuperTrend should be below Mid Bollinger
supertrend_bb_test_buy = supertrend < middle
supertrend_bb_test_sell = supertrend > middle

//compute buy/sell result
buy = RSI_test_buy and stoch_test_buy and supertrend_low_test and supertrend_green_test and supertrend_bb_test_buy 
sell = RSI_test_sell and stoch_test_sell and supertrend_high_test and supertrend_red_test and supertrend_bb_test_sell

//plot
plotshape(buy, style=shape.triangleup, location = location.abovebar, color = color.green, size = size.small)
plotshape(sell, style=shape.triangledown, location = location.belowbar, color = color.red, size = size.small)