Convert chart label into 2 watch list column


0
0

Hello Pete

I’ve been trying to convert my two chart labels into watch list columns with no luck..Hopefully you can help….

 

Thanks for you help…

input Show81321Label = yes;
input ShowWaveTrendLabel = yes;

DefineGlobalColor(“Bullish”, Color.GREEN);
DefineGlobalColor(“Sideways”, Color.YELLOW);
DefineGlobalColor(“Bearish”, Color.RED);

def EMA34High = ExpAverage (high, 34); #was ema1_34
def EMA34Close = ExpAverage (close, 34); #ema2_34
def EMA34Low = ExpAverage (low, 34); # was ema3_34
def EMA8 = ExpAverage(close, 8); #JT Changed var name from EMA1 to EMA8
def EMA21 = ExpAverage(close, 21); #JT Changed var name from EMA2 to EMA21
def EMA13 = ExpAverage (close, 13);

def bullish = (EMA8 > EMA13) and (EMA13 > EMA21);
def bearish = (EMA8 < EMA13) and (EMA13 < EMA21);

def WaveState = {default SW, Bullish, Bearish}; #SW = sideways
WaveState = IF (EMA8 > EMA13) AND (EMA13 > EMA21) AND (EMA21 > EMA34High)
THEN WaveState.Bullish
ELSE IF (EMA8 < EMA13) AND (EMA13 < EMA21) AND (EMA21 < EMA34Low)
THEN WaveState.Bearish
ELSE WaveState.SW;

def IsBullishWave = WaveState == WaveState.Bullish;
def IsBearishWave = WaveState == WaveState.Bearish;
def IsSidewaysWave = WaveState == WaveState.SW;

AddLabel(Show81321Label, “8:13:21: ” + if Bullish then “Bullish” else if Bearish then “Bearish” else “Slop”, if bullish then GlobalColor(“Bullish”) else if bearish then GlobalColor(“Bearish”) else GlobalColor(“Sideways”));

AddLabel(ShowWaveTrendLabel, “Wave: ” + if IsBullishWave then “Bullish” else if IsBearishWave then “Bearish” else “S/W”, if IsBullishWave then GlobalColor(“Bullish”) else if IsBearishWave then GlobalColor(“Bearish”) else GlobalColor(“Sideways”));

#adding a blank label after as a spacer
AddLabel(yes, ” “, color.black);

 

 

Marked as spam
Posted by (Questions: 49, Answers: 42)
Asked on August 20, 2019 1:41 pm
89 views
0
Private answer

Nothing wrong with it. Works fine as it is. Only one label can be displayed per column. You have three labels in your code. Pick one and delete the other two. Add a second column and keep one of the two you deleted for the first.

Marked as spam
Posted by (Questions: 39, Answers: 3664)
Answered on August 20, 2019 4:53 pm
For some reason the background color is not coming through...
( at August 21, 2019 8:51 am)
Ah, yes. That is because GlobalColor is not supported for watchlist columns. I found that out by accident myself a few weeks ago. You will have to replace GlobalColor with actual colors. Such as Color.RED, Color.GREEN... etc.
( at August 21, 2019 9:00 am)
Pete, I can't seem to get the background color to work...Could you show me on the code... input Show81321Label = yes; DefineGlobalColor("Bullish", Color.GREEN); DefineGlobalColor("Sideways", Color.YELLOW); DefineGlobalColor("Bearish", Color.RED); def EMA8 = ExpAverage(close, 8); #JT Changed var name from EMA1 to EMA8 def EMA21 = ExpAverage(close, 21); #JT Changed var name from EMA2 to EMA21 def EMA13 = ExpAverage (close, 13); def bullish = (EMA8 > EMA13) and (EMA13 > EMA21); def bearish = (EMA8 < EMA13) and (EMA13 < EMA21); AddLabel(Show81321Label, "8:13:21: " + if Bullish then "Bullish" else if Bearish then "Bearish" else "Slop", if bullish then GlobalColor("Bullish") else if bearish then GlobalColor("Bearish") else GlobalColor("Sideways"));
( at August 22, 2019 7:34 am)
Stop trying to use GlobalColor. I told you that is not supported. And I explained how to do this in my previous reply.
( at August 22, 2019 8:24 am)

Here is how you replace the GlobalColor with regular colors that are supported by the watchlist. Your code:

AddLabel(Show81321Label, "8:13:21: " + if Bullish then "Bullish" else if Bearish then "Bearish" else "Slop", if bullish then GlobalColor("Bullish") else if bearish then GlobalColor("Bearish") else GlobalColor("Sideways"));

Supported code:

AddLabel(Show81321Label, "8:13:21: " + if Bullish then "Bullish" else if Bearish then "Bearish" else "Slop", if bullish then Color.GREEN else if bearish then Color.RED else Color.YELLOW);

( at August 22, 2019 8:43 am)