Multiple Tools

The 'External Script' block can accept several tools. In this case, the script class must inherit from the IExternalScriptMultiSec interface. There are two options for connecting blocks.

Option 1:

For each instrument, add the 'Traded instrument' block. Connect each block to the 'External Script' block. In this way, you can connect up to 50 sources to an external script.

Option 2:

Add a block 'Multi-source', select the necessary tools in it. Multi-source connect with 'External Script' blocks.

In the example, 'Tool by number' blocks are added. This block extracts the instrument by the specified number from the multi-source and feeds it to the chart panel. This block can be omitted if the script (c#) itself displays charts.

Script example:

The Execute method receives an array of instruments (ISecurity[]). Let's display a list of tool names in the log.

using System.Text;
using TSLab.Script;
using TSLab.Script.Handlers;

namespace MyLib
    public class MultiSecurities : IExternalScriptMultiSec
        public void Execute(IContext ctx, ISecurity[] securities)
            var sb = new StringBuilder();
            for (int i = 0; i < securities.Length; i++)
                sb.Append($"{i + 1}.{securities[i].Symbol}; ");
            ctx.Log(sb.ToString(), MessageType.Info, true);


Last updated