LogoLogo
  • Welcome to AMP Futures (USA) Help
  • Trading Platforms
    • Quantower
      • Shortcuts
        • Overview
      • Getting Started
        • What's new
        • Installation
        • First start
        • Add Exchanges-Symbols
          • Add New Micro Crude Oil (CME) Symbol - MCLE
        • Platform update
        • Backup & restore manager
        • Reset settings to default
        • You have found a bug. What’s next?
      • General Settings
        • Main Toolbar
        • Workspaces
        • Single Panel
        • Link panels
        • Binds
        • Group of panels
        • Templates
        • Set as Default
        • Symbols lookup
        • Table management
        • Setup Actions & Advanced filters
        • Alerts
        • General settings
      • Data-Feed Connections
        • Connection to CQG (AMP Futures)
          • Errors with CQG
      • Analytics Panels
        • Chart
          • Chart Overview
          • Chart Types
            • Tick chart
            • Time aggregation
            • Renko
            • Heiken Ashi
            • Kagi
            • Points & Figures
            • Range bars
            • Line break
            • Volume Bars
            • Reversal Bars
          • Chart Settings
          • Chart Trading
          • Chart overlays
          • Technical indicators
            • Channels
              • Donchian Channel
              • High Low Indicator
              • Round Numbers
              • Highest High
              • Lowest Low
              • Bollinger Bands
              • Bollinger Bands Flat
              • Price Channel
              • Keltner Channel
              • Moving Average Envelope
            • Moving averages
              • 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
              • Aroon Indicator
              • Moving Average Convergence/Divergence
              • Awesome Oscillator
              • Accelerator Oscillator
              • %R Larry Williams
              • Momentum
              • Rate of Change
              • Relative Strength Index (RSI) Indicator
              • Commodity Channel Index
            • Trend
              • Average Directional Movement Index (ADX) Indicator
              • Ichimoku Cloud Indicator
              • Directional Movement Index (DMI) Indicator
              • ZigZag
            • Volatility
              • Average True Range
              • Standard deviation
            • Volume
              • Delta Flow
              • Delta Rotation
              • Level2 indicator
          • Drawing Tools
          • Volume Analysis Tools | Volume Profiles | Footprint chart | VWAP
            • Cluster chart
            • Volume profiles
            • Time statistics
            • Time histogram
            • Historical Time & Sales
          • OHLC
          • Power Trades
          • VWAP | Volume Weighted Average Price
          • Anchored VWAP
        • Watchlist
        • Time & Sales
        • Price Statistic
        • DOM Surface
        • Option Analytics
        • TPO Profile Chart
      • Trading Panels
        • Multiple Order Entry
        • Order Entry
          • Algo Order Types
          • OCO (Multi-Level)
          • OCO (Post Fill)
          • Order Types
        • DOM Trader
          • How to setup DOM for Scalping
        • Market depth
        • Trading simulator
        • Market Replay
      • Portfolio Panels
        • Positions
        • Working Orders
        • Trades
        • Orders History
        • Synthetic Symbols
        • Historical Symbols
      • Information Panels
        • Account info
        • Symbol Info
        • Event Log
        • RSS
        • Reports
      • Miscellaneous
        • Symbol Mapping 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
      • Quantower Algo
        • Introduction
        • Install for Visual Studio
        • Strategy runner
        • 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 advanced aggregations
        • Access to symbol/account additional fields
      • Customization
        • Localization
      • FAQ
        • General Errors
Powered by GitBook
On this page
  • What is a Strategy?
  • Basic methods
  • OnCreated
  • OnRun
  • OnStop
  • OnRemove
  • OnGetMetrics
  • Example

Was this helpful?

  1. Trading Platforms
  2. Quantower
  3. Quantower Algo

Simple strategy

How to create you first strategy and run it the Quantower trading platform

PreviousSimple IndicatorNextInput Parameters

Last updated 4 years ago

Was this helpful?

In our previous articles, we showed you how to use Quantower Algo extension and write your own indicators. Now we show you how to create you first strategy and run it the Quantower trading platform.

