Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Arghhh Many Thanks ...

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 11:02 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by geotrades1, Today, 10:02 AM
        4 responses
        12 views
        0 likes
        Last Post geotrades1  
        Started by rajendrasubedi2023, Today, 09:50 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by lorem, Today, 09:18 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        4 responses
        30 views
        0 likes
        Last Post geddyisodin  
        Working...
        X