Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get brush area to cover current bar

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

    Get brush area to cover current bar

    Hi,
    I am trying to make a change in the current script as I want the brush area to cover my current bar as it is forming.
    Cannot find the right setting and have tried the resource page of NT.
    Need to cover all bars in the chart, imaged attached.

    TIA!!

    Code snip:

    void PlotDevOne()
    {
    PlotVWAP1U[0] = curVWAP + SD1 * deviation;
    PlotVWAP1L[0] = curVWAP - SD1 * deviation;
    Draw.Region(this, "dev1", CurrentBar, 0, PlotVWAP1U, PlotVWAP1L, null, SD1AreaBrush, SD1AreaOpacity);

    }

    void PlotDevTwo()
    {
    PlotDevOne();
    PlotVWAP2U[0] = curVWAP + SD2 * deviation;
    PlotVWAP2L[0] = curVWAP - SD2 * deviation;
    Draw.Region(this, "dev2", CurrentBar, 0, PlotVWAP1U, PlotVWAP2U, null, SD2AreaBrush, SD2AreaOpacity);
    Draw.Region(this, "dev3", CurrentBar, 0, PlotVWAP1L, PlotVWAP2L, null, SD2AreaBrush, SD2AreaOpacity);
    }

    void PlotDevThree()
    {
    PlotDevTwo();
    PlotVWAP3U[0] = curVWAP + SD3 * deviation;
    PlotVWAP3L[0] = curVWAP - SD3 * deviation;
    Draw.Region(this, "dev4", CurrentBar, 0, PlotVWAP2U, PlotVWAP3U, null, SD3AreaBrush, SD3AreaOpacity);
    Draw.Region(this, "dev5", CurrentBar, 0, PlotVWAP2L, PlotVWAP3L, null, SD3AreaBrush, SD3AreaOpacity);​


    Chart:

    Click image for larger version

Name:	image.png
Views:	128
Size:	20.1 KB
ID:	1252810

    #2
    Hello carlosgutierrez,

    Thank you for your inquiry.

    Based on your description and screenshot, I suspect what you are referring to is how the currently forming bar does not display the plots or regions. To get your script to calculate during the current bar, you will need to set the Calculate property to either OnPriceChange or OnEachTick rather than OnBarClose. This may be set in State.SetDefaults or on the UI when configuring the script. For more informaiton:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Thanks. That was the issue!! And now better visual.

      Now another thing came on wrong with that change.

      How can I get these levels static while the bar is forming?

      Click image for larger version

Name:	image.png
Views:	108
Size:	15.0 KB
ID:	1252824

      Comment


        #4
        Another option would be to make the brush zone to expand and cover OnBarClose + 1, I don't know if thats possible. And the indicator would remain with the same setting.

        Comment


          #5
          Hello carlosgutierrez,

          Thank you for your reply.

          If you want the plots to only update once per bar rather than constantly updating when calculating on price change or on each tick, you could separate the logic for the plots to update when IsFirstTickOfBar is true. We have a reference sample that demonstrates how to separate logic between bar close and on each tick that demonstrates this idea:


          Please let us know if we may be of further assistance.

          Comment


            #6
            That worked nicely! Thanks.

            One more issue has come up. As it has that restriction, the indicator need to be "refreshed" to keep it calculating. Anyway to fix this?

            In image you can see lines getting flat.
            Attached Files

            Comment


              #7
              Hello carlosgutierrez,

              Thank you for your reply.

              You may need to add Print() statements to your script to better understand how frequently the plot is calculating. You can determine what values are being assigned to the plot and when to see how your script is behaving, then this can help to identify what might need to be adjusted to get the desired behavior from your script. For more details on using prints to debug your script and better understand its behavior:


              Please let us know if we may be of further assistance.

              Comment

              Latest Posts

              Collapse

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