Here is the loop only without the List which prints the results all right
double sum = 0;
double mean = 0;
double ratio = 0;
double sum1 = 0;
double mean1 = 0;
double ratio1 = 0;
for (int index = 0; index < 10; index++)
{
sum += (Math.Abs(Crude.MasterInstrument.RoundToTickSize(Closes[1][index] - SMA(BarsArray[1], 20)[index])) / Crude.MasterInstrument.TickSize);
sum1 += (Math.Abs(YEN.MasterInstrument.RoundToTickSize(Closes[2][index] - SMA(BarsArray[2], 20)[index])) / YEN.MasterInstrument.TickSize);
}
mean = sum / 10;
ratio = (Math.Abs(Crude.MasterInstrument.RoundToTickSize(CrudeSeries[0] - SMA(BarsArray[1], 20)[0])) / Crude.MasterInstrument.TickSize) / mean;
Print("ratio : " + ratio);
mean1 = sum1 / 10;
ratio1 = (Math.Abs(YEN.MasterInstrument.RoundToTickSize(YENSeries[0] - SMA(BarsArray[2], 20)[0])) / YEN.MasterInstrument.TickSize) / mean;
Print("ratio1 : " + ratio1);
With successful prints the ratio and ratio1 values
ratio1 : 2.43243243243243
Here's my list added to the loop (outside after the loop)
double sum = 0;
double mean = 0;
double ratio = 0;
double sum1 = 0;
double mean1 = 0;
double ratio1 = 0;
for (int index = 0; index < 10; index++)
{
sum += (Math.Abs(Crude.MasterInstrument.RoundToTickSize(Closes[1][index] - SMA(BarsArray[1], 20)[index])) / Crude.MasterInstrument.TickSize);
sum1 += (Math.Abs(YEN.MasterInstrument.RoundToTickSize(Closes[2][index] - SMA(BarsArray[2], 20)[index])) / YEN.MasterInstrument.TickSize);
}
mean = sum / 10;
ratio = (Math.Abs(Crude.MasterInstrument.RoundToTickSize(CrudeSeries[0] - SMA(BarsArray[1], 20)[0])) / Crude.MasterInstrument.TickSize) / mean;
Print("ratio : " + ratio);
mean1 = sum1 / 10;
ratio1 = (Math.Abs(YEN.MasterInstrument.RoundToTickSize(YENSeries[0] - SMA(BarsArray[2], 20)[0])) / YEN.MasterInstrument.TickSize) / mean;
Print("ratio1 : " + ratio1);
List<string> resultsToList = new List<string> {
ratio.ToString(),
ratio1.ToString(),
};
Which does print the ratio and ratio1 values, but then it also throws this Input string was not in a correct format error
ratio1 : 0.615384615384615
Indicator 'Testa': Error on calling 'OnBarUpdate' method on bar 5262: Input string was not in a correct format.
What does it mean "Input string was not in a correct format?" How to check for the format? Isn't ratio.ToString() and ratio1.ToString() the correct format (i.e. from double to string)?
How can I fix it? Thanks!
A new related issue to my previous one
NinjaTrader_ChelseaB
Comment