Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30011.22
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MS_StartAllBots", "MS_StartAllBots\MS_StartAllBots.csproj", "{9242f644-de9a-43ea-9aae-3cfb338b375f}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9242f644-de9a-43ea-9aae-3cfb338b375f}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9242f644-de9a-43ea-9aae-3cfb338b375f}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9242f644-de9a-43ea-9aae-3cfb338b375f}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9242f644-de9a-43ea-9aae-3cfb338b375f}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using cAlgo.API; // Required for ChartManager, ChartFrame, Chart, IChartRobot
|
||||
using cAlgo.API.Collections;
|
||||
using cAlgo.API.Indicators;
|
||||
using cAlgo.API.Internals;
|
||||
|
||||
namespace cAlgo.Plugins
|
||||
{
|
||||
[Plugin(AccessRights = AccessRights.None)]
|
||||
public class MS_StartAllBots : Plugin
|
||||
{
|
||||
private const string TargetBotName = "MS_ExportTickData";
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
// Access the static ChartManager to get all open chart frames.
|
||||
// ChartManager.ChartFrames returns an IReadOnlyList<ChartFrame>.
|
||||
//var chartFrames = ChartManager;
|
||||
|
||||
// Iterate through each chart frame.
|
||||
foreach (var frame in ChartManager)
|
||||
{
|
||||
if( frame is ChartFrame )
|
||||
{
|
||||
var chartFrame = frame as ChartFrame;
|
||||
|
||||
// Each ChartFrame has a Chart property.
|
||||
var chart = chartFrame.Chart;
|
||||
|
||||
// It's good practice to ensure the chart object is not null.
|
||||
if (chart != null)
|
||||
{
|
||||
// Access all cBot instances (IChartRobot) attached to the current chart.
|
||||
// Chart.Robots returns an IReadOnlyList<IChartRobot>.
|
||||
var chartRobots = chart.Robots;
|
||||
|
||||
// Iterate through each cBot instance on the current chart.
|
||||
foreach (var chartRobot in chartRobots)
|
||||
{
|
||||
// Check if the cBot's template name matches the target name
|
||||
// and if the cBot instance is not currently running.
|
||||
if (chartRobot.Name == TargetBotName)
|
||||
{
|
||||
RobotState state = chartRobot.State;
|
||||
if( state == RobotState.Stopped )
|
||||
{
|
||||
var ppath = chartRobot.Parameters.First( p => p.Name == "DirectoryName" );
|
||||
if( ppath != null )
|
||||
{
|
||||
ppath.Value = "\\\\COFFEE\\TickData\\Pepperstone";
|
||||
chartRobot.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
{
|
||||
// Handle Plugin stop here if needed.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="cTrader.Automate" Version="*" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user