WL for HULL in TOS


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
12 views
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: 36, Answers: 2022)
Answered on September 10, 2019 6:47 pm