Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The focus of the chart changes after reloading ninjascript

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

    The focus of the chart changes after reloading ninjascript

    Hello,

    On intraday chart, after I reload ninjascript by pressing "F5", the last bar shown on chart changes to the last bar in historical database before I start NT. For example, if I keep NT running since 10:00 this morning. Now if I reload ninjascripts, the last bar to the right on the chart becomes the bar with time stamp 10:00. I have to click the black arrow at the right top corner to scroll the chart to the left and bring back those bars built in realtime. Is this a bug?


    - Clearpicks

    #2
    Originally posted by clearpicks View Post
    Hello,

    On intraday chart, after I reload ninjascript by pressing "F5", the last bar shown on chart changes to the last bar in historical database before I start NT. For example, if I keep NT running since 10:00 this morning. Now if I reload ninjascripts, the last bar to the right on the chart becomes the bar with time stamp 10:00. I have to click the black arrow at the right top corner to scroll the chart to the left and bring back those bars built in realtime. Is this a bug?


    - Clearpicks
    Hi Clearpicks,

    I am going to test this on my end. However, it might take a little while. Do I need to run the NinjaScript strategies the entire time my chart is open?

    Comment


      #3
      No. Running on 1min for about 15min so that enough realtime bars have been build to fill the margin on right side. You may try sub-minute (5 second or tick) chart to get test done faster, but I never tried. I tried 5min chart only.


      - Clearpicks



      Originally posted by NinjaTrader_Eamon View Post
      Hi Clearpicks,

      I am going to test this on my end. However, it might take a little while. Do I need to run the NinjaScript strategies the entire time my chart is open?

      Comment


        #4
        Originally posted by clearpicks View Post
        No. Running on 1min for about 15min so that enough realtime bars have been build to fill the margin on right side. You may try sub-minute (5 second or tick) chart to get test done faster, but I never tried. I tried 5min chart only.


        - Clearpicks
        Hello,

        What datafeed are you connected to?

        Comment


          #5
          InteractiveBrokers.

          Comment


            #6
            Originally posted by clearpicks View Post
            InteractiveBrokers.
            Hi Clearpicks,

            I tested this on my end and was unable to reproduce. Could you send in a note to my attention to Support at NinjaTrader dot com.

            Comment


              #7
              I can not reproduce it. I will try it during the weekend.
              It might be caused the some texts drawn on chart disappear when reload ninjascript so that I mistakenly think the focus has been changed.
              Anyway either the focus was changed or drawtext() was not executed. It might have something to do this function I stole from sone post. When the chart is scrolled to the right for a few bars (exceeding the chart margin?), reloading ninjascript may cause LastBarOnChart never set to draw so that my texts are not drawn. However scrolling the chart to the left for even one bar would make the texts appear again. Anyway something is wrong here. I will post my test script next week.

              privatebool LastBarOnChart
              {
              get
              {
              if ( ! CalculateOnBarClose && CurrentBar == Bars.Count - 1 )
              returntrue;
              elseif ( CalculateOnBarClose && CurrentBar == Bars.Count - 2 )
              returntrue;
              else
              returnfalse;
              }
              }

              Comment


                #8
                Hello,

                I just found out why I mistakenly thought the focus of the chart is changed.

                In my script, at the biginning of the last bar, some texts are drawn on the chart. If I scroll the chart to the right for a few bars, say 20 bars and reload the ninjascript. Then the function OnBarUpdate() is executed for every bar but the script pauses at the bar with index (Count - 20), which is different as I expected. I expected the script would run on every bar no matter it is out side of the right margin of the chart or not.

                Attched is a script to demonstrate this behavior. Just apply this script to any chart and scroll to the right for a few bar and press "F5", watch the output, and scroll the chart to the LEFT untill the last trading bar shows up, check the output window again.

                Where can I find the document on such behavior of NinjaScript? Maybe I have not spent enough time on learning details of Ninjascript.

                - Clearpicks

                Comment


                  #9
                  the script is attached.
                  Attached Files

                  Comment


                    #10
                    This is normal behavior. You will simply need to run your scripts at the last current bar to start. You can then proceed to scroll backwards or forwards after the strategy has started.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by ghoul, Today, 06:02 PM
                    2 responses
                    12 views
                    0 likes
                    Last Post ghoul
                    by ghoul
                     
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    44 views
                    0 likes
                    Last Post jeronymite  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    7 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    10 responses
                    180 views
                    0 likes
                    Last Post jeronymite  
                    Started by DanielSanMartin, Yesterday, 02:37 PM
                    2 responses
                    13 views
                    0 likes
                    Last Post DanielSanMartin  
                    Working...
                    X