Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I identify "First bar of day"

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

    #31
    double to int convertion

    Appreciate help in this:

    I´m trying to input an incrementing value into the SUM method that counts when [
    VolratioDS[0]>Threshold], and then resets. I need to use a dataseries value as input (I asume). But since these are doubles and the method expects an int input, I get stuck.

    When I try to pass the dataseries value (CountDS) to an int variable (count) I once again get stuck cos I "cannot convert double to int".

    Is there way to make the SUM method accept the double input, to make the dataseries an int, or to convert the dataseries double to a variable int? Any other solution?


    if (VolratioDS[0]>Threshold)
    {
    if (Crossover == false)
    {
    CountDS.Set(1);
    count = CountDS[0];
    CumvolDS.Set(SUM(VoldiffDS, count)[0]);
    Crossover = true;
    if (CumvolDS[0]>0)
    {
    Plotpos.Set(CumvolDS[0]);
    }
    else
    {
    Plotneg.Set(CumvolDS[0]);
    }
    }
    else
    {
    CountDS.Set(CountDS[0]+1);
    count = CountDS[0];
    CumvolDS.Set(SUM(VoldiffDS, count)[0]);

    if (CumvolDS[0]>0)
    {
    Plotpos.Set(CumvolDS[0]);
    }
    else
    {
    Plotneg.Set(CumvolDS[0]);
    }
    }
    }
    else
    {
    Crossover = false;
    count = 0;
    CountDS.Set(0);
    Plotpos.Set(0);
    Plotneg.Set(0);
    }



    //Fredrik

    Comment


      #32
      Lots of answeres on this if I wasn´t so lazy to ask first : ). However, I doubt I did this the most efficient way;

      CountDS.Set(CountDS[0]+1);
      countd = CountDS[0];
      counti = System.Convert.ToInt32(countd);
      CumvolDS.Set(SUM(VoldiffDS, counti)[0]);
      if (CumvolDS[0]>0)

      Comment


        #33
        FREEN, you should also be able to cast it to an int -

        Code:
         
        CumvolDS.Set(SUM(VoldiffDS, (int)countd)[0]);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        182 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        334 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        259 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        358 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        188 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X