Hi, I am trying to use a SymbolData class to store securities specific values but am not able to get it to work properly. I have simplified my algorithm to illustrate the problem below:

Algo Strategy: The illiustrative algo uses fast and slow SMAs to generate buy and sell signals. Buy signals are generated when fast SMA moves above slow SMA and Sell signals are generated when slow SMA moves above fast SMA. The algo then extends to invest in multiple securities.

For the signals, in OnData(), I use a bsignal boolean to store the buy signal then reset its value at the end of OnData(), vice versa for sell signal using ssignal boolean. Orders are then placed according to these signals. Additionally, if the security was originally long in the portfolio, and a sell signal comes in, then the portfolio should liquidate the long and enter a short, vice versa for original short in the portfolio.

The problem is: I could get this working with one security, but when I try to implement this for multiple securities, the algo just breaks down: in particular, i. the buy and sell signal vars (ie. bsignal and ssignal) for each Symbol Data instance do no reset at the end of OnData() shown in the logs. ii. the liquidationplaced var also does not reset at the end of OnData()

Result of the problem: the strategy kept making duplicated trade pairs when I included more than one security to be invested since the bsignal and ssignal were not resetting. liquidationplaced not resetting also caused more problems in my actual extended algo.

Any help on this is deeply appreciated. Thanks a lot!