How to repeat a task multiple times without repeating the formulas?

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

Frankdot

Guest
I have this task i want to reproduce. CMA represent an average, for exemple 20. As the average is moving it increase to 21, 22, 23 etc. I would like to produce a simulation for each price of the moving average. As you can see the price is passing through a series of formulas and at the end closest return a value. It returns one value. I want to be able to test each cma returns, 21, 22, 23 separately and get to keep the returns for each cma in a list or variable. Right now if i replace cma by Price (21,22,23 etc) at the end of the code closest will return one answer for all the prices and not one return per prices or cma's. Anyone as an idea how to do that? I was thinking about switch and cases but dont know how to implement them.


Thank you


for(int barIndex = index; barIndex <= ChartBars.ToIndex; barIndex++)
{

double Price = Bars.GetClose(barIndex);

sumvolms += vols;


if(cma < highPrice && cma > lowPrice)
{
for(int myIndex = index; myIndex <= barIndex; myIndex++)
{

}



List<double> zlist = new List<double>() {sumvolms};

for(int z = 0; z < zlist.Count; z++)
{
zlist[z] = (zlist[z] /= sumvols);

//more formulas than returns end up in a list//

var list = zlist.Union(alist)
.Union(blist)
.Union(clist)
.Union(dlist)

.ToList();

//lambda search closest number from variable in list//

double minDistance = list.Min(no => Math.Abs(fibo1- no));
closest = list.First(no => Math.Abs(fibo1- no) == minDistance);


//closest should return one answer per prices or cma but return only one instead of one value per prices//

Continue reading...
 
Back
Top