Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle

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

    DrawRectangle

    Hi,
    I tried to do the following and realized it only worked for DrawRegion function (plotted historically) but not for DrawRectangle and DrawLine function (only current high/low was plotted) .What if I'd lke to plot the high and low by using DrawRectangle and DrawLine? Advice needed. Thanks!

    if (Bars == null)
    return;
    if (!Data.BarsType.GetInstance(Bars.Period.Id).IsIntr aday )
    return;
    if (Bars.Period.Id == PeriodType.Minute && Bars.Period.Value > minutes/2)
    return;

    if(!isLoaded && !isInit)
    {
    isInit = true;
    hourlyBars= Data.Bars.GetBars(Bars.Instrument, new Period(PeriodType.Minute, minutes, MarketDataType.Last), Bars.From, Bars.To, (Session) Bars.Session.Clone(), Data.Bars.SplitAdjust,
    Data.Bars.DividendAdjust);
    existsHistHourlyData = (hourlyBars.Count <= 1) ? false : true;
    isInit = false;
    isLoaded = true;
    }

    IBar hourlyBar;
    if (CurrentBar == 0) return;
    if (existsHistHourlyData)
    {

    DateTime intradayBarTime01 = Time[0].AddMinutes(-minutes);
    hourlyBar = hourlyBars.Get(hourlyBars.GetBar(intradayBarTime01 ));
    h01.Set (hourlyBar.High);
    l01.Set (hourlyBar.Low);

    DrawRegion ("a", CurrentBar, 0, h01, l01, Color.Transparent, Color.PowderBlue , 5);

    DrawRectangle("b", false, CurrentBar, h01[0], 0, l01[0], Color.Lime, Color.Transparent, 0);

    DrawLine ("c", false, CurrentBar, h01[0], 0, h01[0], Color.Khaki, DashStyle.Dot, 5);

    }
    Attached Files

    #2
    Hello,

    Please check your parameters for DrawLine() I can see off hand that these are off it looks like.



    For example parameter number 3 is set to CurrentBar. This would start this drawing at this bar. You can see there is a green line at the ind of your screenshot horizonal. This is the left and right side of the box as it is drawing on the bar only.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

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