Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting Int to Double

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

    Converting Int to Double

    Hi there

    Just wondering why the following does not complile?

    I attempt to convert the Integer, "barsAgo", into a double, in order that i can create a fraction from it, which is then rounded up.

    double holder=0;
    for (int barsAgo = 1; barsAgo <= 10; barsAgo++)

    { holder=barsAgo;
    if (Low[Math.Round(holder/5,0)] < low_price || low_price == 0)
    {low_price= Low[Math.Round(holder/5,0)] ;}
    }

    Any pointers greatly appreciated...

    Tks
    Ben Heaton

    #2
    Math.Round(holder/5,0) return a double which you need to cast to an int like "(int) Math.Round(holder/5,0)".

    Also: clicking on the error message on the error window always brings you to the erroneous code line and provides you an idea what's going wrong.

    Comment


      #3
      Excellent - Tks for that - BH

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      55 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      30 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      40 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      47 views
      0 likes
      Last Post CarlTrading  
      Working...
      X