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-10-2007, 06:07 AM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

I'm pretty sure there is a problem with MarketPosition.Flat

This works .. for determining if I'm not in a Long or Short ...

if (Position.MarketPosition != MarketPosition.Short && Position.MarketPosition != MarketPosition.Long )

But this seems to be a no-op
if (Position.MarketPosition == MarketPosition.Flat)

6 b2 Plus Dierks mods from last week




zoltran is offline  
Reply With Quote
Old 04-10-2007, 06:29 AM   #2
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

I am 100% positive that it does work.

Try this:

Quote:
Print(Position.MarketPosition.ToString());
if (Position.MarketPosition == MarketPosition.Flat)
Print("Confirm I am flat");
Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-10-2007, 06:49 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

Of course you are right.
I had the strategy running on two charts and I was seeing the debug output from a 'flat' strategy mixed in my long output.

A second question ...

Is there a method I can use to determine the active instrument?






zoltran is offline  
Reply With Quote
Old 04-10-2007, 06:57 AM   #4
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

Do you mean printing out what Instrument the strategy is running? If yes, try this -

http://www.ninjatrader-support.com/H...tFullName.html

Ray
NinjaTrader_Ray 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 09:20 AM.