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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        43 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        21 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        30 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Working...
        X