NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 09-27-2007, 07:18 AM   #1
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default Determining Market Position

It seems there are two different ways to determine market position when using NScript launched ATM Strategies:

protected override void OnBarUpdate()
{
// Check if flat
if (GetAtmStrategyMarketPosition("id") == MarketPosition.Flat)
Print("ATM Strategy position is currently flat");
}


or

protected override void OnBarUpdate()
{
// If not flat print our open PnL
if (Position.MarketPosition != MarketPosition.Flat)
Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
}


I can't seem to get the first approach to work although other "get AtmStrategy...." commands are working.

Is there a preference for one over the other and are there limitations in using one over the other that need to be taken into account?

Also, in the if (GetAtmStrategyMarketPosition("id") == MarketPosition.Flat)
is the "id" element the unique id assigned to the atm strategy or "orderId" from the AtmStategyCreate command or "atmstrategyId" also from the AtmStrategyCreate Command?
daven
daven is offline  
Reply With Quote
Old 09-27-2007, 07:41 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

If you are working with ATM strategies from within a NinjaScript strategy, then you *must* use GetAtmMarketPosition(). Please see the SampleAtmStrategy that installs with NT for proper use of this method. The sample works.

"id" is the "amtStrategyId" value passed into the AtmStrategyCreate() method.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
returning the market position of a symbol HelloHello Automated Trading 1 08-29-2007 02:37 AM
Flat a position on a market Respond SuperDOM and other Order Entry Windows 2 06-27-2007 08:51 AM
Market data for market replay function grd974 Miscellaneous Support 1 05-26-2007 09:02 AM
Determining "Last Bar On Chart" NinjaTrader_Ray General Programming 2 01-16-2007 03:17 PM
Market Position value dwil Automated Trading 7 07-13-2006 04:02 AM


All times are GMT -6. The time now is 12:29 AM.