Robert Payne's "The Edge"

ILIKESTOCKS

Member
@SleepyZ
I do have another question about a Robert Payne indicator called 'the edge' Are you are familiar with it? I listed the code below. Can this be condensed so I dont have to use 5 charts? And it could be placed on a single chart? Thats my first question. Second, if so could this be used to help with entry? For example if its all red with negative numbers or all green with positive numbers? The negative and positive numbers within the indicator show how far out of the normal range I believe. Its simple but works really well.
(the 233 is a tick and set for today at least thats how I interpreted it)

# (1) Trend Signal -- UP or DN


# The short-term trend is based upon the 8 period moving average in accordance with "The Market Maker's Edge". If the current stock price is above the 8MA, then the trend is up and UP will be displayed in green. If the current stock price is below the 8MA, then the trend is down and DN will be displayed in red.





# (2) Net Signal -- NS


# The net change in stock price. If the current price is greater than yesterday's closing price, then NS will be displayed in green. If the current price is less than yesterday's close, then NS will be displayed in red.





# (3) Open Signal -- OS


# The dominant direction of today's movement. If the current price is greater than today's opening price, then OS will be displayed in green. If the current price is less than today's opening price, then OS will be displayed in red.





# (4) High / Low Signal -- H/L


# This shows daily momentum by determining whether the stock is trading above or below yesterday's high or low price. If the current price is above yesterday's high, then H/L will be displayed in green. If the current price is below yesterday's low, then H/L will be displayed in red. If the current price is between yesterday's high and low, then H/L will be displayed in gray.





# (5) Out of Bounds


# This only displays when the stock is outside of the bollinger bands. For example, in the second image above, it may be seen that NFLX is $1.82 outside of the top bollinger band on the 55 min chart and $1.43 outside of the top bollinger band on the 34 min chart. The price will be displayed in white.





# This code may be applied to any chart Daily and below. For me, I like to have all the indicators in agreement across the 55, 34, 21, and 13. It is nice if the 233 and Daily agree, but is not necessary for me.


#The Edge


#Robert Payne





#Plot 8 period moving average


plot MA8 = Average(close, 8);


MA8.SetDefaultColor(Color.YELLOW);


MA8.SetLineWeight(2);





#Trend Signal


def TrendUp = if close > MA8 then 1 else Double.NaN;


def TrendDn = if close < MA8 then 1 else Double.NaN;


AddLabel(TrendUp, "UP", Color.GREEN);


AddLabel(TrendDn, "DN", Color.RED);





#Net Signal


def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;


def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;


AddLabel(NSup, "NS", Color.GREEN);


AddLabel(NSdn, "NS", Color.RED);





#Open Signal


def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;


def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;


AddLabel(OSup, "OS", Color.GREEN);


AddLabel(OSdn, "OS", Color.RED);





#High / Low Signal


def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;


def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;


def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;


AddLabel(Higher, "H/L", Color.GREEN);


AddLabel(Lower, "H/L", Color.RED);


AddLabel(Neutral, "H/L", Color.GRAY);





#Out of Bounds


def sDev = StDev(close, 21);


def MidLine = Average(close, 21);


def UpperBand = MidLine + 2 * sDev;


def LowerBand = MidLine - 2 * sDev;


def CloseAbove = if close > UpperBand then 1 else Double.NaN;


def CloseBelow = if close < LowerBand then 1 else Double.NaN;


AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);


AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);
 
Last edited by a moderator:
  • Like
Reactions: 741
Solution
@SleepyZ
I do have another question about a Robert Payne indicator called 'the edge' Are you are familiar with it? I listed the code below. Can this be condensed so I dont have to use 5 charts? And it could be placed on a single chart? Thats my first question. Second, if so could this be used to help with entry? For example if its all red with negative numbers or all green with positive numbers? The negative and positive numbers within the indicator show how far out of the normal range I believe. Its simple but works really well.
(the 233 is a tick and set for today at least thats how I interpreted it)

# (1) Trend Signal -- UP or DN


# The short-term trend is based upon the 8 period moving average in accordance with "The...
@SleepyZ
I do have another question about a Robert Payne indicator called 'the edge' Are you are familiar with it? I listed the code below. Can this be condensed so I dont have to use 5 charts? And it could be placed on a single chart? Thats my first question. Second, if so could this be used to help with entry? For example if its all red with negative numbers or all green with positive numbers? The negative and positive numbers within the indicator show how far out of the normal range I believe. Its simple but works really well.
(the 233 is a tick and set for today at least thats how I interpreted it)

