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 Waxavi, Today, 02:10 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        13 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Waxavi, Today, 02:00 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by alifarahani, Today, 09:40 AM
        5 responses
        23 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X