Spectre2007, that is one awesome set of posts -- a lot of work for the ET crowd. I would suggest a "Technical Modern Trader & Commodities"* article, straight away. [That would help *me*, anyway, to get beyond those first two posts....to where I missed steps along the way.] * kinda like "TarKWallMartGet"...
2340 is not a precise statistical outlier.. so costs were significant at maintaining the straddle. If you look at: significant deviation @ B is around 2333, if you plugged that into ninjatrader the transaction costs come to a tenth. That's why picking a precise statistical outlier is crucial. Deviations from A and B would need to occur first to create 'structure'.. In upwardly trending market, you want to pick the lower outlier 'B' since, in upward market consolidation structures occur at the upper end of the range.
You could always count the cross overs and stop the algo at a certain number or use the PnL block to stop it if X dollars down.
Had to create an account just to say @Spectre2007 you went all out on that, wow. OP might look into single-crossing property, fixed point theorems, many ways to implement desired trading rule. Try creating an index function with f(.) ∈ {1,0} based on whether your condition is met, and pass the output to your order quantity. Evaluation of a terse expression may be efficient vs evaluation of if/than statements or a while loop. Still have to deal with local jump risk though, GL!
outright straddle costs 1762.5 plus commissions.. 60 points profit on active position.. 3K = 1238 net. 1238 net plus profit on lifting the short straddle.. .. total profit on both plays .. around 2200 if lifting both to go full cash.