Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing Time[0] in OnAccountExecutionUpdate

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

    Accessing Time[0] in OnAccountExecutionUpdate

    I have the following code:
    private void OnAccountExecutionUpdate (object sender, ExecutionEventArgs e)
    {
    NinjaTrader.Code.Output.Process(" Account Execution Update " +e.MarketPosition.ToString(), PrintTo.OutputTab1);
    if(NinjaTrader.NinjaScript.AddOns.AtmSharedVariabl es.SharedMrkPosition=="Flat" && ( e.MarketPosition.ToString()=="Long" || e.MarketPosition.ToString()=="Short" ))
    {
    NinjaTrader.NinjaScript.AddOns.AtmSharedVariables. NewPositionHandShake=true;
    NinjaTrader.Code.Output.Process(Time[0].ToString()+" Account Execution Update - New HandShake Generated for " +e.MarketPosition.ToString()+" Position" , PrintTo.OutputTab1);
    // Clear any existing update requests when New order is recieved from SuperDom
    NinjaTrader.NinjaScript.AddOns.AtmSharedVariables. AtmSharedChangeStopFlag=false;
    }
    }

    However just several minutes ago when I triggered an order at 10:59:43 am I got the following print out.

    Account Execution Update Short
    8/6/2017 6:00:00 PM Account Execution Update - New HandShake Generated for Short Position
    OnAccountPositionUpdate Short

    Why is the Time and Date Wrong ? If it matters I am using Sim101 in Real Time.

    #2
    Hello JerryWar,

    Are you subscribing to Account.OnExecution from an AddOn or are you developing a strategy?

    I would suggest to stick to the Strategy's OnExecutionUpdate() override instead of using the AddOn code if this is for a strategy. However, you can access the time of the execution in a similar way.

    You can check the time of the Execution object to get the correct time for the trade. If you are looking for the time the OnExecutionUpdate() method iterated, you can use DateTime.Now.

    Different properties of the Execution object can be referenced here - https://ninjatrader.com/support/help.../execution.htm

    Looping through the Account.Executions collection from the AddOn's subscribed method can be found here - https://ninjatrader.com/support/help...executions.htm

    The strategy override for OnExecutionUpdate() is documented here - https://ninjatrader.com/support/help...tionupdate.htm

    Comment


      #3
      Its a Strategy but it is not generating the initial order, it is picking up an execution of an ATMStrategy.
      and modifying it with parameters from an indicator. DateTime.Now worked fine.

      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X