![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Just set CalculateOnBarClose=false and OnBarUpdate is triggered for each tick.
Code:
if (Position.AvgPrice > Bars.CurrentAsk)
Print(Position.AvgPrice.ToString());
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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());
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
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());
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#7 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks! I didn't see your reply and asked again.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|