The way to check you put properly orders can be reflected in your code if you consider that the datas come 1 by 1, like in real time (so use a for loop and for each new price, calculate the new moving average point,...).
It's not specific to matlab anyway but it's true that you can use a lot...