LogoLogo
Back to HaasOnline.comSwitch to Trade Platform
3.x
3.x
  • Welcome
  • Getting Started
    • Using Local API Server
    • Authentication
    • Response
      • Error Codes
  • HaasScript
    • Using HaasScript
      • HaasScript Facts
      • Charting
      • Order Handling
      • Interval
      • Input Fields
      • Positions Handling
        • Fee correction
      • Position Information
      • Memory Management
      • Optimizations
      • Signal Handling
      • Trading
    • Script Editor
      • Syntax
      • Parameters
      • Interaction
    • Visual Editor
      • Blocks
      • Parameters
      • Flow Control
      • Interaction
    • Custom Commands
    • Tutorials
      • Trade Bot Guide
        • Creating A Trade Bot
          • Visual Editor Guide
          • Script Editor Guide
          • Custom Containers
        • Customizing Indicators
        • Customizing Safeties
        • Customizing Insurances
        • Creating Easy Indicators
      • Unmanaged Trading Guide
        • Executing Orders
        • Managing Orders
        • Managing Positions
        • Managing Wallet
      • Script Editor
        • Classes
        • MadHatter BBands
        • Percentage Price Change
      • Visual Editor
        • Importing Scripts
        • SmoothRSI
        • Scalper Bot
    • Commands
      • Array Helpers
      • Charting
      • Constants
      • Custom Commands Helpers
      • Easy Indicators
      • Easy Insurances
      • Easy Safeties
      • Equations
      • Flow Control
      • Input Fields
      • Input Settings
      • Mathematical
      • Memory Helpers
      • Miscellaneous
      • Order Handling
      • Order Information
      • Position Information
      • Position Prices
      • Price Data
      • Price Market Information
      • Profit Information
      • Settings
      • Signal Helpers
      • String Helpers
      • Technical Analysis
      • Technical Analysis Helpers
      • Time Information
      • Trade Actions (Managed)
      • Trade Actions (Unmanaged)
      • Trade Bot
      • Trade Market Information
      • Wallet
  • API Endpoints
    • Software API
    • Market Data API
    • Account Data API
    • Trade Data API
    • Advanced Order API
    • Trade Bot API
    • Custom Trade Bot API
    • ENUMS
    • Data Objects
  • Examples
    • Script Bots (C#)
      • Scalper Trade Bot
      • Flash Crash Trade Bot
    • Script Indicators (C#)
      • Indicator Script
      • Technical Analysis Library
    • Pshai Scripts (C#)
      • BBands Ext
      • BBands Ext v2
      • Chaikin A/D Line
      • Calibrator
      • Pshai's RVI
    • Scripted Driver
  • Other Resources
    • YouTube
    • Guides & Tutorials
    • Questions & Answers
    • Community Projects
  • Need Help?
    • Ask on Discord
    • Submit Support Ticket
Powered by GitBook
On this page
  • Framework
  • Input Parameters
  • Output
  • Price Data
  • Calculation
  • Signal Result
  • Plotting
  • Final Indicator
  • Using the command

Was this helpful?

  1. HaasScript
  2. Tutorials
  3. Trade Bot Guide

Creating Easy Indicators

PreviousCustomizing InsurancesNextUnmanaged Trading Guide

Last updated 5 years ago

Was this helpful?

Framework

When we are going to create a custom indicator its best to do this in the form of a Custom Command. This way we will have a clean bot script and a reusable command in one. The command will have 2 inputs, a chartIndex & interval and a single output, the signal.

In this example we will create a SmoothRSI. We will start by using the DefineCommand() command. This set the command name and description for the command.

Input Parameters

For the input parameters we could use DefineParameters() twice but there is an easier way. DefineEasyIndicatorParameters can do the work for us. The command creates 2 parameters for our script. The chart index and interval. It returns both parameter in object we can access.

Output

The output will be a signal result. SingalLong, SignalShort, SignalNone. For this output type we also have an single command that takes care of everything. DefineEasyIndicatorOutput(). It will set the return type, description and suggestions for our command.

Price Data

The next stop is to get some price data to work with. We are going to use the ClosePrices() based on the interval returned by DefineEasyIndicatorParameters()

Calculation

With the ClosePrices() we can calculate the RSI using the RSI() command. The command takes 2 parameters. The prices, our ClosePrices() result, and a period, the length of the RSI. For the second value we are going to use an Input field command.

After the RSI calculation it is time to smooth the RSI. Using the SMA() command will give us a nice smooth RSI result to work with. The SMA() also takes a period parameter. For this we again create an input field. The SMA() result is our smoothed RSI.

Signal Result

RSI's always work with a buy and sell level. So should ours. We could use the IsBiggerThan and IsSmallerThan command but ofcource there is an easier way. In the Signal Helpers category there are a bunch of command that will do the calculation for us. We are going to use the GetBuySellLevelSignal. This will return a SignalLong when the value is below the buy level and a SignalShort when the signal is above the sell level. For the buyLevel and sellLevel parameters we will use an Input command. The result of GetBuySellLevelSignall will be the value for the result parameter in DefineEasyIndicatorOutput().

Plotting

No indicator is complete without some lines on the chart. Lets plot the RSI and the Smoothed RSI on the chart. We are using the chartIndex returned by DefineEasyIndicatorParameters() for the Plot commands.

There are also buy and sell levels we want to draw on the chart. We could use 2 PlotHorizontalLines() command but there is always an easier way. PlotBuySellZone(). This draws 2 lines with an area fill between them.

Final Indicator

The custom indicator is now finished. If we save it and run a quick test we can have a look at the chart.

Using the command

We can now use the command in any other script we like and in combination with other indicators without issues!