RSM Indicator for ThinkorSwim

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

I got a dark background on my chart; how could I make the candle whiter or lighter when it is not printing green or red.
 
I got a dark background on my chart; how could I make the candle whiter or lighter when it is not printing green or red.
Look for the following block and replace "Color.Dark_Gray" with "Color.WHITE"

Ruby:
################################################################
##########         Assign Price Color                  #########
################################################################
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.DARK_GRAY else Color.CURRENT);
 
Is there a post in here detailing how to properly use THIS script, this strategy? It looks great.
 
@cos251 or anyone else monitoring this thread... I really like he ADR/ATR visual for backtesting purposes. I am currently struggling to add it to indicators through "transplanting" as my coding level is well below what is here. It seemed like the edit would be fairly simple adding the parameters for the entry (long or short signal) as
Code:
plot UpTrend = SellExit;
plot DownTrend = BuyExit;
And then adding the rest to get...
Code:
input tradetype = { "long", "short", default "both" };
input rangeType = { default "ADR", "ATR" };
input stopLossMultiplier = 1.0;
input plotADR = yes;
input showADRZones = yes;
input showCurrentTargetsOnly = yes;
input showTodayOnly = yes;
input showTrendLabels = no;
input showADRLabels = no;
input showExtraTargets = no;
input showExtraTargets789 = no;

def afterStart;
def beforeEnd;
def today;
def openPrice;
if GetAggregationPeriod() <= AggregationPeriod.DAY {
    afterStart = GetTime() > RegularTradingStart(GetYYYYMMDD());
    beforeEnd = GetTime() < RegularTradingEnd(GetYYYYMMDD());
    today = if GetLastDay() == GetDay() then 1 else Double.NaN;
    openPrice = DailyOpen();
} else {
    afterstart = Double.NaN;
    beforeEnd = Double.NaN;
    today = Double.NaN;
    openPrice = Double.NaN;
}

#################################################################
############        ADR/ATR Targets Shading              #########
#################################################################
input ATRlength = 14;
input ATRaverageType = AverageType.WILDERS;
def Range;
if rangeType == rangeType.ATR {
    Range = MovingAverage(ATRaverageType, TrueRange(high, close, low), ATRlength);
} else {
    Range = Average(high - low, 7);
}

plot UpTrend = SellExit;
plot DownTrend = BuyExit;

def bnumUp;
def bnumDown;
def closeUpTrendStart;
def closeDownTrendStart;
def UpTrendBarCount;
def DownTrendBarCount;
if UpTrend and (!UpTrend[1] or DownTrend[1]) {
    bnumUp = BarNumber();
    bnumDown = 0;
    closeUpTrendStart = close;
    closeDownTrendStart = 0;
    UpTrendBarCount = 1;
    DownTrendBarCount = 0;
} else if UpTrend {
    bnumUp = bnumUp[1];
    bnumDown = 0;
    closeUpTrendStart = closeUpTrendStart[1];
    closeDownTrendStart = 0;
    UpTrendBarCount = UpTrendBarCount[1] + 1;
    DownTrendBarCount = 0;
} else if DownTrend and (!DownTrend[1] or UpTrend[1]) {
    bnumUp = 0;
    bnumDown = BarNumber();
    closeDownTrendStart = close;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 1;
} else if DownTrend {
    bnumDown = bnumDown[1];
    closeDownTrendStart = closeDownTrendStart[1];
    DownTrendBarCount = DownTrendBarCount[1] + 1;
    bnumUp = 0;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
} else {
    bnumUp = 0;
    bnumDown = 0;
    closeUpTrendStart = 0;
    closeDownTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 0;
}
def c;
if BarNumber() == bnumUp or BarNumber() == bnumDown {
    c = Range;
} else if UpTrend or DownTrend {
    c = c[1];
} else {
    c = 0;
}

def up = if UpTrend   then bnumUp   else Double.NaN;
def dn = if DownTrend then bnumDown else Double.NaN;
# - UpTrend Targets and StopLoss
plot UpTrendStopLoss = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart - (c * stopLossMultiplier) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart - c else Double.NaN;
plot oneADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 1) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + c else Double.NaN;
plot twoADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 2) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + (c * 2) else Double.NaN;
plot threeADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 3) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + (c * 3) else Double.NaN;
plot fourADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 4) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 4) else Double.NaN;
plot fiveADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 5) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 5) else Double.NaN;
plot sixADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 6) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 6) else Double.NaN;
plot sevenADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 7) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 7) else Double.NaN;
plot eightADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 8) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 8) else Double.NaN;
plot nineADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 9) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 9) else Double.NaN;

