Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script doesn't run with historical status

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

    Script doesn't run with historical status

    This enclosed script and output windows shows that the historical status is True. But I'm running this script during the day the status can't be historical. Do I have a setting wrong somewhere ?
    Attached Files

    #2
    This is because the print statement you have is placed just before the return;

    Code:
                           if (Historical)
    			{
    				Print("Yep, its this historical thing " );
    				return;
    			}
    When a strategy or indicator is applied to a chart it will first process all the historical bars.

    This check you have is going to prevent further processing of your calculations but will not stop OnBarUpdate from being called initially.
    All these prints you're seeing are on historical data. If you were to place the print after the return or you were to clear the output window and let it run in real time you would not see additional prints

    Let me know if I can further assist
    LanceNinjaTrader Customer Service

    Comment


      #3
      OK, I changed the Prints and put one before and one after the 'if (historical)'.
      The output window shows the first one but not the second, so this must mean that it first processes the historical bars that are on the chart( that's why there's multiple point 1 prints) then it catches up to the current time. But if that's true why doesn't it go on and print the point 2 print ? Hmmm.

      Comment


        #4
        This is because return is a programming keyword. It causes a method, OnBarUpdate() in this case, to be exited without further processing.

        C# jump statements (break, continue, return, and goto) unconditionally transfer control from the current location to a different statement.


        If you're interested getting up an running more quickly with NinjaScript I'd recommend looking into this class we offer: http://www.ninjatrader.com/PremiumEducation.php

        Let me know if I can further assist.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Opps, sorry you're right, this script is running. The prints are showing up OK now. Just didn't give it enough time before. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          111 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          59 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          38 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          41 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          78 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X