With BacktestJS you can

Get power by backtesting strategies with multi values

leaf leaf leaf Docy banner shape 01 Docy banner shape 02 Man illustration Flower illustration
Write Trading Strategy

Create Trading Strategy In App

Estimated reading: 3 minutes 201 views

Summary: How to add a trading strategy to the BacktestJS application.

About

Creating the strategy in the BacktestJS is much easier than writing a strategy as it is all done through the application.

How To Create A Trading Strategy

Once running the application go to trading strategies

BacktestJS Home Trading Strategies

Next go to Create Strategy

Trading Strategies Create Trading Strategy Menu
Give your strategy a name

*** THIS NAME MUST MATCH THE FILE NAME OF THE STRATEGY IN THE STRATEGIES FOLDER (without .ts or .js)

You will then be asked if you want to add params. If you say yes it will ask for a name for that param.  You will then be asked if you want to add another param and can add as many params as you want. 

Next you will be asked if you have any dynamic params. Most of the time this answer will be no. Below is a use case for dynamic params.

Let’s say you have code that might have 2 params and sometimes 3 params other times. When you go to run the app you can define the name and value of the param when running the strategy.

Trading Strategies Create Trading Strategy


More on Params

Params make your strategy incredibly powerful. These params will be filled out when you go to run a strategy and then are injected into the strategy. Lets explain better with an example

Lets say i write a strategy that says if the lowSMA crosses the highSMA then buy and if it goes lower then sell.

In the app we can hard code 3 as the low sma and 40 as the high sma or whatever you want but keep in mind its hard coded. Now when you go to run you will get the results of the 3 / 40 sma strategy.

If you instead use params you can make a dynamic variable called lowSMA and highSMA (like the example above). In your code you can then call these variables. Now when you go to run your strategy it will ask for a low and high sma which can be different each time!

You can even use many low and high sma’s (comma seperated) and the app will run every combination and tell you which combinations are the best!

Click here for more on how to work with params in the code.

Leave a Comment

Share this Doc

Create Trading Strategy In App

Or copy link

CONTENTS