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

real time value in bar,

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

    real time value in bar,

    Hi

    How to use BarInProgress with AddDataSeries to get the realtime value. please help us with few examples to get value of bar in real time using BarInProgress. Also, if you have better way to get real time value in bar, please suggest.

    #2
    Hello yeshujbp,

    Thanks for your post.

    To work with real time data (or playback with market replay data) and have access to the currently forming bar, the script must be run with Calculate.OnEachTick (or Calculate.OnPriceChange).

    To access data from added data series you can work with the code segmented by the BarsInProgress index and/Or by using the "plurals" of the price type.

    The BarsInProgress identifies which of the data series has called the OnBarUpdate() method. BarsInProgress 0 is the chart Bars, 1 is the 1st listed added data series, 2 is the 2nd added dataseries, etc. etc.

    There are a number of ways to write your code and which way depends on your needs. For example, if you wanted to access the High of the first two added data series when the chart bars call OnBarUpdate():

    if (BarsInprogress == 0)
    {
    if (SMA(20)[0] > Highs[1][0] && SMA(20)[0] > Highs[2][0]) // Is the Chart bars SMA20 current value greater than the current high of the first and second added data series
    {
    // do something
    }

    We highly recommend that you review the help guide on Multi series and multi time frame as this provides an education of all things related to the subject and covers all of your questions with detail ed examples and diagrams: https://ninjatrader.com/support/help...nstruments.htm The best way to review is in the sequence written that covers these topics:
    Working With Multi-Time Frame Objects
    Adding Additional Bars Objects to NinjaScript
    Creating Series<T> Objects
    How Bars Data is Referenced
    Using Bars Objects as Input to Indicator Methods
    True Event Driven OnBarUpdate() Method
    Accessing the Price Data in a Multi-Bars NinjaScript
    Entering, Exiting and Retrieving Position Information
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by yeshujbp View Post
      Hi

      How to use BarInProgress with AddDataSeries to get the realtime value. please help us with few examples to get value of bar in real time using BarInProgress. Also, if you have better way to get real time value in bar, please suggest.
      Hi yeshuijbp,

      Do you now have a final version of the Alert/Smsalert indicator that works ? Could you please post/share it.

      Best Regards.

      Lolu

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bmartz, 03-12-2024, 06:12 AM
      4 responses
      32 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      12 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X