# (1) Trend Signal -- UP or DN


# The short-term trend is based upon the 8 period moving average in accordance with "The Market Maker's Edge". If the current stock price is above the 8MA, then the trend is up and UP will be displayed in green. If the current stock price is below the 8MA, then the trend is down and DN will be displayed in red.





# (2) Net Signal -- NS


# The net change in stock price. If the current price is greater than yesterday's closing price, then NS will be displayed in green. If the current price is less than yesterday's close, then NS will be displayed in red.





# (3) Open Signal -- OS


# The dominant direction of today's movement. If the current price is greater than today's opening price, then OS will be displayed in green. If the current price is less than today's opening price, then OS will be displayed in red.





# (4) High / Low Signal -- H/L


# This shows daily momentum by determining whether the stock is trading above or below yesterday's high or low price. If the current price is above yesterday's high, then H/L will be displayed in green. If the current price is below yesterday's low, then H/L will be displayed in red. If the current price is between yesterday's high and low, then H/L will be displayed in gray.





# (5) Out of Bounds


# This only displays when the stock is outside of the bollinger bands. For example, in the second image above, it may be seen that NFLX is $1.82 outside of the top bollinger band on the 55 min chart and $1.43 outside of the top bollinger band on the 34 min chart. The price will be displayed in white.





# This code may be applied to any chart Daily and below. For me, I like to have all the indicators in agreement across the 55, 34, 21, and 13. It is nice if the 233 and Daily agree, but is not necessary for me.


#The Edge


#Robert Payne





#Plot 8 period moving average


plot MA8 = Average(close, 8);


MA8.SetDefaultColor(Color.YELLOW);


MA8.SetLineWeight(2);





#Trend Signal


def TrendUp = if close > MA8 then 1 else Double.NaN;


def TrendDn = if close < MA8 then 1 else Double.NaN;


AddLabel(TrendUp, "UP", Color.GREEN);


AddLabel(TrendDn, "DN", Color.RED);





#Net Signal


def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;


def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;


AddLabel(NSup, "NS", Color.GREEN);


AddLabel(NSdn, "NS", Color.RED);





#Open Signal


def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;


def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;


AddLabel(OSup, "OS", Color.GREEN);


AddLabel(OSdn, "OS", Color.RED);





#High / Low Signal


def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;


def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;


def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;


AddLabel(Higher, "H/L", Color.GREEN);


AddLabel(Lower, "H/L", Color.RED);


AddLabel(Neutral, "H/L", Color.GRAY);





#Out of Bounds


def sDev = StDev(close, 21);


def MidLine = Average(close, 21);


def UpperBand = MidLine + 2 * sDev;


def LowerBand = MidLine - 2 * sDev;


def CloseAbove = if close > UpperBand then 1 else Double.NaN;


def CloseBelow = if close < LowerBand then 1 else Double.NaN;


AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);


AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);

I am not familar with how RPayne uses this indicator. There are not any aggregation periods for tick charts at all and none for time charts for the minutes that you posted above. Therefore, I do not think you could combine your 5 charts together.
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I am not familar with how RPayne uses this indicator. There are not any aggregation periods for tick charts at all and none for time charts for the minutes that you posted above. Therefore, I do not think you could combine your 5 charts together.
knaNaxQ.png

This is how I have it set up 20 day 55 minutes, 20 day 34 minutes, 20 day 21 minutes, 20 day 13 minutes, and today 233tick. When its all green its going up when its all red it going down. And the H/L shows positive or negative when its way out of range. Further confirmation of direction.
 
@ILIKESTOCKS , I took what you posted and combined it with what samport did with the Three Little Pigs MTF script on this site. Making it a lower panel with colored dots to show the status of the time frame combined signals. This way you do not need five charts up for this.

This script is designed to run on a 13 minute chart. Or create a separate window for it via flexchart and turn off price chart if you want then link it to your main chart. It will not show data on a higher time frame of 15 minutes.

ToS forced me to make a few changes with the aggregation periods. Robert Payne uses 13, 21, 34 and 55 minute aggs. The closest default preset aggs for ToS would allow me are 15, 20, 30 minutes and 1 hour. This shifts the MA's slightly.

I made it, for example, so that if the close is above all the MA's time frames then it plots a green dot. When close is below all the MA's time frames then a red dot is placed. If the signals are mixed over the time frames then a gray dot. At least that is how I was understanding what Robert had written in the description.

