Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trying to retrieve entry price - need help

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

    trying to retrieve entry price - need help

    In the strategy analyzer, when I enter long and then display what I think is the entry price...as follows:

    EnterLong();
    Print(spaces12+"Position.AvgPrice="+Position.AvgPr ice.ToString("0.0000"));

    The value displayed in the output window is 0.0000?






    #2
    Hello joemiller,

    The issue is most likely that the position is not filled when this print is made. (It takes a few moments for an order to fill even with the simulator).

    I recommend that you move the print statement to OnPositionUpdate().

    This will print the position after the order is filled.

    Below is a link to the help guide on OnPositionUpdate().
    http://www.ninjatrader.com/support/h...tionupdate.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      I did the following and the average price still displays as zero?
      I am using hourly bars.
      The analyzer execution and trade tables display many entries, all at non-zero, reasonable prices.

      protected override void OnPositionUpdate(IPosition position)
      {
      if (position.MarketPosition == MarketPosition.Flat)
      {
      Print(spaces12+"***Position.AvgPrice="+Position.Av gPrice.
      ToString("0.0000"));//PPPPPPPPPPPPPPP
      }
      }

      Comment


        #4
        Hi joemiller,

        The check for position being flat is causing your script to only print when there is not a position.

        This means that your code will only ever print 0.

        Try removing the position check.

        For example:
        Code:
        protected override void OnPositionUpdate(IPosition position)
        {
        Print(spaces12+"***Position.AvgPrice="+Position.Av gPrice.
        ToString("0.0000"));//PPPPPPPPPPPPPPP
        }
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          That did it.
          Many Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          4 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          40 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X