Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 CortexZenUSA, Today, 12:53 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by CortexZenUSA, Today, 12:46 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by usazencortex, Today, 12:43 AM
      0 responses
      5 views
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,265 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X