kieran-mackle / AutoTrader

A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
https://kieran-mackle.github.io/AutoTrader/
GNU General Public License v3.0
937 stars 216 forks source link

Range exception index -1 in indicator method unroll_signal_list #74

Open fredblockchain opened 1 year ago

fredblockchain commented 1 year ago

Describe the bug Hi Kieran, First of all, thanks for the work you've done, I'm currently trying to learn from your indicators,I liked the idea you implemented for swing detection, that's when I found this issue. It looks a bit too obvious to me, it kind of looks like it would always fail, so maybe I'm doing something wrong.

I detected that the determination of the range for the following FOR loop is starting with 0 and the "signal[i-1]" part is not working because of a negative index during the first iteration:

for i in range(len(signals)): if signals[i] != signals[i - 1]: unrolled_signals[i] = signals[i]

Same exception if I try to run it on an indicator (rsi)

To Reproduce

Expected behavior The following modification makes it work, making it start from 1. for i in range(1, len(signals)): Results look good

Version of AutoTrader being used the last one, from this commit

If you need anything, just le me know Cheers Fred