Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to plot a weekly box style bar on a daily chart?

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

    How to plot a weekly box style bar on a daily chart?

    Hello,

    I'm trying to plot a weekly box style bar on a daily chart programmatically but to no avail. I have coded the following:

    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Week, 1);
    }​

    ....

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    {
    return;
    }


    if (BarsInProgress == 1)
    {


    if (Close[1][0] > Open[1][0] && ChartBars.Properties.ChartStyleType == ChartStyleType.Box)
    {
    BarBrushes[0] = Brushes.LightGreen; // How to BarBrushes a higher time frame bar?
    CandleOutlineBrushes[0] = Brushes.LawnGreen; // How to CandleOutlinerBrushes a higher time frame bar?
    }

    else
    {
    BarBrushes[0] = Brushes.Pink;
    CandleOutlineBrushes[0] = Brushes.Red;
    }
    }

    else
    {
    return;
    }
    }

    The code compiles but does not plot properly. I can do it manually by adding a data series panel by hand. Is there a way to plot a weekly (higher time frame) bar on a daily chart programmatically? I can't find any documentation or examples on how to do so.

    Any suggestions would be appreciated!

    Thank you.

    Richard​

    #2
    Hello Richard0168,

    What is the outcome that you are trying to get?

    When you have a daily series you cant plot anything less or more granular than daily in regard to scripting. All plotting or drawing that you do would be in relation to the scripts primary series.

    Comment


      #3
      Hello Jesse,

      Thanks for your reply. I see why I can't plot the bars other than the primary series.

      Please see attached picture. This is what I want to do and I can do it manually by creating another data series panel. However, I would prefer to do it programmatically in a script.

      Richard


      Attached Files
      Last edited by Richard0168; 12-02-2022, 08:19 PM.

      Comment


        #4
        Hello Richard0168,

        You could get a similar result by re plotting the OHLC values of the weekly bar on the daily primary. When using the daily as the primary you will have 1 slot for rendering per bar so if you are using weekly data you would just be rendering the last close bar on the weekly series for each day bar to visualize its bars.

        To make rectangles similar to what you pictured it would be easiest to just use Plots and then fill in the region between the plots. For example you could replot the High and Low of the weekly bar and then draw a region between them.




        The OnBarUpdate code would end up looking similar to:


        Code:
        if (BarsInProgress == 0)
        {
            Values[0][0] = Highs[1][0];
            Values[1][0] = Lows[1][0];
            Draw.Region(this, "tag1", CurrentBar, 0, Values[0],Values[1], null, Brushes.Blue, 50);
        }​

        Comment


          #5
          Hello Jesse,

          This is an excellent suggestion. Thank you so much for your help!

          Richard

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X