• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Newtrader101, Today, 03:54 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by williamzz, Today, 03:28 PM
    0 responses
    7 views
    0 likes
    Last Post williamzz  
    Started by Robert87, Today, 11:07 AM
    0 responses
    13 views
    0 likes
    Last Post Robert87  
    Started by phta123, Today, 10:24 AM
    0 responses
    17 views
    0 likes
    Last Post phta123
    by phta123
     
    Started by sidviciousX, Today, 06:47 AM
    0 responses
    16 views
    0 likes
    Last Post sidviciousX  
    Working...
    X