Multiple Time Frames with TALIB and Tulip
#20
There might be a more easy way of handling multiple time scales.
In one of my current strategies, i wrote below code :

SumCandles : function(candles,start,length) // from a candles array start at start, and take a length of candles to sum
{
var sum=
{start : 0,
stop : 0,
high : 0,
low : 0,
volume : 0,
trades : 0
};
sum.high= candles[start].high;
sum.low = candles[start].low;
sum.start=candles[start].open;
sum.stop = candles[start+length].close;

for(i=start;i<length;i++)
{
if(candles[i].high>sum.high)sum.high=candles[i].high;
if(candles[i].low<sum.low)sum.low=candles[i].low;
sum.volume = sum.volume+candles[i].volume;
sum.trades = sum.trades+candles[i].trades;
}
return sum;
},


for above to work you need an array of candles, so in the strategy update function one could write :

candles.push(candle);

if (candles.length > 10) { //keeps 10 candles in memorry
candles.shift();
}


I'm doing candle stick patterns at the moment, but if i remind correctly though that array should be be able to be pushed trough indicators as well.
with a little bit more coding one could create several arrays (say 5, 15, and 60 minute arrays).
  Reply


Messages In This Thread
RE: Multiple Time Frames with TALIB and Tulip - by PGTART - 09-01-2019, 08:41 PM

Forum Jump:


Users browsing this thread: