Не понятно, почему не переменная не определена?
День потрачен, а решение не найдено. Все правильно по сути а ошибка есть (В 3 сконца строки)... result_01[i].High неопределен пишет. Вообще без понятия почему так...
Структура вот такая:
class OHLCTime {
constructor() {
this.Open = null;
this.High = null;
this.Low = null;
this.Close = null;
this.Time = null;
}
}
Фрагмент кода:
let first = [];
let firstIndex = 0;
let second = [];
let secondIndex = 0;
let count = 0;
let temp = "";
for (let i = 0; i < firstHistory.length; ++i) {
if(firstHistory[i] != ";"){
temp += firstHistory[i];
}
else{
if(count == 0){
first[firstIndex] = new OHLCTime();
first[firstIndex].Open = temp;
temp = "";
}
else if(count == 1){
first[firstIndex].High = temp;
temp = "";
}
else if(count == 2){
first[firstIndex].Low = temp;
temp = "";
}
else if(count == 3){
first[firstIndex].Close = temp;
temp = "";
}
else{ // == 4
first[firstIndex].Time = temp;
temp = "";
firstIndex++;
}
count = (count == 4) ? 0 : count+1;
}
}
count = 0;
for (let i = 0; i < secondHistory.length; ++i) {
if(secondHistory[i] != ";"){
temp += secondHistory[i];
}
else{
if(count == 0){
second[secondIndex] = new OHLCTime();
second[secondIndex].Open = temp;
temp = "";
}
else if(count == 1){
second[secondIndex].High = temp;
temp = "";
}
else if(count == 2){
second[secondIndex].Low = temp;
temp = "";
}
else if(count == 3){
second[secondIndex].Close = temp;
temp = "";
}
else{ // == 4
second[secondIndex].Time = temp;
temp = "";
secondIndex++
}
count = (count == 4) ? 0 : count+1;
}
}
// ПРИВЕДЕНИЕ ГРАФИКОВ К "ОБЩЕМУ ЗНАМЕНАТЕЛЮ":
let result_01 = [];
let dualSize = 0;
let result_02 = [];
if(firstIndex <= secondIndex){
for(let i=0; i < firstIndex; ++i){
for(let j=0; j < secondIndex; ++j){
if(first[i].Time == second[j].Time){
result_01[dualSize] = first[i];
result_02[dualSize++] = second[j];
break;
}
}
}
}
else{
for(let i=0; i < secondIndex; ++i){
for(let j=0; j < firstIndex; ++j){
if(second[i].Time == first[j].Time){
result_01[dualSize] = first[i];
result_02[dualSize++] = second[j];
break;
}
}
}
}
// ----------------- ВРЕМЕННЫЙ ПРОВЕРОЧНЫЙ БЛОК:
console.log("length = " + dualSize);
// ---------------------------------------------
// ОПРЕДЕЛЕНИЕ ВОЛАТИЛЬНОСТИ:
// Определяем сумму разниц H-L 1ого и 2ого инструмента:
let firstArifmetic = 0; // Сумма разниц.
let secondArifmetic = 0; // Сумма разниц.
bars = (bars < dualSize) ? bars : dualSize;
for (let i = dualSize-1; i > (dualSize-bars); --i) {
firstArifmetic += result_01[i].High - result_01[i].Low; // Почему то result_01[i].High не определен...
secondArifmetic += result_02[i].High - result_02[i].Low;
}