Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to share methods

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

    How to share methods

    I thought it could be as simple as:

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class cms2
    {
    public double CheckEMA(ISeries<double> Price, int Length)
    {
    double myema = 0;
    myema = EMA(Price, 10);
    return myema;
    }

    and I would have access to cms2 from any indicator ...

    But I get an error of:
    'NinjaTrader.NinjaScript.Indicators.EMA' is a 'type' but is used like a 'variable'

    If I put it in the NinjaTrader.Custom namespace I get an error "The name 'EMA' does not exist in the current context".

    Thanks!

    #2
    EMA(Price, 10) will return EMA, not double. Double value you will get if you access like this EMA(price, 10)[0].

    Comment


      #3
      Hello Skechers,

      Thanks for your post.

      To access the value of the EMA indicator, you would need to use EMA(price, 10)[0] as Leeroy_Jenkins has stated.

      This will return the current bar's EMA value as a double.

      See this help guide page for more information about accessing EMA values in a NinjaScript: https://ninjatrader.com/support/help...onential_e.htm

      Let me know if I may assist further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Arghhh Many Thanks ...

        Comment

        Latest Posts

        Collapse

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