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

Question on conversion of strategy to indicator

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

    Question on conversion of strategy to indicator

    Hi,
    I copied this code from my automated strategy into an indicator shell created by the indicator wizard and I'm getting invalid token errors. Can you give me any tips on how to resolve them so I can compile the indicator?
    Thanks.

    Click image for larger version

Name:	Indicator errors.png
Views:	31
Size:	73.2 KB
ID:	1287571

    #2
    No response to this yet. Does this question violate the rules in some way?

    Comment


      #3
      Hello manraygun,

      Thanks for your post and your patience.

      I apologize for the delayed response. Due to some technical difficulties on our end, we were not notified of your post and did not respond promptly. This question does not violate the rules. The errors are related to the public int and public brush properties declared at the class level; do you intend for these to be user inputs? If so, they must be configured in State.SetDefaults with the appropriate logic in the Properties region of your script as well. I suggest creating these properties in the indicator wizard on the "Input Properties" page and then pasting the code generated for State.SetDefaults and Properties into your script (or pasting your other script logic into the script generated with the desired inputs configured on the User Inputs screen).

      Please let us know if we may be of further assistance.
      Emily C.NinjaTrader Customer Service

      Comment


        #4
        Hi Emily, thanks for the reply.
        Actually no, I don't need user inputs. Glad you pointed that out.
        I made changes and got rid of a bunch of errors. Now I'm left with this: "Type or namespace name 'ExponentialMovingAverage' could not be found." Forgive my ignorance but any suggestions for this one?

        Click image for larger version

Name:	Indicator errors 2.png
Views:	21
Size:	70.6 KB
ID:	1288088

        Comment


          #5
          Hello manraygun,

          Thank you for your reply.

          It seems as though you are trying to create EMA objects, correct? This would be declared as a private EMA and not private ExponentialMovingAverage:


          There is no type called "ExponentialMovingAverage" that exists in NinjaTrader by default, and that is why the error is being thrown.

          An example using SMA instead of EMA may be found on the NinjaScript Best Practices page under Performance Practices > Performance practices > "Referencing indicator methods":


          Please let us know if we may be of further assistance.
          Emily C.NinjaTrader Customer Service

          Comment


            #6
            Thank you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            12 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            15 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Working...
            X