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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    214 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    130 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    146 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    230 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    192 views
    0 likes
    Last Post CarlTrading  
    Working...
    X