# - DownTrend Targets and StopLoss
plot DownTrendStopLoss = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart + (c * stopLossMultiplier) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart + c else Double.NaN;
plot oneADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - c else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - c else Double.NaN;
plot twoADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - (c * 2) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - (c * 2) else Double.NaN;
plot threeADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - (c * 3) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - (c * 3) else Double.NaN;
plot fourADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 4) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 4) else Double.NaN;
plot fiveADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 5) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 5) else Double.NaN;
plot sixADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 6) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 6) else Double.NaN;
plot sevenADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 7) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 7) else Double.NaN;
plot eightADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 8) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 8) else Double.NaN;
plot nineADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 9) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 9) else Double.NaN;

UpTrendStopLoss.SetDefaultColor(Color.LIGHT_RED);
oneADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
twoADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
threeADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
fourADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
fiveADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
sixADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
sevenADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
eightADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
nineADRPlus.SetDefaultColor(Color.LIGHT_GREEN);

DownTrendStopLoss.SetDefaultColor(Color.LIGHT_GREEN);
oneADRMinus.SetDefaultColor(Color.LIGHT_RED);
twoADRMinus.SetDefaultColor(Color.LIGHT_RED);
threeADRMinus.SetDefaultColor(Color.LIGHT_RED);
fourADRMinus.SetDefaultColor(Color.LIGHT_RED);
fiveADRMinus.SetDefaultColor(Color.LIGHT_RED);
sixADRMinus.SetDefaultColor(Color.LIGHT_RED);
sevenADRMinus.SetDefaultColor(Color.LIGHT_RED);
eightADRMinus.SetDefaultColor(Color.LIGHT_RED);
nineADRMinus.SetDefaultColor(Color.LIGHT_RED);
All of which seems to be the pieces for getting the SL and TP targets. Am I missing something?

EDIT: Yes I know this is not a complete code above, just the portion of the code that deals with plotting ADR/ATR targets on chart
 
Last edited:
  • Like
Reactions: IPA
anybody know What is the red green and gray line in the screenshot of post on jan 29, 2021 by @cos251
No, not sure. But if you find that you are getting lines or signals on your chart that you are unsure of.
You can create a post:
  • Include a screenshot of your chart and a shared chart link. This will help others understand the context of your question and allow them to replicate the conditions that you are describing.
  • Annotate your image, highlighting the confluence that you're trying to achieve, along with a more detailed written explanation. This will help others understand your question even better and give them more specific information to work with.
If you're unsure of how to share chart links or upload screenshots to the forum, don't worry, we've included some easy-to-follow directions for you.
How to create a shared chart link:
https://usethinkscript.com/threads/how-to-share-a-chart-in-thinkorswim.14221/
How to upload screenshots to the forum:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58714
 
Perfect.
Code for Watchlist Posed per Request.

Code:
# RSM_WL
#
#CHANGELOG
# 2021.1.31 - V1.0 @SuryaKiranC - RSM Watch List study - to be used as watchlist:
#              Based on @Cos251 RSM_SCAN Code.
#            - Stocks currently in UpTrend
#            - Stocks currently in DownTrend
#            - Stocks where UpTrendJustSarted - first bar of UpTrend for scanend TF
#            - Stocks where DownTrendJustStarted - first bar of DownTrend for scanned TF
#            - Stocks where UpTredJustEnded - first NO Trend bar after UpTrend
#            - Stocks where DownTrendJustEnded - first NO Trend bar after DownTrend
#            - Recommend using default studies for SCANS of RSI, Stochastics or MACD for efficiency
#           
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 14 and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#
#
#CREDITS
# requesed by "@Joseph Patrick 18"
#
#LINK
# https://rockwell-files.s3.amazonaws.com/PXCompanionGuide2ndEd_cover.pdf
# Markus Heikoetter who is the author of the Power X Strategy
# https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#
################################################################
##########                 RSI                         #########
################################################################

