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 12-17-2006, 04:53 PM   #1
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

If I enter the market using EnterShort() or EnterLong(), how can I retrieve and display the entry price in the output window?Can Icheck the current pricefor each tick (notbar) using Bars.CurrentAsk and can it be printed?

Thanks.
SuzyG is offline  
Reply With Quote
Old 12-17-2006, 05:15 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Just set CalculateOnBarClose=false and OnBarUpdate is triggered for each tick.
Code:
   if (Position.AvgPrice > Bars.CurrentAsk)
    Print(Position.AvgPrice.ToString());
NinjaTrader_Dierk is offline  
Reply With Quote
Old 12-18-2006, 03:57 AM   #3
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

This is not working for me. The value is always 0 whether I am in the market or not. I want to see the current price and see what price I got in for.
SuzyG is offline  
Reply With Quote
Old 12-18-2006, 04:03 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
Post imported post

SuzyG,

Close[0] is the lasttrade of the current bar
Bars.CurrentAsk = ask price
Bars.CurrentBid = bid price

Include the following codesnipped into the OnBarUpdate() method and you will see data in the Output window:

Print(Close[0].ToString());
Print(Bars.CurrentAsk.ToString());
Print(Bars.CurrentBid.ToString());
Print(Position.AvgPrice.ToString());


NinjaTrader_Ray is offline  
Reply With Quote
Old 12-18-2006, 04:03 AM   #5
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

Likely something wrong with your strategy. I suggest starting of a sample strategy (copy & paste OnBarUpdate method to your custom strategy) and just add
Code:
Print(Position.AvgPrice.ToString());
and you'll see how the price of your position is plotted.



NinjaTrader_Dierk is offline  
Reply With Quote
Old 12-18-2006, 04:41 AM   #6
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thank you. I got it to print. It printed the average entry price for 15 contracts that were spread over 2 prices. Then it prints 0 when I am out of the market.
SuzyG is offline  
Reply With Quote
Old 12-18-2006, 04:45 AM   #7
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Thanks! I didn't see your reply and asked again.
SuzyG 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


All times are GMT -6. The time now is 11:36 AM.