I had been using a snippet of code that was basically bulletproof - when I was using it on a single account. This code looked to see when the first exit (of many exits) in a trade occurred. When that happened, it would ratchet the trailing stop to the entry price. The snippet of code is as follows:
If( Performance.Executions[Performance.Executions.Count - 1].Exit && !Performance.Executions[Performance.Executions.Count - 1].LastExit && !TradeData[BarsInProgress].firstExit) { ...Code runs... }
Now, here's the rub: After learning that NT does not support allocation to Interactive Brokers, I've gone to running identical scripts in parallel. The only change for each NinjaScript is the account. In other words, I have two separate IB accounts, and I'm running two identical NT scripts, each with a different account.
In backtesting for single accounts, the above code is bullet proof. In live trading for single accounts, again it's bullet proof. However, when running identical scripts in parallel, it will not consistently resolve. I can't figure out the situations where it won't resolve, but I can say that it does not consistently resolve as it should. My solution has been to re-load each script when I know this code would have resolved, and thus everything is set correctly. However, this means that each script was run in serial (basically, backtesting conditions).
Now, you can imagine that I don't want to debug my code in the middle of live trading. And in testing I can't think of ways to debug and run two simultaneous scripts. So I'm here to ask the devs.
Please give me a rundown on how "Performance.Executions[Performance.Executions.Count - 1].Exit" and Performance.Executions[Performance.Executions.Count - 1].LastExit" work in the context of multiple instruments. I get the feeling that .Exit and .LastExit are somehow globally set variables and are not local to the script. Is this the case? If so, I can always re-build the exit logic, but I'd prefer not to.
Comment