def lengthRSI = 7;
def price = close;
def 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             #########
################################################################
def over_boughtSt = 80;
def over_soldSt = 20;
def KPeriod = 14;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def averageTypeStoch = AverageType.WILDERS;
def SlowK = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  priceH,  priceL,  priceC,  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;
def SlowD = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  priceH,  priceL,  priceC,  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

#################################################################
############           MACD Calculation                 #########
#################################################################
def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
def averageTypeMACD = AverageType.WEIGHTED;
def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def Diff = Value - Avg;

#################################################################
############          SCAN Variables                    #########
#################################################################

# If you want to scan for stocks that are not in either trend you can add two filters and scan for false for both conditions

# The UpTrend and DownTrend plots can be used to scan for stocks that are currently in that trend
def UpTrend = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else 0;
def DownTrend = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;

# The UpTrendJustStarted and DownTrendJustStarted plots can be used to find stocks that have just started
# a trend in either direction
def UpTrendJustStartedBool = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else 0;
def DownTrendJustStartedBool = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;
def UpTrendJustStarted = if UpTrendJustStartedBool == 1 and UpTrendJustStartedBool[1] == 0 then 1 else 0;
def DownTrendJustStarted = if DownTrendJustStartedBool == 1 and DownTrendJustStartedBool[1] == 0 then 1 else 0;
def UpTrendJustEnded = if UpTrendJustStartedBool[1] == 1 and UpTrendJustStartedBool == 0 then 1 else 0;
def DownTrendJustEnded = if DownTrendJustStartedBool[1] == 1 and DownTrendJustStartedBool == 0 then 1 else 0;

def GetTrend = if UptrendJustStarted then 3 else if Uptrend then 2 else if UpTrendJustEnded then 1 else if DownTrendJustStarted then -1 else if DownTrend then -2 else if DownTrendJustEnded then -3 else 0;

AddLabel (yes, if GetTrend == 3 then "UpTrendJustStarted" else if GetTrend == 2 then "UpTrend" else if GetTrend == 1 then "UpTrendJustEnded" else if GetTrend == -1  then "DownTrendJustStarted" else if GetTrend == -2  then "DownTrend" else if GetTrend == -3 then "DownTrendJustEnded" else "NoTrend",Color.BLACK);

AssignBackgroundColor( if GetTrend == 3 then Color.LIGHT_GREEN else if GetTrend == 2 then Color.Green else if GetTrend == -1 then Color.LIGHT_RED else if GetTrend == -2 then Color.RED else Color.WHITE);

Version 1.1 For watch list with BarCount Since Up/Down Trend has started. Only for those 2 trends coded for now. Please use Version 1.0 if you have performance concerns, I haven't tested the code during market hours yet.

Code:
# RSM_WL
#
#CHANGELOG
# 2021.3.5  - V1.1 @SuryaKiranC - BarCount for how long Up/Down Trend is in progress.
# 2021.1.31 - V1.0 @SuryaKiranC - RSM Watch List study - to be used as watchlist:
#              Based on @Cos251 RSM_SCAN Code.
#            - Stocks currently in UpTrend
#            - Stocks currently in DownTrend
#            - Stocks where UpTrendJustSarted - first bar of UpTrend for scanend TF
#            - Stocks where DownTrendJustStarted - first bar of DownTrend for scanned TF
#            - Stocks where UpTredJustEnded - first NO Trend bar after UpTrend
#            - Stocks where DownTrendJustEnded - first NO Trend bar after DownTrend
#            - Recommend using default studies for SCANS of RSI, Stochastics or MACD for efficiency
#             
#REQUIREMENTS - RSI Set to 7, EXPONENTIAL
#               Stoch Slow 14 and 3 WILDERS
#               MACD 12,26,9 WEIGHTED
#
#
#CREDITS
# requesed by "@Joseph Patrick 18"
#
#LINK
# https://rockwell-files.s3.amazonaws.com/PXCompanionGuide2ndEd_cover.pdf
# Markus Heikoetter who is the author of the Power X Strategy
# https://usethinkscript.com/threads/mimicking-power-x-strategy-by-markus-heitkoetter.4283/
#
################################################################
##########                 RSI                         #########
################################################################

