Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

error CS0118 NinjaTrader.NinjaScript.Indicators.SMA is a type, but used as variable.

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

    error CS0118 NinjaTrader.NinjaScript.Indicators.SMA is a type, but used as variable.

    Hello, I am implementing indicator.
    And I get error everywhere , when I compare close[0] and value of SMA() indicator.
    What can be a problem?

    The weird is that when I am using indicator - everything is fine.!
    But when I try to export I get error in log file.


    Code:
    private bool current_trend_filter(AkSignalType signal_type)
            {
                bool result = true;
                switch (signal_type) {
                    case AkSignalType.Buy:
                        if (Close[0] < SMA(SlowSMAPeriod)[0])
                            result = false;
                        break;
                    case AkSignalType.Sell:
                        if (Close[0] > SMA(SlowSMAPeriod)[0])
                            result = false;
                        break;
                }
    
                return result;
            }

    #2
    Hello akushyn,
    Thanks for your post.

    The issue does not appear to be with any NinjaScript in this snippet.

    If you exclude this script from compilation are you able to export?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      Hello akushyn,
      Thanks for your post.

      The issue does not appear to be with any NinjaScript in this snippet.

      If you exclude this script from compilation are you able to export?
      Hello, JoshG

      Thank you for the quick reply.
      So far, I have no other scripts in the scope.

      Could it be the issue with VirtualBox running NT8 export?

      Comment


        #4
        I've just tried .... create copy-paste SMA indicator as my custom indicator to try exporting the script.
        But indicator is avaliable only in Script Editor and not visible to add on chart or export.

        See attached picture.

        Comment


          #5
          akushyn,

          Your NinjaScript does not appear in the Indicators window because of your "Name" property inside OnStateChange()

          Can you find the NinjaScript once you change that property to the name you expect to find it under?
          Josh G.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_JoshG View Post
            akushyn,

            Your NinjaScript does not appear in the Indicators window because of your "Name" property inside OnStateChange()

            Can you find the NinjaScript once you change that property to the name you expect to find it under?
            When I comment Description and Name properties the indicator appears in the list.


            And I think it is a BUG with general question about exporting ERROR - can't export scripts from Virtual Machine.

            I've just copied to another notebook with Windows7 (not a virtual drive) and export works like a sharm.
            So, may be you can advise me some topics, how to run NinjaTrader8 on Linux Mint 19 ?

            Comment


              #7
              akushyn, I do not believe that this is a bug. I am able to compile my own custom method just fine when using the same logical comparison. ( Close[0] < SMA(SlowSMAPeriod)[0] )

              Linux is not supported by NinjaTrader, but I can submit your vote towards the open request for Linux support. The internal tracking number for that feature request is SFT-153. Please reference this internal tracking number if you ever have questions regarding this feature request.

              When a feature request is implemented, you'll find it in the release notes:



              Additionally, please write in to PlatformSupport(AT)NinjaTrader(DOT)com and reference this forum post with RE:JOSH in the subject line. Please attach your Log and Trace files to your email so that I may investigate this matter further. You may follow the steps below to attach those files.
              • Open your NinjaTrader folder under My Documents.
              • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
              • Send the 2 compressed folders as attachments to this email.
              • Once complete, you can delete these compressed folders.


              Josh G.NinjaTrader Customer Service

              Comment


                #8
                For anyone finding this post a few years later, I hit a similar issue today whereby often used indicators like EMA or ATR in existing strategies started throwing compile errors but only in certain batches of files. The issue for me was the parent folder name somehow clashing with the strategy name. For example, I created a folder within Strategies called MyStrat and then within that had a strategy named MyStratv1. If I renamed the folder to RandomStrat, the compile errors went away. There must be some special namespace pattern matching that happens under the hood that breaks references to these indicators when the folder name is too close to the strategy name.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by argusthome, Yesterday, 10:06 AM
                0 responses
                21 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                18 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                14 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                9 views
                0 likes
                Last Post TheRealMorford  
                Started by Mindset, 02-28-2026, 06:16 AM
                0 responses
                40 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Working...
                X