Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing a secondary bars object to a custom indicator

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

    Passing a secondary bars object to a custom indicator

    Hi there,

    I can see from this example that it's pretty easy to pass a secondary bars object to a NT indicator (CCI):

    Code:
    protected override void OnBarUpdate()
    {
        // Checks to ensure all Bars objects contain enough bars before beginning
        if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
            return;
     
        if (BarsInProgress == 0)
        {
            if (CCI(20)[0] > 200 && CCI(BarsArray[1], 20)[0] > 200
              && CCI(BarsArray[2], 20)[0] > 200)
             {
                  // Do something
             }
        }
    }
    However, I'd like to know how to pass a secondary bars object to a custom indicator.

    For example, if the condition was:

    Code:
     if (Opens[0][0] < MyCustomIndicator(Period, StdDevThresh).VSLow[0]
                    && Position.MarketPosition != MarketPosition.Long)
                {
                    EnterLong(amount, "EnterLongOpen");
                }
    How would I pass a secondary bars object to this indicator in the same way that it has been done for the CCI indicator:

    Code:
    CCI(BarsArray[1], 20)[0]

    Thanks

    #2
    Scotty, that would be just done in the same manner - any indicator method, also your custom one, will per default offer an overload as well that would allow to pass an IDataSeries in like you have shown for the CCI call. So I would expect that to be working for you -

    Code:
    MyCustomIndicator(BarsArray[1], Period, StdDevThresh).VSLow[0]

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    60 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X