Last little advice:
let cumulativeOutcome = [ TradeOutcome[0] ]
for ( i = 1; i < TradeOutcome.length; i++) {
cumulativeOutcome[i] = cumulativeOutcome[i-1] + TradeOutcome[I]
}
needs to be
let cumulativeOutcome = [ TradeOutcome[0] ]
for (let i = 1; i < TradeOutcome.length; i++) {
cumulativeOutcome[i] = cumulativeOutcome[i-1] + TradeOutcome[I]
}
the missing let
is causing issues in other scripts.