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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      70 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X