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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X