Announcement

Collapse
No announcement yet.

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
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      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.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          23 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          120 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X