Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Click limit order expanded reporting wrong market position

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

    Click limit order expanded reporting wrong market position

    HI
    Jim posted some interesting code here.
    I was using it but noticed an odd thing. When I use say buy bid button on a playback account the print statements correctly identify the price the quantity and the market position.
    If I then close that order with a sell ask it incorrectly states that I am short??
    It should say Flat.

    I am interested in this code precisely because I want my position detailed within an indicator.
    Thanks for any help.

    Here is the offending code
    Code:
    private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
    {
    NinjaTrader.Code.Output.Process("", PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("ExecutionUpdate", PrintTo.OutputTab1);
    // Output the execution
    NinjaTrader.Code.Output.Process(string.Format("Ins trument: {0} Quantity: {1} Price: {2}",
    e.Execution.Instrument.FullName, e.Quantity, e.Price), PrintTo.OutputTab1);
    }
    private void OnPositionUpdate(object sender, PositionEventArgs e)
    {
    NinjaTrader.Code.Output.Process("", PrintTo.OutputTab1);
    NinjaTrader.Code.Output.Process("PositionUpdate", PrintTo.OutputTab1);
    // Output the order
    NinjaTrader.Code.Output.Process(e.Position.ToStrin g(), PrintTo.OutputTab1);
    }
    Hello community, I am looking for a simple way to modify the existing chart trader buy/sell buttons such that when a button click is registered, rather than immediately submitting, the order will delay until the close of the candle. Generally, how can I add logic to the click of these particular buttons. Just to catch any

    #2
    Hello Mindset,

    Thanks for your question.

    Are you referring to the OnPositionUpdate prints specifically? Keep in mind there is a the current marketPosition, and the marketPosition/direction of the position change that is made.

    If you set up the following prints, this may be clearer what you are seeing:

    Code:
    private void OnPositionUpdate(object sender, PositionEventArgs e)
    {
        NinjaTrader.Code.Output.Process("", PrintTo.OutputTab1);
        NinjaTrader.Code.Output.Process("PositionUpdate", PrintTo.OutputTab1);
        // Output the position update
        NinjaTrader.Code.Output.Process(e.ToString(), PrintTo.OutputTab1);
        NinjaTrader.Code.Output.Process(e.Position.ToString(), PrintTo.OutputTab1);
    }
    This difference is also briefly noted at the bottom of our OnPositionUpdate section of the Help Guide.

    https://ninjatrader.com/support/help...tionupdate.htm

    Comment


      #3
      Thanks Jim. I have only been using NT for 10 years and never actually realised that!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      581 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      338 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X