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

Name does not exist in the current context

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

    Name does not exist in the current context

    Hi,

    I’m not calling the Swing indicator, but calculating the Swing indicator in my strategy. I’m getting a compiling error that is part of the swing indicator “Function” and the “Properties” sections:
    The name “Update” does not exist in the current context.

    What will be the proper way to make it work? Thanks

    #2
    Hello 2Look4me,

    Thanks for your post.

    Can you provide your strategy code parts that reference the swing indicator?

    If you prefer not to post your code, you are welcome to send into PlatformSupport[at]NinjaTrader[dot]com, please mark the e-mail Atten Paul, Ticket# 2321106. In the body of the e-mail please include a link to this thread, finally I would suggest attaching your source code file.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,
      The error from the “Properties” section: “The name ‘Update’ does not exist in the current context” section goes away once the Ninjascript generated code at the bottom of the original “Swing” indicator is copied to the strategy.

      In the Ninjascript generated code I replaced all instances of the “Swing” indicator name with the “StrategyName” .

      But still get the following errors: The type or namespace name 'StrategyName' does not exist in the namespace 'NinjaTrader.Indicator' (are you missing an assembly reference?)

      Comment


        #4
        Hello 2Look4me,

        Thank you for the additional details.

        The error "The name ‘Update’ does not exist in the current context” indicates that the Update method is out of context, such as being used from a class which does not inherit from Strategy or Indicator. For this type of error we would need to see a sample of the code used to better understand why that is happening. Copying or editing the generated code manually is not a solution as the platform will try to regenerate that during a compile, we would instead need to better understand the core issue here.

        Can you attach the file you are working on in the state it is currently in, I would like to take a look at the overall structure and how the Update() syntax was used. You can find the .cs file for the strategy in the folder: Documents\NinjaTrader 7\bin\Custom\Strategy



        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 11-01-2019, 09:08 AM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse. Enclosed please find the attached file. In essence I'd like to calculate the Swing indicator from within a strategy.
          aaStrategyTest.cs

          Comment


            #6
            Hello 2Look4me,

            Thank you for providing that, this makes more sense now.

            In the strategy you are using some indicator specific syntax which is the reason for the error. In your properties at the bottom you have Update and have used Values directly which do not apply toward the strategy. You would need to remove the properties you copied into your strategy.

            To pull a value from the swing, you can just use it directly like the following:

            Code:
            Swing().SwingHigh[0]
            https://ninjatrader.com/support/help...lightsub=swing


            As a side note, the documentation for the Swing has been updated in NT8 to reflect that this indicator is not generally good for use in a predictive situation such as a signal:
            The Swing indicator will plot lines that represent the swing points based on the strength (number of bars to the left and right of the swing point) parameter provided, it's mostly a visual tool and not meant to be predictive in nature.
            Based on its logic it cannot be used for a signal directly as it re-writes old plot values and uses special methods to return the swing data.

            You may potentially be able to include the siwngs calculation minus the plotting logic in the strategy to be used in more complex ways. If you try to bring the actual syntax from the indicator into the strategy you would need to remove all plots and plotting logic from the script and replace it with DataSeries. Alternatively leave the code in the indicator and call it directly, you can make a copy of the swing indicator if you needed to change it.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by samish18, Yesterday, 08:31 AM
            4 responses
            14 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by funk10101, Yesterday, 09:43 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            5 responses
            551 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by rtwave, 04-12-2024, 09:30 AM
            5 responses
            37 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by funk10101, Today, 12:02 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Working...
            X