Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error adding MACD to Conditions

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

    Error adding MACD to Conditions

    I'm new at this and not good with computers anyway so bear with me please:

    After adding a MACD crossover to Conditions/Actions my strategy won't compile (Error Message: "X Could not compile NinjaScript"). The strategy compiles if I remove the MACD crossover.

    This is what I added to Conditions: "CrossAbove(MACD(Close, 12,26,9) Default, MACD(Close, 12,26,9) Avg,1)"

    This seems OK to me but it won't compile and I'm stumped. What could be wrong?

    #2
    Hello Jazzman, thanks for writing in and welcome in. The series objects of the MACD need to be accessed through the dot operator e.g.
    CrossAbove(MACD(Close, 12,26,9).Default, MACD(Close, 12,26,9).Avg,1);

    You can also use the strategy builder to generate this syntax for you and unlock or view the code to practice:

    https://ninjatrader.com/support/help...gybuilder_cond ition_builder.htm

    Kind regards,
    -ChrisL​

    Comment


      #3
      Hello Chris,

      Thanks for your reply but I'm still confused. It was not attempting to plug in the syntax directly but only indirectly via the drop-down menus in Strategy Builder, as shown below. It was my understanding that using he Strategy Builder menus alone should be sufficient to make the crossover, but I can't make it compile. Have a look below and tell me if you see a problem...

      Click image for larger version

Name:	image.png
Views:	118
Size:	50.8 KB
ID:	1243041​

      Thanks for your patience,
      Charlie
      Last edited by Jazzman53; 03-27-2023, 02:01 PM.

      Comment


        #4
        Hi, The strategy builder will not generate code that will not compile. If you have an existing compile error in your system, it must be fixed first before using the strategy builder.

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi, The strategy builder will not generate code that will not compile. If you have an existing compile error in your system, it must be fixed first before using the strategy builder.
          Well then; I'm at a total loss.

          I've compiled several test strategies afterward with no problem, and this strategy too will compile if I remove the MACD crossover. I tried adding the MACD crossover to other saved test strategies. None compile after adding the MACD crossover and all compile when it's removed.

          I then figured there may be an issue with the MACD indicator itself so I opened up the MACD Indicator in NinjaScript Editor, clicked the Compile button and it compiled with no errors. I then did a restart on my laptop and attempted to compile the strategy again, to no avail.

          Yesterday I imported several 3rd party indicators from the Ninjacators website, which all loaded with no errors. This doesn't seem related but I can't rule it out.

          I don't know any other course of action at this point except a complete uninstall and re-install of NT8, followed by testing a strategy compile with the MACD crossover, and then re-testing after re-importing each of the 3rd part indicators I imported yesterday.

          Does anyone have any suggestions short of a full un-install & re-install?

          Thanks again,

          Charlie

          Comment


            #6
            Update: I never found the cause of the problem but an uninstall and reinstall of NT8 fixed whatever it was.

            Thanks for your efforts, Chris!

            Charlie

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            58 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            133 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X