Quantower
Quantower Website
  • Welcome to Quantower Help
  • 🚀Getting Started
    • What's new
    • Installation
    • First start
    • Platform update
    • Quantower Beta
    • Quantower Account
    • Quantower Licenses
    • ⚖️License Comparison
    • Backup & restore manager
    • Reset settings to default
    • Payment FAQ
    • “Coinpayments” payment
    • Binance fresh account
    • Referral Program
    • You have found a bug. What’s next?
  • ⚙️General Settings
    • Quantower Main Toolbar
    • Workspaces
    • Single Panel
    • Link panels
    • Binds
    • Group of panels
    • Templates
    • Set as Default
    • Symbols lookup
    • Table management
    • Alerts
    • General settings
    • Custom hotkeys
    • Setup Actions & Advanced filters
    • 📢Notifications center
  • 🔗Connections
    • Connections manager
    • Connection to Binance Futures
      • Errors with Binance connection
    • Connection to CQG (AMP Futures)
      • Errors with CQG
    • Connection to OANDA
    • Connection to FXCM
    • Connection to cTrader
      • How to connect to FxPro via Quantower
      • How to connect to Pepperstone via Quantower
      • How to connect to IC Markets via Quantower
    • Connection to Rithmic
      • Rithmic Issues
    • Connection to Topstep
    • Connection to Interactive Brokers
      • Errors with Interactive Brokers
    • Connection to Bybit
    • Connection to OKEx
    • Connection to MetaStock
    • Connection to IQFeed
  • 💡Analytics Panels
    • Chart
      • Chart Overview
      • Chart Types
        • Tick Bars
        • Time aggregation
        • Renko
        • Heiken Ashi
        • Kagi
        • Points & Figures
        • Range bars
        • Line break
        • Volume Bars
        • Reversal Bars
      • Chart Settings
        • View settings
        • Data Style
        • Time Scale
        • Price Scale
        • Visual Trading
          • Positions
        • Order Entry
        • Quick Ruler
        • Info Window
        • Volume Bars
        • Hotkeys
      • Chart overlays
      • Technical indicators
        • Channels
          • Range Marker
          • Donchian Channel
          • High Low Indicator
          • Round Numbers
          • Highest High
          • Lowest Low
          • Bollinger Bands
          • Bollinger Bands Flat
          • Price Channel
          • Fair Value Gap (FVG)
          • Keltner Channel
          • Moving Average Envelope
        • Moving averages
          • Demand Index
          • Exponential Moving Average
          • FYL Indicator
          • Linearly Weighted Moving Average
          • McGinley Dynamic Indicator
          • Modified Moving Average Indicator
          • Pivot Point Moving Average Indicator
          • Regression Line Indicator
          • Simple Moving Average Indicator
          • Smoothed Moving Average Indicator
          • Guppy Multiple Moving Average Indicator
          • Trend Breakout System Indicator
          • Triple Exponential Moving Average Indicator
        • Oscillators
          • Delta Divergence Reversal
          • Aroon Indicator
          • Moving Average Convergence/Divergence
          • Awesome Oscillator
          • Accelerator Oscillator
          • %R Larry Williams
          • Momentum
          • Rate of Change
          • Relative Strength Index (RSI) Indicator
          • Relative Spread Strength (RSS)
          • Balance of Power (BOP)
          • Commodity Channel Index
        • Trend
          • Bionic Candle
          • Average Directional Movement Index (ADX) Indicator
          • Ichimoku Cloud Indicator
          • Directional Movement Index (DMI) Indicator
          • ZigZag
        • Volatility
          • Average True Range
          • Standard deviation
        • Volume
          • COT High/Low
          • Depth of Bid / Ask
          • Delta Flow
          • Delta Rotation
          • Level2 indicator
          • Abnormal Volume
          • Abnormal Trades
          • Volume Impulse
      • Drawing tools
      • Volume Analysis Tools | Volume Profiles | Footprint chart | VWAP
        • Cluster chart
        • Volume profiles
        • Time statistics
        • Time histogram
        • Historical Time & Sales
      • Power Trades
      • VWAP | Volume Weighted Average Price
      • Anchored VWAP
    • Watchlist
    • Time & Sales
    • Price Statistic
    • DOM Surface
    • Option Analytics
    • TPO Profile Chart
  • 💵Trading Panels
    • Chart Trading
    • Crypto Order Entry
    • Multiple Order Entry
    • Order Entry
      • Order entry for Bybit
      • Order Entry for CQG
      • Order Types
      • Order placing strategies
        • Local SL/TP
    • DOM Trader
      • DOM Trader Settings
        • View Settings
        • DOM Trader Columns
        • Order Entry
        • VWAP Settings
        • Positions Bar
        • Hotkeys
      • DOM Trader Columns
      • How to set up Dom for scalping
    • Copy Trading
    • Market depth
    • Trading simulator
    • Market Replay
    • FX Cell
    • Backtest & Optimize
    • Strategies manager
  • 💼Portfolio Panels
    • Positions
    • Working Orders
    • Trades
    • Orders History
    • Synthetic Symbols
    • Historical Symbols
  • 📊Information Panels
    • Account performance
    • Account info
    • Crypto balances
    • Symbol Info
    • Currencies Exposure
    • Event Log
    • RSS (News panel)
    • Reports
  • 📌Miscellaneous
    • Futures Rollover
    • History Exporter
    • Symbol Mapping Manager
    • Sessions manager
    • Live Support
    • Market Heat map
    • Stat matrix
    • Exchange times
    • Quote Board
    • Browser
    • Excel and RTD function
      • Changing RTD Throttle Interval in Excel
    • Quantower Telegram Bot
    • 🎨Themes editor
  • 🤖Quantower Algo
    • Introduction
    • Install for Visual Studio 2022
    • Strategies manager
    • Backtest & Optimize
    • Debugging in VS 2022
    • Simple Indicator
    • Simple strategy
    • Input Parameters
    • Built-In indicators access
    • Custom indicators access
    • Level2 data
    • Access Volume analysis data from indicators
    • Indicator with custom painting (GDI)
    • Access Chart from indicator
    • Using markers with indicators
    • Using Clouds in Indicator
    • Adding a custom indicator to Watchlist
    • Downloading history
    • Access to trading portfolio
    • Trading operations
    • Example: Simple Moving Average
    • Access to crypto account and balances
    • Access to advanced aggregations
    • Access to symbol/account additional fields
    • Strategy runner (deprecated)
  • 💫Customization
    • Localization
  • ⁉️FAQ
    • General Errors
