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

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 Barry Milan, Yesterday, 10:35 PM
            5 responses
            16 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Started by DJ888, 04-16-2024, 06:09 PM
            4 responses
            13 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            12 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            8 views
            0 likes
            Last Post nandhumca  
            Working...
            X