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 > 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.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 10-30-2008, 09:02 AM   #1
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 329
Thanks: 0
Thanked 11 times in 8 posts
Default Position.AvgPrice Real Value

I have always assumed that when calling "Position.AvgPrice" for position one gets the average ENTRY price for a position, but judging by how my strategy is behaving it appears that I am actually getting the average Price of my combined positions based on what they were at the last bar close. My problem is I am using the above price as a limit order for the remaining runner after I take off two contracts at a first profit target. Here is the code I am using.

Code:
if (Position.MarketPosition == MarketPosition.Short
                && Position.Quantity == 1)
            {
                ExitShortLimit(Position.AvgPrice , "SBreakEven Exit", "SRunner");
            }
The problem is, this order is executing on the next bar after I close out the first two contracts and the price it is closing at, is generally the same as my first profit exit. If, as I suspect, the Position.AvgPrice gives us the avg price of the position at the time it is called, then is there a way to get the average entry price of a position? Perhaps store a variable and refer to it later? Or better yet, there is an actual command that provides the average entry price of a position. It seems that would be a very useful command if you don't already have it.
Thanks
DaveN
daven is offline  
Reply With Quote
 

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
syncing strategy position with acct position pistolpete Automated Trading 21 03-23-2009 07:15 AM
Market Replay vs. Real-world/Real-time ctrlbrk Strategy Development 14 12-01-2008 03:16 PM
Why Position.AvgPrice gives not exact price pmaglio Strategy Development 8 07-24-2008 12:32 PM
How real real-time DOM and TS ? maxima General Programming 5 05-01-2008 02:54 PM
Position.AvgPrice MrBaffalo Strategy Development 1 05-16-2007 09:01 AM


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