Hello I need help. My programm says allways
Executing strategy
C:\Users\24118\Dropbox\1 IVAN Academy\Java Script\Atom\Ivan trading bot\index.js:13
indicators.hourlyMovingAverage(âBTCâ,âUSDâ,100,function(ma){
^
TypeError: indicators.hourlyMovingAverage is not a function
at strategy (C:\Users\24118\Dropbox\1 IVAN Academy\Java Script\Atom\Ivan trading bot\index.js:13:14)
at Object. (C:\Users\24118\Dropbox\1 IVAN Academy\Java Script\Atom\Ivan trading bot\index.js:19:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensionsâŚjs (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
but I dont found the mistake in code:
here is indicators.js
const CCAPIKey = â551639c4572f4d251d15d92936f3bbbe713c93dbd567681849ded2cfbcabb498â
const CryptoCompareAPI = require(âcryptocompareâ);
CryptoCompareAPI.setApiKey(CCAPIKey);
module.export = {
hourlyMovingAverage:function(cryptoAsset,fiatCurrency,hours,callback){
if(hours>169){
console.error("Only 169 allowed!")
return
}
// 1 get data from CC
CryptoCompareAPI.histoHour(cryptoAsset, fiatCurrency)
.then(data => {
// 2 caculate MA from 100 past hours
data = data.reverse()
var sum = 0;
for(var i = 0;i<hours;i++){
sum+=data[i].close;
}
var movingAverage = Math.floor(sum/hours);
callback(movingAverage);
})
.catch(console.error)
}
}
and here the index.js:
global.fetch = require(ânode-fetchâ);
const indicators = require("./indicators.js");
const exchange = require("./exchange.js")
var strategy = function(){
// IF BTC < MA ==> buy (if we have no position)
// IF BTC > MA ==> sell (if we have a position)
console.log(âExecuting strategyâ);
indicators.hourlyMovingAverage(âBTCâ,âUSDâ,100,function(ma){
console.log("MA: ", ma);
setTimeout(strategy,1000);
})
}
strategy();
Why ist says:
TypeError: indicators.hourlyMovingAverage is not a function
thanks for the help.