I started developing NT8 strategies on my own a couple months ago. Until recently, I was using EnterLong/EnterShort, SetProfitTarget, and SetStopLoss for my entry and exit logic. I started using orders as objects logic (private Order entryOrder = null; ) so I could use limit orders (EnterLongLimit/EnterShortLimit) and determine if the orders are active by checking if they are null.
With my first market-order strategies I would use a bool to prevent multiple instances of the same command from being generated.
private bool shortTradeEntered = false; // bool to prevent multiple instances of the same command being generated
if (some logic && shortTradeEntered == false)
{
shortTradeEntered = true;
EnterShort(0, 1, "shortTrade");
SetStopLoss(.......);
SetProfitTarget(.......);
}
Then depending on the strategy I would reset the bool to false at the appropriate time to allow for the another short entry once the trade completes.
With the orders as objects logic I have not done this. When live trading with it I get anywhere from 10 - 25 duplicate/ignored "Entered internal SubmitOrderManaged..." orders. When an order is cancelled before it is filled I get 20-40 "Cancelled custom managed order" messages in the output window. I fully understand why this is occurring, and the strategy is entering and exiting orders as intended.
What I am curious about is if there is a best practice to deal with this? Does this method of allowing and ignoring multiple duplicate commands utilize more resources and possibly create errors that will halt a trading strategy during peak volume? Or does adding bools to limit the entered orders to one instance create additional unneeded complication in a strategy's logic?
I appreciate anyone's input on how they handle this.
And I did look through the forum before submitting this and did not find anything specifically addressing this question. So hopefully it has not been discussed already.
Comment