William Fractal Color Watchlist


Category:
0
0

Hello Pete,

I hope you’re doing well.

Is it possible to have a William Fractal Color Watchlist

Sequence count set to 1

UpFractal turns field Red

Down Fractal turns field Green

And black field if nothing is triggered?

Thank you for any help with this

 

Ellis

Marked as spam
Posted by (Questions: 3, Answers: 5)
Asked on April 27, 2021 12:04 pm
110 views
0
Private answer

I had to color the values green and red because this code would not allow me to apply the background color.

Here is the code that you requested:

input sequenceCount = 1;
def maxSideLength = sequenceCount + 10;
def upRightSide = fold i1 = 1 to maxSideLength + 1 with count1 while count1 != sequenceCount and count1 != -1 do
if GetValue(high, -i1, -maxSideLength) > high or (GetValue(high, -i1, -maxSideLength) == high and count1 == 0) then -1
else if GetValue(high, -i1, -maxSideLength) < high then count1 + 1 else count1; def upLeftSide = fold i2 = 1 to maxSideLength + 1 with count2 while count2 != sequenceCount and count2 != -1 do if GetValue(high, i2, maxSideLength) > high or (GetValue(high, i2, maxSideLength) == high and count2 >= 1) then -1
else if GetValue(high, i2, maxSideLength) < high then count2 + 1 else count2;
def downRightSide = fold i3 = 1 to maxSideLength + 1 with count3 while count3 != sequenceCount and count3 != -1 do
if GetValue(low, -i3, -maxSideLength) < low or (GetValue(low, -i3, -maxSideLength) == low and count3 == 0) then -1 else if GetValue(high, -i3, -maxSideLength) > low then count3 + 1 else count3;
def downLeftSide = fold i4 = 1 to maxSideLength + 1 with count4 while count4 != sequenceCount and count4 != -1 do
if GetValue(low, i4, maxSideLength) < low or (GetValue(low, i4, maxSideLength) == low and count4 >= 1) then -1
else if GetValue(low, i4, maxSideLength) > low then count4 + 1 else count4;
def upFractal = if upRightSide == sequenceCount and upLeftSide == sequenceCount then high else Double.NaN;
def downFractal = if downRightSide == sequenceCount and downLeftSide == sequenceCount then low else Double.NaN;
plot data = if !IsNaN(upFractal[1]) then 1 else if !IsNaN(downFractal[1]) then -1 else 0;
data.AssignValueColor(if data > 0 then Color.GREEN else if data < 0 then Color.RED else Color.CURRENT);

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on April 27, 2021 12:54 pm
0
Hello Pete Thank you so much. This is exactly what I needed. Ellis
( at April 27, 2021 1:20 pm)
0
Hello Pete Since the background color would not work, is it possible to add a label? "Support" label for Green for Down Fractal "Resistance" label Red for Up Fractal
( at April 27, 2021 1:38 pm)
0
The same bug that prevents the background color from working is likely to impact a chart label as well.
( at April 27, 2021 2:00 pm)
0
Ok, Thanks again for all your help.
( at April 27, 2021 2:16 pm)