How to merge values once for loop has been indexed?

  • Thread starter Thread starter Frankdot
  • Start date Start date
F

Frankdot

Guest
Hello,

I indexed a for loop retuning multiple values. I want to create one list of the overall values but indexing of for loop prevent to do so.

Any help?

double fibos = 0;

for(int barIndex = ChartBars.GetBarIdxByX(chartControl, cursorPointX); barIndex <= blueIndex; barIndex++)
{

double closePrice = Bars.GetClose(barIndex);
double open = Bars.GetOpen(barIndex);

double co = closePrice - open;

int bco = 0;

if (co < 0)
{
bco = barIndex;



double sum21 = 0;
double sum22 = 0;
double cmaMu = 0;

//for loop is indexed to bco to create multiple bars and multiple cmaMu

for(int barIndex0 = bco; barIndex0 <= ChartBars.ToIndex; barIndex0++)
{

double closePrice0 = Bars.GetClose(barIndex0);
double volumes = Bars.GetVolume(barIndex0);

double clovol = closePrice0 * volumes;


sum21 += clovol;
sum22 += volumes;

cmaMu = sum21 / sum22;


}



//once you got the fibo values i search for highest value in the list of fibos.


fibos = ((Close.GetValueAt(CurrentBar) - lowPrice)) / (cmaMu - lowPrice);




Print(fibos);


double highPrice = Int32.MinValue;

List<double> uplist = new List<double>() {fibos};

double highFound = highPrice;

foreach (double i in uplist)

{

if (highFound < i)
{

highFound = i;

Print("HF"+highFound);
}

}


}

}
Here's what it returns. Gives the highest value for each return when i want the highest for all of them. Answer LF should return one time 1.3569

1,35691166545776
LF1,35691166545776
1,35640617698412
LF1,35640617698412
1,35600885360173
LF1,35600885360173
1,35493753331619
LF1,35493753331619
1,35449137356122
LF1,35449137356122
1,35374867728372
LF1,35374867728372
1,35202512085795
LF1,35202512085795
1,35140258312983
LF1,35140258312983
1,34999264039604
LF1,34999264039604
1,34944907240576
LF1,34944907240576

Thank you

Continue reading...
 
Back
Top