NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-13-2007, 12:33 PM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

How would you check if your stop has been hit, and at what price?
zoltran is offline  
Reply With Quote
Old 04-13-2007, 11:17 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Do you mean in the strategy isself or in the NT UI?

NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-14-2007, 12:52 AM   #3
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

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.
zoltran is offline  
Reply With Quote
Old 04-14-2007, 04:25 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

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.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 04-15-2007, 08:02 AM   #5
plipa
 
Join Date: Apr 2007
Location: Tucson, Arizona, USA
Posts: 29
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Dierk Droth wrote:
Quote:
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/H...l?ReleaseNotes has some missing .jpg's in the updated NinjaScript Tutorial sections. The installed (local) docu, however,is fine.


plipa is offline  
Reply With Quote
Old 04-15-2007, 08:23 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

See here - http://www.ninjatrader-support.com/H...tPosition.html

Thanks for the missing images comment.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-15-2007, 09:47 AM   #7
plipa
 
Join Date: Apr 2007
Location: Tucson, Arizona, USA
Posts: 29
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Ahh, many thanks!

Sorry, that was a stupid question...
plipa is offline  
Reply With Quote
Old 07-10-2012, 10:05 PM   #8
geekodude
Junior Member
 
Join Date: May 2011
Posts: 15
Thanks: 3
Thanked 2 times in 1 post
Default Query Stop Loss Event

Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

if (Position.MarketPosition = MarketPosition.Flat)

is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?
geekodude is offline  
Reply With Quote
Old 07-10-2012, 10:15 PM   #9
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,219
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by geekodude View Post
Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

if (Position.MarketPosition = MarketPosition.Flat)

is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?
Same question in this thread: http://www.ninjatrader.com/support/f...osition+global
koganam is offline  
Reply With Quote
Old 07-11-2012, 02:11 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Quote:
Originally Posted by geekodude View Post
Hi I am having the same stop loss query issue here. However, I am writing 2 independent strategies where I want to query for a stop loss within each strategy. For example if I use

if (Position.MarketPosition = MarketPosition.Flat)

is the above statement global or local in nature? If strategy#1 has an open position & strategy #2 just got stopped out when using the above line in strategy#2 give flat? If not, how to query for stoploss event WITHIN the strategy?
The Position would report per individual strategy instance, strategies would unfortunately not cross communicate. Some users have reported success by exchanging the info needed via text files for example.

Another option is combining signals into one 'master' strategy so individual fills for each entry become querable.
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:55 PM.