Powered by GitBook
On this page
  • So, what is indicator in general?
  • Indicator code structure
  • Common settings
  • Getting data
  • Setting data
  • Build
  1. Quantower Algo

Simple Indicator

In this topic we will show you how simple is writing indicators in Quantower

Last updated 1 year ago

We will use Quantower Algo extension for Visual Studio, but main principles are valid for all development environments. If you don't have Visual Studio or Quantower Algo extension installed you can read manual. See examples of some strategies, integrations and indicators in our

So, what is indicator in general?

An indicator is mathematical calculations based on a symbol's price or volume. The result is used for displaying on the chart and to help trader make a correct decision. From technical point view Indicator in Quantower is a set of lines with buffers. Each element of the buffer is assigned to a historical bar or tick on the chart. All you need is to make a required calculations and put the result into this buffer.

Sounds not very difficult, doesn't it? Let's start! As for example we will write a code that will implement algorithm of Simple Moving Average indicator.

Use "File -> New project" in the main menu of Visual Studio to open "New project" window. Type "Indicator" and you will see special project type for blank indicator:

At first, you need to create a new project for the indicator. Quantower Algo provides you predefined templates for an empty indicator as well as a few examples of real indicators with source code:

A minimum required source code will be generated automatically and contains the main Indicator functions:

Indicator code structure

Common settings

It is time to go deep into the code. In a constructor method, you can specify name of the indicator, short name for displaying on the charts and whether you indicator require a separate window on the chart. The most important here is specifying the amount of lines and their default style: Solid/Dot/Histogram, color, and width. In our example, we need only one line, but you can add any amount:

/// <summary>
/// Indicator's constructor. Contains general information: name, description, LineSeries etc. 
/// </summary>
public SimpleIndicator()
    : base()
{
    // Defines indicator's name and description.
    Name = "SimpleIndicator";
    Description = "My indicator's annotation";

    // Defines line on demand with particular parameters.
    AddLineSeries("line1", Color.CadetBlue, 1, LineStyle.Solid);

    // By default indicator will be applied on main window of the chart
    SeparateWindow = false;
}

Getting data

The "OnUpdate" method will be called each time on history changing - here we need to add our calculations. Most of the indicators are using prices or volumes in their algorithms. Quantower API provides you a few ways to retrieve this data - you can access Open, High, Low, Close and others data from a current bar or from previous bars if it required.

// To get Low price of the current bar
double low = GetPrice(PriceType.Low);
// To get Volume price for the fifth bar before the current
double volume = GetPrice(PriceType.Volume, 5);    

And a few simplified ways to retrieve the data:

// To get Close price of the current bar
double close = Close();
// To get High price of the current bar
double high = High();
// To get Open price for the fifth bar before the current
double open = Open(5);   

Setting data

// Put value into current bar for first line of indicator
SetValue(1.43);
// Put value into current bar for second line of indicator
SetValue(1.43, 1);
// Put value into fifth bar before the current bar for second line of indicator
SetValue(1.43, 1, 5);

All this is enough to finish our first indicator. Let's add calculations into "OnUpdate" method using standard C# possibilities. This is our total code:

/// <summary>
/// Calculation entry point. This function is called when a price data updates. 
/// </summary>
protected override void OnUpdate(UpdateArgs args)
{
    int Period = 10;

    // Checking, if current amount of bars
    // more, than period of moving average. If it is true
    // then the calculation is possible
    if (Count <= Period)
        return;

    double sum = 0.0; // Sum of prices
    for (int i = 0; i < Period; i++)
        // Adding bar's price to the sum
        sum += GetPrice(PriceType.Close, i);

    // Set value to the "SMA" line buffer.
    SetValue(sum / Period);
}

As you can see, we use only Close prices for calculations and hard code Period value. In the real case, you will allow a user to specify this values. In our next topic, we will show how to use the Input Parameter for your scripts.

Build

Indicator is ready to use in trading platform. We need to compile it - use "Build -> Build Solution" in the main menu or hot key F6. Quantower Algo extension will automatically copy your indicator to assigned Quantower trading platform and you will see it in the "Indicators" lookup on the chart:

If you decide to make some corrections in your calculations, you can rebuild your indicator and you even don't need to re-add it again on the chart - it will be updated automatically and you will see results immediately:

Common method allows to retrieve all type of the data:

You can find more information about "Indicator" class in our .

Now we know how to get prices, but as we told before, we need also to put results into indicator buffer. We can use "" method for this:

As you can see it did not take a lot of time to get the first results. Using this basic example you can easily create your own indicator — all power of C# language is available for you. In the next topic we will show you how to add possibility of .

🤖
GetPrice
API documentation
SetValue
customizing of your indicator via Input Parameters
How to install Quantower Algo
Github repository
New project window
Default source code for blank indicator
You can see your indicator in Indicator Lookup
You will see all your changes right after rebuild