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

FirstTickofBar for Volume

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

    FirstTickofBar for Volume

    Hello NinjaTrader!

    For the life of me I cannot firgure out how to get the first tick of bar for volume chart(s). I've read the tip in the NinjaTrader 8 documentation:
    Tip:

    In NinjaTrader's event driven framework, bar closures are signaled by the tick that opens the next bar. The price of the last tick of a bar can be referenced by checking Close[1] on IsFirstTickOfBar. For volume and tick based bars, Bars.TickCount and Volume[0] can be referenced to see if the number of ticks / volume meet the criteria to build a new bar.


    I need help issuing the correct command to get the first tick of Volume Bar. Any help would be appreciated.

    Thank you​

    #2
    Hello geekodude,

    Rather than using the items from that description you could do the same concept as the BuySellVolume indicator which uses the CurrentBar index to know when a new bar is created. The first tick which is received that creates a new bar will increment the CurrentBar index. A simple condition can be used to check if the index of the CurrentBar is greater than a stored variable. The script would need to be run OnEachTick in realtime.


    Code:
    private int activeBar = 0;
    protected override void OnBarUpdate()
    {​
       if (CurrentBar != activeBar)
       {
          //your first tick of bar logic here
          activeBar = CurrentBar;
       }​
    }
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse:

      This works Thank you! :-)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rhyminkevin, Today, 04:58 PM
      1 response
      43 views
      0 likes
      Last Post Anfedport  
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      49 views
      0 likes
      Last Post futtrader  
      Working...
      X