Scripted bot building
Last updated
Last updated
In this small tutorial, we are going to show you have you can create a very basic scripted bot.
To create a scripted bot, you need to go to the left menu and select the "Web-editor". Once selected a new page will show up. On top of this page you will find a toolbar, click on the most left icon which display icon to create a new script. If all goes well then you will get a windows on your screen, asking you whats sort of script you like to create. Select script and give the script a name.
In this case, we are going to make a scripted RSI bot.
Lets think wat we need to make a RSI bot...
First, we of course, need the RSI indicator. This RSI indicator needs to be setup with 2 variables. The prices and the period. You can use the ClosePrices() command to get the close prices and we can give this to the RSI. As for the period, lets create a input field for this using the Input() command.
We want to see the RSI, so we need to plot to the chart. This can be done using the Plot() command. The Plot commands asks us to give it a chart index, a line name, the data, and optionally the color.
And, we need some trade logic. This can be created by some simple if..else statements where the managed trading commands DoBuy() and DoSell() get used.
TIP: When scripting, pay attention to the intelli-text, which will show when typing.
If we convert this to a haasscript then we get;
This example is enough to get a simple scripted RSI bot running.
Just like in trade-bots, you can script your own insurances too.
For example, suppose we want to add a way to "never sell cheaper then we have bought". Well, that would result in a script like this:
Again, just like in trade-bots, you can script your own safeties too.
For example, suppose we want to add a basic stop-loss. Well, that would result in a script like this: