diff --git a/Robots/.samples.json b/Robots/.samples.json index 740ec5d..501fe3a 100644 --- a/Robots/.samples.json +++ b/Robots/.samples.json @@ -59,6 +59,9 @@ { "name": "Commodity Channel Index Sample" }, + { + "name": "Compilation Robot" + }, { "name": "CoordinatesConversion Sample" }, diff --git a/Robots/Compilation Robot/Compilation Robot.sln b/Robots/Compilation Robot/Compilation Robot.sln new file mode 100644 index 0000000..913398c --- /dev/null +++ b/Robots/Compilation Robot/Compilation Robot.sln @@ -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}") = "Compilation Robot", "Compilation Robot\Compilation Robot.csproj", "{569816c4-6ab8-4c81-aa59-b13056da93b1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {569816c4-6ab8-4c81-aa59-b13056da93b1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {569816c4-6ab8-4c81-aa59-b13056da93b1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {569816c4-6ab8-4c81-aa59-b13056da93b1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {569816c4-6ab8-4c81-aa59-b13056da93b1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Robots/Compilation Robot/Compilation Robot/Compilation Robot.cs b/Robots/Compilation Robot/Compilation Robot/Compilation Robot.cs new file mode 100644 index 0000000..6076972 --- /dev/null +++ b/Robots/Compilation Robot/Compilation Robot/Compilation Robot.cs @@ -0,0 +1,38 @@ +// ------------------------------------------------------------------------------------------------- +// +// This code is a cTrader Algo API example. +// +// The code is provided as a sample only and does not guarantee any particular outcome or profit of any kind. Use it at your own risk. +// +// This example cBot generates and saves algorithms by compiling .csproj files. +// +// ------------------------------------------------------------------------------------------------- + + + + +using System; +using cAlgo.API; +using cAlgo.API.Collections; +using cAlgo.API.Indicators; +using cAlgo.API.Internals; + +namespace cAlgo.Robots +{ + [Robot(AccessRights = AccessRights.FullAccess)] + public class CompilationRobot : Robot + { + + protected override void OnStart() + { + CompilationOptions options = new CompilationOptions + { + IncludeSourceCode = true, + OutputAlgoFilePath = @"C:\Users\{preferred path}\NameOfAlgo.algo" + }; + + CompilationResult resultSync = Compiler.Compile(@"C:\Users\{path to project}\NameOfCbot.csproj", options); + Print(resultSync.Succeeded); + } + } +} diff --git a/Robots/Compilation Robot/Compilation Robot/Compilation Robot.csproj b/Robots/Compilation Robot/Compilation Robot/Compilation Robot.csproj new file mode 100644 index 0000000..51ac844 --- /dev/null +++ b/Robots/Compilation Robot/Compilation Robot/Compilation Robot.csproj @@ -0,0 +1,9 @@ + + + net6.0 + + + + + +