Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 DavidHP, Today, 07:56 AM
        0 responses
        0 views
        0 likes
        Last Post DavidHP
        by DavidHP
         
        Started by Aviram Y, 08-09-2023, 09:04 AM
        10 responses
        298 views
        0 likes
        Last Post MrHump
        by MrHump
         
        Started by jpapa, Today, 07:22 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by kevinenergy, 02-17-2023, 12:42 PM
        116 responses
        2,758 views
        1 like
        Last Post kevinenergy  
        Started by franatas, 12-04-2023, 03:43 AM
        7 responses
        106 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X