PDA

View Full Version : Retrieving Post-Entry Positions Data


borland
02-09-2010, 03:29 PM
Is there a method in NinjaScript to find the position...

- entry price or the current price at the time the entry order was triggered,
- date/time the current entry was ordered or triggered,
- number of entry shares
- current number of trades triggered when multiple round trips are permitted.

NinjaTrader_Josh
02-09-2010, 03:46 PM
borland,

To receive this information you would have had to hold onto an IOrder reference to the entry order. Then you can access the various IOrder properties to grab the information you need.

borland
02-09-2010, 08:00 PM
I see the note in the Help guide....

Tips
1. Not all connectivity providers support all MarketDataTypes.

NinjaTrader_Josh
02-10-2010, 07:13 AM
borland,

MarketDataType is not relevant in this case as your question is about orders. MarketDataType refers to things like L2 bid/ask data.

borland
02-16-2010, 11:03 AM
Actually I found that the IPosition interface provide most of what I was looking for except for the entry date....

- AvgPrice
- Quantity
- Instrument
- MarketPosition (Flat, Long, Short)

It would be nice if the IPosition interface also included the EntryDate (hint suggestion for improvement).

When entering a new position, I can set user variables for entryDate using OnPositionUpdate().

protected override void OnPositionUpdate(IPosition position)
{
if (position.MarketPosition == MarketPosition.Flat)
{
// Do something like reset some variables here
}
}


Question is, when NT7 is released, will these user variables also be persistant/retained?

NinjaTrader_Austin
02-16-2010, 02:16 PM
borland, thank you for the suggestion. I'm not sure what you mean by 'will these variables be persistant/retained'. Could you please clarify?

Variables will only exist in the scope they are created, and you can set/reset/whatever these variables when you want to. They will not be saved if you close and restart NinjaTrader, for example. Each time you apply an indicator to a chart or a strategy, that counts as one instance of the object and thus variables will stick around for that instance, unless you write to some external area (database, flat file, etc).

borland
02-16-2010, 04:29 PM
Austin,

After restarting the computer and relaunching NT version 7 (when released).

I understood that unlike the current version of NT (version 6), version 7 would allow restarting the computer with a running strategy since any changes to a trade position would be automatically saved to file. So, based on that, I was wondering if any user defined Ninjascript variables in a trade Strategy would be also saved?

NinjaTrader_Josh
02-17-2010, 07:19 AM
borland,

I am not sure where you got the idea that the strategy writes a trade position to a file. In NT7 there is strategy persistence in that you can persist strategies on the Strategies tab for quick relaunching when you restart NT. This is not to say anything is "saved" in regards to position, etc.

When restarting a strategy in NT7 you have the option to try and have it match back to live accounts. If it can't you can have it try to sync your account position to the strategy position.