Announcement

Collapse
No announcement yet.

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.

    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))

        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.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cmoran13, 04-16-2026, 01:02 PM
              0 responses
              43 views
              0 likes
              Last Post cmoran13  
              Started by PaulMohn, 04-10-2026, 11:11 AM
              0 responses
              25 views
              0 likes
              Last Post PaulMohn  
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              163 views
              1 like
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              98 views
              1 like
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              158 views
              2 likes
              Last Post CaptainJack  
              Working...
              X