def lengthRSI = 7;
def price = close;
def 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             #########
################################################################
def over_boughtSt = 80;
def over_soldSt = 20;
def KPeriod = 14;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def averageTypeStoch = AverageType.WILDERS;
def SlowK = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  priceH,  priceL,  priceC,  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;
def SlowD = reference StochasticFull(over_boughtSt,  over_soldSt,  KPeriod,  DPeriod,  priceH,  priceL,  priceC,  3, if (averageTypeStoch == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullD;

#################################################################
############           MACD Calculation                 #########
#################################################################
def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
def averageTypeMACD = AverageType.WEIGHTED;
def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def Diff = Value - Avg;



#################################################################
############          SCAN Variables                    #########
#################################################################

# If you want to scan for stocks that are not in either trend you can add two filters and scan for false for both conditions

# The UpTrend and DownTrend plots can be used to scan for stocks that are currently in that trend
def UpTrend = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else 0;
def DownTrend = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;

def bnumUp;
def bnumDown;
def closeUpTrendStart;
def closeDownTrendStart;
def UpTrendBarCount;
def DownTrendBarCount;
if UpTrend and (!UpTrend[1] or DownTrend[1]) {
    bnumUp = BarNumber();
    bnumDown = 0;
    closeUpTrendStart = close;
    closeDownTrendStart = 0;
    UpTrendBarCount = 1;
    DownTrendBarCount = 0;
} else if UpTrend {
    bnumUp = bnumUp[1];
    bnumDown = 0;
    closeUpTrendStart = closeUpTrendStart[1];
    closeDownTrendStart = 0;
    UpTrendBarCount = UpTrendBarCount[1] + 1;
    DownTrendBarCount = 0;
} else if DownTrend and (!DownTrend[1] or UpTrend[1]) {
    bnumUp = 0;
    bnumDown = BarNumber();
    closeDownTrendStart = close;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 1;
} else if DownTrend {
    bnumDown = bnumDown[1];
    closeDownTrendStart = closeDownTrendStart[1];
    DownTrendBarCount = DownTrendBarCount[1] + 1;
    bnumUp = 0;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
} else {
    bnumUp = 0;
    bnumDown = 0;
    closeUpTrendStart = 0;
    closeDownTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 0;
}

# The UpTrendJustStarted and DownTrendJustStarted plots can be used to find stocks that have just started
# a trend in either direction
def UpTrendJustStartedBool = if RSI > 50 and SlowK > 50 and Value > Avg then 1 else 0;
def DownTrendJustStartedBool = if RSI < 50 and SlowK < 50 and Value < Avg then 1 else 0;
def UpTrendJustStarted = if UpTrendJustStartedBool == 1 and UpTrendJustStartedBool[1] == 0 then 1 else 0;
def DownTrendJustStarted = if DownTrendJustStartedBool == 1 and DownTrendJustStartedBool[1] == 0 then 1 else 0;
def UpTrendJustEnded = if UpTrendJustStartedBool[1] == 1 and UpTrendJustStartedBool == 0 then 1 else 0;
def DownTrendJustEnded = if DownTrendJustStartedBool[1] == 1 and DownTrendJustStartedBool == 0 then 1 else 0;

def GetTrend = if UptrendJustStarted then 3 else if Uptrend then 2 else if UpTrendJustEnded then 1 else if DownTrendJustStarted then -1 else if DownTrend then -2 else if DownTrendJustEnded then -3 else 0;

AddLabel (yes, if GetTrend == 3 then "UpTrendJustStarted" else if GetTrend == 2 then "BC:" + UpTrendBarCount + " UpTrend" else if GetTrend == 1 then "UpTrendJustEnded" else if GetTrend == -1  then "DownTrendJustStarted" else if GetTrend == -2  then "BC:" + DownTrendBarCount + " DownTrend" else if GetTrend == -3 then "DownTrendJustEnded" else "NoTrend",Color.BLACK);

AssignBackgroundColor( if GetTrend == 3 then Color.LIGHT_GREEN else if GetTrend == 2 then Color.Green else if GetTrend == -1 then Color.LIGHT_RED else if GetTrend == -2 then Color.RED else Color.WHITE);

i cant figure out how to creat a watchlist using this, please help : )
 
Is it possible to show only the latest occurence for the RSM Up or Down Signal targets so that there is less clutter on the chart ? Would be extremely grateful if the option is made available. tks
 
Is it possible to show only the latest occurence for the RSM Up or Down Signal targets so that there is less clutter on the chart ? Would be extremely grateful if the option is made available. tks
It's built in, set showTodayonly and set ShowCurrentTrend to Yes, I may be off on those parameters will look and tell, if you can't find it.
 
Is it possible to show only the latest occurence for the RSM Up or Down Signal targets so that there is less clutter on the chart ? Would be extremely grateful if the option is made available. tks
Its in the RSM_Upper code already v1.9 >> input showCurrentTargetsOnly = yes;

2021.05.11 V1.9 @cos251 - Added feature to plot only current ADR Targets and Stoploss
# - Feature credit goes to @SleepyZ (thx)
 
Greetings. I use this every day but can't figure out how to add in the RSM MTF labels a candle count. So I am referring to the original developers to possibly have them look into this. Is there any way to do this ? So @SuryaKiranC, @cos251 Any possibility ?
 
Last edited:
Is it at all possible to have this portion of the code plot when the entry signal is given for assessment purposes? I know the function is purposely set up to take an entry after the first candle close but being able to see your target/stop before that would be useful. If anyone could help I'd appreciate it, thanks.

Code:
############          ADR/ATR Zone Shading              #########
#################################################################
def u = if UpTrend then closeUpTrendStart else Double.NaN;
def d = if DownTrend then closeDownTrendStart else Double.NaN;
def bnumUpCheck = if bnumUp != 0 then 1 else Double.NaN;
def bnumDownCheck = if bnumDown != 0 then 1 else Double.NaN;

AddCloud(if showADRZones and UpTrend and bnumUpCheck and showExtraTargets and showExtraTargets789 then nineADRPlus else if showADRZones and UpTrend and bnumUpCheck and showExtraTargets then sixADRPlus else if showADRZones and UpTrend and bnumUpCheck then threeADRPlus else Double.NaN, if showADRZones and UpTrend and bnumUpCheck then u else Double.NaN , CreateColor(0, 100, 0));
AddCloud(if showADRZones and UpTrend then u else Double.NaN, if showADRZones and UpTrend then UpTrendStopLoss else Double.NaN , CreateColor(139, 0, 0));

# - Shade Downtrend ADR/ATR zones
AddCloud( if showADRZones and DownTrend and bnumDownCheck then d else Double.NaN ,if showADRZones and DownTrend and bnumDownCheck and showExtraTargets and showExtraTargets789 then nineADRminus else if showADRZones and DownTrend and bnumDownCheck and showExtraTargets then sixADRMinus else if showADRZones and DownTrend and bnumDownCheck then threeADRMinus else Double.NaN, CreateColor(0, 100, 0));

AddCloud(if showADRZones and DownTrend then DownTrendStopLoss else Double.NaN, if showADRZones and DownTrend then d else Double.NaN, CreateColor(139, 0, 0));
 
Greetings. I use this every day but can't figure out how to add in the RSM MTF labels a candle count. So I am referring to the original developers to possibly have them look into this. Is there any way to do this ? So @SuryaKiranC, @cos251 Any possibility ?
Is it at all possible to have this portion of the code plot when the entry signal is given for assessment purposes? I know the function is purposely set up to take an entry after the first candle close but being able to see your target/stop before that would be useful. If anyone could help I'd appreciate it, thanks.

Code:
############          ADR/ATR Zone Shading              #########
#################################################################
def u = if UpTrend then closeUpTrendStart else Double.NaN;
def d = if DownTrend then closeDownTrendStart else Double.NaN;
def bnumUpCheck = if bnumUp != 0 then 1 else Double.NaN;
def bnumDownCheck = if bnumDown != 0 then 1 else Double.NaN;

AddCloud(if showADRZones and UpTrend and bnumUpCheck and showExtraTargets and showExtraTargets789 then nineADRPlus else if showADRZones and UpTrend and bnumUpCheck and showExtraTargets then sixADRPlus else if showADRZones and UpTrend and bnumUpCheck then threeADRPlus else Double.NaN, if showADRZones and UpTrend and bnumUpCheck then u else Double.NaN , CreateColor(0, 100, 0));
AddCloud(if showADRZones and UpTrend then u else Double.NaN, if showADRZones and UpTrend then UpTrendStopLoss else Double.NaN , CreateColor(139, 0, 0));

# - Shade Downtrend ADR/ATR zones
AddCloud( if showADRZones and DownTrend and bnumDownCheck then d else Double.NaN ,if showADRZones and DownTrend and bnumDownCheck and showExtraTargets and showExtraTargets789 then nineADRminus else if showADRZones and DownTrend and bnumDownCheck and showExtraTargets then sixADRMinus else if showADRZones and DownTrend and bnumDownCheck then threeADRMinus else Double.NaN, CreateColor(0, 100, 0));

AddCloud(if showADRZones and DownTrend then DownTrendStopLoss else Double.NaN, if showADRZones and DownTrend then d else Double.NaN, CreateColor(139, 0, 0));
Thanks for sharing your suggestions! Currently, it doesn't look like the OP has any plans for additional enhancements.
However, don't let that stop you! Keep posting your ideas, you never know what the future might bring.
 
@cos251 or anyone else monitoring this thread... I really like he ADR/ATR visual for backtesting purposes. I am currently struggling to add it to indicators through "transplanting" as my coding level is well below what is here. It seemed like the edit would be fairly simple adding the parameters for the entry (long or short signal) as
Code:
plot UpTrend = SellExit;
plot DownTrend = BuyExit;
And then adding the rest to get...
Code:
input tradetype = { "long", "short", default "both" };
input rangeType = { default "ADR", "ATR" };
input stopLossMultiplier = 1.0;
input plotADR = yes;
input showADRZones = yes;
input showCurrentTargetsOnly = yes;
input showTodayOnly = yes;
input showTrendLabels = no;
input showADRLabels = no;
input showExtraTargets = no;
input showExtraTargets789 = no;

def afterStart;
def beforeEnd;
def today;
def openPrice;
if GetAggregationPeriod() <= AggregationPeriod.DAY {
    afterStart = GetTime() > RegularTradingStart(GetYYYYMMDD());
    beforeEnd = GetTime() < RegularTradingEnd(GetYYYYMMDD());
    today = if GetLastDay() == GetDay() then 1 else Double.NaN;
    openPrice = DailyOpen();
} else {
    afterstart = Double.NaN;
    beforeEnd = Double.NaN;
    today = Double.NaN;
    openPrice = Double.NaN;
}

#################################################################
############        ADR/ATR Targets Shading              #########
#################################################################
input ATRlength = 14;
input ATRaverageType = AverageType.WILDERS;
def Range;
if rangeType == rangeType.ATR {
    Range = MovingAverage(ATRaverageType, TrueRange(high, close, low), ATRlength);
} else {
    Range = Average(high - low, 7);
}

plot UpTrend = SellExit;
plot DownTrend = BuyExit;

def bnumUp;
def bnumDown;
def closeUpTrendStart;
def closeDownTrendStart;
def UpTrendBarCount;
def DownTrendBarCount;
if UpTrend and (!UpTrend[1] or DownTrend[1]) {
    bnumUp = BarNumber();
    bnumDown = 0;
    closeUpTrendStart = close;
    closeDownTrendStart = 0;
    UpTrendBarCount = 1;
    DownTrendBarCount = 0;
} else if UpTrend {
    bnumUp = bnumUp[1];
    bnumDown = 0;
    closeUpTrendStart = closeUpTrendStart[1];
    closeDownTrendStart = 0;
    UpTrendBarCount = UpTrendBarCount[1] + 1;
    DownTrendBarCount = 0;
} else if DownTrend and (!DownTrend[1] or UpTrend[1]) {
    bnumUp = 0;
    bnumDown = BarNumber();
    closeDownTrendStart = close;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 1;
} else if DownTrend {
    bnumDown = bnumDown[1];
    closeDownTrendStart = closeDownTrendStart[1];
    DownTrendBarCount = DownTrendBarCount[1] + 1;
    bnumUp = 0;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
} else {
    bnumUp = 0;
    bnumDown = 0;
    closeUpTrendStart = 0;
    closeDownTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 0;
}
def c;
if BarNumber() == bnumUp or BarNumber() == bnumDown {
    c = Range;
} else if UpTrend or DownTrend {
    c = c[1];
} else {
    c = 0;
}

def up = if UpTrend   then bnumUp   else Double.NaN;
def dn = if DownTrend then bnumDown else Double.NaN;
# - UpTrend Targets and StopLoss
plot UpTrendStopLoss = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart - (c * stopLossMultiplier) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart - c else Double.NaN;
plot oneADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 1) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + c else Double.NaN;
plot twoADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 2) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + (c * 2) else Double.NaN;
plot threeADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly then closeUpTrendStart + (c * 3) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeUpTrendStart + (c * 3) else Double.NaN;
plot fourADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 4) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 4) else Double.NaN;
plot fiveADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 5) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 5) else Double.NaN;
plot sixADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets then closeUpTrendStart + (c * 6) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets then closeUpTrendStart + (c * 6) else Double.NaN;
plot sevenADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 7) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 7) else Double.NaN;
plot eightADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 8) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 8) else Double.NaN;
plot nineADRPlus = if showCurrentTargetsOnly == yes and (bnumUp < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 9) else if (tradetype == tradetype.both or tradetype == tradetype.long) and UpTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd and showExtraTargets and showExtraTargets789 then closeUpTrendStart + (c * 9) else Double.NaN;

