Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Errors trying to initialize 3 indicators

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

    Errors trying to initialize 3 indicators

    I have been putting together a strategy based off of a trading strategy I use daily. I have gotten rid of all compiling errors except for three. It is the same error for 3 different indicators I am trying to initialize in the "OnStateChange()" and "State.DataLoaded" state.

    The error I am getting is "Non-Invocable member 'EMA' cannot be used like a method". I am getting it for 2 other indicators as well.

    This is the code I am using:


    else if (State == State.DataLoaded)
    {
    ema = EMA(EmaPeriod);
    adx = ADX(AdxPeriod);
    alligator = WisemanAlligator(Close);
    }​


    Can anybody help me resolve these compiling errors?

    #2
    Hello nunu1919,

    Welcome to the NinjaTrader forums!

    More information is needed.

    May we see where the variables are being declared?

    Or can you attach the .cs file for the script from Documents\NinjaTrader 8\bin\Custom\Strategies?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      This is where I declare my variables:
      Click image for larger version

Name:	image.png
Views:	97
Size:	7.5 KB
ID:	1317936

      This is where I initialize them and where the errors are coming from:
      Click image for larger version

Name:	image.png
Views:	91
Size:	36.5 KB
ID:	1317937

      And these are the errors:
      Click image for larger version

Name:	image.png
Views:	91
Size:	13.8 KB
ID:	1317938

      Comment


        #4
        Hello nunu1919,

        Be sure you are creating scripts with the NinjaScript Editor so these have the correct default structure.

        Change the inheritance from StrategyBase to Strategy on line 14.

        Let me know if that does not correct the error.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          That is how I had it at first, but that presents a slew of other compiling errors including that the type of namespace name 'Strategy' does not exist in the namespace NinjaTrader.NinjaScript

          Click image for larger version

Name:	image.png
Views:	91
Size:	149.1 KB
ID:	1317980

          Comment


            #6
            Hello nunu1919,

            Try creating a new strategy from the NinjaScript Editor.

            Then copy the variables and logic into the new script's OnStateChange() and OnBarUpdate().
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Okay, I got it working. I created a new strategy as you suggested and just used the generic template to add my coding into.

              Turns out that what I was missing was the following:

              Click image for larger version

Name:	image.png
Views:	93
Size:	12.3 KB
ID:	1318000

              I didn't have that line 26 in there and my line 28 was written wrong.

              Thank you for your assistance!​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              45 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
              31 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
              42 views
              0 likes
              Last Post CarlTrading  
              Working...
              X