Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

prints to proper execution

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

    prints to proper execution

    I have something like this:

    /// In State == State.SetDefaults)
    Calculate = Calculate.OnEachTick;​

    /// In OnBarUpdate()
    double pAP = Position.AveragePrice;​

    bool loss10Ticks = Close[0] <= ( pAP - (10 * TickSize) );​

    if ( loss10Ticks )
    {
    ExitLong();
    }​


    I noticed at first it did not execute the ExitLong() order despite conditions met.

    Then I tested adding prints before the Exit statement like this and it now works:


    /// In State == State.SetDefaults)
    Calculate = Calculate.OnEachTick;​

    /// In OnBarUpdate()
    double pAP = Position.AveragePrice;​

    bool loss10Ticks = Close[0] <= ( pAP - (10 * TickSize) );​

    Print(" ");
    Print("pAP: " + pAP);​​
    Print("loss10Ticks: " + loss10Ticks);​​​

    if ( loss10Ticks )
    {
    ExitLong();
    }​​


    Why didn't the 1st version work without intermediary prints?
    Is there some best practice missing?
    Why does the prints prompts work better?
    Last edited by PaulMohn; 09-16-2024, 08:09 AM.

    #2
    Hello PaulMohn,

    This is an impossible question because you are lacking details from the first test. In order to be able to answer this you would have needed to already have a print in the condition to know it actually did become true. If no order was placed there is no way to know that the condition was actually true without using a print. Without having that data you can't make a comparison to your other test.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello PaulMohn,

      This is an impossible question because you are lacking details from the first test. In order to be able to answer this you would have needed to already have a print in the condition to know it actually did become true. If no order was placed there is no way to know that the condition was actually true without using a print. Without having that data you can't make a comparison to your other test.
      The possibility is such (revealed after the fact of adding the prints, by process of elimination​ logic):

      Before adding the print the ExitLong();​ order executed beyond the given condition (much lower than - 10 Ticks).
      After adding the prints, the order executes at the given condition (-10 Ticks or so with slippage).
      Why is it so? the only modification between the 1st and 2nd version being the added prints.

      Comment


        #4
        Hello PaulMohn

        There are not enough details to answer the question. If you had prints in the script for the original test you could compare those results to newer tests to know why that happened in that way during that test. Without doing that it would be impossible to say what may have happened, anything would just be a guess without having the debug output.

        Comment


          #5
          Isn't the answer such or a start:

          The prints call the execution condition preemptively and so forces the condition check higher accuracy.
          While no prints for some reason do not.

          Is it due to some special OnBarUpdate caracteristic for strategies?
          In this regards, would a Class Variables or external higher scope boolean method provide the observed preemptive effect?

          Comment


            #6
            Hello PaulMohn

            Prints would not have any effect on how a script is being executed other than producing text in the output window. Because there is no output from the original test it would only be an assumption that adding the print had any effect, we have no way to verify that the condition was in fact true and no order was placed. Without some kind of debug output from your original test it would just be a guess as to what may have happened.

            Comment


              #7
              How do you explain the execution delay without prints?

              Please reread the questions asked in the previous post and provide answers to these instead of giving reiterated unsubstantiated opinions.
              Answer by yes or no to the questions, with documented points from the Ninjascript documentation to support the answers.
              Else state clearly the Ninjascript documentation does not provide these answers.

              If you did not exeperience or don't know about this problem, please ask strategies developers for the appropriate answer.
              To prevent any ignorant or negligent reply in place of proper answers.
              Last edited by PaulMohn; 09-17-2024, 01:34 AM.

              Comment


                #8
                Hello PaulMohn,

                I cannot explain it, that is why I said any explanation would be a guess. We have no output from that test to be able to know what happened.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                46 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                126 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                66 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