using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using TSLab.DataSource; using TSLab.Script; using TSLab.Script.Control; using TSLab.Script.Handlers; using TSLab.Script.Optimization; using TSLab.Script.Realtime; namespace test { public class TestScript : IExternalScript { public BoolOptimProperty StopTrade = new BoolOptimProperty(false, false); public void Execute(IContext ctx, ISecurity sec) { IControlPane controlPane = ctx.CreateControlPane("Control Pane", "Control Pane", "Control Pane", false); controlPane.Visible = true; IControl control = controlPane.AddControl("StopTrade", "остановить торговлю", ControlParameterType.Checkbox, true, 0D, 0D, double.NaN, double.NaN, false, false, null, StopTrade, -1, -16777216); control.IsVisible = true; control.IsNeedRecalculate = true; var secRt = sec as ISecurityRt; if (StopTrade) { foreach (var order in secRt.Orders) if (order.IsActive) secRt.CancelOrder(order); return; } } } }