The candle is locally-longest if it is longer than 3 candles in both sides. The locally-longest candle dominates the said candles in either side of it and they don't count no matter the color.
You can't know the 3 candles in the future.
So you have to wait 3 periods to determine wether a candle is locally dominant.
Have you simulated what's the rentability of your strategy if you place the buy/sell order 3 periods later than the locally dominant candle?
The script you quoted was based on my earlier, "soft" way of assessing whether we are in an uptrend or not. It was criticized because of unaccountability (by the very people who never divulge anything they have actually done, just claiming to have been, and being, correct all the time which is kind of annoying).
So I wanted to write an algorithm that would work in a similar way but actually be implementable:
IF "the last row volume is at least A" &
"the highest volume in the last B rows is to the same direction as the last volume" &
"the last change is at least C" &
"the new signal is to the opposite direction as the current signal",
THEN give a new signal.
- The parameters A, B, C can be fully customized. As you change them, you see in real time what signals the system would have given and when, how many total signals (too many leads to increase in fees), and what is the end result in $ or bitcoins in this time period. You can try several values per minute, and then zoom in to the interesting parts of the data, such as the flashcrashes.
It is not looking into the future, but it places a lag on the trend changes because the volume towards the new trend direction has to be greater than the volume in the old direction, in any of the previous B time periods.
I am hesitant to implement this because it is based on volume, which is so easy to manipulate. Also this one seems to do terribly once the rise starts. (If you can know the exact high and low points of the downtrend, even more than 3-4x your bitcoins can easily be achieved so trading algo is not needed

)
Price is not considered when it gives the signals, haha funny. Blind monkey.