Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High between two times with Getbar

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

    #16
    ij001,

    Koganam suggestion would be the correct method at this point
    Code:
    if(CurrentBar < BarsRequired)
    				return;
    			
    		
    			startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 30, 0);
    			endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 23, 00, 0);
    			timeOfInterest = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 30, 0);
    
    			if (ToTime(Time[0]) < 93000 && ToTime(Time[0]) > 94000 && once == false)
    			{
    				counter++;
    				once = true;
    			}
    						
    			if 	(
    				BarsPeriod.Id == PeriodType.Tick &&
    				(ToTime(Time[0]) >= 93000) &&
    				(ToTime(Time[0]) <= 94000)
    				)
    			{
    				barsAgo2 = GetBar(timeOfInterest);
    							
    				openingRangeHigh = MAX(High, barsAgo2)[0];
    				openingRangeLow = MIN(Low, barsAgo2)[0];
    							
    				//DrawFibonacciRetracements("Default"+counter, false, startDateTime, openingRangeHigh, endDateTime, openingRangeLow);				
    				if(fR == null)
    					fR = DrawFibonacciRetracements(Time[0].Date.ToString("d"), false, startDateTime, openingRangeHigh, endDateTime, openingRangeLow);
    				else if(fR.Tag != Time[0].Date.ToString("d"))
    					fR = DrawFibonacciRetracements(Time[0].Date.ToString("d"), false, startDateTime, openingRangeHigh, endDateTime, openingRangeLow);
    
    				once = false;
    			}
    This will get your once a day drawing placement for the Fib
    Cal H.NinjaTrader Customer Service

    Comment


      #17
      I had to modify the code from the last post slightly because it was getting the high/low of only the first bar. So, it is a combination of Chelsea's and Kognam suggestions. Thanks to all for baring with me.

      Below is the working code, perhaps it may help others starting with tick charts for the first time.

      Code:
      private double		openingRangeHigh		= 0;
      private double		openingRangeLow		= 0;		
      private int barsAgo2 = 0;
      private DateTime startDateTime;
      private IFibonacciRetracements fR;
      private bool once = false;
      Code:
      if (Bars == null)
      return;
      
      startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 30, 0);
      
      if (ToTime(Time[0]) < 93000 && ToTime(Time[0]) > 94000 && once == false)
      {
      	once = true;
      }
      			
      if 	(
      	BarsPeriod.Id == PeriodType.Tick &&
      	(ToTime(Time[0]) >= 93000) &&
      	(ToTime(Time[0]) <= 94000)
              )
      {
      	barsAgo2 = GetBar(startDateTime);
      	openingRangeHigh = MAX(High, barsAgo2)[0];
      	openingRangeLow = MIN(Low, barsAgo2)[0];				
      				
      }
      			
      if ((ToTime(Time[0]) > 94000))
      {	
      		fR = DrawFibonacciRetracements(Time[0].Date.ToString("d"), false, startDateTime, openingRangeHigh, endDateTime, openingRangeLow);
      
      		once = false;
      }

      Comment


        #18
        I get the following message in Fibonacci Retracements Properties :

        Please specify a different value for the 'Anchor 2 Time' field as the one you have entered falls outside the specified session start and end times.

        I am using the plotted fibonnaci retracement code from below.

        What is considered anchor 2 time?

        Comment


          #19
          Hello ij001,

          The anchor2 time would be the endDateTime.

          You may want to add a Print statement to aid in debugging to ensure you are using/getting the expected datetime value.

          Comment


            #20
            Thanks.

            I had to adjust the endDateTime for Fridays because the market closes at 17:15. I had it until 23:00.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            600 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 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
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X