==========
//Friday Code
if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 133000)
{
if (Position.MarketPosition == MarketPosition.Long)
ExitLong(@"LongHACEU");
else if (Position.MarketPosition == MarketPosition.Short)
ExitShort(@"ShortHACEU");
if (State == State.Realtime)
{
CloseStrategy(null);
SetState(State.Terminated);
Print("Condition not met. Disabling Strategy" + Time[0].ToString());
return;
}
}
===========================
The code is correctly closing positions but opening duplicates leaving me open with buy and sell orders. I suspect the CloseStrategy() call is not working properly. I put the CloseStratgy() as a precautionary measure to close any pending orders that might not have closed out properly but what is happening is, If I have a position open on Friday at 13:30, then the Exit closes out the position but I see an additional buy and sell placed after the successful close.
See below the logs. Looks like there is no need for CloseStratgy() here. Is it not a supported call?
Closing Position:
============
6/22/2018 13:29 Order Order='639495729/401308720' Name='Profit target' New state='Cancel submitted' Instrument='EURUSD' Action='Sell' Limit price=1.18102 Stop price=0 Quantity=2,000 Type='Limit' Time in force=GTC Oco='639495726' Filled=0 Fill price=0 Error='No error' Native error=''
6/22/2018 13:29 Order Order='639510005/401308720' Name='Sell' New state='Submitted' Instrument='EURUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=2,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
6/22/2018 13:29 Default Disabling NinjaScript strategy 'Ninja8HACUD/140038321'
6/22/2018 13:29 NinjaScript NinjaScript strategy 'Ninja8HACUD/140038321' submitting order
6/22/2018 13:29 Default Disabling NinjaScript strategy 'Ninja8HACEU/140038320'
6/22/2018 13:29 NinjaScript NinjaScript strategy 'Ninja8HACEU/140038320' submitting order
Then NT8 reports an error saying "Order ID not found" and places a new sell order.
=============
6/22/2018 13:30 Order Order='639510007/401308720' Name='' New state='Accepted' Instrument='EURUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=2,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
6/22/2018 13:30 Order Order='639510007/401308720' Name='' New state='Submitted' Instrument='EURUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=2,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
6/22/2018 13:30 Position Instrument='EURUSD' Account='401308720' Average price=0 Quantity=0 Market position=Flat Operation=Remove
6/22/2018 13:30 Order 401308720, Order id 639510005 is not found. affected Order: Sell 2000 Market
================
Comment