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

Highest Bar time

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

    Highest Bar time

    please help, broke my head, but I can't solve the following problem.
    I need the code to determine at what second the price had the highest value when the signal came on the minute chart.

    below attached screenshot
    Attached Files

    #2
    Hello Papercut110,
    Thanks for your post.

    You could do that by simply adding a 1 second data series and then seeing what the highest bar was during that period. Something like the following snippets would accomplish this.

    Code:
    protected override void Initialize()
    {
    	Add(PeriodType.Second,1);
            CalculateOnBarClose = true;
    	
    }
    
    protected override void OnBarUpdate()
    {
    	if (BarsInProgress == 1)
    	{
    		double highestBar    = HighestBar(Close, 60);
                    double highestPrice = Closes[1][highestBar]
    	}
    }
    Additionally, see the following help guide documentation for more information on the concepts used in the snippet above.

    Help Guide- Add()

    Help Guide- HighestBar()

    Help Guide- Multi-Time Frame Considerations

    Please let me know if you have any questions.
    Last edited by NinjaTrader_JoshG; 04-20-2018, 08:35 AM.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hello, NinjaTrader_JoshG!
      Thank you for your attention to my problem.
      I did this, but the Output gets out of some strange information...

      Code

      Code:
              protected override void Initialize()
              {
      	    Add(PeriodType.Second, 1);
                  CalculateOnBarClose = true;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
      			if (BarsInProgress == 1)
      			{
      				if (Opens[0][0]<Closes[0][0])
      				{
      					BarColor = Color.Blue;
      					int highestPrice = HighestBar(Close, 60);
      					Print("highestPrice ");
      					Print(highestPrice);
      					var Time = Bars.GetTime(highestPrice);  
      					Print("Time ");
      					Print(Time);
      				}
      			}
      		}
      Attached Files
      Last edited by Papercut110; 04-20-2018, 12:23 AM.

      Comment


        #4
        Hello Papercut110,
        Thanks for your note.

        My apologies. I must have though I was on the NT8 Strategy Development page. I have edited my original response to fit for NT7 and should clear things up a bit here. The output you are seeing is a bars index value.

        Sorry for the confusion and let me know if you have any questions.
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TraderBCL, Today, 04:38 AM
        2 responses
        16 views
        0 likes
        Last Post TraderBCL  
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        106 views
        0 likes
        Last Post martin70  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        609 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        5 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        471 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X