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

onexecution live-playback

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

    onexecution live-playback

    Hello,

    I´m testing strategies on the weekend and I experience a strange behavior always with playback so I have to ask please:

    when connected live my strategies work ok but when connected with playback the doubles from onexecution maintain with 0.

    In onexecution I have
    if (entryOrderLr1a == execution.Order)
    {
    if (execution.Order.OrderState == OrderState.Filled)
    {
    avgFillLr1a=execution.Order.AverageFillPrice;​
    ....
    }

    In the attached screenshot one can see that the double avgFillLr1a is "0", I plot some numbers in the chart to have control (and so my doubles for derived stops are also 0 of course...)

    Again: there is no issue when enabling the strategy with live data (sim or live account) and there would not be a question here now, its referring only to playback.

    Thank you!
    Tony
    Attached Files
    Last edited by tonynt; 07-01-2023, 02:58 AM. Reason: translation error

    #2
    What about execution.Price?
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello Tony,

      Thanks for your post.

      What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.? or 8.1.?.?)

      Are you using Historical Tick data or Market Replay data with the Playback connection?

      I have modified the SampleOnOrderUpdate reference sample from the help guide to print out execution.Order.AverageFillPrice and tested it on the Playback connection with Market Replay data and I am not able to reproduce the behavior reported.

      See this demonstration video: https://brandonh-ninjatrader.tinytak...OF8yMTY4MjQ4Nw

      I have also attached the script used to test this.

      Do you see the behavior occur when testing the attached script on your end with Market Replay data?​
      Attached Files
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Hello,

        thank you for your reply. I use NT version 8.1.1.6 64-bit and market replay data.

        Your sample is working, but my code is not. Can you see what I have wrong there please? I reduced it to the very minimum with only few lines but I can not find it.

        Thank you!
        Tony
        Attached Files
        Last edited by tonynt; 07-03-2023, 03:52 PM. Reason: Translation error

        Comment


          #5
          Hello tonynt,

          Thank you for your reply.

          I can see from what you provided that when you instantiate your variables, such as avgFillLr1a, you also initialize them with a value of 0:
          private double avgFillLr1a = 0;

          I suggest adding additional print statements throughout your script when you expect this value to be updated from 0 to see if those lines of code are being hit or not. If not, you may need to consider the conditions that should result in the value being updated and determine if the condition needs to be modified. You may also compare your prints to the TextFixed object on your chart to see if they match each other or if there is a discrepancy. This can help you to understand what part(s) of your code would be the cause of the value showing as 0 rather than updating to the expected value.

          Here is an example of a print statement you could add to your script in OnExecutionUpdate() along with some comments I added to help explain the debugging process you could take:
          Code:
          // adding a print outside of the condition to see which order is being executed when OnExecutionUpdate() is called
          Print("execution.Order: " + execution.Order + " execution.Name: " + execution.Name);
          
          // this next condition means that the following actions will only take place when the order object entryOrderSr1a is the execution.Order
          // You could also consider checking execution.Name to identify the order so you are not using execution.Order, which may not be up to date if an ExecutionUpdate is seen before an OrderUpdate in a partial fill
                 if (entryOrderSr1a == execution.Order)
          //     if (execution.Name == "rS1a")
                  {
                  if (execution.Order.OrderState == OrderState.Filled)
                      {
                      Print("updating avgFillSr1a.  Previous value: " + avgFillSr1a);
                      avgFillSr1a=execution.Order.AverageFillPrice;
                      Print("updated value for avgFillSr1a: " + avgFillSr1a);
                          Print("execution.Order.AverageFillPrice: " + execution.Order.AverageFillPrice);
                      }
                  }
          ​
          For more details on using prints to debug your script, please see the following link:


          Please let us know if you have questions about the output from your prints or if we may be of further assistance.
          Emily C.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,789 views
          0 likes
          Last Post aligator  
          Started by Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          837 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,293 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          13 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          63 views
          0 likes
          Last Post halgo_boulder  
          Working...
          X