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 Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              583 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              338 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              552 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X