Charting

Estimated reading time: 1 min
The Machina Engine has an API for adding your own plots to the price chart generated by the backtest interface.

Plotter Method

The Plotter() method has a one-line structure:
Plotter(string chart, string series, decimal value, string color = "Green", SeriesType lineType = SeriesType.Line, LineStyleType lineStyleType = LineStyleType.Solid, int thickness = 1, bool requiresOwnChart = false) 
Provide the Plotter() with the following parameters: Group Name Serie Name Value (Y value at current bar) Color Serie Type Line Type Thickness / Size Whether a dedicated chart is required (if false or not set will be rendered over the main chart)

Plot on the Main Chart

To render two custom series on the main chart, for instance a Fast and a Slow Moving Average, see the following code example:
Plotter("Fast", "fast", fastMA, "red", SeriesType.Line, LineStyleType.Dashed, 2); 
Plotter("Slow", "slow", slowMA, "black", SeriesType.Line, LineStyleType.Solid, 2); 
The above code would provide this result on the main chart: [chart]

Plot in a Dedicated Area

Some indicators and oscillators, such as RSI, MFI, etc. and therefore should be plotted in a dedicated slot below the price chart. This can be achieved with the requiresOwnChart parameter set to true.
Plotter("RSI", "RSI", rsi, "navy", SeriesType.Line, LineStyleType.Solid, 2, true); 
As a result, we have our RSI being rendered below the main chart. [chart]

Series and Line Types

There are a few available options for different types of shapes and lines. ####
public enum SeriesType 
{ 
    Line, 
    Scatter, 
    Candle,
    Bar, 
    Flag, 
    StackedArea, 
    Pie, 
    Treemap 
}
public enum LineStyleType : int 
{ 
    Solid = 1, 
    Dashed = 2, 
    Dotted = 3, 
    Shapes = 4 
}
Was this article helpful?
Dislike 0
Views: 6