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 geddyisodin, Yesterday, 05:20 AM
            8 responses
            49 views
            0 likes
            Last Post geddyisodin  
            Started by DayTradingDEMON, Today, 09:28 AM
            3 responses
            19 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by Stanfillirenfro, Today, 07:23 AM
            9 responses
            23 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by George21, Today, 10:07 AM
            0 responses
            8 views
            0 likes
            Last Post George21  
            Started by navyguy06, Today, 09:28 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X