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 kinfxhk, 07-13-2026, 10:18 AM
        0 responses
        33 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 09:50 AM
        0 responses
        29 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 07:21 AM
        0 responses
        36 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-11-2026, 02:11 AM
        0 responses
        33 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        143 views
        0 likes
        Last Post SalmaTrader  
        Working...
        X