• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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, 10: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)
      
      {
      Print ("MyKitKatBarsType run time error:"); Print (E.ToString());
      }
      Last edited by Ricam; 04-12-2016, 12: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 jcbnoles, Today, 12:18 PM
        0 responses
        1 view
        0 likes
        Last Post jcbnoles  
        Started by stafe, Today, 11:57 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by tvaughan4, Today, 11:01 AM
        3 responses
        9 views
        0 likes
        Last Post tvaughan4  
        Started by Branpo, Today, 10:51 AM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by fourpeaks99, Today, 10:51 AM
        2 responses
        7 views
        0 likes
        Last Post fourpeaks99  
        Working...
        X