Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help needed for a newbie. Stop loss with SMA

Hi community,

I am new in both Quantopian and python, so bear with me and my horrible programming skills. I am trying to implement a simple Dynamic Stop loss in few random securities. So far, I am using a small percentage of the entry price i.e. 1-2% to set up the width of the STOP LOSS.

However, after analyzing results and transactions I appreciate there is a problem with the buying/selling. I switched on a counter to monitor the amount of times I buy or sell shares of a security.

QUESTIONS:
1-When I plot SMA on record()...which of the securities is being displayed? Presumably each security has its own SMA value...
2-If I rebalance everyday, shouldn't I only buy share of one security ONCE every day. Looking into the transaction details I see this is not the case...
3-How can I implement a cleaner code to control the dynamic stop loss and the transactions?

Many thanks,

Juan