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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 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
    55 views
    0 likes
    Last Post CarlTrading  
    Working...
    X