I'm trying to set up a really nice strategy here that will co-operate with my way of life. I travel a lot, and some times I just need to lose internet for a few minutes, or shut my computer down and come back in a few minutes. I want to keep my strategies running.
So with exceedingly great difficulty, I've actually got a ninja trader script that does that, all except for the annoying problem mentioned above.
See, because when I come back, all my strategies are shut down. So I have to restart them. And that means that Ninja Trader completely forgets that I am in the market, and Position.MarketPosition == flat, even though I'm still in my trades. Because the "Position" collection correlates to your strategy position, and not to your account position. So since the strategy was shut down, then strategy position == flat, and so Position.MarketPosition == flat as well.
So I use... brace yourself...
MyInstrument = new Instrument(new MasterInstrument("USDCAD", InstrumentType.Currency), Exchange.Default, DateTime.Today, 0, NinjaTrader.Cbi.Right.Unknown);
MyPosition = Account.Positions.FindByInstrument(MyInstrument);
Now please don't harass me for calling non-ninja script functions. I'm trying to make this work. Anyway, that gets me an accurate market position. I can now see that MyPosition.MarketPosition != flat. Great. And every time I place a new order, I simply refresh it by calling "MyPosition = Account.Positions.FindByInstrument(MyInstrument)" again, and that keeps me up-to-date on my position.
Problem...
When I then place a market trade, and I tell it to sell 1 contract at a limit order... I mean what I said, just 1 contract please. It will often sell two, because it doesn't realize that I am flat in the market. Because according to my "strategy position" I'm long, but in reality according to my account position I'm flat. That's caused by me shutting off the CPU while I'm in a short position, and so my first trade is long, which makes my account == flat, but my strategy == long. So then I try to sell 1 short limit entry, and it sells 2, one to supposedly "flatten" me, and one to fulfill my every desire.
I know this is a lot of trouble to fix, but please when you are developing the next edition of NT, please try to bare in mind that you have no idea what people might be doing. One of the most annoying things about the older versions of windows was how that Microsoft thought it knew what was best, and would try to dictate how people used Windows. Like when there were no cancel buttons, or programs would run or shut down or install things by force, because Microsoft knew what was best. I'm not trying to be mean in saying all of this, but to trade 2 contracts when I said to trade only 1 is a direct violation of user control.
Aaron
Comment