See examples of some strategies, integrations and indicators in our

What is a Strategy?

We use the name "Strategy" for code, that can implement absolutely any logic and can be executed in Quantower. You can use strategies for the realization of trading algorithms, a specific logic of controlling closing orders (for example Trailing stop), for arbitrage between different connections, etc. We don't have any restrictions or limitations for this, moreover, we provide you access to almost all functions from our trading core.

Quantower Algo provides you with two predefined templates of strategies. We will start from a blank template, which contains only basic functions. Use "File -> New project" in the main menu of Visual Studio to open "New project" window. Type "Strategy" and you will see special project type for blank strategy:

New project window

You will get generated code with a few empty functions:

As you can see, this blank version is not related to any trading functionality - it is a just general code-basis. It is inherited of class Strategy, by this Quantower recognize that your code is compatible and can be executed in Quantower.

Basic methods

Let's go deep into the code - it contains a few methods:

OnCreated

Will be called when user select required strategy from Strategy lookup. Use this method to implement logic, that needs to be executed once on creation.

OnRun

Will be called when user press Run button in Strategy Runner panel. Use this method to set initial values before running.

OnStop

Will be called when user press Stop button in Strategy Runner panel. Use this method to clear state of your strategy (if required).

OnRemove

Will be called when user close Strategy Runner Panel or select another strategy. Use this method for final clearing used resources.

OnGetMetrics

Via this method, you can display the required information in the Strategy Panel and control your strategy. For example, you can display how many quotes were processes, or how many but or sell orders were sent, etc.

You don't need to add logic to all these methods, the most often used is a pair of OnRun/OnStop methods.

The most popular case is when you use strategy to implement some trading algorithm and you need only one instrument and one account for this. For this we have a predefined template - you can use it as a basis. Use "One symbol strategy" in "New project" window:

Now we have a little more code - strategy contains Symbol and Account input variables, which we described before. It subscribes to all type of quotes for selected symbol in OnRun() method and you can receive and process them if it required by your algorithm.

Example

Let's create some trivial example and try to run it in the Quantower platform. We will talk about retrieving current trading information and trading operations in our next articles, for the current moment, we just add counters for each type of quotes and strategy metrics for displaying in Strategy Runner panel. We will add examples of logs also - you should always use them, as it can help you to understand the current strategy state or display error information. You can specify a type of log: Info, Error or Trading.

int quotesCount = 0;int level2Count = 0;int lastCount = 0;​private void SymbolOnNewQuote(Symbol symbol, Quote quote){    quotesCount++;​    Log("Quotes received", StrategyLoggingLevel.Info);}​private void SymbolOnNewLevel2(Symbol symbol, Level2Quote level2, DOMQuote dom){    level2Count++;​    Log("Level2 received", StrategyLoggingLevel.Error);}​private void SymbolOnNewLast(Symbol symbol, Last last){    lastCount++;​    Log("Last received", StrategyLoggingLevel.Trading);}​protected override List<StrategyMetric> OnGetMetrics(){    List<StrategyMetric> result = base.OnGetMetrics();​    result.Add(new StrategyMetric() { Name = "Quotes count", FormattedValue = quotesCount.ToString() });    result.Add(new StrategyMetric() { Name = "Level2 count", FormattedValue = level2Count.ToString() });    result.Add(new StrategyMetric() { Name = "Last count", FormattedValue = lastCount.ToString() });​    return result;}

Build your project, and if your Quantower Algo is properly assigned to an instance of Quantower, your strategy will be automatically copied to an appropriate folder and you will see it in Strategy Lookup window:

You need to specify the required input parameters: symbol and account and then press the "Run" button. Now your strategy is running and you will see logs and metrics, that we have added:

It is a very simple example and it provides you only basic knowledge about how strategies are working in Quantower. In our further lessons, we will show you how to create real algorithms using analysis of your current trading portfolio and trading operations.

Source code for Strategy template
New Project window and One symbol strategy template
Now your strategy is available in the Strategies Lookup
Strategy runner panel with our running strategy
Github repository