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 charlesugo_1, 05-26-2026, 05:03 PM
              0 responses
              51 views
              0 likes
              Last Post charlesugo_1  
              Started by DannyP96, 05-18-2026, 02:38 PM
              1 response
              142 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 05-11-2026, 05:56 AM
              0 responses
              160 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 05-10-2026, 08:12 PM
              0 responses
              96 views
              0 likes
              Last Post CarlTrading  
              Started by Hwop38, 05-04-2026, 07:02 PM
              0 responses
              275 views
              0 likes
              Last Post Hwop38
              by Hwop38
               
              Working...
              X