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 NullPointStrategies, Today, 05:17 AM
      0 responses
      43 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      124 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      65 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X