# - DownTrend Targets and StopLoss
plot DownTrendStopLoss = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart + (c * stopLossMultiplier) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart + c else Double.NaN;
plot oneADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - c else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - c else Double.NaN;
plot twoADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - (c * 2) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - (c * 2) else Double.NaN;
plot threeADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly then closeDownTrendStart - (c * 3) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd then closeDownTrendStart - (c * 3) else Double.NaN;
plot fourADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 4) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 4) else Double.NaN;
plot fiveADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 5) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 5) else Double.NaN;
plot sixADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets then closeDownTrendStart - (c * 6) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets then closeDownTrendStart - (c * 6) else Double.NaN;
plot sevenADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 7) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 7) else Double.NaN;
plot eightADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 8) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 8) else Double.NaN;
plot nineADRMinus = if showCurrentTargetsOnly == yes and (bnumDown < Max(HighestAll(dn), HighestAll(up)))
                         then Double.NaN
                         else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and !showTodayOnly and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 9) else if (tradetype == tradetype.both or tradetype == tradetype.short) and DownTrend and plotADR and showTodayOnly  and today and afterStart and beforeEnd  and showExtraTargets and showExtraTargets789 then closeDownTrendStart - (c * 9) else Double.NaN;

UpTrendStopLoss.SetDefaultColor(Color.LIGHT_RED);
oneADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
twoADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
threeADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
fourADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
fiveADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
sixADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
sevenADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
eightADRPlus.SetDefaultColor(Color.LIGHT_GREEN);
nineADRPlus.SetDefaultColor(Color.LIGHT_GREEN);

