Code:

```
input Value = close;
input Length = 55;
def HMA = MovingAverage(AverageType.HULL, Value, length);
def HMADisplaced = MovingAverage(AverageType.HULL, Value, length)[1];
def cu = Crosses(HMA, HMADisplaced, CrossingDirection.ABOVE);
def cd = Crosses(HMA, HMADisplaced, CrossingDirection.BELOW);
def Sell = if cd then high else Double.NEGATIVE_INFINITY;
def Buy = if cu then low else Double.POSITIVE_INFINITY;
plot uptrend = Sell > Sell[1] and Buy > Buy[1];
plot dntrend = Sell < Sell[1] and Buy < Buy[1];
```