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 Belfortbucks, Today, 09:29 PM
          0 responses
          3 views
          0 likes
          Last Post Belfortbucks  
          Started by zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          150 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          6 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Working...
          X