2. Basic Definitions

From MultiCharts
Jump to: navigation, search
NOTE: Both indicators and signals can be referred to as studies or techniques.

Indicator

Insert Study

Indicators in MultiCharts .NET allow the user to analyze price and trade information and to graphically display it on the chart. To add an Indicator on a chart, right-click on the chart, click Insert Study, select the Indicator tab, then select the required Indicator and click OK.


For example, the ADX indicator calculation results will appear in a graph displayed at the bottom of the chart.


In MultiCharts .NET indicators are objects of the class, inherited from IndicatorObject class. Indicators, unlike other types of studies (functions, signals), can create and use plot objects (IPlotObject). These objects allow indicators to draw graphs, histograms, bars, etc. Before using plots, they should be created in the Create () method of indicator class using the AddPlot() method.

Here is an example of a simple indicator, which draws a gaps graph of day bars (the difference between the current bar open and the previous bar close in percent) in the form of histogram at the bottom of the chart:

public class DAY_GAP : IndicatorObject {
	public DAY_GAP(object _ctx):base(_ctx){}
	private IPlotObject plot_gap;//Plot object for graph drawing 
	protected override void Create() {
		//Adds a graph to the chart
		plot_gap = AddPlot(new PlotAttributes("GAP", EPlotShapes.Histogram, Color.Red));
	}
	protected override void CalcBar(){
		// Determines next bar plot value 
		plot_gap.Set(100*((Bars.Open[0] - Bars.Close[1])/Bars.Open[0]));
	}
}

Signal/Strategy

Format Objects

Trade strategies in MultiCharts .NET consist of one or several signals which are algorithms for order generation based on the analysis of price information on the chart.

For example, a strategy consists of one or more signals (algorithms) as shown in the chart below.

  • Bollinger_Bands_LE signal is an algorithm of order generation for long position entry.
  • Bollinger_Bands_SE signal is an algorithm of order generation for short position entry.
  • Profit_Target signal is an algorithm of profit fixation.
  • Stop_Loss is an algorithm protecting the position from a loss.


A signal is able to generate orders in accordance with a built-in algorithm, which will be executed by the strategy.

Signals have access to the information about the current condition and performance of a strategy.

To add a strategy with one or several signals to a chart:

  1. right clink on the chart,
  2. select Insert Study,
  3. select the Signals tab.

After the strategy calculation you can see markers of orders executed by the strategy. A report upon the results of strategy calculation can be found in the View menu in the Strategy Performance Report.

In MultiCharts .NET signals are objects of the class, inherited from SignalObject.

In the process of the signal calculation orders will be generated according to the algorithm as described in the CalcBar () method. These orders will subsequently be executed by the strategy.

Here is an example of a simple signal:

public class TestSignal : SignalObject 
{
	public TestSignal(object _ctx):base(_ctx){}
 
	// Declaring orders-objects
private IOrderMarket buy_order;
 
	protected override void Create() {
buy_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Buy));
}
 
	protected override void CalcBar(){
		// Signal’s algorithm
                //…………………………
                //Order Generation
		buy_order.Send();
	}
}

Inputs

Inputs in MultiCharts .NET are user-defined options of the studies. Almost no indicators or signals exist without them. Inputs in PowerLanguage .Net are a public property of a study class, marked with an attribute [Input]. There are different types of inputs: int, double, string, DateTime, Color, Enum.


An example of integral type input in the study:

[Input]
public int length { get; set; }


Now this input will be available in Format Study dialog on the Inputs tab under the name “length”. Input values, chosen by the user in “Format Study” dialog, become available in the protected override void StartCalc() class study method. Default values can be set in study constructor.
Example:

A study has one adjustable double type parameter:

public class Test : IndicatorObject {
	public Test(object _ctx):base(_ctx)	{
               Percent = 10; // Default value
	}
 
        [Input]
        public double Percent {get; set;}//Input in percent.
}