With BacktestJS you can

Easily download candle data from binance and export to a csv.

100% FREE BACKTEST
TRADING STRATEGY TOOL

Download Candle Data, Write and Run Trading Strategies with Ease

THE POWER OF BACKTESTJS

BACKTESTING FEATURES

Blazing Fast


BacktestJS was built with efficiency and speed in mind from the coding language to the db down to the dependencies while using top of the line coding practices.

Easy To Use


Complete package to get historical candle data, write / create strategies. Get full results and graphs as well as easy infra to run trading strategies and save results.

CLI / UI Driven


While most backtesters give a basic infra and thats it, BacktestJS is an incredibly easy to use CLI driven application that gives beautiful results inside a google chrome browser.

Multi Value


Run any strategy with as many params and options as you want. For example if you have low and high sma you can put 2,3,4 for low and 40,50,60 for high and get all the result combinations in one run.

Multi Symbol


Choose to run any trading strategy over multiple symbols in one run, whether its Apple stock on the 1 day with bitcoin on the 4 hour, run any symbol with any timeframe and get all the results together.

Indicators


BacktestJS comes with tulind included which has over 100 indicators at your disposal to use in your trading strategies as well as various internal trading indicators to choose from.

Download Candles


With BacktestJS you can easily download all the historical candle data through the CLI and it's kept in an internal DB to be used on demand whenever you run any strategy. You can export the data to a csv as well.

Import Candles


Have candle data in a csv that cant be downloaded from binance? No problem just import the csv into BacktestJS and your up and running to choose a trading strategy to run over your imported candle data.

Interactive Resutls


3 types of results (single, multi value and multi symbol) with full tables and graphs to see all of your results. See your trading results in the CLI or see them in a full fledged UI.

EXAMPLES

Run SMA Strategy

Trading Strategies Run Trading Strategy More Options

Code


import { BTH } from "../infra/interfaces"
import { indicatorSMA } from "../indicators/moving-averages"
export async function sma(bth: BTH) {
// Get low and high SMA from input
const lowSMAInput = bth.params.lowSMA
const highSMAInput = bth.params.highSMA
// Get Candles
const lowSMACandles = await bth.getCandles('close', 0, lowSMAInput)
const highSMACandles = await bth.getCandles('close', 0, highSMAInput)
// Get SMA's
const lowSMA = await indicatorSMA(lowSMACandles, lowSMAInput, 1)
const highSMA = await indicatorSMA(highSMACandles, highSMAInput, 1)
// Perform Buy / Sell when low crosses high
if (lowSMA > highSMA) {
await bth.buy()
} else {
await bth.sell()
}
}

Results

Run SMA Strategy With Multi Value & Multi Symbol

To run with multi value or multi symbol, you do not need to change your code only your run params!!!

Run Trading Strategy Multi Value And Multi Symbol

Results

GET HISTORICAL CANDLE DATA

Historical Candle Data Download Historical Candle Data

Download Crypto Candle Data From Binance

Download any data from whatever timeframe interval you desire in a matter of seconds with ease. Any downloaded data can easily be exported to a csv.

Historical Candle Data Import CSV

Import Data From CSV

Your candle data is not crypto related? No problem just import your data from a csv and your on your way to running that killer strategy on your desired historical candle data set.

BACKTESTJS DOCS

Historical Candle Data

View All
Download Candle Data From Binance
Download Candle Data From Binance

Easily download crypto candle data from binance

Import Candle Data From CSV
Import Candle Data From CSV

Import any candle data to the app to then run strategies on

View / Update / Delete Historical Candle Data
View / Update / Delete Historical Candle Data

Access the candle data, add more candle data or delete the data.

Export Candle Data To CSV
Export Candle Data To CSV

Easily export any downloaded candle data to a csv

Install

View All
Install
Install

2 Ways To Install 1. Github (Coder) Use preinstalled strategies and write your own strategies 2. NPM (Non Coder) Use preinstalled strategies only, no ability to write your own strategies

Run Trading Strategy

View All
Run Strategy
Run Strategy

How to run a strategy in the BacktestJS application.

Run Strategy (More Options)
Run Strategy (More Options)

How to run a strategy in the BacktestJS application with more options.

Run Strategy With Multi Values (Easy & Powerful)
Run Strategy With Multi Values (Easy & Powerful)

How to run a strategy in the BacktestJS application with multi values.

Run Strategy With Multi Symbol (Easy & Powerful)
Run Strategy With Multi Symbol (Easy & Powerful)

How to run a strategy in the BacktestJS application with multiple symbols.

Trading Strategy Examples

View All
Simple SMA
Simple SMA

How to code a simple sma trading strategy.

SMA With Params
SMA With Params

How to code a simple sma trading strategy with paramaters.

SMA With Shorting & Stop Loss
SMA With Shorting & Stop Loss

Code a more advanced sma trading strategy including shorting / stop losses.

