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

Apply an indicator only on the last day

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

    Apply an indicator only on the last day

    Hi all,

    I've scanned through the forum very quickly but couldn't find I think a simple answer.

    Is there a way to show extended lines for an indicator only on the last trading day ?

    For example if I ask for a chart from 1/12009 to 1/6/2009 only draw extended lines for day 1/6/2009


    Thanks Bernard

    #2
    Bernard, I believe you could just query if you're calling OnBarUpdate() on the current day and then use DrawExtentedLine() instead of DrawLine() as method.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I have tried :
      if(DateTime.Now == DateTime.Today)

      but it doesn't work

      Bernard

      Comment


        #4
        No, as DateTime.Now will give you today's date and current time and DateTime.Today will give you today's date, but 12:00 AM.

        Try comparing the date portion so -

        Code:
         
        if(ToDay(DateTime.Now) == ToDay(DateTime.Today))
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand

          It doesn't work because it is always showing equality...

          I printed the result on the output window and they showed always equality. It makes sense because I am asking if Date time now is equal to today..

          What I want to compare is the date of the current bar. Is it equal to today ?

          I don't know how to code that


          Bernard

          Comment


            #6
            Here is how I solved the problem :

            if( ToDay(Time[0]) == ToDay(DateTime.Today))





            Bernard

            Comment


              #7
              You're correct Bernard, sorry for the extra spin...great you got it working.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X