Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating percentage of bar after bar opens

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

    Calculating percentage of bar after bar opens

    Hello all,

    I am really newbie on ninja trader script. I am trying to calculate certain percentage of current bar since this one opened. I am configuring the calculation as Calculate = Calculate.onEachTick but, my biggest challenge so far is on how to get the current price (price when the tick changes). I know that close[0] is for bar closed but I don't need to get that price but the one intrabar before it close to calculate on each tick until match with condition to trigger a long or short position depending on other conditions that I have in strategy.

    Thank you very much in advance for your time and answers.

    #2
    Hi, thanks for posting. The Close[0] price will represent the latest price in an OnEachTick script. You can use Print(); to print out the Close[0] value and you will see it printing the intrabar values:

    //OnBarUpdate:
    Print(Close[0]);

    Kind regards,
    -ChrisL

    Comment


      #3
      Thank you very much on your quick answer Chris L.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X