Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 TraderCro, Today, 12:13 AM
              0 responses
              1 view
              0 likes
              Last Post TraderCro  
              Started by Skifree, Yesterday, 11:47 PM
              0 responses
              5 views
              0 likes
              Last Post Skifree
              by Skifree
               
              Started by Skifree, Yesterday, 11:41 PM
              0 responses
              4 views
              0 likes
              Last Post Skifree
              by Skifree
               
              Started by Skifree, Yesterday, 11:38 PM
              0 responses
              1 view
              0 likes
              Last Post Skifree
              by Skifree
               
              Started by KonAdams, Yesterday, 10:53 PM
              0 responses
              6 views
              0 likes
              Last Post KonAdams  
              Working...
              X