data fixes, partial custom indicator support
This commit is contained in:
@@ -367,6 +367,22 @@ export function useTradingViewIndicators(tvWidget: IChartingLibraryWidget) {
|
||||
}
|
||||
isChartReady = true
|
||||
|
||||
// Apply any indicators that arrived before chart was ready (e.g. from workspace sync on page load)
|
||||
const pendingIndicators = Object.values(indicatorStore.indicators).filter(ind => !ind.tv_study_id)
|
||||
if (pendingIndicators.length > 0) {
|
||||
console.log('[Indicators] Chart ready, applying', pendingIndicators.length, 'pending indicators from store')
|
||||
isApplyingTVUpdate = true
|
||||
;(async () => {
|
||||
try {
|
||||
for (const indicator of pendingIndicators) {
|
||||
await createTVStudy(indicator)
|
||||
}
|
||||
} finally {
|
||||
isApplyingTVUpdate = false
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
console.log('[Indicators] Setting up indicator event subscriptions')
|
||||
console.log('[Indicators] Chart ready, widget:', tvWidget)
|
||||
|
||||
@@ -781,6 +797,10 @@ export function useTradingViewIndicators(tvWidget: IChartingLibraryWidget) {
|
||||
async function createTVStudy(indicator: IndicatorInstance) {
|
||||
if (!isChartReady) return
|
||||
|
||||
// Custom indicators (pandas_ta_name starts with "custom_") are handled by
|
||||
// useCustomIndicators — they use TV createCustomStudy, not createStudy.
|
||||
if (indicator.pandas_ta_name.startsWith('custom_')) return
|
||||
|
||||
try {
|
||||
const chart = tvWidget.activeChart()
|
||||
if (!chart) return
|
||||
|
||||
Reference in New Issue
Block a user