Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing Custom Indicator to Strategy Error, "is a method but is used like a type"

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

    Passing Custom Indicator to Strategy Error, "is a method but is used like a type"

    I'm having an issue passing an indicator through to a strategy.

    I always use a private call to an indicator just under public class like the following example

    Code:
    public class ExampleStrat: Strategy
    	{
    		private Stochastics stoch0;
    Then define the indicator under State.Configure and State.DataLoaded

    Code:
    	else if (State == State.Configure)
    			{			
    				stoch0 = Stochastics(periodD,periodK,smooth);
    	
    			}
    	else if (State == State.DataLoaded)
    			{
    
    				stoch0 = Stochastics(periodD,periodK,smooth);
    				AddChartIndicator(stoch0);
    			}
    I never have issues with this.

    But I have a custom indicator where I am doing the exact same thing, and it is throwing a compiling error

    saying the indicator "is a 'method' but is used like a 'type'

    Is there anything special that might cause this? Not sure why I have never had this issue with passing through any other default or custom indicators.
    -EC_Chris-
    NinjaTrader Ecosystem Vendor - Emergent Cybernetics

    #2
    Hello EC_Chris,
    Thanks for your post.

    I see no reason for this error to be occurring with the information you have provided. Why are you defining the indicator in both State.Configure and State.DataLoaded?

    If possible may I review the entire code for this indicator and the strategy you are developing?

    If you prefer, you can send your files to PlatformSupport(at)NinjaTrader(dot)com with 'ATTN: JOSH' in the subject line.

    I look forward to your response.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      I am having the same issue with custom indicators. I would love to see a public reply in the forum.

      Comment


        #4
        Welcome to the forums ColTrader!

        This would be a C# programming error. We suggest looking up compile errors using your favorite search engine to learn more about the compile errors as they would be related to C# and are not specific to NinjaScript.

        Various publicly available C# resources on these sorts of compile errors can be found below.

        https://www.c-sharpcorner.com/forums...ed-like-a-type
        https://stackoverflow.com/questions/...-error-c-sharp
        https://stackoverflow.com/questions/...used-as-a-type
        https://social.msdn.microsoft.com/Fo...csharplanguage
        https://www.experts-exchange.com/que...type'.html

        If you are new to C#, we suggest using the Strategy Builder to generate syntax so you can see how the Builder generates code, and how you can do the same.

        Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

        If you provide the full context of the error, (snippet that creates the error) we could provide some additional insight.

        We look forward to assisting.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hello everyone,

          I sorted the issue with the same error message

          In fact my indicator was in a subfolder.
          adding this

          using NinjaTrader.NinjaScript.Indicators.NewFolder;

          sorted my issue :-)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by elderan, Today, 08:03 PM
          0 responses
          2 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          9 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          169 views
          0 likes
          Last Post jeronymite  
          Working...
          X