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.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 05-16-2007, 07:38 AM   #1
MrBaffalo
Senior Member
 
Join Date: Nov 2006
Location: Ferrara, , Italy
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default Position.AvgPrice

Hi Guys,
just a technical question:
During bar update process, I need to change dynamically stop orders, so I tried to follow two different approaches to valorize my actual position (p&l), the first is Position.AvgPrice-Close[0] or Close[0]-Position.AvgPrice if short, the second one is Position.GetProfitLoss(Close[0], PerformanceUnit.Points).
Well, the question is: do the following methods get updated at the same time?

For example, the code below does a partial exit with 2 different stop orders, when I apply it and when I've been executed limit, the first stop order is not cancelled till the end of the bar, while the second stop order, as the second limit one are placed, so during fast market as today under datas, I've been long 2 with 2 stop orders placed.
I'm running the code with Calculateonbarclose=false.
In this case which one is the best method I can use?
That's a piece of code:
Code:
if (Position.MarketPosition == MarketPosition.Long){
					if (Position.Quantity == ctr)
					{
					
						ExitLongLimit(ctr/3, (Position.AvgPrice + target1), "1st Exit", "");
						ExitLongStop(ctr, (Position.AvgPrice - stop), "1stStop", "");
					}
					else if (Position.Quantity == (ctr/3)*2)
					
					{
						ExitLongLimit(ctr/3, (Position.AvgPrice + target2), "2nd Exit", "");
					    ExitLongStop(Position.Quantity , (Position.AvgPrice - secondstop), "2ndStop", "");
						
					}
Tnaks
Marce
MrBaffalo 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


All times are GMT -6. The time now is 02:23 PM.