Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle and Time ?

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

    DrawRectangle and Time ?

    I get the rectangle to plot but when it starts at start time it goes back 10 bars then starts advancing as the bars form. Is there a way to start at time A and finish at time B without plotting rectangle previous to the start time. Start at A, End at B only.

    Thanks

    if (CurrentBar < 1)
    {
    return;
    }


    if (ToTime(Time[0]) >= 64500 && ToTime(Time[0]) <= 65000)
    {
    DrawRectangle("tag", true, 10, Low[LowestBar(Low, 10)], 0, High[HighestBar(High, 10)], Color.Cyan, Color.Cyan, 1);
    }

    #2
    To start at a bar and and end at another bar, you need to grab the actual bar number and pass that to the DrawRectnagle method

    Code:
    			//set the start and end time variables for the current day
    			DateTime startTime =  new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 6, 45, 00);
    			DateTime endTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 6, 55, 00);
    			
    			//get the bar number for those time variables
    			int startBar = GetBar(startTime);
    			int endBar = GetBar(endTime);
    
    			if (Time[0] >= startTime && Time[0] <= endTime)
    			{				
    				DrawRectangle("tag", true, startBar, Low[LowestBar(Low, 10)], endBar, High[HighestBar(High, 10)], Color.Cyan, Color.Cyan, 1);
    			}
    More information on methods used in the example above can be found in the following reference sample:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks I will give it a try.

      Comment


        #4
        Thanks Matthew works great..

        Comment

        Latest Posts

        Collapse

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