Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Region problem

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

    Draw.Region problem

    Hello,

    I am trying to draw a region when the Plot0 is above Zero line, but it doesn'w work very well as you can check in the picture attached.

    My code is as follows:

    if(Plot0[0]>=0 && controlcorte) {icorte++; barrascorte=CurrentBar; controlcorte=false;}
    if(Plot0[0]<0.05) controlcorte=true;

    if(Plot0[0]>0) Draw.Region(this,"tag1"+icorte,(CurrentBar-barrascorte),0,Plot0,Zero,null,Brushes.White,50);

    Please, help me to understand what I am doing wrong.

    Thanks in advance
    Attached Files

    #2
    Hello Sangui,

    Thanks for opening the thread.

    I would advise to use the first overload for Draw.Region so you supply a Series<double> and a double holding the value for your zero line.

    Draw.Region will draw shapes filling in the gap between these Series<double> values and the value for the zero line specified.

    If you would like to only draw shapes above the zero line, I suggest to create your own Series<double> that is synchronized with the primary data series and has a MaximumBarsLookBack of MaximumBarsLookBack.Infinite. You should then check if the Plot's value is above your zero line. If it is, assign it to the Series<double>. If not, assign the Series<double> the value of your zero line.

    I have attached a rough example that can demonstrate this on an ES chart.

    Please let me know if I may be of further assistance.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X