I have a fully functional code for taking my automated trades. It has always been taking market orders for entry. I have made a copy where I want to have it switched to limit orders a set number of ticks below the market. I currently have all of that working so that's all good. My issue is when my limit order is cancelled if not filled in the first bar, I assume my system thinks it is still in a trade or something because it is not reset.
I have read through all the code pieces related to limit trades and cancelled trades and attempted to use those pieces of codes but have not had any luck. I have attached a few links I have been using to try and figure it out. The code pieces that I have entered will be in here as well. Maybe I have the code in the wrong areas?
Code for LongLimit:
private Order myEntryOrder = null; -this is defined at the beginning of the code, do I need this defined before the onbarupdate?
if(TradeSize1 != 0)
{
Trade_1_In_Progress_Long = true;
EnterLongLimit(TradeSize1, (Close[0]-(TicksLimitLong* TickSize)) , "LE 1");
InTrade = true;
IsLongTrade = true;
activeBar = CurrentBar;
if (myEntryOrder.OrderState == OrderState.Cancelled)
{
myEntryOrder = null;
}
}

Comment