Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Requests: Bartype error handlers, Example of iterating through Draw objects

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

    Requests: Bartype error handlers, Example of iterating through Draw objects

    1. For NT8 would appreciate sample of a For/Next loop to iterate through the collections of Lines, Horizontal Lines, Texts, etc placed on a chart by user Draw() methods and retrieving some of their key properties. I have done this in NT7, will NT8 be different?
    2. If adding, to a custom BARSTYPE, try / catch error handlers that print the error text, System.Text must be added to the using declarations since it includes the ToString method. What OTHER libraries need to be added to ensure that error handling will work, that the Exception object can be created, etc?



    Thanks in advance.
    Last edited by Ricam; 04-12-2016, 11:34 AM.

    #2
    Hello Ricam,

    The help guide outlines how to loop through the DrawObject collection. See the code block labelled 'Looping through the collection to find specific draw objects'.
    https://ninjatrader.com/support/help...rawobjects.htm

    Are you finding the example on this page is insufficient information for looping through drawing objects on the chart?

    To print to the output window in an Addon use:
    Output.Process("string to print", PrintTo.OutputTab1);
    https://ninjatrader.com/support/help...g_concepts.htm

    To print from a BarsType file, call Print() with the supplied string.

    From my understanding, the string variable type is available without any using statements.
    However, .ToString() will be a method of whatever type you are trying to send to a string.
    For example, using an IOrder with .ToString() calls an override in the IOrder class that creates a string for you based on the members of the IOrder class for that object.
    Double.ToString() has a method in it that turns a double to a string.

    There will not be a single using statement that allows you to use .ToString() on any variable type. The variable type will already need to have .ToString() implemented.

    Attached is an example bar
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the link to the Help topic about the Draw Objects.

      Regarding bartypes I want to make sure that the following type of error handling code will not cause any problems in OnDataPoint of MyKitKatBars... such as errors pertaining to Display Class 421.

      Code:
      try{
      
      ... bar logic ..
      
      }catch(Exception E)
      [INDENT]{ [INDENT]Print ("MyKitKatBarsType run time error:");
        Print (E.ToString());[/INDENT]
      }[/INDENT]
      Last edited by Ricam; 04-12-2016, 01:27 PM.

      Comment


        #4
        Hello Ricam,

        Using try and catches are up to you to decide to use and will not prevent the script from functioning.

        When a try and catch is used, no error message will be generated by NinjaTrader in the log. You would have to add this to the log yourself. Should something happen in the script that causes it to fail, it may be harder to track down for an end user and support.

        So use your discretion with these.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Aviram Y, Today, 05:29 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by TradeForge, Today, 02:09 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by elirion, Today, 01:36 AM
        2 responses
        14 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by DJ888, 04-16-2024, 06:09 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X