Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator on Primary Data Series vs Secondary Data Series

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

    Indicator on Primary Data Series vs Secondary Data Series

    Hi,

    I've a strategy running with the below format. If I've a strategy with multiple data series. Inside else if (State == State.DataLoaded) do I need to call the indicator with the below example1 or example 2?

    Example 1: CurrentDayOHL1 = CurrentDayOHL(Close);
    Example 2: CurrentDayOHL1 = CurrentDayOHL(Closes[0]);

    I've attached a small portion of the script with 2 options highlighted in red. Option 1 shows without the "s[0]", and Option 2 with it. All the indicators that I've are on the Primary Data Series, so my assumption is that all of them will be one way or the other.

    Option 1:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "Name";
    Calculate = Calculate.OnEachTick;
    EntriesPerDirection = 3;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    AddVolumetric(Instrument.FullName, BarsPeriodType.Minute, 1440, VolumetricDeltaType.BidAsk, 1);
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
    ClearOutputWindow();
    VOL1 = VOL(Close);
    VolumeUpDown1 = VolumeUpDown(Close);
    CurrentDayOHL1 = CurrentDayOHL(Close);
    VWAP11 = VWAP1(Close, 1);
    CumDelta1 = CumDelta(Close, Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false);

    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 60 || (BarsInProgress == 1 && BarsArray[1] == null))
    return;

    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType1 = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

    if (barsType1 == null)
    return;

    try
    {
    // Condition
    }
    catch{}


    Option 2:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "Name";
    Calculate = Calculate.OnEachTick;
    EntriesPerDirection = 3;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    AddVolumetric(Instrument.FullName, BarsPeriodType.Minute, 1440, VolumetricDeltaType.BidAsk, 1);
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    }
    else if (State == State.DataLoaded)
    {
    ClearOutputWindow();
    VOL1 = VOL(Closes[0]);
    VolumeUpDown1 = VolumeUpDown(Closes[0]);
    CurrentDayOHL1 = CurrentDayOHL(Closes[0]);
    VWAP11 = VWAP1(Closes[0], 1);
    CumDelta1 = CumDelta(Closes[0], Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false);

    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 60 || (BarsInProgress == 1 && BarsArray[1] == null))
    return;

    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe barsType1 = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsTy pe;

    if (barsType1 == null)
    return;

    try
    {
    // Condition
    }
    catch{}​

    #2
    Hello AgriTrdr,

    Thank you for your post.

    If you specifically want to use the close series, you can use the second version. You could also use BarsArray[0]. Please see this section of our help guide:



    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Hi Kate,

      Thanks for your response. Would all of them be using the second example with "Closes[0]" since all of them are with Primary Data Series?

      Also, just as knowledge, BarsArray[0] would go where if I wanted to use that route?

      Thanks

      Comment


        #4
        Hello AgriTrdr,

        Thank you for your reply.

        Closes[0] would refer specifically to the Close series of the primary bars.

        BarsArray[0] is just a specific way to refer to the primary bars series, you'd use that in place of using Closes[0].

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Hi Kate,

          So in the below example, would BarsArray[0] would be referred the correct way:

          ClearOutputWindow();
          VOL1 = VOL(BarsArray[0])[0];
          VolumeUpDown1 = VolumeUpDown(BarsArray[0])[0];
          CurrentDayOHL1 = CurrentDayOHL(BarsArray[0])[0];
          VWAP11 = VWAP1(BarsArray[0], 1)[0];
          CumDelta1 = CumDelta(BarsArray[0], Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false)[0];

          Thanks

          Comment


            #6
            Hello AgriTrdr,

            Thank you for your reply.

            Not quite, if you try to refer to the current bar value there you'll hit errors, so you want to eliminate the bars ago:

            Code:
            ClearOutputWindow();
            VOL1 = VOL(BarsArray[0]);
            VolumeUpDown1 = VolumeUpDown(BarsArray[0]);
            CurrentDayOHL1 = CurrentDayOHL(BarsArray[0]);
            VWAP11 = VWAP1(BarsArray[0], 1);
            CumDelta1 = CumDelta(BarsArray[0], Brushes.Red, Brushes.LimeGreen, Brushes.Black, 1, 0, false);

            Please let us know if we may be of further assistance to you.​

            Comment


              #7
              Thanks this is good info to know.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              62 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              134 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              75 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X