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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        168 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        322 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        246 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X