Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to reference CurrentBar for DataSeries added directly to a chart

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

    How to reference CurrentBar for DataSeries added directly to a chart

    Hi.
    I have a chart that have grown used to manually trading that I am now trying to build a strategy for.
    This chart has multiple timeframes on it already and indicators associated with those timeframes.

    I created a strategy in Strategy Builder that of course doesn't know about the multiple timeframes/data series on the chart that I use.
    I'm okay with unlocking the code if necessary. But how would I reference these secondary/other data series/bars in the Strategy NinjaScript?

    Output when I try to display the values to the Log show that, even though there are 4 data series on the chart, when I trigger the strategy on this chart, the strategy still can not reference anything besides the primary.
    BarsInProgress = 0, and CurrentBars[0] have data. CurrentBars[1] is an out of range index.
    ChartControl.BarsArray.Count = 1.

    1) Is there a way I could dynamically make the strategy understand it's being run on a chart that already has multiple data series on it?
    2) If I have to use AddDataSeries() in the Ninjascript for the strategy to be aware of, how would I distinguish these script Added Data series/bars from the ones that are already on the chart I'm using? I'm hesitant to remove my on data series from my chart because my indicators are already using them.

    Thanks,
    Q



    #2
    Hello q40bomb,

    Your strategy is only associated with the series you apply it to, the other series on your chart are unknown to the strategy. This is the same with indicators too. If your strategy needs to reference secondary data you need to program the strategy to use that data with AddDataSeries.

    A strategy builder script can add secondary data using the additional data tab. The series that it adds can only be used for accessing prices, those secondary series cannot be used for processing. If you also need those series to call OnBarUpdate to drive logic or submit orders to them you would have to unlock the script to do that.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X