Did not show price of close outside BB just to keep things simple. I'm no super coder so if someone wants to improve on this then that is great.

MerryDay had this to say on MTF's from the above thread. Not sure if / how it applies to this.
" When placing a higher timeframe indicator on a lower timeframe chart there will ALWAYS be repainting until the higher timeframe candle closes. If there is a 4hr indicator on a 15min chart, it will continually repaint all the previous 16 bars until the 4hr candle close.

This is built-into the DNA of all multi-timeframe indicators. By definition the bars cannot know what the final close is going to be until the close actually happens. "


Code:
# https://usethinkscript.com/threads/robert-paynes-the-edge.12153/
 # from ilikestocks

# Combined with idea from  3 little pigs by samport
#https://usethinkscript.com/threads/three-little-pigs-mtf-swing-trading-for-thinkorswim.8004/

# ------as per MerryDay's wisdom------
# ----- When placing a higher timeframe indicator on a lower timeframe chart there will ALWAYS be repainting until the higher timeframe candle closes. If there is a 4hr indicator on a 15min chart, it will continually repaint all the previous 16 bars until the 4hr candle close.

# ----- This is built-into the DNA of all multi-timeframe indicators. By definition the bars cannot know what the final close is going to be until the close actually happens.
#---

# Must be set to 13 min.  If that is not your main timeframe then set in it's own window and link to your main.




#The Edge
#Robert Payne

declare lower;

input showdotplot = yes;
input useupper_lower = {default lower, upper};


#Plot 8 period moving average
plot MA8 = Average(close, 8);
MA8.SetDefaultColor(Color.YELLOW);
MA8.SetLineWeight(2);
MA8.Hide();


 # Can't get ToS to use 13/21/34/55 min increments, must use preset values
input Period1 = AggregationPeriod.Fifteen_Min;
input Period2 = AggregationPeriod.Twenty_Min;
input Period3 = AggregationPeriod.Thirty_Min;
input Period4 = AggregationPeriod.HOUR;
input AvgType = averageType.SIMPLE;

def AggPer1 = MovingAverage(AvgType, close(period = Period1), 8);
def AggPer2 = MovingAverage(AvgType, close(period = Period2), 8);
def AggPer3 = MovingAverage(AvgType, close(period = Period3), 8);
def AggPer4 = MovingAverage(AvgType, close(period = Period4), 8);

# MA test compare Rob's numbers to ToS preset Agg's
#plot M8_15 = AggPer1;
#plot M8_20 = AggPer2;
#plot M8_30 = AggPer3;
#plot M8_Hour = AggPer4;


#Trend Signal
def M8AllUp = if close > AggPer1 and close > AggPer2 and close > AggPer3 and close > AggPer4 then 1 else 0;
def M8AllDn = if close < AggPer1 and close < AggPer2 and close < AggPer3 and close < AggPer4 then 1 else 0;
def M8mixed = if M8AllUp == 0 and M8AllDn == 0 then 1 else 0;

plot M8LineUp = if M8AllUp == 1 then 1.8 else Double.NaN;
M8LineUp.SetPaintingStrategy(PaintingStrategy.POINTS);
M8LineUp.SetLineWeight(3);
M8LineUp.SetDefaultColor(Color.GREEN);
plot M8LineDn = if M8AllDn == 1 then 1.8 else Double.NaN;
M8LineDn.SetPaintingStrategy(PaintingStrategy.POINTS);
M8LineDn.SetLineWeight(3);
M8LineDn.SetDefaultColor(Color.Red);
plot M8Neut = if M8mixed == 1 then 1.8 else Double.NaN;
M8Neut.SetPaintingStrategy(PaintingStrategy.POINTS);
M8Neut.SetLineWeight(3);
M8Neut.SetDefaultColor(Color.gray);
AddLabel(M8AllUp == 1, "TrendUp", color.green);
AddLabel(M8mixed == 1, "Neutral", color.gray);
AddLabel(M8AllDn == 1, "TrendDn", color.red);


#Net Signal
def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;
def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;
AddLabel(NSup, "NetSig", Color.GREEN);
AddLabel(NSdn, "NetSig", Color.RED);

