Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling an indicator as a method does not compile in BarTypes (NT8)

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

    Calling an indicator as a method does not compile in BarTypes (NT8)

    Dear team,
    when calling an existing indicator as a method in another new indicator, this compiles fine, such as:

    public double offset1;
    protected override void OnBarUpdate()
    {
    offset1 = SMA(10)[0];
    }

    However, if the same call to SMA is made in a BarsTypes file, from within the OnDataPoint method it generates an error:
    CS0118 : NinjaTrader.NinjaScript.Indicators.SMA is a 'type' but is used like a 'variable'

    I'm thinking this is to be expected, i.e. we can't call an existing indicator as a method within a BarsTypes file,
    but we can call an Indicator as a method from within another Indicator, is this correct ?

    Alternatively, Is there a way to make use of an existing indicator, as a method within a BarsType file ?

    Many thanks,
    Louis

    #2
    check link https://ninjatrader.com/support/foru...-show-on-chart

    Comment


      #3
      Hello Louis365,

      Thanks for your question.

      BarsTypes are simply meant to create Bars objects based off of incoming market data. There would not be a supported way to call an indicator from a BarsType since the indicator requires a data series which would be constructed from a BarsType, and we do not offer a way to build these scripts in a circular fashion.

      If you need certain logic from an indicator implemented in the BarsType, I would suggest reviewing the indicator's code and then adapting that code in the BarsType's OnDataPoint method.

      Please let us know if we can be of further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X