Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get price information

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Get price information

    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
    imported post

    Just set CalculateOnBarClose=false and OnBarUpdate is triggered for each tick.
    Code:
       if (Position.AvgPrice > Bars.CurrentAsk)
        Print(Position.AvgPrice.ToString());

    Comment


      #3
      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.

      Comment


        #4
        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());


        RayNinjaTrader Customer Service

        Comment


          #5
          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.



          Comment


            #6
            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.

            Comment


              #7
              imported post

              Thanks! I didn't see your reply and asked again.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              63 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              35 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              54 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              61 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              48 views
              0 likes
              Last Post CarlTrading  
              Working...
              X