Triple SMA (Advanced Buy / Sell)
Triple SMA (Advanced Buy / Sell)

Code an advanced sma trading strategy with more advanced buy / sells.

Trading Strategy Results

View All
View Trading Strategy Results
View Trading Strategy Results

What trading results are given and how to view them.

View Multi Value Trading Strategy Results
View Multi Value Trading Strategy Results

What multi value trading results are given and how to view them.

View Multi Symbol Trading Strategy Results
View Multi Symbol Trading Strategy Results

What multi symbol trading results are given and how to view them.

Save / View / Delete Trading Strategy Results
Save / View / Delete Trading Strategy Results

How to save / delete trading results.

Write Trading Strategy

View All
Create Structure
Create Structure

Create the basic skeleton structure that every strategy needs.

Working With Candles
Working With Candles

How to retrieve candle data in your strategy.

Using Indicators
Using Indicators

How and where to call indicators / make your own indicators.

Perform Buy Sell
Perform Buy Sell

How to perform buy / sells within your strategy.

Access Order Book
Access Order Book

How to access the order book data object in your strategy.

BACKTESTJS FAQ

BacktestJS is completely free, not freemium, no signups, no credit cards and no ads. Not only is the application free but its open source as well so users can contribute to the application!

Glad you asked! We currently accept donations in Bitcoin, Ethereum and Paypal. Wanna donate some other way? Feel free to contact us.

Bitcoin:

Ethereum:

Paypal

Great question! There are a lot of moving parts keeping this project alive. One great way is to contribute to the code of the BacktestJS application itself or adding indicators / strategies. Feel free to put in a PR (follow the guidelines) via github.

I dont code but want to help? Thats even better. Main areas where we can use help is marketing (would love help here 🙂 ), website development and graphic design. If you have a different expertise that you think can help, feel free to contact us!

Remember we are an open source project, all work is done from the bottom of your heart 🙂 and of course all work will be credited to the maker.

Contact us for a quote as we do offer paid services to code trading strategies. Your coded strategy will be kept private to you and not published to the application.

A second option is to reach out to the community forum. If we or someone else find it interesting it might get coded!

Head over to the community we would love to hear about it!

Now this is a great question 🙂 . In general its always a better practice to code in TS over JS in my honest opinion. With that said you can always convert the project to JS with one simple command (learn more here) and choose to write your strategies in JS instead. Basically TS is a wrapper to JS, in the end of the day we code in JS which is why it’s called BacktestJS.

Update: the above was a cover up don’t tell anyone 🙂 i just like the name BacktestJS more than BacktestTS.

My name is Andrew and i made this monstrosity of an application, website, documentation and youtube videos.

The why is a bit harder to explain. A friend once asked me to write a backtest of a strategy he had. I didn’t know what a strategy was, not even what a candle was. But like a good, curious friend i figured out this stock world, how to get candle data and then wrote some rudimentary tests. I found that i really liked this and had ideas of strategies. As time went on i realized i had around 100 strategies with most of them having the same basic infra and indicators rewritten over and over and tons of different candle data in spreadsheets throughout my computer. This was a huge mess to say the least.

So I decided to make an infra that can get and save candle data to a db and provide a super smooth infra to code ANY strategy no matter how complex. I then realized many people could benefit from this so i can either keep it to myself or i can put in a lot more work 🙂 and make it open source. I then spent a lot of time making sure the app has good error validation, ease of use, automation and of course i needed a pretty website, docs, examples and youtube videos to go along with it!!

But wait pinescript exists why rewrite the wheel? Well although i did learn pinescript before writing this i was not thrilled to learn yet another language at first and i figured it would be easy to code this infra in JS and of course would run much faster. Eventually while i did succumb to pinescript at first, I quickly learned that it wasn’t powerful enough for the very intricate things i wanted and went back to JS and wrote this app.

While i personally don’t recommend the approach it can easily be done. Run the command “npm run makejs” or “npm build” and then the typescript will be converted to javascript in a new folder called “dist”. To code a strategy you must go inside “/dist/strategies” and you can code your strategy inside here with javascript instead of “/src/strategies” which is the place to code strategies using typescript.

This is most likely due to asking for more candles than are available.

Lets say you have 2 years of data on a daily timeframe and your strategy requires 60 candles worth of data for the indicator to work. When you call the getCandle() function on the first day, it realizes that you dont have 60 candles worth of data in the past and instead returns an array of 60 0’s and blocks the buy() / sell() functions. This happens for 2 months worth of candles (60 candles) until you have enough data and the getCandles() function returns candles correctly and buy / sell is no longer blocked.

The indicators are coming from a plugin called tulind. If tulind is returning incorrect data please reach out to the tulind project. From experience i have seen that some indicators need more candle data. For example if the indicator needs 60 closes try to give it 120 closes instead. Keep in mind a trading view indicator and tulind indicator might use different math to get their value.