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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        38 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        14 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        20 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X