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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      71 views
      0 likes
      Last Post PaulMohn  
      Working...
      X