WL for HULL in TOS


Category:
0
0

Could you please help me code for this WL on HULL to give a signal as soon as it changes from down to up or viceversa… for example “UP now” and the next bar just “up”. The code I have is the following:

input price = close;

input length = 20;

input displace = 0;

plot HMA = MovingAverage(AverageType.HULL, price, length)[-displace];

Addlabel (yes, if HMA < HMA [1] then “DN” else “UP”, color.BLACK);

Assignbackgroundcolor(if HMA < HMA[1] then color.MAGENTA else color.CYAN);

#Alert

Alert(HMA > HMA[1] and HMA[1] < HMA[2], “Up”, Alert.BAR, Sound.Bell);

Alert(HMA < HMA[1] and HMA[1] > HMA[2], “Down”, Alert.BAR, Sound.Bell);

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on September 10, 2019 4:15 pm
517 views
0
Where do I create this code? Did not work in Create in Watch List or Scan. Scan rejected AddLabel line.
( at November 24, 2019 3:51 pm)
0
It's not a scan. This is for a watchlist column. It will not work in a scan because it was never intended to be used as a scan. It works perfectly well in the custom watchlist column, as shown in the screenshot included with my solution.
( at November 24, 2019 6:37 pm)
0
Private answer

Here you go. Screenshot below shows the result.

input price = close;
input length = 20;
input type = AverageType.HULL;
input displace = 0;
plot ma = MovingAverage(type, price, length)[-displace];
def isHigher = ma > ma[1];
def isLower = ma < ma[1];
AddLabel(yes, if isHigher and !isHigher[1] then "Up Now" else if isHigher then "Up" else if isLower and !isLower[1] then "Down Now" else if isLower then "Down" else "Flat", Color.BLACK);
AssignBackgroundColor(if isHigher and !isHigher[1] then Color.GREEN else if isHigher then Color.DARK_GREEN else if isLower and !isLower[1] then Color.RED else if isLower then Color.DARK_RED else Color.WHITE);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on September 10, 2019 6:47 pm