Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cascading Indicators with 2 Instruments or more

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

    Cascading Indicators with 2 Instruments or more

    Hi, I have a problem with cascading indicator not showing the correct value. It shows the value of the main chart price instead. By cascading, I mean the input of an indicator is another indicator.

    SomeIndicator1:
    Code:
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    			Add(instrumentB, PeriodType.Minute, 1);
                Overlay				= false;
    			CalculateOnBarClose = false;
            }
            protected override void OnBarUpdate()
            {
    			if (CurrentBars[0] < 390 || CurrentBars[1] < 390)
    				return;
                Plot0.Set((Closes[0][0]+Closes[1][0])/2);
            }
    SomeIndicator:
    Code:
            protected override void OnBarUpdate()
            {
            if (CurrentBar < 390 )
    				return;
    	double val = SomeIndicator1()[0];
    	Print(val);
            Plot0.Set(val);
            }
    However, if SomeIndicator1 does not use 2 instruments, it works okay. Am I doing something wrong here?

    PS: the
    Code:
    if (CurrentBars[0] < 390 || CurrentBars[1] < 390)
    is needed to ensure both instruments have at least 1 full day of minute bars.

    Thank you in advance.

    #2
    Hi,

    it Seems that CurrentBars[1] is always return value of 1 (or other small integer).
    Isn't this supposed to increase as time passes by?

    Comment


      #3
      Please try removing any CalculateOnBarClose hardcoded reference in your called indicators.

      I just printed CurrentBars in a MultiSeries indicator and it's working here as expected for me, returning the CurrentBar count for both series for example.

      Are you on the latest B18?

      Thanks

      Comment


        #4
        Hi, I don't know how to explain this. But after a restart, it is now displaying the correct value. I didn't even have to remove CalculateOnBarClose .

        Yes, I'm on the latest B18.

        Next time I encounter inconsistency, I'll try restarting first before posting. Thanks

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        42 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        157 views
        2 likes
        Last Post CaptainJack  
        Working...
        X