plot NetSigUp = if NSup == 1 then 1.6 else Double.NaN;
NetSigUp.SetPaintingStrategy(PaintingStrategy.POINTS);
NetSigUp.SetLineWeight(3);
NetSigUp.SetDefaultColor(Color.GREEN);
plot NetSigDn = if NSdn == 1 then 1.6 else Double.NaN;
NetSigDn.SetPaintingStrategy(PaintingStrategy.POINTS);
NetSigDn.SetLineWeight(3);
NetSigDn.SetDefaultColor(Color.Red);


#Open Signal
def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;
def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;
AddLabel(OSup, "OpenSig", Color.GREEN);
AddLabel(OSdn, "OpenSig", Color.RED);

plot OpenSigUp = if OSup == 1 then 1.4 else Double.NaN;
OpenSigUp.SetPaintingStrategy(PaintingStrategy.POINTS);
OpenSigUp.SetLineWeight(3);
OpenSigUp.SetDefaultColor(Color.GREEN);
plot OpenSigDn = if OSdn == 1 then 1.4 else Double.NaN;
OpenSigDn.SetPaintingStrategy(PaintingStrategy.POINTS);
OpenSigDn.SetLineWeight(3);
OpenSigDn.SetDefaultColor(Color.Red);


#High / Low Signal
def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;
def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;
def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;

AddLabel(Higher, "H/Lsig", Color.GREEN);
AddLabel(Lower, "H/Lsig", Color.RED);
AddLabel(Neutral, "H/Lsig", Color.GRAY);

plot PlotH = if Higher == 1 then 1.2 else Double.NaN;
PlotH.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotH.SetLineWeight(3);
PlotH.SetDefaultColor(Color.GREEN);
plot PlotL = if Lower == 1 then 1.2 else Double.NaN;
PlotL.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotL.SetLineWeight(3);
PlotL.SetDefaultColor(Color.Red);
plot PlotN = if Neutral == 1 then 1.2 else Double.NaN;
PlotN.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotN.SetLineWeight(3);
PlotN.SetDefaultColor(Color.Gray);

#Out of Bounds
#Agg1
def sDev1 = StDev( close(period = Period1), 21);
def MidLine1 = Average( close(period = Period1), 21);
def UpperBand1 = MidLine1 + 2 * sDev1;
def LowerBand1 = MidLine1 - 2 * sDev1;
def CloseAbove1 = if close(period = Period1) > UpperBand1 then 1 else 0;
def CloseBelow1 = if close(period = Period1) < LowerBand1 then 1 else 0;

#AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);
#AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);

#Agg2
def sDev2 = StDev(close(period = Period2), 21);
def MidLine2 = Average(close(period = Period2), 21);
def UpperBand2 = MidLine2 + 2 * sDev2;
def LowerBand2 = MidLine2 - 2 * sDev2;
def CloseAbove2 = if close(period = Period2) > UpperBand2 then 1 else 0;
def CloseBelow2 = if close(period = Period2) < LowerBand2 then 1 else 0;

#Agg3
def sDev3 = StDev(close(period = Period3), 21);
def MidLine3 = Average(close(period = Period3), 21);
def UpperBand3 = MidLine3 + 2 * sDev3;
def LowerBand3 = MidLine3 - 2 * sDev3;
def CloseAbove3 = if close(period = Period3) > UpperBand3 then 1 else 0;
def CloseBelow3 = if close(period = Period3) < LowerBand3 then 1 else 0;

#Agg4
def sDev4 = StDev(close(period = Period4), 21);
def MidLine4 = Average(close(period = Period4), 21);
def UpperBand4 = MidLine4 + 2 * sDev4;
def LowerBand4 = MidLine4 - 2 * sDev4;
def CloseAbove4 = if close(period = Period4) > UpperBand4 then 1 else 0;
def CloseBelow4 = if close(period = Period4) < LowerBand4 then 1 else 0;

def AllAbove = if CloseAbove1 == 1 and CloseAbove2 == 1 and CloseAbove3 == 1 and CloseAbove4 == 1 then 1 else 0;
def AllBelow = if CloseBelow1 == 1 and CloseBelow2 == 1 and CloseBelow3 == 1 and CloseBelow4 == 1 then 1 else 0;

