Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    6 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    41 views
    0 likes
    Last Post alifarahani  
    Working...
    X