Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Here's a script to convert indicators and strategies

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

    #16
    I see. Unfortunately, the script does not do any compilation so it will not know if anything is broken. If you set the indicatorDestinationFolder and strategyDestinationFolder variables to point to the appropriate NinjaTrader 8 folders, NinjaTrader will automatically compile and give you a list of all the errors and their location in the ScriptEditor. You may have to manually create a ScriptEditor in NinjaTrader.

    Thanks again for your input. Let me know if you need any further help.

    Comment


      #17
      Worked but Indi does not show up???

      Used the conversion and the only issues I had were Brushes.Empty. Changed it to Brushes.Black and it compiled.

      Oddly though the indicator does not show up in the list of indicators for a chart. It is there when I choose the editor and look for indicators to edit. Opened again and compiled again. Still not listed in the available list.

      I tried moving them to the "Add0ns" library, compiled again, and still not showing up when selecting chart indicators.

      This may not be the right thread for this, but asking here because it is where I started.

      Any hints?

      Comment


        #18
        Brushes.Transparent will probably be closer to what you want.

        Check the OnStateChange method to see what the Name property is being set to. It may be that the name is different and so the indicator is just in a different position than you expect.

        From my understanding, putting them in the AddOns folder will cause them not to show up for charts.

        Comment


          #19
          when running the .ling file I keep getting a asking if I want to download Nuget which I affirm but then get a second error stating I need 3.0 or higher but the current NuGet version is 2.8.5......

          Comment


            #20
            Are you running LinqPad 5?

            There was a problem with LinqPad using NuGet 3 (see http://forum.linqpad.net/discussion/.../#Comment_2100). I think you may need to download the latest LinqPad.

            Comment


              #21
              UPDATED: I ran the beta version of LinQPad 5 and it ran successfully.

              I am running LinQPad 5 and get the following error when I press the green arrow:

              CS0234 The type or namespace name 'CodeAnalysis' does not exist in the namespace 'Microsoft' (Press F4 to check imported namespaces)
              Last edited by whiterhino; 01-11-2016, 07:56 PM.

              Comment


                #22
                Problem with LinqPad using NuGet 3

                Yes. I was running version 5.03.03 which I downloaded only a couple days ago. I am running Window 10 in case that makes any difference. When I try to run the .linq file I got from you message, I first get a message stating "This query requires the following NuGet packages : Microsoft CodeAnalysis.CSharp. " I say Yes to download which appears to start then I get LinqPad error message stating The System.ResourcesManger 4.00 package requires Nuget Client version3.0 or above, but the current NuGet version is 2.8.5.....

                I just downloader Version 5.04 and now it runs correctly. There was a bug in 5.03.

                The latest LINQPad 5 betas include fixes to bugs reported on the LINQPad forum, plus the following new features:
                •NuGet V3 package support
                •(Pro/Premium Editions) Autocompletion/tooltips in F# queries
                •An optional parameter for specifying columns/members to exclude on the Dump method
                •A checkbox to disable the shortcut key on 'Upload to Instant Share'
                Last edited by dcluggy; 01-11-2016, 09:56 PM.

                Comment


                  #23
                  Cool! Glad it's working for you!

                  Let me know if you run into any problems. The script wasn't meant to be public or robust since it was supposed to be a one time run to convert my indicators so it's a bit hacky.

                  Comment


                    #24
                    whiterhino: To be clear: Are you able to run successfully now?

                    To fix namespace reference problems, you can press "ctrl + ." on any identifier with a squiggly line and then press enter to add the reference. You can also press "F4" and use the dialog to add references.

                    Comment


                      #25
                      No, I can't run most of the indicators as they have issues. For example:

                      All indicators that reference another indicator's bool variable or have a test condition error out like this one:
                      // price above trendline
                      && AutoTrendH(true,true,5).TrendPrice < Close[0]
                      The error thrown is CS0118, ..<name of indicator> is a 'type' but is used like a 'variable'

                      Any ideas?

                      Comment


                        #26
                        Hmmm...

                        Can you create a contrived example and send it to me? I'm going to be out of town until Sunday so I won't have a chance to look at it until Monday.

                        I can't think of a reason off the top of my head that would cause it without it also being an issue with the existing indicator.

                        The example line you posted doesn't seem as if it would have been modified by the script. Can you verify what was in the original indicator for this line vs the converted one? The first thing that comes to mind is that a namespace reference is missing or the generated code is incorrect. Try deleting the generated code and then compiling using the NinjaScript Editor so it regenerates the code (the script should be doing this but maybe there is a bug).

                        Comment


                          #27
                          Thanks, but....

                          Hi wbennettjr,

                          Thanks so much for this conversion program. I was able to convert all of my NT 7 scripts to NT 8 and they all compiled fine! However, when I try to execute any of them in the Strategy Analyzer I get the pop up:

                          There was a problem initializing '<the script>'. Selecting next valid strategy.

                          I have included the translated strategy.

                          Any idea what is happening here?
                          Attached Files

                          Comment


                            #28
                            Originally posted by wbennettjr View Post
                            Sorry to hear that Skann .

                            I need a bit more context to diagnose. I've uploaded a new version of the script that adds an exception handler so I can get a stacktrace. Please download, run and send me the output so I can fix.

                            Thanks!
                            wbennettjr Thankyou for this script, it is a real time saver!!!

                            I'm wondering if you have a fix for the above error, I am getting it as well.

                            System.InvalidCastException: Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.QualifiedNam eSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSy ntax'.

                            Thanks!

                            Comment


                              #29
                              In the code line 556 add this

                              if (newIdentifierName.GetType() != typeof(QualifiedNameSyntax))
                              {
                              replacements.Add(identifierName, newIdentifierName);
                              }

                              then fix by hand the ChartBars.FromIndex etc which is causing the error

                              Comment


                                #30
                                Originally posted by Serialcoder View Post
                                In the code line 556 add this

                                if (newIdentifierName.GetType() != typeof(QualifiedNameSyntax))
                                {
                                replacements.Add(identifierName, newIdentifierName);
                                }

                                then fix by hand the ChartBars.FromIndex etc which is causing the error
                                This is what I have a line 556 In red....

                                private SyntaxNode UpdateMinMaxMethod(SyntaxNode node)
                                {
                                MethodDeclarationSyntax minMaxMethod = node
                                .DescendantNodes()
                                .OfType<MethodDeclarationSyntax>()
                                .FirstOrDefault(n => n.Identifier.ToString() == "OnCalculateMinMax");

                                if (minMaxMethod != null)
                                {
                                node = ReplacePropertyNames(
                                node,
                                new Dictionary<string, string>
                                {
                                { "min", "MinValue" },
                                { "max", "MaxValue" },
                                });
                                }

                                Is that the correct place?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Mongo, Today, 11:05 AM
                                4 responses
                                14 views
                                0 likes
                                Last Post Mongo
                                by Mongo
                                 
                                Started by traderqz, Today, 12:06 AM
                                7 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by Skifree, Today, 03:41 AM
                                5 responses
                                13 views
                                0 likes
                                Last Post Skifree
                                by Skifree
                                 
                                Started by traderqz, Yesterday, 09:06 AM
                                5 responses
                                35 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by guillembm, Today, 11:25 AM
                                1 response
                                6 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Working...
                                X