Multi-Plot Example

Author: Optuma Team Last updated: Jan 23, 2024 09:00

The following code is an example of how to create a multi plot with the custom tool scripting.

 //
 // Sample script for Optuma tool scripting
 //

 // This section is where variable are defined that need to be used in both the Init and Process procedures
 var
     Plot1 : TPlot;
     Plot2 : TPlot;
     Plot3 : TPlot;

 // DefineTool is where the settings for the Tool are defined
 // This procedure is called once when the tool is loaded
 // Normally this procedure does not need to be changed
 procedure DefineTool(Tool : TTool);
 begin
     Tool.Name := 'Multi Plots';
     Tool.Key := '210189E5-77AF-4616-B5A1-04829030C11E';
     Tool.MouseClicks := 1;
     Tool.Hint := '';
     Tool.ToolType := ttDataList;
 end;

 // Init is called to initialise the tool
 // This procedure is called once when the tool is added to a chart
 procedure Init(Tool : TTool);
 begin
     Plot1 := Tool.AddPlot('MA(Bars=200)');
     Plot1.Color := clBlue;
     Plot1.PlotStyle := Line; // possible values are (Line, Dot, Histogram, Step, Shaded)
     Plot1.FillColor := clBlue;

     Plot2 := Tool.AddPlot('MA(Bars=50)');
     Plot2.Color := clGreen;
     Plot2.PlotStyle := Line; // possible values are (Line, Dot, Histogram, Step, Shaded)
     Plot2.FillColor := clBlue;

     Plot3 := Tool.AddPlot('MA(Bars=25)');
     Plot3.Color := clRed;
     Plot3.PlotStyle := Line; // possible values are (Line, Dot, Histogram, Step, Shaded)
     Plot3.FillColor := clBlue;
 end;

 // Process is called to calculate and drawn the tool on screen
 // This procedure is called when new data is received or loaded and
 // when a selection point is moved by the user
 procedure Process(Tool : TTool; ProcessStart : Integer; ProcessEnd : Integer; DataIn : TDataList);
 begin
 end;

Discussion