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