Keep track of both the daily and weekly candles?
I am trying to keep track of the daily and the weekly candles. I set the default candle to the daily.

I am attempting to use CandleBatcher, but when I log out the candles for both the daily and the weekly, I noticed the order is strange. For example, if I just wanted to keep track of the weekly price and price of the previous day, the daily candles sort of "get ahead" of the weekly candles and it's inconsistent.

I am sure I am just doing something wrong, but if not I am thinking of a better way to store them. Perhaps store a map of the last 30 days where: date => { dailyCandle, weeklyCandle } or something.
strat.init = function () {
 this.batcherWeekly = new CandleBatcher(7);

 this.batcherWeekly.on('candle', this.update1Week);

strat.update = function (candle) {
 console.log('D', candle);
  this.lastDailyPrice = candle.close;


strat.update1Week = function (candle) {
 console.log('W', candle);

  // if I'm on week that ends on Jan 7, it's unclear how to get the previous day Jan 6 price because it's not this.lastDailyPrice

Forum Jump:

Users browsing this thread: