Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

adding comma between numbers from barIndex

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

    adding comma between numbers from barIndex

    Hello,

    Is it possible to add commas between numbers from method of a for loop.

    Code:
    for(int barIndex = foundIndex; barIndex <= ChartBars.ToIndex; barIndex++)
    {
    closePrice = Bars.GetClose(barIndex);
    }
    I want all closePrice to appear seperated by commas in output window. Any pointers?

    Thank you

    #2
    Hello frankduc, thanks for your question.

    You would need to keep a List<String> and add the closePrice and comma to that string.

    e.g.
    Code:
    int x = 1;
    
    List<string> mylist = new List<string>();
    
    string tempString = x.ToString();
    
    tempString += ",";
    
    mylist.Add(tempString);
    Please let me know if I can assist any further.

    Comment


      #3
      Chris,

      Code:
       int po = 1;
      
      List<string> mylist = new List<string>() {closePricel};
      
      string tempString = po.ToString();
      
      tempString += ",";
      
      mylist.Add(tempString);
      
      Print("mylist" +mylist);
      It return impossible to convert double to string.

      But my goal is to apply a lambda to closePrice.

      Code:
      double CW = mylist.Aggregate((x, y) => Math.Abs(x - 2800) < Math.Abs(y - 2800) ? x : y);
      It will find the closest price from 2800.

      Code:
      List<double> mylist = new List<double>() {closePrice};
      The problem if i list a variable i thought it would search in all the price in the list. But instead it returns the last double value in the list.
      Will add commas to the list will solve the problem?

      Thank you

      Comment


        #4
        Hi frankduc, thanks for your reply.

        Unfortunately, I can not provide support for common C# or LINQ commands. I rarely use them, and better information can be found on the internet elsewhere on these subjects.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        68 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        151 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X