• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    JimNinjaTrader Customer Service

    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 tff2011, Today, 03:55 PM
      0 responses
      1 view
      0 likes
      Last Post tff2011
      by tff2011
       
      Started by itrader46, Today, 03:24 PM
      4 responses
      11 views
      0 likes
      Last Post itrader46  
      Started by MercuryRed, Today, 03:24 PM
      0 responses
      11 views
      0 likes
      Last Post MercuryRed  
      Started by beobast, Today, 01:56 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by daigo1, Today, 02:21 PM
      2 responses
      6 views
      0 likes
      Last Post daigo1
      by daigo1
       
      Working...
      X