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 to code below yesterday close?

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

    How to code below yesterday close?

    Hi,

    I need to create a logic

    IF ( CLOSE BELOW YESTERDAY CLOSE )
    THEN .....

    IF ( BELOW TODAY'S OPEN )
    THEN ...

    IF ( BELOW TODAY'S 50% DAY RANGE ) // basically simple (high-low)/2
    THEN ....

    How to code the logic in NT?

    Thanks

    #2
    ssg10,

    I am happy to assist you.

    Do you mean :

    If ( Current Close < Yesterday Close )
    then ....

    If ( Current Close < Todays Open )
    then ....

    If ( Current Close < Todays 50% )
    then ....

    Are you trying to test for all three at the same time before you execute something, or are you executing something after testing each one?

    What time-frame chart are you trying to run this on?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I am trying to execute something after each one. Simple things. I just want to write a text saying that currect close is below yesterday close, etc.

      The logic is correct that you explained.

      I am running on intraday, such as 15 min chart.

      Thanks.

      Comment


        #4
        ssg10,

        I'm happy to assist.

        Please find a basic outline of what you want below.

        private double current_close=Close[1];

        if ( current_close < Bars.GetDayBar(1).Close )
        {

        }

        if ( current_close < Bars.GetDayBar(0).Open )
        {

        }

        If ( current_close < (Bars.GetDayBar(0).High + Bars.GetDayBar(0).Low)/2 )
        {

        }

        You will want to check out the following links for displaying text :





        Don't hesitate to contact us should you require additional assistance.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AdamP View Post
          ssg10,

          I'm happy to assist.

          Please find a basic outline of what you want below.

          private double current_close=Close[1];

          if ( current_close < Bars.GetDayBar(1).Close )
          {

          }

          if ( current_close < Bars.GetDayBar(0).Open )
          {

          }

          If ( current_close < (Bars.GetDayBar(0).High + Bars.GetDayBar(0).Low)/2 )
          {

          }

          You will want to check out the following links for displaying text :





          Don't hesitate to contact us should you require additional assistance.
          Do not forget to do a null reference check for GetDayBar().

          Comment


            #6
            Thanks

            Good stuff. Thanks!

            By the way, for Bars.GetDayBar

            This depends on time frame selection , right? (RTH, default 24/7, etc)

            Comment


              #7
              ssg10,

              It depends on your current session since its a "virtually" created bar.

              Please have a look at the following link.

              Adam P.NinjaTrader Customer Service

              Comment


                #8
                Thanks.

                From that link:
                !!! This method should ONLY be used for accessing prior trading day data. To access current trading day data, use the CurrentDayOHL() method.


                Instead of using Bars.GetDayBar(0) like you said above, don't we have to use CurrentDayOHL ?

                Comment


                  #9
                  Hi ssg10,

                  Yes, good point. GetDayBar() is only used for prior sessions. For the current session there is dedicated CurrentDayOHL()
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by f.saeidi, Today, 05:56 AM
                  1 response
                  3 views
                  0 likes
                  Last Post Jltarrau  
                  Started by Jltarrau, Today, 05:57 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post Jltarrau  
                  Started by Stanfillirenfro, Yesterday, 09:19 AM
                  7 responses
                  51 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by TraderCro, 04-12-2024, 11:36 AM
                  4 responses
                  70 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Mindset, Yesterday, 02:04 AM
                  1 response
                  15 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X