PDA

View Full Version : How to tell if a stop loss/target has been hit in NinjaScrpt?


zoltran
04-13-2007, 12:33 PM
How would you check if your stop has been hit, and at what price?

NinjaTrader_Dierk
04-13-2007, 11:17 PM
Do you mean in the strategy isself or in the NT UI?

zoltran
04-14-2007, 12:52 AM
In the strategy.
For example, I want to fire an alert and/or email when the stop is hit.

Easy to do if the strategy just uses ExitShort/Long as I have control.
But Stops are set and then triggered outside my program logic.

NinjaTrader_Dierk
04-14-2007, 04:25 AM
Hmm, let me think. You could monitor Position.MarketPosition and Position.Quantity and check for changes in your OnBarUpdate method. If your position "goes down" an exit must have triggered.

plipa
04-15-2007, 08:02 AM
Dierk Droth wrote: You could monitor Position.MarketPosition and Position.Quantity and check for changes in your OnBarUpdate method.


Hi, I can't find any reference to the Position.MarketPosition and Position.Quantity members in the Help doucmentation (NT6beta11). I think there was an empty page titled 'Position' in the NinjaScript section of the manual of the NT6beta10, but now it seems to be gone.

a) Is it not possible to access these fields any more?

b) If they are still accessible (and will remain in the forseeable future), what exactly do they return (i.e. I guess that Position.MarketPosition holds the total current position of the primary instrument - that is all filled orders, but what does Position.Quantity hold?).

c) are there other undocumented position related fields of interest for an automated strategy?

Thanks in advance for clarification.

Peter Lipa


PS: FYI, the current Nt6beta11 online docu http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?ReleaseNotes has some missing .jpg's in the updated NinjaScript Tutorial sections. The installed (local) docu, however,is fine.

NinjaTrader_Ray
04-15-2007, 08:23 AM
See here - http://www.ninjatrader-support.com/HelpGuideV6/MarketPosition.html

Thanks for the missing images comment.

Ray

plipa
04-15-2007, 09:47 AM
Ahh, many thanks!

Sorry, that was a stupid question...