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

Strategy Not Listed to Add to Chart

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

    Strategy Not Listed to Add to Chart

    I have a custom strategy for VWAP that is saved without errors, but is not listed to add to a chart.

    Thanks

    #2
    I have the exact same issue that I'm trying to solve. The strategy compiles perfectly, but won't execute anything. I can't add it to a chart because it's not listed in the "strategies" menu. It produces no logs, no errors, nothing. I've tried everything I can think of with no success.

    Comment


      #3
      Originally posted by mattlaguardia View Post
      I have the exact same issue that I'm trying to solve. The strategy compiles perfectly, but won't execute anything. I can't add it to a chart because it's not listed in the "strategies" menu. It produces no logs, no errors, nothing. I've tried everything I can think of with no success.
      Exact same issue. I am sure it is just 1 line of script that does the trick. I will forward you info when I find out, even through a third party.

      Comment


        #4
        Hello smitheric222,

        Thanks for your post.

        Typically, when a strategy does not display in the Strategies window this indicates that you have some offending code in the OnStateChange() section of your script.

        You could reduce your code by commenting out code line by line in OnStateChange() and testing to see if the issue persists. If you see the strategy appear in the Strategies window after commenting out a section of code in OnStateChange(), this is likely where the offending code is located and you could narrow in on the offending code to correct it from there.

        Please let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Here is what I found so far with my code.

          I had not included a namespace declaration, so even though the code compiled correctly, it did not show up in the strategies menu. Adding one below the Region declaration allowed the code to compile, but gave me a weird error 'Extern alias declarations, using clauses, assembly/module attributes, or namespace/type declarations expected'. Once I moved the namespace declaration above the Region block, the error disappeared. I can now add the code to a chart.

          Unfortunately, it still won't take trades in the backtester, and it won't generate any real log info, in spite of having print commands in the code. So I'm working to solve this.

          Here is my OnStateChange block:

          protected override void OnStateChange()

          {

          if (State == State.SetDefaults)

          {

          Description = "Crude Oil Opening Range Breakout Strategy";

          Name = "CrudeOilOpeningRangeBreakoutStrategy";

          Calculate = Calculate.OnPriceChange;
          }
          else if (State == State.Realtime)
          {
          }
          base.OnStateChange();
          }

          Comment


            #6
            Hello mattlaguardia,

            Thanks for your note.

            Is this a strategy your programmed yourself? Or, was this made by a third-party?

            If you created it, did you use the Strategy Builder or the NinjaScript Editor window to create the script?

            If you used the NinjaScript Editor window, did you set up the script using the New Strategy Wizard window (Click '+' tab on NinjaScript Editor window > New Strategy. Or, right-click in Strategies folder > New Strategy)?

            base.OnStateChange() does not need to be called within State.Realtime. This can likely be removed from the script.

            Please share a copy of your script so that I may look into this further. Ninjascript strategies could be found in the Documents\NinjaTrader 8\bin\Custom\Strategies folder.

            I look forward to assisting further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hello Brandon
              Thanks for the reply. This is my strategy, coded in the NinjaScript Editor window. I think I started with the Wizard because I couldn't find any other way to start a new file in the editor. Then I deleted all the code and started over. I've attached it here.

              Curiously, this doesn't have the @ symbol in front of the filename like all the other strategies do. Not sure what that means.



              Attached Files

              Comment


                #8
                Hello mattlaguardia,

                Thanks for your note.

                Only NinjaScript files that come default with NinjaTrader will contain '@' in the name of the file. Custom NinjaScripts will not contain '@' in the file name.

                Using declarations must be placed at the top of the script (outside of the namespace) in the strategy. You could click the '+' button in the NinjaScript Editor window, select 'New strategy', go through the Strategy Wizard prompts to set up the new strategy, and then view the code of the new strategy to see exactly how the Using declarations should be added to a NinjaScript strategy.

                'base.OnStateChange()' could be removed from the OnStateChange() method in the script.

                I also see that you have a section of code in OnMarketData() within curly braces that do not have an associated condition.

                {
                longPositionOpened = false;
                shortPositionOpened = false;
                openingRangeHigh = 0;
                openingRangeLow = 0;
                stopLoss = 0;
                profitTarget = 0;
                }​

                The curly braces can be removed from this section of code.

                After making these changes, I am able to see the strategy appear in the Strategies window.

                Please let me know if I may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                10 responses
                36 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by DayTradingDEMON, Today, 09:28 AM
                4 responses
                24 views
                0 likes
                Last Post DayTradingDEMON  
                Started by geddyisodin, Yesterday, 05:20 AM
                8 responses
                51 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by George21, Today, 10:07 AM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by Stanfillirenfro, Today, 07:23 AM
                9 responses
                25 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X