Algocdk v2 lets you write a custom indicator as a plain JavaScript object: the platform supplies candle data, your calculate(data, params) function returns one value per candle, and the built-in renderer draws those values as a line unless you provide a custom draw() function. That makes a simple indicator relatively direct to prototype, while more specialized visuals can use Canvas 2D and a separate chart pane.
How an Algocdk indicator file is structured
The Algocdk v2 Developer Docs describe each indicator file as a JavaScript object literal wrapped in ({}). In their words: “Every file is a plain JS object literal wrapped in ({}). No imports, no export default, no build step needed.” The required object fields are a display name and a calculate function. Optional fields include color, lineWidth, hasWindow2, defaultParams, and draw. The platform combines parameter defaults with any user overrides when it calls the indicator. See the Algocdk v2 Developer Docs.
A minimal conceptual shape is:
({
name: "Example",
color: "#4f7cff",
lineWidth: 2,
defaultParams: { period: 14 },
calculate(data, params) {
// Return one value for every candle in data.
}
})
This is a structural sketch, not a complete trading rule: the calculation must return an output array aligned with the supplied candles.
What candle data the platform supplies
The input is an array ordered from oldest candle to newest; the last element is the current candle. Each documented candle includes open, high, low, close, time, and volume. Build calculations around that ordering rather than assuming the newest candle is at index zero.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
There is an important instrument-specific limitation: Algocdk’s guide says volume is always zero on Deriv synthetic indices. For those instruments, a volume-based calculation will not have informative volume values to work with.
Return one result per candle
calculate(data, params) is called as new candle data arrives. Its returned array should have the same length as data, so each result lines up with its corresponding candle. When a calculation needs more history before it can produce a meaningful value, return null for those warm-up positions instead of shifting the remaining outputs.
Rank #2
For example, a period-based measure may not be defined until enough candles have accumulated. Keeping those early entries as null preserves the index relationship between the indicator and the chart.
Choose the default line or custom drawing
Use the default line for a straightforward series
If a line is all you need, omit draw() and configure color and lineWidth. The guide states: “If you skip draw(), the platform automatically draws your returned array as a line using color and lineWidth.” This is the simplest choice for a value series intended to follow the main chart.
Use Canvas 2D for specialized visuals
Implement optional draw() when the display needs custom shapes, bars, an oscillator treatment, or a different layout. The documented drawing function receives a Canvas 2D context, calculated values, chart offsets and spacing, a price-to-y coordinate function, and parameters. That lets the renderer map values into the chart’s geometry rather than relying on the platform’s standard line.
Put an indicator in its own pane
Set hasWindow2: true when the indicator should be shown in a separate pane instead of sharing the main price chart. The guide’s custom-drawing example writes window.window2Bounds = { y, height } at the end of drawing. This layout can suit an oscillator or other series whose scale should be visually distinct from price.
Rank #4
| Choice | Use it when | What it means |
|---|---|---|
| Default line | A normal line represents the calculated values | Omit draw(); set color and lineWidth. |
| Custom draw on the main chart | You need non-line marks or chart-specific styling | Implement Canvas 2D drawing and use the chart geometry supplied to the function. |
| Custom draw in a second pane | The indicator should have a separate visual area or scale | Set hasWindow2: true; the documented example sets window.window2Bounds. |
What the documented RSI example does
The official RSI example calculates close-to-close changes, separates gains and losses, seeds average gains and losses, and then smooths those averages period by period. Its early results remain null until the calculation has enough history. This describes the algorithm shown in the example; inclusion in the guide is not independent validation of its mathematical correctness or trading usefulness.
The same implementation pattern applies more broadly: identify the candle fields needed, decide how much history is required, maintain the data-to-output alignment, and choose a renderer suited to the indicator’s meaning.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
How to upload an indicator and evaluate a bot
Algocdk’s guide documents uploading custom indicator files through the chart’s Indicators management route. It also describes loading bots in Strategy Lab, replaying them against historical data, loading them into Digit Lab, and publishing through the bot store. Those are platform workflows, not evidence that a strategy will earn a return.
- Write the indicator object. Include its display name and calculation function, plus optional defaults and rendering fields required by your design.
- Upload it from the chart. Use the chart’s Indicators management route to load the custom JavaScript indicator, as described in the Algocdk v2 Developer Docs.
- Keep indicator and bot roles distinct. An indicator calculates and displays values. A bot adds signal behavior; the guide’s
getSignalAt()examples can return a signal ornull, and its bot examples show platform-driven trade execution. - Replay a bot before considering live use. Load it in Strategy Lab and use historical replay/backtesting to inspect its behavior. A backtest is an evaluation step, not a guarantee of future or live results.
When this authoring model may fit
- Good fit: you are comfortable with JavaScript and want a direct way to calculate chart values without a separate build step.
- Good fit: your indicator is a simple line, or you are prepared to write Canvas 2D code for a more specific visualization.
- Plan carefully: your formula depends on volume and you are using Deriv synthetic indices, where the guide says volume is always zero.
- Keep expectations grounded: the platform documentation explains code structure and workflow; it does not provide measured indicator accuracy, expected returns, or proof of live performance.
If you need a refresher before writing the file, JavaScript fundamentals are useful preparation, but a programming book or other learning resource is optional rather than an Algocdk requirement.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




