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

Bars.BarsSinceSession returning 0

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

    Bars.BarsSinceSession returning 0

    Hello,

    whether I have my indicator on a chart or in the analyzer, Bars.BarsSinceSession is returning zero....

    Not sure what I need to do to fix this.

    The Ninja CurrentDayOHL indicator is working OK.

    Please advise, thank you.

    #2
    Hi Turtle Trader,

    Do you have a sample script that can demonstrate this?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      want to get data for the first bar of session

      well...now I am getting a value...strange

      but when I use the value of Bars.BarsSinceSession to get High[], Low[], or Volume[] I am getting an array index out of bound error....

      I want to get the these values for the first bar of the session, and all the subsequent bars until [0]

      the chart has plenty of bars loaded, and I have the lookback set to infinite

      in order to speed testing I am using a 30 second chart with a live feed

      I don't know how the BarsSinceSession determines the session....I want a default of 24/7....this is how my charts recognize a new session and draw the session bar...at midnight New York

      ??

      Comment


        #4
        Hi Turtle Trader,

        How are you calling the data?

        Are you using High[Bars.BarsSinceSession]?

        Are you using if (Bars.FirstBarOfSession) sessionHighValue = High[0]?

        The session used, will be the session selected for your chart.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          code

          for (int x = Bars.BarsSinceSession; x == 0; x--)
          {
          VolumeToday = VolumeToday + Volume[x];

          if (Bars.BarsSinceSession == x)
          {
          LastHigh = High[x];
          LastLow = Low[x];
          }
          else
          {
          if (High[x] > LastHigh)
          LastHigh = High[x];

          if (Low[x] < LastLow)
          LastLow = Low[x];
          }
          }

          Comment


            #6
            session in market analyzer?

            Hello,

            when this indicator is running in market analyzer....what session is used?

            Comment


              #7
              Hi Turtle Trader,

              I wouldn't expect this loop to work correctly because of the x==0.

              for (int x = Bars.BarsSinceSession; x == 0; x--)

              This means that if x equals 0 then x will decrement. If x does not equal 0 then it will not decrement.

              x starts as the Bars.BarsSinceSession. This means it is not 0. This means that x will not decrement.

              Did you try printing Bars.BarsSinceSession to see if you get a value?

              Did you try using this for loop with an integer instead of Bars.BarsSinceSession?

              For example:

              for (int x = 10; x == 0; x--)
              Print(x);

              This would also do nothing because x starts as 10 not as 0.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Turtle Trader,

                When running an indicator in the Market Analyzer, the session template of the instrument will be used.
                (This is the session template selected for the instrument in the Instrument Manager for that instrument).

                You can change the session template for all instruments in the window by right-clicking the Market Analyzer -> select Properties... -> set the Session template.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Duh.....

                  Well, my error!!

                  Yes, BarsSinceSession is returning a value.

                  I thought this for loop was an until condition...will test it with the changes...thank you

                  (obviously I'm not a native C# guy...)

                  (Don't laugh too hard....you might fall off your chair...)

                  :-)

                  Comment


                    #10
                    session default

                    hi, this is another thread...but is it possible to set 24/7 session for Everything....

                    would be preferable than changing all the default instrument settings with Ninja...I had them set to 24/7 but sometimes I've had to uninstall and reinstall Ninja, then the settings get lost.

                    It would be great if there was a global session setting...does that exist? I didn't see any.

                    thank you

                    Comment


                      #11
                      Hello Turtle Trader,

                      There is not a global setting for this as instruments do trade a different times during the day.

                      The Market Analyzer will allow you to set the session templates for all instruments in that window.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bc24fl, 08-30-2019, 01:58 PM
                      3 responses
                      255 views
                      0 likes
                      Last Post PaulMohn  
                      Started by tradingnasdaqprueba, 04-09-2024, 09:52 AM
                      6 responses
                      28 views
                      0 likes
                      Last Post tradingnasdaqprueba  
                      Started by PaulMohn, Today, 02:06 AM
                      1 response
                      3 views
                      0 likes
                      Last Post PaulMohn  
                      Started by Mindset, Today, 01:27 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by EB Worx, 03-07-2023, 05:05 AM
                      4 responses
                      99 views
                      1 like
                      Last Post cls71
                      by cls71
                       
                      Working...
                      X