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:	89
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:	82
Size:	36.5 KB
ID:	1317937

      And these are the errors:
      Click image for larger version

Name:	image.png
Views:	83
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:	84
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:	85
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 NullPointStrategies, Today, 05:17 AM
              0 responses
              23 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              120 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              63 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              41 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              45 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X