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

How not to use the first bar of the session

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

    How not to use the first bar of the session

    Hello. Excuse my English. I'm a novice programmer. I'm developing a strategy and I don't want you to take into account the first bar of the session to do the calculations. Please, can you guide me how to do it? thank you.

    #2
    Hello julifro,

    Thank you for your note.

    You could see the following example in the helpguide on first bar of session,


    The if statement to avoid bars processing on this first bar of session may look like this,

    if (Bars.IsFirstBarOfSession)
    return;

    Which will return the current OnBarUpdate and avoid any processing until the next bar.

    If writing this in the strategy builder, you would select under Conditions and Actions page, a condition which you would find in Misc Folder>FirstBarOfSession, then for the operator you would select Not Equal To, then on the right side Misc Section >true.


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Bars.FirstBarOfSession I used it before I asked and it doesn't do what I want.
      I use ninjatrader 7 and I use it like this

      if(Bars.FirstBarOfSession )
      return;

      but it still uses the first bar of the session to make the calculations of the strategy.

      I have not been able to find in the strategy builder of nt 7 or nt8 Conditions and Actions page.
      Thank you.

      Comment


        #4
        Hello julifro,

        You wouldn't be able to access barsfirstbarofsessoin in the builder in NT7 but in NT8 it would be listened in the Misc folder.

        Without the full code we're unable to test how you're doing the check.

        What instrument are you applying the script to?

        If you'd like to provide the full code I can take a look and see if anything jumps out. Please use the following format.

        To export a NinjaScript from NinjaTrader 7 do the following:
        From the Control Center window select File-> Utilities>Export
        Click Add>Select the indicator>OK>Export.

        Then attach that file you saved; under My Docs>NT7>Bin>Custom>Select the downloaded .zip file.

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your response and your time. I solved it with this code

          if(Bars.BarsSinceSession > 1)
          {
          }

          Comment


            #6
            So for Ninjatrader 7... does this work?

            if (Bars.FirstBarOfSession)
            return;

            or should I use this?

            if (Bars.BarsSinceSession > 1)
            {
            DoThisDoThat
            }

            Comment


              #7
              Hello otislauwaert,

              It would depend on what you're looking to do. FirstBarOfSession would return true if it was the first bar of session. BarsSinceSession would tell you how many bars into the session you're in.

              See the following sections of our helpguide,




              Please let us know if you need further assistance.


              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Hi NinjaTrader_AlanP I am sorry to ask you this on a thread unrelated to my question.. I have your jteconnews2a add-on and it works well. I am just curious as to what the "debug" option in the settings does for it?

                Thanks for a great add-on.

                Comment


                  #9
                  Hello pheonixt157,

                  Alan is no longer in a customer facing role and we wanted to make sure this post got a reply.

                  You can open the source code for the indicator and check where the "Debug" variable is used. This controls prints that are used to debug and test parts of the script.

                  We look forward to assisting.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CortexZenUSA, Today, 12:53 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by CortexZenUSA, Today, 12:46 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post CortexZenUSA  
                  Started by usazencortex, Today, 12:43 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post usazencortex  
                  Started by sidlercom80, 10-28-2023, 08:49 AM
                  168 responses
                  2,265 views
                  0 likes
                  Last Post sidlercom80  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  3 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X