1) Don't call GetQty() unless you want to know the quantity. What you did in the EnterLong/EnterShort is how you use it. Don't call any methods in OnStateChange. I removed GetQty() from both OnStateChange and that call you had in OnBarUpdate. Of course I left it where you had it in the calls to EnterLong/EnterShort.
2) Call the base class in OnStateChange AND OnBarUpdate
That was it, I think. I was impressed you figured out how to inherit MartingaleBase!! Points for that...
TestDemo.zip
Comment