I need to collect a sufficient amount of historical data at the start of a custom indicator — typically between 600 and 1000 bars — using 1-minute, 5-minute, or 15-minute timeframes. I’m working on Tradovate with a basic Apex account, which should allow access to at least 1–2 months of historical data.
However, I’ve noticed that at indicator startup, I can retrieve only around 300 bars for symbols like ES, CL, and GC, while for 6E I receive up to approximately 1000 bars.
Where are these limits defined?
Is there a way to increase the amount of historical data retrieved at initialization?
I need this historical base because I apply a frequency transform over the last M closing prices.
Below is a fragment of my map()
code:
map(bar, index, history) {
const close = bar.close();
const timestamp = bar.timestamp();
// Inizializzazione
if (this.initialized === undefined) {
this.bars = [];
this.hasProcessed = false;
this.initialized = false;
this.lastLiveTime = null;
this.lastHistoricalComplete = null;
this.estimatedTF = null;
}
// Gestione delle barre incomplete
if (!bar.isComplete()) {
this.lastLiveTime = timestamp;
console.log(`🚀 [${index}] Trovata barra incompleta (live): ${new Date(timestamp).toISOString()}`);
console.log(`⛔ [${index}] Barra incompleta scartata (${new Date(timestamp).toISOString()})`);
return null;
}
// Stima del timeframe
if (!this.estimatedTF && history && history.prior()) {
const priorTimestamp = history.prior().timestamp();
this.estimatedTF = timestamp - priorTimestamp;
console.log(`🕒 TimeFrame stimato: ${this.estimatedTF / 60000} minuti`);
}
// Salvataggio della barra storica
this.bars.push({ close, date: timestamp });
console.log(`📌 [${index}] Barra storica: close=${close.toFixed(4)}, time=${new Date(timestamp).toISOString()}`);
// Verifica se abbiamo raggiunto la barra storica immediatamente precedente alla prima barra live
if (this.lastLiveTime && this.estimatedTF) {
const expectedLastHistoricalTime = new Date(this.firstLiveTime.getTime() - this.estimatedTF);
if (timestamp.getTime() === expectedLastHistoricalTime.getTime() && this.bars.length >= 600) {
this.initialized = true;
console.log(`✅ [${index}] Raggiunta ultima barra storica: ${new Date(timestamp).toISOString()}`);
}
}
// Se non ancora inizializzato o già elaborato, non fare nulla
if (!this.initialized || this.hasProcessed) return null;
// Elaborazione dei dati
const required = this.maxPeriod * this.periodMultiplier;
const windowBars = this.bars.slice(-required);
const slice = windowBars.map(b => b.close);
console.log(`✅ [${index}] Slice estratta: ${slice.length} elementi`);
console.log(` ↪︎ Inizio: ${slice.slice(0, 3).map(v => v.toFixed(2))}`);
console.log(` ↪︎ Fine: ${slice.slice(-3).map(v => v.toFixed(2))}`);
let detrended = this.hpFilter(slice);
if (!detrended.length) return null;
detrended = this.minMaxScale(detrended);
const windowed = this.kaiserWindow(detrended);
const periods = [];
for (let p = this.minPeriod; p <= this.maxPeriod; p += this.periodStep) {
periods.push(p);
}
const transformed = this.goertzelTransform(windowed, periods);
const dominant = this.selectDominantCycles(transformed);
const best = this.optimizeCycles(dominant, windowed);
const composite = this.extendSignal(dominant, best, windowed.length);
const relIndex = windowed.length - 1 + windowed.length;
this.hasProcessed = true;
console.log(`🚩 [${index}] CDC=${composite[relIndex].toFixed(3)} Detrended=${detrended[windowed.length - 1].toFixed(3)}`);
return {
CDC: composite[relIndex],
Detrended: detrended[windowed.length - 1]
};
}