I want to check upon startup that my code is running in a flat environment for the Instrument. It already is set to wait until flat. But it doesn't actually wait until flat. and this code I created also doesn't work. What I mean is, I create a short position in the chart trade for an instrument... then when I enable the strategy, the strategy runs immediately and won't print this error message.
also if I remove this code, and just rely on "wait until flat".. that also doesn't care about the flat state of the instrument in the Positions tab beforehand. Both chart trader and my strategy run on Sim101
This code from OnStateChange I created, I can't get it to work
else if (State == State.Active)
{
if (PositionAccount.Quantity > 0) {
Print(String,Format("{0} already has open position in the Account\n{1}\nStopping {2}", Instrument.MasterInstrument.Name, PositionAccount, this.GetType().Name));
CloseStrategy(this.GetType().Name);
}
Comment