How to use Next values inside a loop

 

hi,

i want to access next values inside a loop. As an example

i = 100, 90, 80, 70, 60, 50, 40

for(int j=i; j>=i; --j)
            {

}


inside this for loop i want to use,

  • get 100 and 90
  • get 100 and 80
  • get 100 and 70
  • get 100 and 60
  • get 100 and 50
  • get 100 and 40 etc....

Next i want to use it like this,

  • get 90 and 80
  • get 90 and 70
  • get 90 and 60
  • get 90 and 50
  • get 90 and 40 etc....

next

  • get 80 and 70
  • get 80 and 60
  • get 80 and 50
  • get 80 and 40 etc....

continue this loop until last one.

you can see i am trying to use every numbers in the  list(i) with next lowest or available value.

anyone know how to do this?

Thank you.

 
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//Chart width
   int X_1 = (int)ChartGetInteger(0, CHART_VISIBLE_BARS);
   int X_0 = 0;

   for(int i=X_1; i>=X_0; --i)
   {
      if(daySeparate)
      {
         if(TimeHour(Time[i]) == 0.00) //In here it filter my number list like i sad (100, 90, 80, 70, 60, 50, 40 etc..)
         {
            for(int j=i; j>=i; --j) // next i am going to use that number list
            {
            }
         }
     }
  }
 }


This is my code. I hope it filtering numbers one by one. first 100, second 90 etc. In my case i hope it need like array[]. may i correct?

 
Thushara Dissanayake: i want to access next values inside a loop. As an example

i = 100, 90, 80, 70, 60, 50, 40

inside this for loop i want to use,

  • get 100 and 90
  • get 100 and 80 etc....

Next i want to use it like this,

  • get 90 and 80
anyone know how to do this?
When in doubt, think.
for(int i=100; i > 0; i -= 10)
   for(int j=i - 10; j > 0; j -= 10)
      PrintFormat("i=%i, j=%i", i,j);
Was that so hard?
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=90
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=80
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=70
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=60
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=50
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=40
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=30
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=20
0    11:15:00.882    testscr AUDCAD,M1: i=100, j=10
0    11:15:00.882    testscr AUDCAD,M1: i=90, j=80
:
0    11:15:00.882    testscr AUDCAD,M1: i=40, j=10
0    11:15:00.882    testscr AUDCAD,M1: i=30, j=20
0    11:15:00.882    testscr AUDCAD,M1: i=30, j=10
0    11:15:00.882    testscr AUDCAD,M1: i=20, j=10
 

Thank you for your answer. But the number distance(10) is not a static one like 100, 90, 80 etc...

Actually it generate randomly.

  • 105, 91, 87, 50, 44, 37 etc 

any idea?

 
When in doubt, think. You haven't stated a problem. Show us your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
Reason: