Skip to main content

Configuration

Exports​

NameKindDescription
WidgetIccandleComponentScanner overlay (host owns the results iframe)
WidgetIccandlePropsTypeProps for WidgetIccandle
WidgetChartMaskColorsType{ light?: string; dark?: string } for chartMaskColors
WidgetLanguageTypeSupported locale codes
withPlayChartFunctionWraps a TradingView datafeed (or factory) for replay bar injection
getCustomIndicatorsFunctionReturns iC Candle custom indicators (generated candles)
GeneratedCandlesThemeType"light" | "dark" for getCustomIndicators
handleResultIframeLoadFunctionPosts parent-origin / payment-success to the results iframe on load
useICCandleAuthComposableHost-side session: { isAuthenticated, idToken } from iccandle_token
ICCandleAuthTypeReturn type of useICCandleAuth
WIDGET_RESULT_URLConst"https://embed-iccandle-app.iccandle.ai"
OPEN_PRICING_MESSAGE_TYPEConst"open-pricing" postMessage type
postOpenPricingToEmbedFunctionAsk the results iframe to open pricing. Returns false if no contentWindow.
postOpenPricingToParentFunctionForward pricing to window.parent when this widget is itself embedded.
postOpenPricingToWindowFunctionPost an open-pricing message to an arbitrary Window.
OpenPricingMessageType{ type, theme?, language? }

WidgetIccandle props​

PropTypeRequiredDescription
chartWidgetIChartingLibraryWidget | nullYesLive TradingView widget (null until ready). Template: :chart-widget.
submitCallback(iframeSrc: string) => voidYesCalled when a scan, news navigation, or pricing fallback should update the results iframe. Set your iframe src to this URL (optionally append header=false). Template: :submit-callback.
theme"light" | "dark" | "system"NoScanner chrome + iframe theme. "system" follows prefers-color-scheme. Defaults to the portal default_theme when apiKey is set, otherwise "light".
chartMaskColorsWidgetChartMaskColorsNoPer-theme color that hides unrevealed predicted candles. Must match the chart pane background. Defaults: { light: "#ffffff", dark: "#0F0F0F" }. Template: :chart-mask-colors.
apiKeystringNoPublishable Plugin Portal key (pk_live_…). Loads the client's portal style and forwards &apiKey= to the results iframe. See apiKey (Plugin Portal style). Template: api-key / :api-key.
languageWidgetLanguageNoUI + iframe locale. One of: en, zh, vi, th, ko, ja, mn, ru. Defaults to en.
onCloseResult() => voidNoCalled when the embed posts selector.closeResult. Template: :on-close-result (prop callback, not an emit).
iframeLoadedbooleanNoWhen false, disables scan / track actions until the results iframe is ready. Defaults to true. Template: :iframe-loaded.
resultIframeRef{ current: HTMLIFrameElement | null } | nullNoResults iframe box (not a Vue ref). Receives open-pricing and chart-resolution postMessages. Template: :result-iframe-ref.
isShowScanButtonbooleanNoShow Scan inside the popup. Defaults to true. Template: :is-show-scan-button.
isShowTrackerButtonbooleanNoShow Pattern Tracker inside the popup. Defaults to true. Template: :is-show-tracker-button.
isShowScannerPopupbooleanNoShow the scanner popup. Defaults to true. Template: :is-show-scanner-popup.
availableIntervalsstring[]NoResolutions allowed when drawing a pattern date range from embed selection. Template: :available-intervals.
onScanClick() => voidNoFired when the user clicks Scan, before login / config / scan logic. Template: :on-scan-click.

Default slot: place your chart UI as the child of WidgetIccandle. The slot also receives { chartRefs } (highlight bars + generated-candles study ids). The same chartRefs object is exposed via the component instance.

IChartingLibraryWidget must be imported from your Charting Library typings — this package does not re-export TradingView types.

submitCallback​

Required. The host owns the results iframe. When the user runs a scan, opens similar events from a news mark, or (if no iframe ref / parent) requests pricing, WidgetIccandle builds a full embed URL and passes it to submitCallback. Update your iframe src with that value.

Typical URLs look like:

https://embed-iccandle-app.iccandle.ai/{locale}?symbol=…&res=…&ref_res=…&cid=…&tk=…&from=…&to=…&theme=light
https://embed-iccandle-app.iccandle.ai/{locale}/news/similar-events/{id}?symbol=…&theme=light
https://embed-iccandle-app.iccandle.ai/{locale}?pricing=true&theme=light

Optional scan filters may also be appended: fs (symbol filter), period, model (light / standard / plus / pro), temp (0.5 / 1 / 1.5). When apiKey is set, &apiKey= is appended on the same URLs.

<script setup lang="ts">
import { ref, watch } from "vue";
import {
WidgetIccandle,
handleResultIframeLoad,
WIDGET_RESULT_URL,
} from "@iccandle/vuejs-widget";

const iframeSrc = ref(`${WIDGET_RESULT_URL}/en?theme=light&header=false`);
const iframeLoaded = ref(false);
const resultIframeRef = ref<HTMLIFrameElement | null>(null);
const resultIframeBox = { current: null as HTMLIFrameElement | null };

watch(
resultIframeRef,
(el) => {
resultIframeBox.current = el;
},
{ immediate: true },
);

const submitCallback = (nextSrc: string) => {
const url = new URL(nextSrc);
url.searchParams.set("header", "false");
const next = url.toString();
if (iframeSrc.value !== next) {
iframeSrc.value = next;
}
};

const handleIframeLoad = () => {
iframeLoaded.value = true;
handleResultIframeLoad(resultIframeRef.value);
};
</script>

<template>
<WidgetIccandle
:chart-widget="chartWidget"
:submit-callback="submitCallback"
theme="light"
language="en"
:iframe-loaded="iframeLoaded"
:result-iframe-ref="resultIframeBox"
>
<!-- chart -->
</WidgetIccandle>
<iframe
ref="resultIframeRef"
:src="iframeSrc"
title="iC Candle results"
@load="handleIframeLoad"
/>
</template>

result-iframe-ref is a mutable { current } box, not a Vue ref. Sync it from the iframe element as shown above.

header=false​

Append header=false on the embed URL (initial src and inside submitCallback) to hide the embed app header when your host already provides navigation. Footer and in-page UI still render; nav.click messages from header tabs will not fire.

Scanner-built URLs include scan params and theme but do not add header=false automatically — set it in the host when needed.

See Search params → header for full embed query-param details.

handleResultIframeLoad(iframe)​

Call this from your results iframe @load handler. It posts the host origin to the embed (for Stripe return and so auth.signIn is addressed to the correct host) and, when the parent URL has ?payment=success, posts payment-success so the embed refreshes subscription state.

parent-origin is retried at 0 / 300 / 1000 / 2500 ms because the embed has no message buffering — its listener must be mounted before the message arrives.

import { handleResultIframeLoad } from "@iccandle/vuejs-widget";

handleResultIframeLoad(resultIframeRef.value);

useICCandleAuth()​

Host-side view of whether the results iframe is already signed in. Reads iccandle_token, rejects JWTs within 60 seconds of exp, and updates on auth.signIn / auth.signOut.

import { useICCandleAuth } from "@iccandle/vuejs-widget";

const { isAuthenticated, idToken } = useICCandleAuth();
FieldTypeDescription
isAuthenticatedRef<boolean>true when iccandle_token is present and unexpired
idTokenRef<string | null>Live identity token, or null when signed out

For corporate partners: watch isAuthenticated first, then call get-user-token only when it is false. See Seamless auth example.

withPlayChart(datafeed)​

Required for chart replay / predict. Wraps your TradingView datafeed’s subscribeBars so the widget can:

  1. Inject replay bars into the live tick stream when the embed posts chart.play, chart.stop, or replay payloads.
  2. Block live ticks while playback is active, so real-time updates do not overwrite predicted candles.

Signature​

withPlayChart(datafeed: IBasicDataFeed): IBasicDataFeed
ArgumentTypeDescription
datafeedIBasicDataFeedReady datafeed instance (must expose onReady).
factory, ...argsfunction overloadOptional: pass a factory plus args; withPlayChart invokes it and wraps the result.

Usage​

import { withPlayChart } from "@iccandle/vuejs-widget";

datafeed: withPlayChart(myDatafeed),
// or: withPlayChart(createDatafeed, arg1, arg2)

Notes​

  • The returned object is still a normal datafeed; only subscribeBars is wrapped. Other methods such as optional getTimescaleMarks are left unchanged.
  • Pair with getCustomIndicators — without both, replay / predict overlays will not work.

getCustomIndicators(theme?)​

Registers iC Candle’s custom studies used to draw generated / predicted candles on top of the main series. Returns a Promise of TradingView CustomIndicator[] for custom_indicators_getter.

Signature​

getCustomIndicators(theme?: "light" | "dark"): Promise<readonly CustomIndicator[]>
ArgumentTypeDefaultDescription
theme"light" | "dark""light"Pane mask color so predicted bars hide the underlying series. Must match the chart theme.

Studies returned​

Study nameRole
Generated Candles Background - By iC CandleHidden mask layer that paints over real bars at predicted timestamps.
Generated Candles - By iC CandleVisible OHLC overlay (bullish #00dfb9 / bearish #ffb84d) for predicted candles.

WidgetIccandle creates and drives these studies when the embed sends replay / predict data.

Usage​

import { getCustomIndicators } from "@iccandle/vuejs-widget";

const options: ChartingLibraryWidgetOptions = {
// ...
datafeed: withPlayChart(yourDatafeed),
custom_indicators_getter: () => getCustomIndicators("light"),
};

Keep getCustomIndicators(theme) in sync with the chart widget theme (and preferably with WidgetIccandle’s theme prop). After the studies are created, WidgetIccandle overrides the background-study color from chartMaskColors so unrevealed predicted bars match the pane.

Together with withPlayChart​

HelperJob
withPlayChartLets the widget push bars into the datafeed and mute live ticks during playback.
getCustomIndicatorsDraws the predicted candle visuals (mask + colored OHLC) as custom studies.

Both are required for replay / predict from the results iframe.

chartMaskColors​

During replay / predict, the widget draws generated candles and hides bars that have not been revealed yet by painting them in a solid mask color. That color must match the TradingView pane background (paneProperties.background); otherwise unrevealed bars show up as visible blocks ahead of the replay cursor.

Chart mask covering unrevealed predicted candles on a dark pane

KeyDefaultWhen it is used
light#fffffftheme="light", or theme="system" when the OS is in light mode
dark#0F0F0Ftheme="dark", or theme="system" when the OS is in dark mode

Only the entry for the active theme is applied. Each key is optional — omit one to keep its default. Any CSS color string the charting library accepts works; do not use transparency, or the real series bleeds through.

If your chart pane is not the default white / #0F0F0F, pass matching values:

<WidgetIccandle
:chart-widget="chartWidget"
:submit-callback="submitCallback"
theme="dark"
:chart-mask-colors="{ dark: '#2F2F2F', light: '#ffffff' }"
>
<!-- chart -->
</WidgetIccandle>

WidgetIccandle applies this color as an override on the Generated Candles Background study. Changing chartMaskColors or theme recreates those studies, so the host can update it when the chart background changes.

This is not the scan-window (date_range) fill — that uses --iccandle-primary on .iccandle-selector-widget.

apiKey (Plugin Portal style)​

Clients manage their style in the iC Candle Plugin Portal (plugin-portal.iccandle.ai) and create an API key there (see Getting access). Pass that key to the widget:

<WidgetIccandle
api-key="pk_live_…"
:chart-widget="chartWidget"
:submit-callback="submitCallback"
>
<!-- chart -->
</WidgetIccandle>
  • The widget calls GET https://api.iccandle.ai/plugin-client/v1/plugin/style with the api-key header once per key. The result is cached in memory and refetched only when apiKey changes (not on theme change). The request times out after 5 s and is aborted on unmount.
  • The key is also forwarded to every results-iframe URL as &apiKey=, so the embed uses the same style. Add it to your initial iframe src too, so the first load matches.
  • The key is publishable: it only reads style data and is meant to ship in client-side code. Restrict it in the portal with allowed origins (scheme://host[:port], e.g. https://app.example.com). With no allowed origins any site can use the key (the portal warns about this). Requests from other origins get 403 and the widget falls back to the defaults.
  • apiKey is only for style. It has nothing to do with user sign-in — see Auth and storage.

Supported style fields, per theme (light and dark):

FieldCSS variableAccepted values
iccandle_primary--iccandle-primary#rgb, #rgba, #rrggbb, #rrggbbaa, rgb(r, g, b), rgba(r, g, b, a)
iccandle_primary_gradient_end--iccandle-primary-gradient-endsame as above
iccandle_background--iccandle-backgroundsame as above
iccandle_border--iccandle-bordersame as above
iccandle_text--iccandle-textsame as above
icc_font--iccandle-fontInter Tight, Inter, Roboto, Open Sans, Lato, Montserrat, Poppins, Nunito, Source Sans 3, IBM Plex Sans, system-ui

The portal also sets default_theme (light | dark). The widget re-validates every value and ignores anything outside the formats above. Non-system fonts are loaded once from Google Fonts.

Priority (highest first):

  1. Theme: theme prop → portal default_theme → light.
  2. Colors: portal style → bundled defaults.

Fallback: with no apiKey, an invalid or revoked key, a disallowed origin, rate limiting, no saved style, or a network error, the widget uses the bundled defaults. The chart keeps working and nothing is thrown.

Replay masking on the chart stays on chartMaskColors.

Getting access​

Plugin Portal: https://plugin-portal.iccandle.ai

  1. Sign up on the Plugin Portal, then sign in.
  2. Set your style — light and dark colors, font, and default theme.
  3. Create an API key and add your website under allowed origins.
  4. Pass the key to WidgetIccandle as api-key, and add &apiKey= to your initial iframe src.

Style changes in the portal apply on the next page load — no widget release needed.

Migrating from bg_dark / bg_light​

The bg_dark and bg_light props were removed in 0.4.0. The widget no longer appends bg_* query params. Set the background colors in the Plugin Portal instead and pass apiKey. Remove bg_dark / bg_light from your WidgetIccandle props and from your initial iframe src.

Pricing helpers​

When the user clicks upgrade in scanner settings, the widget posts open-pricing to the results iframe (resultIframeRef), then to window.parent, then falls back to submitCallback with ?pricing=true.

You can also trigger pricing yourself:

import { postOpenPricingToEmbed } from "@iccandle/vuejs-widget";

postOpenPricingToEmbed(resultIframeRef.value, {
theme: "light",
language: "en",
});

Auth and storage​

Use useICCandleAuth() to read the live session from the host. Corporate partners should watch isAuthenticated before calling get-user-token — see Seamless auth example.

KeyPurpose
iccandle_tokenBearer token for scan cache, pattern tracker, and related APIs. Set by the embed via auth.signIn; cleared on auth.signOut.
search-filterPersisted scanner advanced options (symbols, top_k, period, model, temperature).
search-filter-sessionSession-scoped copy of advanced filters when the user does not persist them.
scanner-always-showWhether the scanner stays visible ("true" / unset).
tv:selected-news-eventsJSON array of news events used as timescale marks.
tv:clicked-news-eventLast clicked calendar event for mark highlighting.
tv:latest-symbolLast chart symbol (used by the demo app / fallbacks).

postMessage bridge​

Messages are accepted only from the results origin (https://embed-iccandle-app.iccandle.ai). Embed → parent payloads use a structured { name, data } shape.

DirectionNameEffect
Embed → parentchart.play / chart.stopInject / clear replay candles on the chart
Embed → parentselector.loadingToggle scanner loading UI
Embed → parentauth.signInPersist iccandle_token from data.idToken
Embed → parentauth.signOutRemove iccandle_token
Embed → parentselector.closeResultClears play state; calls onCloseResult
Embed → parentpattern.classicPatternSelected / pattern.custom_pattern_selectedDraw date range for the compared pattern
Embed → parentpattern.clearClassicPatternSelected / pattern.clear_custom_pattern_selectedRemove pattern date range
Embed → parentnews.eventClickedCenter chart, draw event line, show mark
Embed → parentnews.back / news.backToSimilarEventsClear event line / replay
Embed → parentnav.clickClear date range on /news routes
Embed → parentchart.requestResolutionRe-post the current chart resolution to the iframe
Parent → embedparent-originHost origin for Stripe return
Parent → embedpayment-successRefresh subscription after checkout
Parent → embedopen-pricingAsk the embed to open pricing (requires resultIframeRef)
Parent → embedchart-resolutionCurrent chart resolution (posted when iframeLoaded becomes true)

Host → embed helpers use { type: "parent-origin" | "payment-success" | "open-pricing" | "chart-resolution", ... }.

Optional: timescale marks (news/events)​

News marks on the time axis are optional. WidgetIccandle does not add them. To show calendar / economic events, implement TradingView’s getTimescaleMarks on your datafeed — the object you pass into withPlayChart. withPlayChart only wraps subscribeBars, so your getTimescaleMarks still runs as-is.

News event mark on the time axis with a currency icon and vertical line

Advertise support in the datafeed onReady configuration (supports_timescale_marks: true), or the library will not call getTimescaleMarks.

The widget writes events to localStorage. Your implementation should read those keys and return marks:

KeyValueMark
tv:clicked-news-eventOne event JSONBlue mark, rich tooltip (actual / forecast / previous)
tv:selected-news-eventsEvent array JSONGreen marks

Event timestamp is unix milliseconds; TradingView marks use unix seconds (time: timestamp / 1000). Event shape: NewsEvent.

import type {
GetMarksCallback,
LibrarySymbolInfo,
TimescaleMark,
} from "charting_library/charting_library";

type NewsEventType = {
id: string;
timestamp: number; // unix ms
event_name: string;
currency?: string;
actual?: string;
forecast?: string;
previous?: string;
};

const yourDatafeed = {
// ...onReady, resolveSymbol, getBars, subscribeBars, ...
getTimescaleMarks: async (
_symbolInfo: LibrarySymbolInfo,
_from: number,
_to: number,
onResult: GetMarksCallback<TimescaleMark>,
) => {
const marks: TimescaleMark[] = [];

const pushEventMark = (
event: NewsEventType,
options?: { color?: TimescaleMark["color"]; richTooltip?: boolean },
) => {
const { id, timestamp, event_name, currency, actual, forecast, previous } =
event;
if (!id || !Number.isFinite(timestamp) || timestamp <= 0) return;
if (marks.some((m) => String(m.id) === String(id))) return;

const tooltip = options?.richTooltip
? [
event_name,
currency ? `Currency: ${currency}` : null,
actual ? `Actual: ${actual}` : null,
forecast ? `Forecast: ${forecast}` : null,
previous ? `Previous: ${previous}` : null,
].filter((line): line is string => Boolean(line))
: [event_name];

marks.push({
id,
time: timestamp / 1000,
color: options?.color ?? "green",
label: event_name.slice(0, 1) || "N",
tooltip,
...(currency
? {
imageUrl: `https://cdn.backprop.services/symbols/${currency}.svg`,
}
: {}),
showLabelWhenImageLoaded: true,
});
};

try {
const clickedEvent = JSON.parse(
localStorage.getItem("tv:clicked-news-event") || "null",
) as NewsEventType | null;
if (clickedEvent) {
pushEventMark(clickedEvent, { color: "blue", richTooltip: true });
}
} catch {
// no-op
}

try {
const allNewsEvents = JSON.parse(
localStorage.getItem("tv:selected-news-events") || "[]",
) as NewsEventType[];
allNewsEvents?.forEach((event) => pushEventMark(event));
} catch {
// no-op
}

onResult(marks);
},
};

Then wrap as usual: datafeed: withPlayChart(yourDatafeed).

Theming​

Scanner UI uses CSS variables on .iccandle-selector-widget:

  • --iccandle-primary
  • --iccandle-primary-gradient-end
  • --iccandle-background
  • --iccandle-border
  • --iccandle-text
  • --iccandle-secondary
  • --iccandle-font

Light and dark defaults live in the bundled stylesheet. The theme prop toggles the .iccandle-dark class and is forwarded to the iframe URL via submitCallback. Pass apiKey to load the client's Plugin Portal style; it overrides these defaults and is forwarded to the iframe.

Replay mask color is not a CSS variable: set chartMaskColors to match paneProperties.background.

Layout helpers​

Injected CSS includes split-pane classes used by the demo:

ClassRole
.iccandle-selector-widget__containerFlex row (stacks below 1024px). --chart-pane-size defaults to 60%.
.iccandle-selector-widget__chart-paneChart column.
.iccandle-selector-widget__resize-handleDrag handle; add --stacked for the stacked layout.
.iccandle-selector-widget__iframeResults pane.

Behavior summary​

  • Subscribes to chart readiness, resolution, symbol changes, visible range, drawings, and timescale-mark clicks.
  • Manages a date_range multipoint drawing so the user can adjust the bar window (default: 25 bars).
  • Posts candles to https://scan-service.iccandle.ai/cacheCandle, then calls submitCallback with an embed URL (symbol, res, ref_res, cid, tk, from, to, filters, theme, and apiKey when set).
  • Syncs with the host-owned results iframe at https://embed-iccandle-app.iccandle.ai via postMessage.