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 Salahinho99, Today, 04:13 AM
        0 responses
        5 views
        0 likes
        Last Post Salahinho99  
        Started by junkone, 04-28-2024, 02:19 PM
        8 responses
        92 views
        1 like
        Last Post brucerobinson  
        Started by mkouitra, 10-23-2021, 04:40 PM
        17 responses
        1,964 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
        4 responses
        29 views
        0 likes
        Last Post Vietanhnguyen2hotmailcom  
        Started by PhillT, 04-19-2024, 02:16 PM
        4 responses
        37 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Working...
        X