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

NinjaTrader generated indicator code should use namespace in the cache vars

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

    NinjaTrader generated indicator code should use namespace in the cache vars

    There are name clashes in the Indicator partial class if you redefine an indicator name within your own workspace. As a simple example, if I create an SMA indicator in a workspace (i.e. WS), I will get a a name clash because cacheSMA is already defined in the Indicator partial class.

    This would be solved if the generated code used the namespace (i.e. cacheWSSMA). Then I could have two SMA indicators that would not clash and could be called out via namespaces.

    Please consider fixing this.

    #2
    Hello aslane,

    In your example it is not the namespace which is the problem but the name of the generated cache variable, the namespace is being used in the generated code:
    Code:
    private [B]CustomFolder[/B].SMA[] cacheSMA;
    Adding the namespace wouldn't help here, a unique variable name would still be needed as this is a variable of the partial class. The SMA has the same named cacheSMA variable in its partial class causing an error.

    For your specific example there is also now logic in the newest update to prevent this situation. Using system indicator names like SMA specifically is not a valid name that you can use so this generates a warning now. This does not currently happen with custom indicator names so I will put in a feature request to have the wizards prevent you from creating an item that uses an existing name.

    If the goal is to have two SMA indicators which do not clash you would need to use two unique names such as SMA1 and SMA2 or you can use the existing SMA and a unique named type SMA1.


    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Right, but you made my point. The cache var should be "cacheCustomFolderSMA", then it would be unique.

      Anyway, does not matter, I suspected you would not support.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      23 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      22 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X