hi people, copy this to your custom quote!!!!
#START OF RSI/Stochastic/MACD Confluence Strategy for ThinkOrSwim
# RSM Strategy - BASIC
#CHANGELOG
# 2020.10.27 V1.0
@cos251 - Added RSI, StochasticSlow and MACD to same indicator
# - also calculates MACD;
# Will shade the lower plot area of the following conditions are met
# Shade GREEN = RSI > 50 and SlowK > 50 and (macd)Value > (macd)Avg
# Shade RED = RSI < 50 and SlowK < 50 and (macd)Value < (macd)Avg
#
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
# Stoch Slow 14 and 3 WILDERS
# MACD 12,26,9 WEIGHTED
declare upper;
################################################################
########## AddOrder Prep #########
################################################################
def bar = BarNumber();
def CloseAllCondition = SecondstillTime(1558) == 0;
def EOD = if SecondsTillTime(1558) == 0 and SecondsFromTime(1558) == 0 then 1 else 0;
def NotActive = if SecondsFromTime(1550) > 0 then 1 else 0;
def Active1 = if SecondsFromTime(0930) > 0 then 1 else 0;
def notrades = if SecondstillTime(1500) > 0 then 1 else 0;
################################################################
########## RSI #########
################################################################
input paintBars = yes;
input showShade = no;
input tradetype = { default "long", "short", "both" };
input lengthRSI = 7;
input price = close;
input averageTypeRSI = AverageType.EXPONENTIAL;
def NetChgAvg = MovingAverage(averageTypeRSI, price - price[1], lengthRSI);
def TotChgAvg = MovingAverage(averageTypeRSI, AbsValue(price - price[1]), lengthRSI);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
################################################################
########## Stochastic Slow #########
################################################################
input over_boughtSt = 100;
input over_soldSt = 50;
input KPeriod = 14;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageTypeStoch = AverageType.WILDERS;
def SlowK = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullK;
def SlowD = reference StochasticFull(over_boughtSt, over_soldSt, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageTypeStoch).FullD;
#################################################################
#MACD Calculation
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.WEIGHTED;
def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def Diff = Value - Avg;
#AssignPriceColor
AssignPriceColor(if paintBars and RSI >= 50 and SlowK >= 50 and Value > Avg then Color.GREEN else if paintBars and RSI < 50 and SlowK < 50 and Value < Avg then Color.RED else if paintBars then Color.white else Color.CURRENT);
#################################################################
############ Shade areas based on criteria; adjust as needed ##
#################################################################
AddCloud(if showShade and RSI >= 50 and SlowK >= 50 and Value > Avg then Double.POSITIVE_INFINITY else Double.NaN, if RSI >= 50 and SlowK >= 50 and Value > Avg then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_Green);
AddCloud(if showShade and RSI < 50 and SlowK < 50 and Value < Avg then Double.POSITIVE_INFINITY else Double.NaN, if RSI < 50 and SlowK < 50 and Value < Avg then Double.NEGATIVE_INFINITY else Double.NaN, Color.LIGHT_RED);
#################################################################
############ SCAN Variables #########
#################################################################
plot UpTrend = if RSI >= 50 and SlowK >= 50 and Value > Avg then 1 else 0;
plot DownTrend = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;
def LongBuy = if UpTrend == 1 and UpTrend[1] == 0 then 1 else 0;
def LongExit = if UpTrend[1] == 1 and UpTrend == 0 then 1 else 0;
def ShortSell = if DownTrend == 1 and DownTrend[1] == 0 then 1 else 0;
def ShortExit = if DownTrend == 0 and DownTrend[1] == 1 then 1 else 0;
UpTrend.Hide();
DownTrend.Hide();
AddLabel(yes, if UpTrend == 1 then "::RSM-Signal:LONG" else if DownTrend == 1 then "::RSM-Signal:SHORT" else "::RSM-Signal:IDLE", if UpTrend == 1 then Color.GREEN else if DownTrend == 1 then Color.RED else Color.yellow);
plot upArrow = if UpTrend == 1 and UpTrend[1] == 0 then low else Double.NaN;
upArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upArrow.SetDefaultColor(Color.GREEN);
plot downArrow = if DownTrend == 1 and DownTrend[1] == 0 then high else Double.NaN;
downArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downArrow.SetDefaultColor(Color.RED);
### BUY
#AddOrder(OrderType.BUY_TO_OPEN, LongBuy == 1 and (tradetype == tradetype.long or tradetype == tradetype.both), open, tickcolor = GetColor(9), #arrowcolor = GetColor(9), name = "LONG");
#AddOrder(OrderType.SELL_TO_CLOSE, LongExit == 1 and (tradetype == tradetype.long or tradetype == tradetype.both), open, tickcolor = #GetColor(9), arrowcolor = GetColor(9), name = "LONG_EXIT");
AddOrder(OrderType.BUY_AUTO, LongBuy == 1 and (tradetype == tradetype.long or tradetype == tradetype.both) and Active1 and notrades, price = close, tickcolor = Color.ORANGE, arrowcolor = Color.ORANGE, name = "BUY");
AddOrder(OrderType.Sell_To_Close, LongExit == 1 and (tradetype == tradetype.long or tradetype == tradetype.both), price = open[-1], tickcolor = Color.ORANGE, arrowcolor = Color.ORANGE, name = "Sell To Close");
AddOrder(OrderType.Sell_TO_CLOSE, EOD or closeAllCondition, price = close, tickcolor = Color.ORANGE, arrowcolor = Color.ORANGE, name = "SELL EOD");
### SELL
#AddOrder(OrderType.SELL_TO_OPEN, ShortSell == 1 and (tradetype == tradetype.short or tradetype == tradetype.both), open, tickcolor = #GetColor(9), arrowcolor = GetColor(8), name = "SHORT");
#AddOrder(OrderType.BUY_TO_CLOSE, ShortExit == 1 and (tradetype == tradetype.short or tradetype == tradetype.both), open, tickcolor = #GetColor(9), arrowcolor = GetColor(8), name = "Short_EXIT");
AddOrder(OrderType.SELL_AUTO, ShortSell == 1 and (tradetype == tradetype.short or tradetype == tradetype.both) and Active1 and notrades , price = close, tickcolor = Color.YELLOW, arrowcolor = Color.YELLOW, name = "SELL");
AddOrder(OrderType.Buy_To_Close, ShortExit == 1 and (tradetype == tradetype.short or tradetype == tradetype.both), price = open[-1], tickcolor = Color.ORANGE, arrowcolor = Color.ORANGE, name = "Buy To Close");
AddOrder(OrderType.BUY_TO_CLOSE, EOD or closeAllCondition, price = close, tickcolor = Color.ORANGE, arrowcolor = Color.ORANGE, name = "BUY EOD");