plot BBAbove = if AllAbove == 1 then 1.0 else Double.NaN;
BBAbove.SetPaintingStrategy(PaintingStrategy.POINTS);
BBAbove.SetLineWeight(3);
BBAbove.SetDefaultColor(Color.GREEN);
plot BBbelow = if AllBelow == 1 then 1.0 else Double.NaN;
BBbelow.SetPaintingStrategy(PaintingStrategy.POINTS);
BBbelow.SetLineWeight(3);
BBbelow.SetDefaultColor(Color.Red);
plot BBinside = if AllAbove == 0 and AllBelow == 0 then 1.0 else Double.NaN;
BBinside.SetPaintingStrategy(PaintingStrategy.POINTS);
BBinside.SetLineWeight(3);
BBinside.SetDefaultColor(Color.Gray);

AddLabel(AllAbove, "AboveBB", Color.GREEN);
AddLabel(AllBelow, "BelowBB", Color.RED);
AddLabel( AllAbove == 0 and AllBelow == 0, "InsideBB", Color.GRAY);


# makes plot look nicer
plot lineh = if IsNaN(close) or showdotplot == no
             then Double.NaN
             else if useupper_lower == useupper_lower.lower then 2.0 else Double.NaN;
plot linel = if IsNaN(close) or showdotplot == no
             then Double.NaN
             else if useupper_lower == useupper_lower.lower then .8 else Double.NaN;
lineh.SetDefaultColor(Color.DARK_GRAY);
linel.SetDefaultColor(Color.DARK_GRAY);
 
Last edited by a moderator:
@ILIKESTOCKS , I took what you posted and combined it with what samport did with the Three Little Pigs MTF script on this site. Making it a lower panel with colored dots to show the status of the time frame combined signals. This way you do not need five charts up for this.

This script is designed to run on a 13 minute chart. Or create a separate window for it via flexchart and turn off price chart if you want then link it to your main chart. It will not show data on a higher time frame of 15 minutes.

ToS forced me to make a few changes with the aggregation periods. Robert Payne uses 13, 21, 34 and 55 minute aggs. The closest default preset aggs for ToS would allow me are 15, 20, 30 minutes and 1 hour. This shifts the MA's slightly.

I made it, for example, so that if the close is above all the MA's time frames then it plots a green dot. When close is below all the MA's time frames then a red dot is placed. If the signals are mixed over the time frames then a gray dot. At least that is how I was understanding what Robert had written in the description.

Did not show price of close outside BB just to keep things simple. I'm no super coder so if someone wants to improve on this then that is great.

MerryDay had this to say on MTF's from the above thread. Not sure if / how it applies to this.
" When placing a higher timeframe indicator on a lower timeframe chart there will ALWAYS be repainting until the higher timeframe candle closes. If there is a 4hr indicator on a 15min chart, it will continually repaint all the previous 16 bars until the 4hr candle close.

This is built-into the DNA of all multi-timeframe indicators. By definition the bars cannot know what the final close is going to be until the close actually happens. "


Code:
# https://usethinkscript.com/threads/robert-paynes-the-edge.12153/
 # from ilikestocks

# Combined with idea from  3 little pigs by samport
#https://usethinkscript.com/threads/three-little-pigs-mtf-swing-trading-for-thinkorswim.8004/

# ------as per MerryDay's wisdom------
# ----- When placing a higher timeframe indicator on a lower timeframe chart there will ALWAYS be repainting until the higher timeframe candle closes. If there is a 4hr indicator on a 15min chart, it will continually repaint all the previous 16 bars until the 4hr candle close.

# ----- This is built-into the DNA of all multi-timeframe indicators. By definition the bars cannot know what the final close is going to be until the close actually happens.
#---

# Must be set to 13 min.  If that is not your main timeframe then set in it's own window and link to your main.




#The Edge
#Robert Payne

declare lower;

input showdotplot = yes;
input useupper_lower = {default lower, upper};


#Plot 8 period moving average
plot MA8 = Average(close, 8);
MA8.SetDefaultColor(Color.YELLOW);
MA8.SetLineWeight(2);
MA8.Hide();


 # Can't get ToS to use 13/21/34/55 min increments, must use preset values
input Period1 = AggregationPeriod.Fifteen_Min;
input Period2 = AggregationPeriod.Twenty_Min;
input Period3 = AggregationPeriod.Thirty_Min;
input Period4 = AggregationPeriod.HOUR;
input AvgType = averageType.SIMPLE;

def AggPer1 = MovingAverage(AvgType, close(period = Period1), 8);
def AggPer2 = MovingAverage(AvgType, close(period = Period2), 8);
def AggPer3 = MovingAverage(AvgType, close(period = Period3), 8);
def AggPer4 = MovingAverage(AvgType, close(period = Period4), 8);