DownTrendStopLoss.SetDefaultColor(Color.LIGHT_GREEN);
oneADRMinus.SetDefaultColor(Color.LIGHT_RED);
twoADRMinus.SetDefaultColor(Color.LIGHT_RED);
threeADRMinus.SetDefaultColor(Color.LIGHT_RED);
fourADRMinus.SetDefaultColor(Color.LIGHT_RED);
fiveADRMinus.SetDefaultColor(Color.LIGHT_RED);
sixADRMinus.SetDefaultColor(Color.LIGHT_RED);
sevenADRMinus.SetDefaultColor(Color.LIGHT_RED);
eightADRMinus.SetDefaultColor(Color.LIGHT_RED);
nineADRMinus.SetDefaultColor(Color.LIGHT_RED);
All of which seems to be the pieces for getting the SL and TP targets. Am I missing something?

EDIT: Yes I know this is not a complete code above, just the portion of the code that deals with plotting ADR/ATR targets on chart
it gives error, "sellexit" and "buyexit" is not defined
 
it gives error, "sellexit" and "buyexit" is not defined
Yes it would give that error naturally because the whole code is not given. You can define sell as something simple like "price < 100ema" or something and the plots still do not show up for the ADR/ATR targets. That is why i am looking to find if there was error in that specific portion of code.
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
340 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top