Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to extend a line

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

    How to extend a line

    Hello,

    Is there a way how to extend a line (I mean line „provided“ by an indicator)? E.g. there is an indicator PriorDayOHLC. When I create its copy, how can I extend its OHLC values?

    Thank you

    #2
    Hello emuns,

    Thank you for the post.

    I wanted to check, what do you mean by extend the line? Do you mean to extend it to the panel edge, or are you scrolling forward and seeing a gap? Can you provide more detail on what you want to do with the line?

    I look forward to being of further assistance.

    Comment


      #3
      Hello Jesse,

      sorry…

      Let´s say that I would like to extend it to the end of the next day. So market had some OHLC values on Monday. PriorDayOHLC indicator shows these values on a chart on Tuesday. And my question is, how to extend them to the end of the Wednesday´s ETH session?

      Comment


        #4
        Hello emuns,

        In this situation, there is not necessarily a specific solution I can suggest as we are dealing with future dates which have not happened. The platform technically can draw drawing objects on future bars if you specify an exact number of negative bars ago which represents that date, or supply a DateTime for that date. Depending on the chart settings used, future dates can become inaccurate so please verify what you see is correct if using future dates.

        Part of the problem here would be gathering the end of tomorrows session as that would take some logic to find. You can find today's session easy enough, but there is not a "tomorrows" session object, you would need to proceed to calculate that to make sure that's a session date.

        One possible option would be to use the SessionIterator to calculate the current session, and then do this again supplying a time which is after the end of today's session.




        Code:
        // use the current bar time to calculate the next session
        sessionIterator.GetNextSession(Time[0], true);
        
        // store the desired session information
        DateTime tradingDay   = sessionIterator.ActualTradingDayExchange;
        DateTime beginTime       = sessionIterator.ActualSessionBegin;
        DateTime endTime     = sessionIterator.ActualSessionEnd;
        Print(string.Format("The Current Trading Day {0} starts at {1} and ends at {2}", tradingDay.ToShortDateString(), beginTime, endTime));
        
        Print("Calculating trading day for " + endTime.AddDays(1));
        sessionIterator.GetNextSession(endTime.AddDays(1), true);
        
        Print(string.Format("The Current Trading Day {0} starts at {1} and ends at {2}", tradingDay.ToShortDateString(), beginTime, endTime));
        This would allow you to retrieve the session information to know if the time is a trading day or not. You can simplify this even more if you know the session information is static, for example if the session is always at 4 pm monday through friday, a simple DateTime would be easier to use. Assuming you have created a DateTime that represents the date of tomorrow and the time you want the line to end you can pass that to the Draw. method.

        I look forward to being of further assistance.




        Comment


          #5
          Hello Jesse,


          thank you very much for your help. I was able to create it for daily and weekly values. But now I struggle with monthly and higher values (quarterly etc.). The biggest problem is how to define start of the period, because 1st of a month is not always first trading day of the month. Is there a way how to determine it?

          Comment


            #6
            Hello emuns,

            I believe for the purpose of finding the trading day, you can use CalculateTradingDay which can then be used with the previously shown properties:

            Code:
            sessionIterator.CalculateTradingDay(Time[0], false);
            
            Print(sessionIterator.ActualSessionBegin + " " + sessionIterator.ActualSessionEnd);
            This method is used to calculate a day based on an existing date. Testing this with the ES, I see that on 5/31 - 6/1 the calculated trading day shows as 6/2/2019 at the start of the session due to the normal session being accounted for.


            I look forward to being of further assistance.

            Comment


              #7
              Hello Jesse,

              yes, it is working for replicating/extending daily values.

              It also works for weekly values (my changes highlighted by bold print):

              DateTime tradingDay = sessionIterator.ActualTradingDayExchange;
              DateTime beginTime = sessionIterator.ActualSessionBegin;
              DateTime endTime = sessionIterator.ActualSessionEnd;

              if (Times[0][0].DayOfWeek == DayOfWeek.Monday) and than ´endTime.AddDays(5)´. The only problem could be when Monday would be a holiday with closed market...?!

              When I want to extend monthly values then I need to have beginTime = 3rd of June, endTime = 30th of June for month of June (different for other months). I think that I can change endTime by adding .AddMonth(1), but begin time need to be always the first trading day of that month...

              Comment


                #8
                Hello emuns,

                I believe using the AddMonth could be a solution, you could pass the 1st of the month DateTime to the method so it can calculate the next trading day. If you wanted to do that, you would likely need to just create a new DateTime with the values after adding a month which would adjust the year in the case of december.

                Code:
                DateTime aheadOneMonth = Time[0].AddMonths(1);
                DateTime myDateTime = new DateTime(aheadOneMonth.Year, aheadOneMonth.Month, 1, aheadOneMonth.Hour, aheadOneMonth.Minute, aheadOneMonth.Second);
                This would take the Time and add a month, then we use the found time and reconstruct a date using the year/month and 1 for the day.


                I look forward to being of further assistance.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                579 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X