# MA test compare Rob's numbers to ToS preset Agg's
#plot M8_15 = AggPer1;
#plot M8_20 = AggPer2;
#plot M8_30 = AggPer3;
#plot M8_Hour = AggPer4;


#Trend Signal
def M8AllUp = if close > AggPer1 and close > AggPer2 and close > AggPer3 and close > AggPer4 then 1 else 0;
def M8AllDn = if close < AggPer1 and close < AggPer2 and close < AggPer3 and close < AggPer4 then 1 else 0;
def M8mixed = if M8AllUp == 0 and M8AllDn == 0 then 1 else 0;

plot M8LineUp = if M8AllUp == 1 then 1.8 else Double.NaN;
M8LineUp.SetPaintingStrategy(PaintingStrategy.POINTS);
M8LineUp.SetLineWeight(3);
M8LineUp.SetDefaultColor(Color.GREEN);
plot M8LineDn = if M8AllDn == 1 then 1.8 else Double.NaN;
M8LineDn.SetPaintingStrategy(PaintingStrategy.POINTS);
M8LineDn.SetLineWeight(3);
M8LineDn.SetDefaultColor(Color.Red);
plot M8Neut = if M8mixed == 1 then 1.8 else Double.NaN;
M8Neut.SetPaintingStrategy(PaintingStrategy.POINTS);
M8Neut.SetLineWeight(3);
M8Neut.SetDefaultColor(Color.gray);
AddLabel(M8AllUp == 1, "TrendUp", color.green);
AddLabel(M8mixed == 1, "Neutral", color.gray);
AddLabel(M8AllDn == 1, "TrendDn", color.red);


#Net Signal
def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;
def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;
AddLabel(NSup, "NetSig", Color.GREEN);
AddLabel(NSdn, "NetSig", Color.RED);

plot NetSigUp = if NSup == 1 then 1.6 else Double.NaN;
NetSigUp.SetPaintingStrategy(PaintingStrategy.POINTS);
NetSigUp.SetLineWeight(3);
NetSigUp.SetDefaultColor(Color.GREEN);
plot NetSigDn = if NSdn == 1 then 1.6 else Double.NaN;
NetSigDn.SetPaintingStrategy(PaintingStrategy.POINTS);
NetSigDn.SetLineWeight(3);
NetSigDn.SetDefaultColor(Color.Red);


#Open Signal
def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;
def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;
AddLabel(OSup, "OpenSig", Color.GREEN);
AddLabel(OSdn, "OpenSig", Color.RED);

plot OpenSigUp = if OSup == 1 then 1.4 else Double.NaN;
OpenSigUp.SetPaintingStrategy(PaintingStrategy.POINTS);
OpenSigUp.SetLineWeight(3);
OpenSigUp.SetDefaultColor(Color.GREEN);
plot OpenSigDn = if OSdn == 1 then 1.4 else Double.NaN;
OpenSigDn.SetPaintingStrategy(PaintingStrategy.POINTS);
OpenSigDn.SetLineWeight(3);
OpenSigDn.SetDefaultColor(Color.Red);


#High / Low Signal
def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;
def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;
def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;

AddLabel(Higher, "H/Lsig", Color.GREEN);
AddLabel(Lower, "H/Lsig", Color.RED);
AddLabel(Neutral, "H/Lsig", Color.GRAY);

plot PlotH = if Higher == 1 then 1.2 else Double.NaN;
PlotH.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotH.SetLineWeight(3);
PlotH.SetDefaultColor(Color.GREEN);
plot PlotL = if Lower == 1 then 1.2 else Double.NaN;
PlotL.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotL.SetLineWeight(3);
PlotL.SetDefaultColor(Color.Red);
plot PlotN = if Neutral == 1 then 1.2 else Double.NaN;
PlotN.SetPaintingStrategy(PaintingStrategy.POINTS);
PlotN.SetLineWeight(3);
PlotN.SetDefaultColor(Color.Gray);

#Out of Bounds
#Agg1
def sDev1 = StDev( close(period = Period1), 21);
def MidLine1 = Average( close(period = Period1), 21);
def UpperBand1 = MidLine1 + 2 * sDev1;
def LowerBand1 = MidLine1 - 2 * sDev1;
def CloseAbove1 = if close(period = Period1) > UpperBand1 then 1 else 0;
def CloseBelow1 = if close(period = Period1) < LowerBand1 then 1 else 0;

#AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);
#AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);

#Agg2
def sDev2 = StDev(close(period = Period2), 21);
def MidLine2 = Average(close(period = Period2), 21);
def UpperBand2 = MidLine2 + 2 * sDev2;
def LowerBand2 = MidLine2 - 2 * sDev2;
def CloseAbove2 = if close(period = Period2) > UpperBand2 then 1 else 0;
def CloseBelow2 = if close(period = Period2) < LowerBand2 then 1 else 0;

#Agg3
def sDev3 = StDev(close(period = Period3), 21);
def MidLine3 = Average(close(period = Period3), 21);
def UpperBand3 = MidLine3 + 2 * sDev3;
def LowerBand3 = MidLine3 - 2 * sDev3;
def CloseAbove3 = if close(period = Period3) > UpperBand3 then 1 else 0;
def CloseBelow3 = if close(period = Period3) < LowerBand3 then 1 else 0;

#Agg4
def sDev4 = StDev(close(period = Period4), 21);
def MidLine4 = Average(close(period = Period4), 21);
def UpperBand4 = MidLine4 + 2 * sDev4;
def LowerBand4 = MidLine4 - 2 * sDev4;
def CloseAbove4 = if close(period = Period4) > UpperBand4 then 1 else 0;
def CloseBelow4 = if close(period = Period4) < LowerBand4 then 1 else 0;

def AllAbove = if CloseAbove1 == 1 and CloseAbove2 == 1 and CloseAbove3 == 1 and CloseAbove4 == 1 then 1 else 0;
def AllBelow = if CloseBelow1 == 1 and CloseBelow2 == 1 and CloseBelow3 == 1 and CloseBelow4 == 1 then 1 else 0;

plot BBAbove = if AllAbove == 1 then 1.0 else Double.NaN;
BBAbove.SetPaintingStrategy(PaintingStrategy.POINTS);
BBAbove.SetLineWeight(3);
BBAbove.SetDefaultColor(Color.GREEN);
plot BBbelow = if AllBelow == 1 then 1.0 else Double.NaN;
BBbelow.SetPaintingStrategy(PaintingStrategy.POINTS);
BBbelow.SetLineWeight(3);
BBbelow.SetDefaultColor(Color.Red);
plot BBinside = if AllAbove == 0 and AllBelow == 0 then 1.0 else Double.NaN;
BBinside.SetPaintingStrategy(PaintingStrategy.POINTS);
BBinside.SetLineWeight(3);
BBinside.SetDefaultColor(Color.Gray);

AddLabel(AllAbove, "AboveBB", Color.GREEN);
AddLabel(AllBelow, "BelowBB", Color.RED);
AddLabel( AllAbove == 0 and AllBelow == 0, "InsideBB", Color.GRAY);


# makes plot look nicer
plot lineh = if IsNaN(close) or showdotplot == no
             then Double.NaN
             else if useupper_lower == useupper_lower.lower then 2.0 else Double.NaN;
plot linel = if IsNaN(close) or showdotplot == no
             then Double.NaN
             else if useupper_lower == useupper_lower.lower then .8 else Double.NaN;
lineh.SetDefaultColor(Color.DARK_GRAY);
linel.SetDefaultColor(Color.DARK_GRAY);
Very cool I will look at this, I have basically ZERO coding experience so Ill run it and compare to the other...thanks!
 
@majidg
"can someone write this for daily aggregation?"


No, not the way Thinkorswim is currently set up. One cannot plot the 4 sub-hour moving averages of this script on a daily chart.

Think of it like this... if the smallest bill in your pocket is a Twenty (daily chart). You cannot make change for a Five (15min chart) or a Ten (1hr chart) if asked. You just do not have the bills (data chunks) small enough to do so.

If you really want Intraday signals along with a Daily chart then here is an option. That is why I suggested a flexchart with your larger time frame main window and a separate window on a 13 min time frame for this script. For the 13min window un-click price graph in window settings, click overlap volume, then link them together so both windows follow when you change ticker symbol. That way you get just this script in it's own window.

But you have to remember the two charts are different time frames. Make labels for the windows if you need to. Something like so.
http://tos.mx/SSeoGev

Also keep in mind MerryDay's warning. Which would apply to the MAs and BollingerBands part of the script.


added
@ILIKESTOCKS the shared chart might be of interest for you. Not the daily part, just general chart setup for this script.
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
354 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