Skip to Main Content

05/10/2023 |

TrendSpider Software Update: JavaScript Custom Indicator Scripting Added

Hello, traders, and welcome to another software update from your friends here at TrendSpider! In this update, we are pleased to announce the introduction of custom scripting to the platform. Details after the jump!

If you’re a developer or coder, this update is for you! We now offer a robust environment to build your own custom indicators on TrendSpider using the JavaScript language.

Watch the Intro to Scripting Video

New Feature! Introducing JavaScript Custom Indicator Scripting | TrendSpider Software Updates

Why JavaScript?

JavaScript is a widely used general-purpose programming language that is utilized in numerous applications, including almost every website on the web.

“General purpose” means that it was not explicitly invented for finance, investing, or trading. Rather, it is a versatile programming language that can be applied across various industries and for diverse purposes.

If you know JS already, you’re ready to go: Any developer experienced in JavaScript can write sophisticated scripts on TrendSpider with a minimal learning curve. If you are a beginner, or familiar with other languages like Pine Script™, MQL or Think Script™, you should be able to adapt to JavaScript pretty easily by reading the documentation.

Built For Developers

Our scripting is packed with developer-centric features and capabilities, including:

  1. Example scripts included with the platform to learn off. Even more examples available right in the Code Editor within the platform.
  2. Integrated auto-complete and syntax highlighting.
  3. Integrated help and documentation (control+click on a command to open the documentation panel.)
  4. Browser-based debugging with your browsers debugging tools (JavaScript Console.)
  5. Support for select open source NPM packages.
  6. Ability to use your own IDE with the Code Editor to synchronize code you write in your preferred environment
  7. Dozens of helper functions to compute indicators, detect trendlines, find chart patterns and formations, and perform mathematical functions, transformations or operations.

Enabling the Code Editor

In order to access the scripting environment, click on the ‘Code Editor’ button in the top right corner of your platform view.

Code Editor Button Location

The Code Editor panel will appear at the bottom of your screen, similar to the Market Scanner or Strategy Tester, and it will come preloaded with a sample script.

In the image below, you can see the sample script and the corresponding indicator the script has built. In the top left corner of your chart, note the ‘Current Script’ indicator in the indicator list.

Examples of Custom Scripts

Inside of the platform, there are dozens of examples. Just click on Example Scripts in the Code Editor window to load them. You are free to copy these examples and base your own indicators on them. Here are a few samples to get you going:

Coloring candles basing on RSI value

The example below colors candles depending on what’s the corresponding RSI value. Color is blue when RSI is around 50, red when it’s around 100 and bright blue when it’s around 0.

const tinycolor = library('tinycolor2');

const colors = rsi(close, 14).
	map(value => {
		return tinycolor('blue').spin(3 * (value - 50)).toHexString()
	});

color_candles(colors);Code language: JavaScript (javascript)


Double SMA colored clouds

color_cloud(sma(close, 10), sma(close, 30), 'red', 'green');
color_cloud(sma(close, 30), sma(close, 50), 'black', 'lime');Code language: JavaScript (javascript)


Other Example Scripts of Custom Scripting in Action


Start Exploring Now

For a more in-depth view of how custom scripting works on the platform, please take time to read through the documentation provided here.

Our marketing department has demanded us mentioning docs. But we’re developers too. We know that nobody wants to read the docs. Go play with it!