new Check out the all new Drag-and-Drop Visual Editor with HaasScript 2.0
  • BTC/USD $8,505.81 USD
  • ETH/USD $179.59 USD
  • LTC/USD $57.63 USD

Use the HaasScript visual designer to create a SMA based simple trade bot

    • haasscript
    • pinescript
    • simple trade bot
    • sma indicator
    • visual editor
    • visual scripting
    • visual trade bot designer
    1015
    posted 3 months ago
    by Pshai
    Tutorial Featured Image

    Intro

    In this quick and simple guide we will be going through the steps of using HaasScript and our visual designer to generate signals with the SMA technical indicator, plotting the results on our charts, and backtesting the script to see how it performs with historical price data.

    The visual designer allows us to drag-and-drop hundreds of built-in blocks to perform the desired logic, instead of using a text-based editor. This method vastly improves the speed and accuracy of the scripts that you are creating as you will learn through this guide.

    Getting Started

    Before we get started you will need:

    • An active simple or advanced license for HaasOnline Trade Server
    • Hardware that meets our software's minimum specifications
    • Broadband internet

    If you don't have access to one or more of the above, you can choose to test on one of our demo servers. Please remember these machines are public and you should never add any private information.

    Creating a New Script

    Visual Editor! We will be creating the same type of bot, but in a "drag & drop" environment. Let's get started by clicking the [Visual Editor] in the main menu panel.

    haas-script-visual-designer-

    Yet again a new world opens in front of us. Don't be scared though! It will be fun, I promise. Here I have set the same market and interval settings as we had in the [Script Editor]. Now where is that button we create new scripts with...

    haas-script-visual-designer-fresh

    Right. Here we go. Let's click it!

    haas-script-visual-designer-new

    I went ahead and skipped the [New Script] window. I gave it a name and set the [Type] to [Script]. Now, like last time, first we want the historical close prices. Click on the [Commands] tab on the left hand [Menu].

    haas-script-visual-designer-blank-slate

    Exploring Command Blocks

    Here you will find everything you need. You can also set any command as a favorite (the star icon). These commands will be listed in the top most category [Favorites]. I went ahead and expanded the [Price Data] category. There we will find the [ClosePrices] command we were after. To create it just click it once.

    haas-script-visual-designer-add-close-price

    Our first block appeared, great! Now we need those SMA commands. Let's use the search field in [Commands] tab to find it faster.

    haas-script-visual-designer-search-commands

    Here we go. We will be creating two of these so we click it twice. They will be created on top of each other, but thankfully we have a working mouse with a button to drag and drop them around as we like. Right?

    haas-script-visual-designer-commands-list

    Managing Visual Blocks

    I added two [Number] blocks to set the [period] parameters for the SMA's. Connect the dots by clicking on the output of one and the input of the second block.

    haas-script-visual-designer-connected-blocks

    Again, to be able to see them on our charts we will need two [Plot] blocks and two color constant blocks to define their line colors. Define the chart index and name for each [Plot] and connect our SMA outputs to them.

    haas-script-visual-designer-connected-blocks-02

    Hit CTRL+R and open the chart.

    haas-script-visual-designer-chart

    Adding Trade Logic & Backtesting

    There we go! Nice and simple, but we are again missing the trade logic. I will be re-aligning them a little and separate them to 3 sections:

    • Price data and indicator calculations
    • Plot charts
    • Trade logic

    haas-script-visual-designer-charted-blocks

    I threw in some [Comment] blocks too to describe what each section does. Nice and clean! After everything is laid out and connected as shown, open the [Compile Log] and [Chart]. Then hit CTRL+R again and you should be seeing some results again. Awesome stuff!

    You know what to do next. Good luck!

    haas-script-visual-designer-summary

    Video Example

    Conclusion

    I hope this quick and simple guide gives you a better understanding of what HaasScript is capable of.

    • If you found this guide interesting, check out the guide where we recreate this strategy while using the HaasScript text-based editor
    • For the complete list of built-in commands and documentation of all our features, check out our HaasScript documentation
    • You can use HaasScript to recreate other popular strategies and indicators from languages such as PineScript

    If you enjoyed this guide or have comments please post them down below.

    — Pshai

Be the first to comment

The community content is generated by people from the community and is actively moderated. However, we do not endorse or claim to maintain any user generated content, links, tutorials, guides, projects, or questions that may appear in community sections.