Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error with custom indicator

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

    #16
    I am having the same error happen because I'm using TickSize in the Intialize method. But TickSize was not faked to 0.01 before -- it actually worked fine. Here is the code in question that causes the error:

    Code:
                 double temp = TickSize - (int)TickSize;                // get fractional part of TickSize
                string a = temp.ToString();                         // make it into a string
                if (a.IndexOf(".") > 0) decimals = (a.Length - 2);    // get the number of characters in the string minus the leading 0 and the decimal point
                if (a.IndexOf("E") > 0) decimals = Convert.ToInt16(a.Substring(3));    // If scientific notation, then extract the number of decimal places, e.g. 1E-06
    Do I need to move this code into the OnBarUpdate() method now? I suppose I could do that just when CurrentBar = 0, but I like it in Initialize() better.

    Bryan

    Comment


      #17
      Thanks for your help - got it working now.

      Comment


        #18
        Originally posted by cassb View Post
        I am having the same error happen because I'm using TickSize in the Intialize method. But TickSize was not faked to 0.01 before -- it actually worked fine. Here is the code in question that causes the error:

        Code:
                     double temp = TickSize - (int)TickSize;                // get fractional part of TickSize
                    string a = temp.ToString();                         // make it into a string
                    if (a.IndexOf(".") > 0) decimals = (a.Length - 2);    // get the number of characters in the string minus the leading 0 and the decimal point
                    if (a.IndexOf("E") > 0) decimals = Convert.ToInt16(a.Substring(3));    // If scientific notation, then extract the number of decimal places, e.g. 1E-06
        Do I need to move this code into the OnBarUpdate() method now? I suppose I could do that just when CurrentBar = 0, but I like it in Initialize() better.

        Bryan
        Moving to OnBarUdpate() is probably the safest option since you are guaranteed to have TickSize value then.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        626 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        359 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        562 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        567 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X