I am a newb, first and foremost, and starting out fresh. Currently I am trying to build out an Algo that simply follows a 30,60 MAVG.
Right out of the gate, my algo tries dumping position I do not (or should not) have; if my buy criteria is 30MAVG > 60MAVG, and the backtest starts out with just the opposite, I should NOT be sitting on any open positions. However, sell my close criteria is 30MAVG < 60MAVG, it tries to dumping my order amount, which in this case is +/-100%.
What is even odder is that I am getting some returns before any positions are actually opened, aka 30MAVG < 60MAVG (about 75-days into the backtest).
Any I missing something or is this something to do with the IDE?
Additionally, I am trying to figure out how to restricting the number of open orders to X so I am not constantly buying—even if X is a fraction of my overall portfolio—and the buy amount to the current value of said stock:
current_value = data.current(context.stock, "price")
order(context.stock, current_value*1)
Thanks for any and all help!