Im trying to get the bar number and ultimate the high of the last FractalUP. I can't seem to get the data though. I want to know when the current high crosses above the high of the last fractalUp.
The white label give me N/A.
The white label give me N/A.
Code:
def sequenceCount = 2;
def bn = barnumber();
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;
def UpFractalBN = if UpFractal then bn else UpFractalBN[1];
def UpHigh = if bn == UpFractalBN then high else UpHigh[1];
def CrosSUp = if high crosses above Uphigh then 1 else 0;
addlabel(yes, CrosSUp, color.white);
addchartbubble(UpHigh,high,UpHigh,color.white);