WL For Supertrend in TOS


Category:
0
0

Mr. Hahn, I have the indicator code for Supertrend. Can this be made for a watchlist? Here is the code. Many thanks!

input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
plot SuperTrend = ST;
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
AssignPriceColor(if PaintBars and close < ST

then Color.RED

else if PaintBars and close > ST

then Color.GREEN

else Color.CURRENT);

AddChartBubble(close crosses below ST, low[1], low[1], color.Dark_Gray);
AddChartBubble(close crosses above ST, high[1], high[1], color.Dark_Gray, no);
# End Code SuperTrendplot Data = close;

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on October 2, 2019 8:20 am
1035 views
0
Private answer

This is so easy it will make your head spin.

Step 1:

Remove the last three lines of code:

AddChartBubble(close crosses below ST, low[1], low[1], color.Dark_Gray);
AddChartBubble(close crosses above ST, high[1], high[1], color.Dark_Gray, no);
# End Code SuperTrendplot Data = close;

Step 2:

Change the word AssignPriceColor to AssignBackgroundColor color.

AssignBackgroundColor(if PaintBars and close < ST then Color.RED else if PaintBars and close > ST then Color.GREEN else Color.CURRENT);

I compressed that statement into a signal line of code because it makes for a more compact statement that is easier to read.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 2, 2019 9:33 am
0
Thank you so much. I followed your instructions but it doesn't show up as an available watchlist column. I must be doing something wrong.
( at October 2, 2019 10:52 am)
0
"doesn't show up as an available column" Do you know how to add custom columns to a watchlist? It should not show up "as an available column". You have to take one of your custom columns and insert that code, then add that custom column to your watchlist.
( at October 2, 2019 11:39 am)
0
Thank you. It works fine now.
( at October 3, 2019 5:48 am)