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 08-05-2008, 08:51 AM   #1
Ninja in Training
Junior Member
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Question How to return the Position Entry Price??

How do I return the Position Entry Price after an entry is filled?

I have a StopLoss/TrailStop strategy that sets a tight Stoploss and turns into a loose Trailstop as the price rises. The Stop Price that I use for the ExitLongStop( ) is currently based on the previous close[0] from the entry price. However, this produces bad results when the price gap up or down, so I’d like to base the stoploss price off the Position Entry Price rather than the previous Close[0].
Ninja in Training is offline  
Reply With Quote
Old 08-05-2008, 08:56 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
Default

You can get the average price of a position via

Position.AvgPrice - http://www.ninjatrader-support.com/H.../AvgPrice.html
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-05-2008, 09:33 AM   #3
Ninja in Training
Junior Member
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank You Ray,

Will the code below return the entry price of the Long Position??

If (Position.MarketPostion == MarketPosition.Flat)
{
If (Close[0] > Close [1]) //entry condition
{
EnterLong(1)
x = Position.AvgPrice // positon entry price
}
}

Given my current understanding NT will enter on the next BarUpdate and therefore the code will NOT work because the Long postion will not have been completed yet.
Last edited by Ninja in Training; 08-05-2008 at 09:34 AM. Reason: clarification
Ninja in Training is offline  
Reply With Quote
Old 08-05-2008, 10:06 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
Default

Your understanding is correct, it would not work.
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
Avg Entry Price in a Strategy Sartis23 SuperDOM and other Order Entry Windows 1 03-28-2008 08:17 AM
Price Entry and EMA Close gygraham Strategy Development 6 03-21-2008 10:06 AM
Price Entry and EMA Close gygraham Strategy Development 0 03-19-2008 12:38 PM
capture Strategy position ENTRY by bar Bob10 Strategy Development 7 02-09-2008 11:38 AM
Incorrect position entry on SIM EuroFX Miscellaneous Support 12 09-24-2006 01:33 PM


All times are GMT -6. The time now is 10:22 AM.