INNER CODE UNIT · Python
high1
aticio/legitindicators · legitindicators.py:235
high1 = data[i-1][0]
low = data[i][1]
low1 = data[i-1][1]
close1 = data[i-1][2]
trng = max(max(high - low, abs(high - close1)), abs(low - close1))
if high - high1 > low1 - low:
directional_movement_plus = max(high - high1, 0)
else:
directional_movement_plus = 0
if low1 - low > high - high1:
directional_movement_minus = max(low1 - low, 0)
else:
directional_movement_minus = 0
smoothed_true_range.append(smoothed_true_range[i-1] - (smoothed_true_range[i-1] / length) + trng)
smoothed_directional_movement_plus.append(smoothed_directional_movement_plus[i-1] - (smoothed_directional_movement_plus[i - 1] / length) + directional_movement_plus)