Hello guys

I am pretty new to this so forgive me if the answer to this is obvious. I'll attach the code below for anyone interested but essentially I have tried to make a trading strategy where I buy the “EURUSD” currency pair whenever the price crosses above a long term Moving Average, and liquidate my position when the price falls back below either the long term Moving Average or the shorter term one, depending on which it hits first.

This works for the first few hundred trades but then on (2011, 6, 7) the algorithm places a buy order which is then never liquidated. I cannot figure out why.

In theory for my equity to fall as much as it does after this point the price must hit one of the moving averages but it does not.