PDA

View Full Version : Get price information


SuzyG
12-17-2006, 04:53 PM
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.

NinjaTrader_Dierk
12-17-2006, 05:15 PM
Just set CalculateOnBarClose=false and OnBarUpdate is triggered for each tick.
if (Position.AvgPrice > Bars.CurrentAsk)
Print(Position.AvgPrice.ToString());

SuzyG
12-18-2006, 03:57 AM
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.

NinjaTrader_Ray
12-18-2006, 04:03 AM
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_Dierk
12-18-2006, 04:03 AM
Likely something wrong with your strategy. I suggest starting of a sample strategy (copy & paste OnBarUpdate method to your custom strategy) and just add
Print(Position.AvgPrice.ToString());
and you'll see how the price of your position is plotted.

SuzyG
12-18-2006, 04:41 AM
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
12-18-2006, 04:45 AM
Thanks! I didn't see your reply and asked again.