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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        83 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        45 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        65 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        68 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        57 views
        0 likes
        Last Post CarlTrading  
        Working...
        X