|
cAlgo
|
Some general info.
This manual is divided in the following sections:
cAlgo Reference Basics cAlgo is a new automated trading platform. It allows users to create Robots that implement your own trade strategies in forms of algorithms. In addition to robots, cAlgo can be used to create custom indicators. Many functions are vital for technical analysis of the current and previously income quotes, as well as some arithmetic and logic operations. They are included in cAlgo API along with the built-in cTrader indicators and order management commands. cAlgo source code editor is used for writing algorithms in C#. It helps users to create and immediately integrate their Robots and Custom Indicators to the platform. This guide contains a description of the core cAlgo API functions and allows finding the description of every element we use. cAlgo programs written in C# are divided into 2 types:
Robot is an automated trading system linked up to a certain chart. A Robot starts to run with every incoming tick for a given symbol. The Robot can trade from any account automatically sending orders directly to the server. Custom Indicator is a technical indicator written in addition to the built-in indicators. They cannot trade and are intended for implementing of analytical functions only.
Syntax cAlgo Editor supports C# with no restrictions (currently .NET Framework 4 is supported). It means that syntax, comments, keywords, data types, precedence rules etc are well-known C# ones. If you would like to see the reference on C# language please refer to Microsoft C# Reference at http://msdn.microsoft.com/en-us/library/kx37x362.aspx Special Functions
There are three special functions with pre-defined names in cAlgo for Robots:
OnStart() is an event handler to be called during the Robot initialization (when Robot is activated on the chart). If it is not available, no function will be called at initialization.
OnTick() is the basic event handler. It is called when the next tick has come. It is not recommended to call OnTick() function from OnStart() function as chart data, market prices, etc. can be incomplete by the moment of the Robot initialization.
OnStop() is an event handler to be called during deinitialization of the Robot (when Robot is stopped). If it is not available, no function will be called at deinitialization.
Sample:
[Robot("My Robot")] public class MyRobot : Robot { protected override void OnStart() { Put your initialization logic here }
protected override void OnTick() { Put your core logic here }
protected override void OnStop() { Put your deinitialization logic here } }
=== For custom indicators, there is 1 special function: Calculate(int index) it is called at recalculation after the indicator has been added to the chart and after the next tick has income. Standard API functions To allow users access to the information and to make Robots and Custom Indicators’ source code more simple to comprehend there is a number of predefined constants, enumerations, variables. In this document they are grouped by purpose.