Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Printing the entry

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

    Printing the entry

    Hi, I'm trying to send a line to the output window when I enter a new position. The problem is that it's printing multiple times for each entry, presumably because it's taking a while to fill the position. There have been a few times when it printed after the position filled, but that could have just been a delay in the output display.

    Here's the code:

    double positionQualCount = 0;

    ...

    protected override void OnBarUpdate()
    {
    if (entrycondition)
    {
    EnterLong();
    positionQualCount = positionQualCount + 1;
    if (positionQualCount == 1)
    {
    Print(Instrument.MasterInstrument.Name + "Strategy1");
    }

    ...

    if (Position.MarketPosition = MarketPosition.Flat)
    {
    positionQualCount = 0;
    }

    Is there a better way to determine if the position has just been entered?

    #2
    Hello egan857,

    Thank you for your post.

    The OnBarUpdate() method will be called everytime there is a tick, so you are getting multiple Prints to your Output Window.

    The OnPositionUpdate() method will only be called on when a position that is entered by a strategy is changed. An example of using the OnPositionUpdate() method can be found below:

    protected override void OnPositionUpdate
    {
    if (position.MarketPosition == MarketPosition.Long)
    {
    Print(Instrument.MasterInstrument.Name + 'Strategy1');
    }
    }


    For information on the OnPositionUpdate() please visit the following link: http://www.ninjatrader.com/support/h...tionupdate.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Sure enough, that worked. Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      368 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      571 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X