Hi All,
I created a label for the hull indicator and I tried to add a bar counter to the label. I took some code from else where and tried to make it work, with no success. Can anyone take a look at it and help me out. I am not coder but I try.
Thanks,
Erik
input timeFrame = AggregationPeriod.hour;
input maLengthOne = 16;
input maTypeOne = AverageType.HULL;
def maOne = MovingAverage(maTypeOne, close(period = timeFrame), maLengthOne);
rec trackDirection = if maOne > maOne[1] then 1 else -1;
AddLabel(yes, "HMA-H", if trackDirection > 0 then Color.GREEN else Color.RED);
def nan = double.nan;
def barUp = maOne > 0;
def barDown = maOne < 0;
def barUpCount = CompoundValue(1, if barUp then barUpCount[1] + 1 else 0, 0);
def pBarUpCount = if barUpCount > 0 then barUpCount else nan;
def barDownCount = CompoundValue(1, if barDown then barDownCount[1] - 1 else 0, 0);
def pBarDownCount = if barDownCount < 0 then barDownCount else nan;
AddLabel(yes, "" +(" "+(Round(barDownCount + barUpCount, 1))), if barUpCount >= 1 then color.green else if barDownCount <= -1 then color.red else Color.gray);
I created a label for the hull indicator and I tried to add a bar counter to the label. I took some code from else where and tried to make it work, with no success. Can anyone take a look at it and help me out. I am not coder but I try.
Thanks,
Erik
input timeFrame = AggregationPeriod.hour;
input maLengthOne = 16;
input maTypeOne = AverageType.HULL;
def maOne = MovingAverage(maTypeOne, close(period = timeFrame), maLengthOne);
rec trackDirection = if maOne > maOne[1] then 1 else -1;
AddLabel(yes, "HMA-H", if trackDirection > 0 then Color.GREEN else Color.RED);
def nan = double.nan;
def barUp = maOne > 0;
def barDown = maOne < 0;
def barUpCount = CompoundValue(1, if barUp then barUpCount[1] + 1 else 0, 0);
def pBarUpCount = if barUpCount > 0 then barUpCount else nan;
def barDownCount = CompoundValue(1, if barDown then barDownCount[1] - 1 else 0, 0);
def pBarDownCount = if barDownCount < 0 then barDownCount else nan;
AddLabel(yes, "" +(" "+(Round(barDownCount + barUpCount, 1))), if barUpCount >= 1 then color.green else if barDownCount <= -1 then color.red else Color.gray);