Watchlist background color not matching chart


Category:
0
0

hi pete.

i have this indicator i am trying to adjust for my watchlist.

this is the code for the indicator:

input price = close;
input length = -10;
def displacement = (length / 2) + 1;
def dPrice = price[displacement];
def tmp = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else tmp[1] + (tmp[1] – tmp
[2]);
def tmp1 = if !IsNaN(price) then tmp else Double.NaN;
plot Data = tmp1;
Data.SetDefaultColor(color.CYAN );
Data.SetStyle(Curve.SHORT_DASH);
def pct=100;
input width=65;
def d=width/pct;
def d1=0.8*d;
def d2=1.05*d;
def d3=1.15*d;
def stdDeviation = Highestall(“data” = AbsValue(tmp1 – price));
plot UpperLine = tmp1 + stdDeviation*d1;
plot LowerLine = tmp1 – stdDeviation*d1;
plot UpperLine1 = tmp1 + stdDeviation*d2;
plot LowerLine1 = tmp1 – stdDeviation*d2;
plot UpperLine2 = tmp1 + stdDeviation*d3;
plot LowerLine2 = tmp1 – stdDeviation*d3;
UpperLine.SetDefaultColor(color.red);
UpperLine1.SetDefaultColor(color.red );
UpperLine2.SetDefaultColor(color.red );
LowerLine.SetDefaultColor(color.cyan );
LowerLine1.SetDefaultColor(color.cyan );
LowerLine2.SetDefaultColor(color.cyan );
AddCloud(UpperLine,UpperLine1,color.plum,color.plum);
AddCloud(LowerLine,LowerLine1,color.green,color.dark_green);

and this is me trying to get the watchlist to turn green when price is below LowerLine

and red when price is above UpperLine. but it does not work. i will add screenshots to help explain.

thank you for your time. -josh-

input price = close;
input length = -10;
def displacement = (length / 2) + 1;
def dPrice = price[displacement];
def tmp = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else tmp[1] + (tmp[1] – tmp
[2]);
def tmp1 = if !IsNaN(price) then tmp else Double.NaN;
def Data = tmp1;
def pct=100;
input width=65;
def d=width/pct;
def d1=0.8*d;
def d2=1.05*d;
def d3=1.15*d;
def stdDeviation = Highestall(“data” = AbsValue(tmp1 – price));
plot UpperLine = tmp1 + stdDeviation*d1;
def LowerLine = tmp1 – stdDeviation*d1;

AssignBackgroundColor (if close > UpperLine then color.DARK_RED else if close < LowerLine then color.DARK_GREEN else color.CURRENT);

 

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on February 22, 2020 8:20 pm
63 views
0
Private answer

The code contains a call to a function named "HighestAll()". This function gets the highest value for the data loaded on the chart. Change the amount of data on the chart and this indicator changes. So if you have 1 year of daily bars the values will change when you load 2 years of daily bars.

The reason y0ur attempts do not match is the amount of data used to compute the values in the watchlist column does not match the amount of data on the chart. The amount of historical data available to a watchlist column varies based on the selected time frame. Full details at the bottom of this post:

https://tlc.thinkorswim.com/center/howToTos/thinkManual/MarketWatch/Quotes/customquotes

The problem here is we have absolutely no way to adjust the amount of historical data on a watchlist column as we can with a chart. So if you want them to match you will need to adjust the amount of data loaded on your chart, to EXACTLY match the amount of data available to the watchlist column at the time frame selected. (which means that link above is your decoder ring).

Because these plots will change when you adjust the historical data on the chart I suggest you don't really have a viable piece of code here.

Marked as spam
Posted by (Questions: 37, Answers: 4073)
Answered on February 23, 2020 8:32 am
0
ah ok. that makes sense then. glad i asked. thank you
( at February 23, 2020 8:47 am)