• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Mykro, Today, 08:42 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by franki, Yesterday, 12:52 PM
          3 responses
          23 views
          0 likes
          Last Post koganam
          by koganam
           
          Started by SuperDriveGuy, Today, 08:13 AM
          0 responses
          2 views
          0 likes
          Last Post SuperDriveGuy  
          Started by bouncetherubble, Today, 07:24 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by fiddich, Today, 08:06 AM
          1 response
          6 views
          0 likes
          Last Post fiddich
          by fiddich
           
          Working...
          X