NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > ATM Strategies (Discretionary Trading)

ATM Strategies (Discretionary Trading) Support for Advanced Trade Management, AutoTrail, AutoBreakeven, Stop Strategy and Simulated Stops etc...

Reply
 
Thread Tools Display Modes
Old 11-01-2010, 03:52 PM   #1
james377
Member
 
Join Date: May 2009
Posts: 60
Thanks: 0
Thanked 0 times in 0 posts
Default Position.Avgprice

Print ("Position.AvgPrice = " + Position.AvgPrice);
EnterLongStop(High[1] + (entry * ATR(14)[0]), "");

Why does this print a value before I have entered the trade?

is this Position.AvgPrice looking at my last trade or something???

how do i clear this value or set it to 0 as it seems to be messing up my calculations further on in my code..

or could somebody tell me why this is happening?
james377 is offline  
Reply With Quote
Old 11-01-2010, 04:24 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello James 377,

Position.Avg price returns zero when you're flat.

You could check that you are in a position prior to accessing it.

if (Position.MarketPosition != MarketPosition.Flat)
Print ("Position.AvgPrice = " + Position.AvgPrice);
NinjaTrader_RyanM 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
position.AvgPrice causing problems within strategy suprsnipes Strategy Development 7 03-19-2010 05:00 AM
Position.AvgPrice Faspomy Strategy Development 7 02-16-2010 10:52 AM
Position.AvgPrice Real Value daven Automated Trading 1 10-30-2008 09:31 AM
Why Position.AvgPrice gives not exact price pmaglio Strategy Development 8 07-24-2008 12:32 PM
Position.AvgPrice MrBaffalo Strategy Development 1 05-16-2007 09:01 AM


All times are GMT -6. The time now is 01:20 AM.