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

Compile issues

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

    Compile issues

    I start by saying I have a lot of C# experience but new to Ninjascript. I used the Ninjascript Indicator wizard to generate code and filled in some of the methods. When I go to compile I get the same 3 errors:

    Line 16 Unexpected preprocessor directive
    Line 14 { expected
    Line 129 } expected


    I thought I had nested something incorrectly but there is simply no code there. For giggles I pulled up some existing indicators that work and tried to compile them but got the same errors. Ideas?
    Attached Files
    Last edited by stuart; 05-09-2012, 08:26 PM.

    #2
    Welcome to our forums and please give the attached a try, compiles well here.

    1. For the Add() overload including the marketdata type, please include the specific symbol name

    2. For MultiSeries access to the Close prices array use, please use Closes and not Close -



    Generally it's helpful to step through available parameters / overloads with Intellisense -

    Attached Files
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply Bertrand. I did use intellisense and there were serveral overloads for the Add function and I was trying to use the one that referred to the primary symbol. That said the code you sent me still did not compile and I got the same three errors

      Comment


        #4
        There's unfortunately no overload for adding marketdata types on the primary series, you have to explicitly specify the instrument name here to use.

        Add(string instrumentName, PeriodType periodType, int period, MarketDataType marketDataType)

        Are you sure you copied my file over yours and are not accidentially using your old uncompilable one? Please recheck.

        You can of course also simply fix your present file with the points I mentioned so it could compile normally.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          If you look at my post I specifically stated that I can't compile anything. If I bring up existing indicators that work and try to compile them I get the same three errors

          Comment


            #6
            Right, that would be expected - all files have to be compilable, or nothing would compile - since all is compiled into one assembly for runtime use.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              So a partially completed script was causing the issue. Once deleted your code compiles. It doesn't work but it does compile. So when you use "Add" you give the "ES" as the contract. Is that just a placeholder that is overwritten by the primary contract when used in a chart?

              Comment


                #8
                Correct, one script with compile issues could stop the whole compile process for all scripts you have installed as everything is maintained in one assembly for performance reasons.

                I've added the ES in as example for a symbol, so you could compile your code - you would need to add here the symbol you wish to use.

                For an index, for example ^SP500

                For a spot fx instrument $EURUSD

                For a stock MSFT
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  But I want the symbol to reference the primary symbol i am adding the indicator to. ie. if you are charting $AUDUSD i don't want to have to change the code every time. How do you choose the context symbol?

                  Comment


                    #10
                    Although we can't support dynamically adding offically, you can try using Instrument.FullName here in your Add() call. Cleanest way would be setting up a string user input to enter the instrument you would like to run on.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by PaulMohn, Today, 12:36 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post PaulMohn  
                    Started by love2code2trade, 04-17-2024, 01:45 PM
                    4 responses
                    38 views
                    0 likes
                    Last Post love2code2trade  
                    Started by alifarahani, Today, 09:40 AM
                    2 responses
                    14 views
                    0 likes
                    Last Post alifarahani  
                    Started by junkone, Today, 11:37 AM
                    3 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by frankthearm, Yesterday, 09:08 AM
                    12 responses
                    44 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X