• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
          Paul H.NinjaTrader Customer Service

          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 Tyler7498, Today, 07:34 PM
            0 responses
            4 views
            0 likes
            Last Post Tyler7498  
            Started by Woomera, Today, 07:24 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by Newtrader101, Today, 12:31 PM
            2 responses
            13 views
            0 likes
            Last Post Newtrader101  
            Started by kweiss, Today, 06:42 PM
            0 responses
            2 views
            0 likes
            Last Post kweiss
            by kweiss
             
            Started by Newtrader101, Today, 06:31 PM
            0 responses
            6 views
            0 likes
            Last Post Newtrader101  
            Working...
            X