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 kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    28 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    17 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    26 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    24 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    139 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X