Baseline Summation has now been simplified from 123 lines to 29 lines of code.
And finally, the Baseline Summation parameter is no longer fixed at 35 period lookback...it can be changed to whatever the user prefers.
_first = close - low
_second = close - high
_third = 0.
for i = 1 to 35
_first := _first + (high <= close ? tr : 0)
_second := _second + (low >= close ? -tr : 0)
_third := _third + (high > close ? (low < close ? (close - low) + (close - high) : 0 ) : 0)
summation = _first + _second + _third
BaselineSummation = Baseline()
BaselineColor = BaselineSummation > 0 ? color.green : color.red
plot(BaselineSummation, "BaselineSummation", BaselineColor)
Although I have a question, would not be better to declare high, low, close just once? like CLOSE = close, HIGH = high and LOW = low? Wouldn`t this make script faster? Asking this because I want to combine this code with what I have and already having dozens and looking to improve the loading speed. Thanks in advance