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

Linq selection of drawn hlines works 95% of the time...why not 100%

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

    Linq selection of drawn hlines works 95% of the time...why not 100%

    We have an indicator that needs to select all drawn horizontal lines with the word "Support" in their tag field. We use this statement:

    var valid_hlines = DrawObjects.Where(x => x is NinjaTrader.NinjaScript.DrawingTools.HorizontalLin e && x.Tag.Contains("Support")).ToList();


    This statement returns valid results flawlessly on 95% of the NT8 platforms (and they are all running 8.0.16.3). The other 5% of the platforms, there are always zero results returned.


    ...and there are no runtime exceptions.

    What can we do to get it working on all NT8 platforms?

    #2
    Originally posted by sbgtrading View Post
    What can we do to get it working on all NT8 platforms?
    Try rearranging your statement as such...

    Code:
    [COLOR=#0000ff]var[/COLOR] [COLOR=#080808]valid_hlines[/COLOR] = [COLOR=#080808]DrawObjects[/COLOR].[COLOR=#080808]ToList[/COLOR]().[COLOR=#080808]Where[/COLOR]([COLOR=#080808]x[/COLOR] => [COLOR=#080808]x[/COLOR] [COLOR=#0000ff]is[/COLOR] [COLOR=#080808]NinjaTrader[/COLOR].[COLOR=#080808]NinjaScript[/COLOR].[COLOR=#080808]DrawingTools[/COLOR].[COLOR=#080808]HorizontalLine[/COLOR] && [COLOR=#080808]x[/COLOR].[COLOR=#080808]Tag[/COLOR].[COLOR=#080808]Contains[/COLOR]([COLOR=#b22222]"Support"[/COLOR]));

    Reason outlined in HelpGuide Here...








    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      Hello sbgtrading,

      Thank you for the post.

      Edge has a good solution in his post, thank you for that Edge. This Labeled Horizontal Lines indicator is also relevant and could serve as a good example of identifying a particular draw object, although the criteria in that indicator is the draw object must be a horizontal line.

      This indicator will read the horizontal lines that you have applied to a chart and display the price at which that line sits.


      The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

      Please let me know if this does not resolve your inquiry.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Unfortunately, this one didn't solve the issue...I had to resort to the solution referenced by NinjaTrader_ChrisL. That appears to be working for most of the users...we'll see if it holds for all of them.

        Lots of small pitfalls here in NT8...we have code that works for some, and not for others.


        Originally posted by -=Edge=- View Post

        Try rearranging your statement as such...

        Code:
        [COLOR=#0000ff]var[/COLOR] [COLOR=#080808]valid_hlines[/COLOR] = [COLOR=#080808]DrawObjects[/COLOR].[COLOR=#080808]ToList[/COLOR]().[COLOR=#080808]Where[/COLOR]([COLOR=#080808]x[/COLOR] => [COLOR=#080808]x[/COLOR] [COLOR=#0000ff]is[/COLOR] [COLOR=#080808]NinjaTrader[/COLOR].[COLOR=#080808]NinjaScript[/COLOR].[COLOR=#080808]DrawingTools[/COLOR].[COLOR=#080808]HorizontalLine[/COLOR] && [COLOR=#080808]x[/COLOR].[COLOR=#080808]Tag[/COLOR].[COLOR=#080808]Contains[/COLOR]([COLOR=#b22222]"Support"[/COLOR]));

        Reason outlined in HelpGuide Here...



        Comment


          #5
          Hello sbgtrading,

          Thanks for the follow up.

          I know you said there were no runtime exceptions when this occurs. Were you sure to check the trace files of the client? All unhandled exceptions will be written there. The files can be found under ..\Documents\NinjaTrader 8\trace

          Since you are accessing the DrawObjects connection in the way the help guide does, it could be a special problem with looking for the "Support" string. Possibly other drawing tools have "Support" in the name with some clients.

          I look forward to your reply.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Thanks for the suggestions Chris...but no help. There aren't any exceptions in the trace file...and the problem manifests itself even if the Tag isn't selected on.

            Also, I tested the authorized code you suggested (the "Labeled Horizontal Lines" indicator), and the problem continues to manifested itself there as well. So again, the majority of computers run it without an issue, but 5% (approx.) are having no success at all.

            Comment


              #7
              Hello sbgtrading,

              Thanks for the reply.

              This seems to be a specific environment issue with the small number of users seeing this problem. In the past have seen a completely non-related third party assembly effect the properties of another third party script. If one of the clients could write an email to platformsupport[at]ninjatrader[dot]com and reference the link to this forum thread in the body, I could possibly call that client and look at their system through TeamViewer to find the problem.

              I look forward to assisting further.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hey...good news! I found out the problem! Encryption! Your indicator ("Labeled Horizontal Lines") only works as an opensource file...if you encrypt it, and import the encrypted version, it no longer works (does not find horizontal lines).

                The encryption I used is from the NT8 export method...I did not use any form of secure encryption.

                You can certainly try this yourself...or, you can use the zips I have here.

                So we're onto something! Let me know what you find
                Attached Files

                Comment


                  #9
                  Hello sbgtrading,

                  Thank you for catching that. I did not think that you are likely compiling this script into a .dll. Please read the page below.



                  You must cast the object as a Dynamic type to clear the ambiguity between your DLL and the NinjaTrader.Custom.dll.

                  Please let me know if this does not resolve your inquiry.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks for that info...lots of tricks!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by benmarkal, Yesterday, 12:52 PM
                    3 responses
                    23 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    19 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    11 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    244 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Working...
                    X