@@ -64,40 +64,41 @@ function updateValues(data){
");
- Account.Switched += Account_Switched;
- }
+ Account.Switched += Account_Switched;
+ }
- private void webView_NavigationCompleted(WebViewNavigationCompletedEventArgs obj)
- {
- UpdateAccountInfo();
- }
+ private void webView_NavigationCompleted(WebViewNavigationCompletedEventArgs obj)
+ {
+ UpdateAccountInfo();
+ }
- private void Account_Switched(AccountSwitchedEventArgs obj)
- {
- UpdateAccountInfo();
- }
+ private void Account_Switched(AccountSwitchedEventArgs obj)
+ {
+ UpdateAccountInfo();
+ }
- private void webView_WebMessageReceived(WebViewWebMessageReceivedEventArgs args)
+ private void webView_WebMessageReceived(WebViewWebMessageReceivedEventArgs args)
+ {
+ if (args.Message == @"""close all message""")
+ {
+ foreach (var position in Positions)
{
- if (args.Message == @"""close all message""")
- {
- foreach (var position in Positions)
- {
- position.Close();
- }
- }
+ position.Close();
}
+ }
+ }
- private void UpdateAccountInfo()
- {
- var data = new {
- ctid = Account.UserId,
- account = Account.Number,
- broker = Account.BrokerName,
- };
- var dataJson = System.Text.Json.JsonSerializer.Serialize(data);
-
- webView.ExecuteScript("updateValues(" + dataJson +")");
- }
- }
+ private void UpdateAccountInfo()
+ {
+ var data = new
+ {
+ ctid = Account.UserId,
+ account = Account.Number,
+ broker = Account.BrokerName,
+ };
+ var dataJson = System.Text.Json.JsonSerializer.Serialize(data);
+
+ webView.ExecuteScript("updateValues(" + dataJson + ")");
+ }
+ }
}
\ No newline at end of file
diff --git a/Plugins/My ASP Example/My ASP Example/My ASP Example.cs b/Plugins/My ASP Example/My ASP Example/My ASP Example.cs
index 9d4128b..77cf506 100644
--- a/Plugins/My ASP Example/My ASP Example/My ASP Example.cs
+++ b/Plugins/My ASP Example/My ASP Example/My ASP Example.cs
@@ -2,11 +2,12 @@
//
// This code is a cTrader Algo API example.
//
-// This code is intended to be used as a sample and does not guarantee any particular outcome or
-// profit of any kind. Use it at your own risk.
+// 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 plugin adds a new section to the Active Symbol Panel (ASP), with styles applied to the plugin controls.
//
+// For a detailed tutorial on creating this plugin, watch the video at: https://www.youtube.com/watch?v=WRwhT7jxTNs
+//
// -------------------------------------------------------------------------------------------------
using System;
diff --git a/Plugins/My Custom Frame Example/My Custom Frame Example.sln b/Plugins/My Custom Frame Example/My Custom Frame Example.sln
new file mode 100644
index 0000000..dd62670
--- /dev/null
+++ b/Plugins/My Custom Frame Example/My Custom Frame Example.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}") = "My Custom Frame Example", "My Custom Frame Example\My Custom Frame Example.csproj", "{bcac2c14-878a-4dff-aea7-df2f6d634f09}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {bcac2c14-878a-4dff-aea7-df2f6d634f09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {bcac2c14-878a-4dff-aea7-df2f6d634f09}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {bcac2c14-878a-4dff-aea7-df2f6d634f09}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {bcac2c14-878a-4dff-aea7-df2f6d634f09}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.cs b/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.cs
new file mode 100644
index 0000000..f0a6c2c
--- /dev/null
+++ b/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.cs
@@ -0,0 +1,57 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 plugin adds two custom frames to the charts area, displaying two different websites.
+//
+// For a detailed tutorial on creating this plugin, watch the video at: [to:do]
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Plugins
+{
+ [Plugin(AccessRights = AccessRights.None)]
+ public class MyCustomFrameExample : Plugin
+ {
+ WebView _cTraderWebView = new WebView();
+ WebView _cTraderWebViewSite = new WebView();
+
+ protected override void OnStart()
+ {
+ _cTraderWebView.Loaded += _cTraderWebView_Loaded;
+ var webViewFrame = ChartManager.AddCustomFrame("Forum");
+ webViewFrame.Child = _cTraderWebView;
+ webViewFrame.ChartContainer.Mode = ChartMode.Multi;
+ webViewFrame.Attach();
+
+ _cTraderWebViewSite.Loaded += _cTraderWebViewSite_Loaded;
+ var webViewFrameSite = ChartManager.AddCustomFrame("Site");
+ webViewFrameSite.Child = _cTraderWebViewSite;
+ webViewFrameSite.ChartContainer.Mode = ChartMode.Multi;
+ webViewFrameSite.Attach();
+ }
+
+ private void _cTraderWebView_Loaded(WebViewLoadedEventArgs args)
+ {
+ _cTraderWebView.NavigateAsync("https://www.ctrader.com/forum");
+ }
+
+ private void _cTraderWebViewSite_Loaded(WebViewLoadedEventArgs args)
+ {
+ _cTraderWebViewSite.NavigateAsync("https://www.spotware.com");
+ }
+
+ protected override void OnStop()
+ {
+ // Handle Plugin stop here
+ }
+ }
+}
\ No newline at end of file
diff --git a/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.csproj b/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Plugins/My Custom Frame Example/My Custom Frame Example/My Custom Frame Example.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Plugins/Order by Margin/Order by Margin/Order by Margin.cs b/Plugins/Order by Margin/Order by Margin/Order by Margin.cs
index 43613d0..42e96a2 100644
--- a/Plugins/Order by Margin/Order by Margin/Order by Margin.cs
+++ b/Plugins/Order by Margin/Order by Margin/Order by Margin.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This code is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -18,17 +18,17 @@ namespace cAlgo.Plugins
[Plugin(AccessRights = AccessRights.None)]
public class OrderByMargin : Plugin
{
- TextBlock availableMarginTextBlock = new TextBlock();
- TextBlock quantityToTradeTextBlock = new TextBlock();
+ TextBlock availableMarginTextBlock = new TextBlock();
+ TextBlock quantityToTradeTextBlock = new TextBlock();
ViewModel viewModel = new ViewModel();
TextBox tradeableMarginTextBox;
-
+
protected override void OnStart()
{
viewModel.Changed += viewModel_Changed;
-
+
AddControls();
-
+
Positions.Opened += Positions_Opened;
Positions.Closed += Positions_Closed;
Positions.Modified += Positions_Modified;
@@ -52,9 +52,8 @@ private void AspSymbolTab_SymbolChanged(AspSymbolChangedEventArgs obj)
private void AddControls()
{
var block = Asp.SymbolTab.AddBlock("New Order by Margin");
- block.IsExpanded = true;
+
block.IsDetachable = false;
- block.Index = 1;
block.Height = 150;
var rootStackPanel = new StackPanel { Margin = new Thickness(10) };
@@ -96,18 +95,18 @@ private void AddControls()
volumeStackPanel.AddChild(quantityToTradeTextBlock);
volumeStackPanel.AddChild(new TextBlock { Text = " Lots" });
rootStackPanel.AddChild(volumeStackPanel);
-
- var tradeButtons = new StackPanel{Orientation = Orientation.Horizontal, Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Center};
+
+ var tradeButtons = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Center };
tradeButtons.AddChild(CreateTradeButton("Sell", Styles.CreateSellButtonStyle(), TradeType.Sell));
tradeButtons.AddChild(CreateTradeButton("Buy", Styles.CreateBuyButtonStyle(), TradeType.Buy));
rootStackPanel.AddChild(tradeButtons);
block.Child = rootStackPanel;
}
-
+
private Button CreateTradeButton(string text, Style style, TradeType tradeType)
{
- var tradeButton = new Button
+ var tradeButton = new Button
{
Text = text,
Style = style,
@@ -129,10 +128,10 @@ private void increaseMarginButton_Click(ButtonClickEventArgs obj)
{
var symbol = Asp.SymbolTab.Symbol;
var leverage = Math.Min(symbol.DynamicLeverage[0].Leverage, Account.PreciseLeverage);
-
+
if (viewModel.Quantity > symbol.VolumeInUnitsMax / symbol.LotSize)
return;
-
+
viewModel.Quantity += symbol.VolumeInUnitsMin / symbol.LotSize;
RecalculateMargin(viewModel.Quantity);
}
@@ -141,16 +140,16 @@ private void decreaseMarginButton_Click(ButtonClickEventArgs obj)
{
var symbol = Asp.SymbolTab.Symbol;
var leverage = Math.Min(symbol.DynamicLeverage[0].Leverage, Account.PreciseLeverage);
-
+
if (viewModel.Quantity <= symbol.VolumeInUnitsMin / symbol.LotSize)
return;
-
+
viewModel.Quantity -= symbol.VolumeInUnitsMin / symbol.LotSize;
RecalculateMargin(viewModel.Quantity);
}
private void viewModel_Changed()
- {
+ {
availableMarginTextBlock.Text = Math.Floor(viewModel.AvailableMargin).ToString() + " " + Account.Asset.Name;
quantityToTradeTextBlock.Text = Math.Round(viewModel.Quantity, 2).ToString();
tradeableMarginTextBox.Text = viewModel.MarginToTrade.ToString();
@@ -175,28 +174,28 @@ private void UpdateAvailableMargin()
{
viewModel.AvailableMargin = Account.FreeMargin;
}
-
+
private void SetMaximumMargin()
{
var symbol = Asp.SymbolTab.Symbol;
- var leverage = Math.Min(symbol.DynamicLeverage[0].Leverage, Account.PreciseLeverage);
+ var leverage = Math.Min(symbol.DynamicLeverage[0].Leverage, Account.PreciseLeverage);
var volume = Account.Asset.Convert(symbol.BaseAsset, Account.FreeMargin * leverage);
var tradeableVolume = symbol.NormalizeVolumeInUnits(volume, RoundingMode.Down);
-
- viewModel.Quantity = tradeableVolume / symbol.LotSize;
+
+ viewModel.Quantity = tradeableVolume / symbol.LotSize;
viewModel.MarginToTrade = symbol.BaseAsset.Convert(Account.Asset, tradeableVolume / leverage);
}
private void RecalculateMargin(double quantity)
{
var symbol = Asp.SymbolTab.Symbol;
var leverage = Math.Min(symbol.DynamicLeverage[0].Leverage, Account.PreciseLeverage);
-
+
var volume = quantity * symbol.LotSize;
var margin = symbol.BaseAsset.Convert(Account.Asset, volume / leverage);
viewModel.MarginToTrade = Math.Floor(margin);
}
- }
-
+ }
+
public static class Styles
{
public static Style CreateBuyButtonStyle()
@@ -219,57 +218,57 @@ private static Style CreateButtonStyle(Color color, Color hoverColor)
style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.DarkTheme);
style.Set(ControlProperty.ForegroundColor, Color.FromHex("#FFFFFF"), ControlState.LightTheme);
style.Set(ControlProperty.Width, 100);
- style.Set(ControlProperty.Margin, new Thickness(5,0,5,0));
+ style.Set(ControlProperty.Margin, new Thickness(5, 0, 5, 0));
return style;
}
}
-
-
+
+
class ViewModel
{
private double _availableMargin;
public double AvailableMargin
{
- get { return _availableMargin; }
- set
+ get { return _availableMargin; }
+ set
{
if (value == _availableMargin)
return;
_availableMargin = value;
-
+
Changed?.Invoke();
}
}
-
+
private double _quantity;
public double Quantity
{
- get { return _quantity; }
- set
+ get { return _quantity; }
+ set
{
if (value == _quantity)
return;
_quantity = value;
-
+
Changed?.Invoke();
}
}
-
+
private double _marginToTrade;
public double MarginToTrade
{
- get { return _marginToTrade; }
- set
+ get { return _marginToTrade; }
+ set
{
if (value == _marginToTrade)
return;
_marginToTrade = value;
-
+
Changed?.Invoke();
}
}
-
-
+
+
public event Action Changed;
}
}
\ No newline at end of file
diff --git a/Plugins/Previous Bar Info/Previous Bar Info.sln b/Plugins/Previous Bar Info/Previous Bar Info.sln
new file mode 100644
index 0000000..86e5502
--- /dev/null
+++ b/Plugins/Previous Bar Info/Previous Bar Info.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}") = "Previous Bar Info", "Previous Bar Info\Previous Bar Info.csproj", "{745f073c-3ae0-4138-a7ef-5f56c8c43c40}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {745f073c-3ae0-4138-a7ef-5f56c8c43c40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {745f073c-3ae0-4138-a7ef-5f56c8c43c40}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {745f073c-3ae0-4138-a7ef-5f56c8c43c40}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {745f073c-3ae0-4138-a7ef-5f56c8c43c40}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.cs b/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.cs
new file mode 100644
index 0000000..52d7806
--- /dev/null
+++ b/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.cs
@@ -0,0 +1,106 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 plugin adds a new section to Trade Watch, featuring a two-by-two grid that displays information about the last known bar prices.
+//
+// For a detailed tutorial on creating this plugin, watch the video at: https://youtu.be/0HB-rdwpMAY
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Plugins
+{
+ [Plugin(AccessRights = AccessRights.None)]
+ public class PreviousBarInfo : Plugin
+ {
+
+ Bars _bars;
+ Grid _grid;
+ TextBlock _lowBlock;
+ TextBlock _openBlock;
+ TextBlock _highBlock;
+ TextBlock _closeBlock;
+
+ protected override void OnStart()
+ {
+ var tradeWatchTab = TradeWatch.AddTab("Previous Bar Info");
+ tradeWatchTab.IsSelected = true;
+
+ var webView = new WebView();
+ tradeWatchTab.Child = webView;
+
+ webView.NavigateAsync("https://ctrader.com/");
+
+ _grid = new Grid(2, 2)
+ {
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ ShowGridLines = true,
+ Height = 150,
+ Width = 150,
+ };
+
+ _bars = MarketData.GetBars(TimeFrame.Minute, "USDJPY");
+
+ _lowBlock = new TextBlock
+ {
+ Text = "Low:" + _bars.LowPrices.LastValue,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
+
+ _highBlock = new TextBlock
+ {
+ Text = "High:" + _bars.HighPrices.LastValue,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
+
+ _closeBlock = new TextBlock
+ {
+ Text = "Close:" +_bars.ClosePrices.LastValue,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
+
+ _openBlock = new TextBlock
+ {
+ Text = "Open:" + _bars.OpenPrices.LastValue,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ };
+
+ _grid.AddChild(_lowBlock, 0, 0);
+ _grid.AddChild(_highBlock, 0, 1);
+ _grid.AddChild(_openBlock, 1, 0);
+ _grid.AddChild(_closeBlock, 1, 1);
+
+ tradeWatchTab.Child = _grid;
+
+ _bars.Tick += _bars_Tick;
+
+
+ }
+
+ private void _bars_Tick(BarsTickEventArgs obj)
+ {
+ _lowBlock.Text = "Low: " +_bars.LowPrices.LastValue.ToString();
+ _highBlock.Text = "High: " +_bars.HighPrices.LastValue.ToString();
+ _openBlock.Text = "Open: " +_bars.OpenPrices.LastValue.ToString();
+ _closeBlock.Text = "Close: " +_bars.ClosePrices.LastValue.ToString();
+ }
+
+ protected override void OnStop()
+ {
+ // Handle Plugin stop here
+ }
+ }
+}
\ No newline at end of file
diff --git a/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.csproj b/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Plugins/Previous Bar Info/Previous Bar Info/Previous Bar Info.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/README.md b/README.md
index 9b1cad5..72d3530 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
-# cTrader Automate API Samples
-cBot / Indicator Samples of cTrader Automate API
+# cTrader Algo API Samples
+cBot / Indicator Samples of cTrader Algo API
diff --git a/Robots/.samples.json b/Robots/.samples.json
index 740ec5d..3794733 100644
--- a/Robots/.samples.json
+++ b/Robots/.samples.json
@@ -5,6 +5,9 @@
{
"name": "Accumulative Swing Index Sample"
},
+ {
+ "name": "Add Indicator Sample"
+ },
{
"name": "AddToChart Sample"
},
@@ -59,6 +62,9 @@
{
"name": "Commodity Channel Index Sample"
},
+ {
+ "name": "Compilation Robot"
+ },
{
"name": "CoordinatesConversion Sample"
},
@@ -77,6 +83,9 @@
{
"name": "Directional Movement System Sample"
},
+ {
+ "name": "Discord Message Example"
+ },
{
"name": "Donchian Channel Sample"
},
@@ -161,6 +170,9 @@
{
"name": "Partial Close Sample"
},
+ {
+ "name": "Patterns Strategy Sample"
+ },
{
"name": "Pending Order Cancelation Sample"
},
@@ -227,6 +239,9 @@
{
"name": "Relative Strength Index Sample"
},
+ {
+ "name": "RSI Reversal Strategy Sample"
+ },
{
"name": "Running Mode Sample"
},
@@ -239,6 +254,9 @@
{
"name": "Standard Deviation Sample"
},
+ {
+ "name": "Start cBot Sample"
+ },
{
"name": "Stochastic Oscillator Sample"
},
@@ -299,6 +317,9 @@
{
"name": "Volume ROC Sample"
},
+ {
+ "name": "Web Sockets Sample"
+ },
{
"name": "WebSocket Sample"
},
diff --git a/Robots/Accelerator Oscillator Sample/Accelerator Oscillator Sample/Accelerator Oscillator Sample.cs b/Robots/Accelerator Oscillator Sample/Accelerator Oscillator Sample/Accelerator Oscillator Sample.cs
index e9bffd4..08a1403 100644
--- a/Robots/Accelerator Oscillator Sample/Accelerator Oscillator Sample/Accelerator Oscillator Sample.cs
+++ b/Robots/Accelerator Oscillator Sample/Accelerator Oscillator Sample/Accelerator Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Accumulative Swing Index Sample/Accumulative Swing Index Sample/Accumulative Swing Index Sample.cs b/Robots/Accumulative Swing Index Sample/Accumulative Swing Index Sample/Accumulative Swing Index Sample.cs
index 3afe36c..19cf9ff 100644
--- a/Robots/Accumulative Swing Index Sample/Accumulative Swing Index Sample/Accumulative Swing Index Sample.cs
+++ b/Robots/Accumulative Swing Index Sample/Accumulative Swing Index Sample/Accumulative Swing Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -30,10 +30,10 @@ public class AccumulativeSwingIndexSample : Robot
[Parameter("Label", DefaultValue = "AccumulativeSwingIndexSample")]
public string Label { get; set; }
-
+
[Parameter("Limit Move Value", DefaultValue = 12, Group = "Accumulative Swing Index", MinValue = 0)]
public int LimitMoveValue { get; set; }
-
+
public Position[] BotPositions
{
get
diff --git a/Robots/Add Indicator Sample/Add Indicator Sample.sln b/Robots/Add Indicator Sample/Add Indicator Sample.sln
new file mode 100644
index 0000000..f47d4da
--- /dev/null
+++ b/Robots/Add Indicator Sample/Add Indicator Sample.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}") = "Add Indicator Sample", "Add Indicator Sample\Add Indicator Sample.csproj", "{1751be77-fe78-4e12-b558-7fb418ed6b44}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.cs b/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.cs
new file mode 100644
index 0000000..92265c5
--- /dev/null
+++ b/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.cs
@@ -0,0 +1,93 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 sample cBot adds two moving averages for trading to a chart.
+//
+// For a detailed tutorial on creating this cBot, see this video: https://www.youtube.com/watch?v=DUzdEt30OSE
+//
+// -------------------------------------------------------------------------------------------------
+
+
+using cAlgo.API;
+using cAlgo.API.Indicators;
+
+namespace cAlgo
+{
+ [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, AddIndicators = true)]
+ public class SampleTrendcBot : Robot
+ {
+ [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
+ public double Quantity { get; set; }
+
+ [Parameter("MA Type", Group = "Moving Average")]
+ public MovingAverageType MAType { get; set; }
+
+ [Parameter("Source", Group = "Moving Average")]
+ public DataSeries SourceSeries { get; set; }
+
+ [Parameter("Slow Periods", Group = "Moving Average", DefaultValue = 10)]
+ public int SlowPeriods { get; set; }
+
+ [Parameter("Fast Periods", Group = "Moving Average", DefaultValue = 5)]
+ public int FastPeriods { get; set; }
+
+ private MovingAverage slowMa;
+ private MovingAverage fastMa;
+ private const string label = "Sample Trend cBot";
+
+ ChartIndicator _indicator1;
+ ChartIndicator _indicator2;
+
+ protected override void OnStart()
+ {
+ fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
+ slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
+
+ _indicator1 = Chart.Indicators.Add("Simple Moving Average", SourceSeries, FastPeriods, MAType);
+ _indicator2 = Chart.Indicators.Add("Simple Moving Average", SourceSeries, SlowPeriods, MAType);
+
+ _indicator1.Lines[0].Color = Color.Red;
+ _indicator1.Lines[0].Thickness = 3;
+ }
+
+ protected override void OnBarClosed()
+ {
+ Chart.Indicators.Remove(_indicator1);
+ Chart.Indicators.Remove(_indicator2);
+ }
+
+ protected override void OnTick()
+ {
+ var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);
+ var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);
+
+ var currentSlowMa = slowMa.Result.Last(0);
+ var currentFastMa = fastMa.Result.Last(0);
+ var previousSlowMa = slowMa.Result.Last(1);
+ var previousFastMa = fastMa.Result.Last(1);
+
+ if (previousSlowMa > previousFastMa && currentSlowMa <= currentFastMa && longPosition == null)
+ {
+ if (shortPosition != null)
+ ClosePosition(shortPosition);
+
+ ExecuteMarketOrder(TradeType.Buy, SymbolName, VolumeInUnits, label);
+ }
+ else if (previousSlowMa < previousFastMa && currentSlowMa >= currentFastMa && shortPosition == null)
+ {
+ if (longPosition != null)
+ ClosePosition(longPosition);
+
+ ExecuteMarketOrder(TradeType.Sell, SymbolName, VolumeInUnits, label);
+ }
+ }
+
+ private double VolumeInUnits
+ {
+ get { return Symbol.QuantityToVolumeInUnits(Quantity); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.csproj b/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/Add Indicator Sample/Add Indicator Sample/Add Indicator Sample.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Alligator Sample/Alligator Sample/Alligator Sample.cs b/Robots/Alligator Sample/Alligator Sample/Alligator Sample.cs
index 30e3570..9ddfc29 100644
--- a/Robots/Alligator Sample/Alligator Sample/Alligator Sample.cs
+++ b/Robots/Alligator Sample/Alligator Sample/Alligator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Aroon Sample/Aroon Sample/Aroon Sample.cs b/Robots/Aroon Sample/Aroon Sample/Aroon Sample.cs
index a990203..6b98738 100644
--- a/Robots/Aroon Sample/Aroon Sample/Aroon Sample.cs
+++ b/Robots/Aroon Sample/Aroon Sample/Aroon Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample.cs b/Robots/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample.cs
index a4c6b3d..ad7f4de 100644
--- a/Robots/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample.cs
+++ b/Robots/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample/Average Directional Movement Index Rating Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -33,7 +33,7 @@ public class AverageDirectionalMovementIndexRatingSample : Robot
[Parameter("Periods", DefaultValue = 14, Group = "Average Directional Movement Index Ratin")]
public int Periods { get; set; }
-
+
[Parameter("ADXR Level", DefaultValue = 25, Group = "Average Directional Movement Index Ratin")]
public int ADXRLevel { get; set; }
diff --git a/Robots/Average True Range Sample/Average True Range Sample/Average True Range Sample.cs b/Robots/Average True Range Sample/Average True Range Sample/Average True Range Sample.cs
index a0f3478..ace4bbf 100644
--- a/Robots/Average True Range Sample/Average True Range Sample/Average True Range Sample.cs
+++ b/Robots/Average True Range Sample/Average True Range Sample/Average True Range Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Awesome Oscillator Sample/Awesome Oscillator Sample/Awesome Oscillator Sample.cs b/Robots/Awesome Oscillator Sample/Awesome Oscillator Sample/Awesome Oscillator Sample.cs
index e66eda8..4a4cc0c 100644
--- a/Robots/Awesome Oscillator Sample/Awesome Oscillator Sample/Awesome Oscillator Sample.cs
+++ b/Robots/Awesome Oscillator Sample/Awesome Oscillator Sample/Awesome Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Bollinger Bands Sample/Bollinger Bands Sample/Bollinger Bands Sample.cs b/Robots/Bollinger Bands Sample/Bollinger Bands Sample/Bollinger Bands Sample.cs
index a9c0221..0d4fa79 100644
--- a/Robots/Bollinger Bands Sample/Bollinger Bands Sample/Bollinger Bands Sample.cs
+++ b/Robots/Bollinger Bands Sample/Bollinger Bands Sample/Bollinger Bands Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Center Of Gravity Sample/Center Of Gravity Sample/Center Of Gravity Sample.cs b/Robots/Center Of Gravity Sample/Center Of Gravity Sample/Center Of Gravity Sample.cs
index 5eb1773..0395aa7 100644
--- a/Robots/Center Of Gravity Sample/Center Of Gravity Sample/Center Of Gravity Sample.cs
+++ b/Robots/Center Of Gravity Sample/Center Of Gravity Sample/Center Of Gravity Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Chaikin Money Flow Sample/Chaikin Money Flow Sample/Chaikin Money Flow Sample.cs b/Robots/Chaikin Money Flow Sample/Chaikin Money Flow Sample/Chaikin Money Flow Sample.cs
index a85376c..216ce65 100644
--- a/Robots/Chaikin Money Flow Sample/Chaikin Money Flow Sample/Chaikin Money Flow Sample.cs
+++ b/Robots/Chaikin Money Flow Sample/Chaikin Money Flow Sample/Chaikin Money Flow Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Chaikin Volatility Sample/Chaikin Volatility Sample/Chaikin Volatility Sample.cs b/Robots/Chaikin Volatility Sample/Chaikin Volatility Sample/Chaikin Volatility Sample.cs
index 52eec95..0e5dd52 100644
--- a/Robots/Chaikin Volatility Sample/Chaikin Volatility Sample/Chaikin Volatility Sample.cs
+++ b/Robots/Chaikin Volatility Sample/Chaikin Volatility Sample/Chaikin Volatility Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Close All On Market Close Sample/Close All On Market Close Sample/Close All On Market Close Sample.cs b/Robots/Close All On Market Close Sample/Close All On Market Close Sample/Close All On Market Close Sample.cs
index eb61542..e49c4dd 100644
--- a/Robots/Close All On Market Close Sample/Close All On Market Close Sample/Close All On Market Close Sample.cs
+++ b/Robots/Close All On Market Close Sample/Close All On Market Close Sample/Close All On Market Close Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Commodity Channel Index Sample/Commodity Channel Index Sample/Commodity Channel Index Sample.cs b/Robots/Commodity Channel Index Sample/Commodity Channel Index Sample/Commodity Channel Index Sample.cs
index a6d96f2..6b57c15 100644
--- a/Robots/Commodity Channel Index Sample/Commodity Channel Index Sample/Commodity Channel Index Sample.cs
+++ b/Robots/Commodity Channel Index Sample/Commodity Channel Index Sample/Commodity Channel Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
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
+
+
+
+
+
+
diff --git a/Robots/Custom Fitness Functions/Custom Fitness Functions/Custom Fitness Functions.cs b/Robots/Custom Fitness Functions/Custom Fitness Functions/Custom Fitness Functions.cs
index 9470485..649397b 100644
--- a/Robots/Custom Fitness Functions/Custom Fitness Functions/Custom Fitness Functions.cs
+++ b/Robots/Custom Fitness Functions/Custom Fitness Functions/Custom Fitness Functions.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -82,7 +82,7 @@ private double VolumeInUnits
protected override double GetFitness(GetFitnessArgs args)
{
- if(args.TotalTrades > 20 && args.MaxEquityDrawdownPercentages < 50)
+ if (args.TotalTrades > 20 && args.MaxEquityDrawdownPercentages < 50)
{
return Math.Pow(args.WinningTrades + 1, 2) / (args.LosingTrades + 1);
}
diff --git a/Robots/Cyber Cycle Sample/Cyber Cycle Sample/Cyber Cycle Sample.cs b/Robots/Cyber Cycle Sample/Cyber Cycle Sample/Cyber Cycle Sample.cs
index b02f3a4..33aa3c5 100644
--- a/Robots/Cyber Cycle Sample/Cyber Cycle Sample/Cyber Cycle Sample.cs
+++ b/Robots/Cyber Cycle Sample/Cyber Cycle Sample/Cyber Cycle Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample.cs b/Robots/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample.cs
index 2cdc6b1..19b8975 100644
--- a/Robots/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample.cs
+++ b/Robots/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample/Detrended Price Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Directional Movement System Sample/Directional Movement System Sample/Directional Movement System Sample.cs b/Robots/Directional Movement System Sample/Directional Movement System Sample/Directional Movement System Sample.cs
index 116d6e4..5f4753e 100644
--- a/Robots/Directional Movement System Sample/Directional Movement System Sample/Directional Movement System Sample.cs
+++ b/Robots/Directional Movement System Sample/Directional Movement System Sample/Directional Movement System Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Discord Message Example/Discord Message Example.sln b/Robots/Discord Message Example/Discord Message Example.sln
new file mode 100644
index 0000000..e891495
--- /dev/null
+++ b/Robots/Discord Message Example/Discord Message Example.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}") = "Discord Message Example", "Discord Message Example\Discord Message Example.csproj", "{4fff20d4-4ec9-4c51-ae35-32c172c2cb2b}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4fff20d4-4ec9-4c51-ae35-32c172c2cb2b}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4fff20d4-4ec9-4c51-ae35-32c172c2cb2b}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4fff20d4-4ec9-4c51-ae35-32c172c2cb2b}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4fff20d4-4ec9-4c51-ae35-32c172c2cb2b}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/Discord Message Example/Discord Message Example/Discord Message Example - Backup.csproj b/Robots/Discord Message Example/Discord Message Example/Discord Message Example - Backup.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/Discord Message Example/Discord Message Example/Discord Message Example - Backup.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Discord Message Example/Discord Message Example/Discord Message Example.cs b/Robots/Discord Message Example/Discord Message Example/Discord Message Example.cs
new file mode 100644
index 0000000..d3ecbcc
--- /dev/null
+++ b/Robots/Discord Message Example/Discord Message Example/Discord Message Example.cs
@@ -0,0 +1,56 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 send messages to a Discord channel.
+//
+// For a detailed tutorial on creating this cBot, watch the video at: https://youtu.be/NhEeySAKZUo
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+using Discord.WebSocket;
+using Discord;
+
+namespace cAlgo.Robots
+{
+ [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
+ public class DiscordMessageExample : Robot
+ {
+ [Parameter("Discord Bot Token")]
+ public string BotToken { get; set; }
+
+ [Parameter("Discord Channel ID")]
+ public string ChannelID { get; set; }
+
+ DiscordSocketClient _discordSocketClient;
+ IMessageChannel _channel;
+
+ protected override void OnStart()
+ {
+ _discordSocketClient = new DiscordSocketClient();
+ _discordSocketClient.LoginAsync(TokenType.Bot, BotToken);
+ _discordSocketClient.StartAsync();
+
+ var channelID = Convert.ToUInt64(ChannelID);
+ _channel = _discordSocketClient.GetChannelAsync(channelID).Result as IMessageChannel;
+ _channel.SendMessageAsync("Example cBot Started");
+ }
+
+ protected override void OnTick()
+ {
+ // Handle price updates here
+ }
+
+ protected override void OnStop()
+ {
+ // Handle cBot stop here
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/Discord Message Example/Discord Message Example/Discord Message Example.csproj b/Robots/Discord Message Example/Discord Message Example/Discord Message Example.csproj
new file mode 100644
index 0000000..544c69c
--- /dev/null
+++ b/Robots/Discord Message Example/Discord Message Example/Discord Message Example.csproj
@@ -0,0 +1,29 @@
+
+
+
+ net6.0
+
+
+
+
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.Commands.dll
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.Core.dll
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.Interactions.dll
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.Rest.dll
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.Webhook.dll
+
+
+ ..\..\..\..\..\..\..\..\Discord DLL Files\Discord.Net.WebSocket.dll
+
+
+
\ No newline at end of file
diff --git a/Robots/Donchian Channel Sample/Donchian Channel Sample/Donchian Channel Sample.cs b/Robots/Donchian Channel Sample/Donchian Channel Sample/Donchian Channel Sample.cs
index 5563cf1..5f6ff8e 100644
--- a/Robots/Donchian Channel Sample/Donchian Channel Sample/Donchian Channel Sample.cs
+++ b/Robots/Donchian Channel Sample/Donchian Channel Sample/Donchian Channel Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Ease Of Movement Sample/Ease Of Movement Sample/Ease Of Movement Sample.cs b/Robots/Ease Of Movement Sample/Ease Of Movement Sample/Ease Of Movement Sample.cs
index 09c4aed..47a0d18 100644
--- a/Robots/Ease Of Movement Sample/Ease Of Movement Sample/Ease Of Movement Sample.cs
+++ b/Robots/Ease Of Movement Sample/Ease Of Movement Sample/Ease Of Movement Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Error Sample/Error Sample/Error Sample.cs b/Robots/Error Sample/Error Sample/Error Sample.cs
index d75d108..a5b34bd 100644
--- a/Robots/Error Sample/Error Sample/Error Sample.cs
+++ b/Robots/Error Sample/Error Sample/Error Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Exponential Moving Average Sample/Exponential Moving Average Sample/Exponential Moving Average Sample.cs b/Robots/Exponential Moving Average Sample/Exponential Moving Average Sample/Exponential Moving Average Sample.cs
index f58e492..35d48c0 100644
--- a/Robots/Exponential Moving Average Sample/Exponential Moving Average Sample/Exponential Moving Average Sample.cs
+++ b/Robots/Exponential Moving Average Sample/Exponential Moving Average Sample/Exponential Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -45,7 +45,7 @@ public class ExponentialMovingAverageSample : Robot
[Parameter("Source", Group = "Exponential Moving Average 2")]
public DataSeries SourceSecond { get; set; }
-
+
public Position[] BotPositions
{
get
@@ -55,15 +55,15 @@ public Position[] BotPositions
}
protected override void OnStart()
- {
+ {
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_fastExponentialMovingAverage = Indicators.ExponentialMovingAverage(SourceFirst, PeriodsFirst);
-
+
_fastExponentialMovingAverage.Result.Line.Color = Color.Blue;
_slowExponentialMovingAverage = Indicators.ExponentialMovingAverage(SourceSecond, PeriodsSecond);
-
+
_slowExponentialMovingAverage.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample.cs b/Robots/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample.cs
index c13ba01..018c001 100644
--- a/Robots/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample.cs
+++ b/Robots/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample/Fractal Chaos Bands Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Fractals Sample/Fractals Sample/Fractals Sample.cs b/Robots/Fractals Sample/Fractals Sample/Fractals Sample.cs
index 5357f27..648028f 100644
--- a/Robots/Fractals Sample/Fractals Sample/Fractals Sample.cs
+++ b/Robots/Fractals Sample/Fractals Sample/Fractals Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/GetFitnessArgs Sample/GetFitnessArgs Sample/GetFitnessArgs Sample.cs b/Robots/GetFitnessArgs Sample/GetFitnessArgs Sample/GetFitnessArgs Sample.cs
index 7e502fa..a7b5555 100644
--- a/Robots/GetFitnessArgs Sample/GetFitnessArgs Sample/GetFitnessArgs Sample.cs
+++ b/Robots/GetFitnessArgs Sample/GetFitnessArgs Sample/GetFitnessArgs Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Grid/Grid/Grid.cs b/Robots/Grid/Grid/Grid.cs
index d625e96..13e77b2 100644
--- a/Robots/Grid/Grid/Grid.cs
+++ b/Robots/Grid/Grid/Grid.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -23,43 +23,43 @@ public class Grid : Robot
{
[Parameter("Volume (lots)", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
public double VolumeInLots { get; set; }
-
+
[Parameter("Trade Side")]
public TradeType TradeType { get; set; }
-
+
[Parameter("Step (pips)", DefaultValue = 5, MinValue = 0.1, Step = 0.1)]
public double StepPips { get; set; }
-
+
[Parameter("Target Profit", DefaultValue = 20)]
public double TargetProfit { get; set; }
-
+
private bool enoughMoney = true;
protected override void OnStart()
- {
- if (GridPositions.Length == 0)
- OpenPosition();
+ {
+ if (GridPositions.Length == 0)
+ OpenPosition();
}
protected override void OnTick()
{
if (GridPositions.Sum(p => p.NetProfit) >= TargetProfit)
{
- Print("Target profit is reached. Closing all grid positions");
- CloseGridPositions();
- Print("All grid positions are closed. Stopping cBot");
- Stop();
- }
+ Print("Target profit is reached. Closing all grid positions");
+ CloseGridPositions();
+ Print("All grid positions are closed. Stopping cBot");
+ Stop();
+ }
if (GridPositions.Length > 0 && enoughMoney)
{
var lastGridPosition = GridPositions.OrderBy(p => p.Pips).Last();
var distance = CalculateDistanceInPips(lastGridPosition);
-
+
if (distance >= StepPips)
- OpenPosition();
+ OpenPosition();
}
}
-
+
private Position[] GridPositions
{
get
@@ -68,26 +68,26 @@ private Position[] GridPositions
.Where(p => p.SymbolName == SymbolName && p.TradeType == TradeType)
.ToArray();
}
- }
-
+ }
+
private double CalculateDistanceInPips(Position position)
{
if (position.TradeType == TradeType.Buy)
- return (position.EntryPrice - Symbol.Ask) / Symbol.PipSize;
+ return (position.EntryPrice - Symbol.Ask) / Symbol.PipSize;
else
return (Symbol.Bid - position.EntryPrice) / Symbol.PipSize;
}
-
+
private void OpenPosition()
- {
+ {
var result = ExecuteMarketOrder(TradeType, SymbolName, Symbol.QuantityToVolumeInUnits(VolumeInLots), "Grid");
if (result.Error == ErrorCode.NoMoney)
{
enoughMoney = false;
- Print("Not enough money to open additional positions");
+ Print("Not enough money to open additional positions");
}
}
-
+
private void CloseGridPositions()
{
while (GridPositions.Length > 0)
@@ -97,6 +97,6 @@ private void CloseGridPositions()
ClosePosition(position);
}
}
- }
+ }
}
}
\ No newline at end of file
diff --git a/Robots/High Minus Low Sample/High Minus Low Sample/High Minus Low Sample.cs b/Robots/High Minus Low Sample/High Minus Low Sample/High Minus Low Sample.cs
index 4bf8782..3c280c2 100644
--- a/Robots/High Minus Low Sample/High Minus Low Sample/High Minus Low Sample.cs
+++ b/Robots/High Minus Low Sample/High Minus Low Sample/High Minus Low Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -21,7 +21,7 @@ public class HighMinusLowSample : Robot
[Parameter("Volume (Lots)", DefaultValue = 0.01)]
public double VolumeInLots { get; set; }
-
+
[Parameter("Stop Loss (Pips)", DefaultValue = 10, MaxValue = 100, MinValue = 1, Step = 1)]
public double StopLossInPips { get; set; }
diff --git a/Robots/Historical Volatility Sample/Historical Volatility Sample/Historical Volatility Sample.cs b/Robots/Historical Volatility Sample/Historical Volatility Sample/Historical Volatility Sample.cs
index 94eca59..a080e80 100644
--- a/Robots/Historical Volatility Sample/Historical Volatility Sample/Historical Volatility Sample.cs
+++ b/Robots/Historical Volatility Sample/Historical Volatility Sample/Historical Volatility Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Hull Moving Average Sample/Hull Moving Average Sample/Hull Moving Average Sample.cs b/Robots/Hull Moving Average Sample/Hull Moving Average Sample/Hull Moving Average Sample.cs
index 587ec0c..caf3b58 100644
--- a/Robots/Hull Moving Average Sample/Hull Moving Average Sample/Hull Moving Average Sample.cs
+++ b/Robots/Hull Moving Average Sample/Hull Moving Average Sample/Hull Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -59,7 +59,7 @@ protected override void OnStart()
_fastHull = Indicators.HullMovingAverage(FastMaSource, FastMaPeriod);
_slowHull = Indicators.HullMovingAverage(SlowMaSource, SlowMaPeriod);
-
+
_fastHull.Result.Line.Color = Color.Blue;
_slowHull.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample.cs b/Robots/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample.cs
index 294d86b..46e2b96 100644
--- a/Robots/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample.cs
+++ b/Robots/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample/Ichimoku Kinko Hyo Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Keltner Channels Sample/Keltner Channels Sample/Keltner Channels Sample.cs b/Robots/Keltner Channels Sample/Keltner Channels Sample/Keltner Channels Sample.cs
index c86620c..99d3f8d 100644
--- a/Robots/Keltner Channels Sample/Keltner Channels Sample/Keltner Channels Sample.cs
+++ b/Robots/Keltner Channels Sample/Keltner Channels Sample/Keltner Channels Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Linear Regression Forecast Sample/Linear Regression Forecast Sample/Linear Regression Forecast Sample.cs b/Robots/Linear Regression Forecast Sample/Linear Regression Forecast Sample/Linear Regression Forecast Sample.cs
index ff75566..3aa73fc 100644
--- a/Robots/Linear Regression Forecast Sample/Linear Regression Forecast Sample/Linear Regression Forecast Sample.cs
+++ b/Robots/Linear Regression Forecast Sample/Linear Regression Forecast Sample/Linear Regression Forecast Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Linear Regression Intercept Sample/Linear Regression Intercept Sample/Linear Regression Intercept Sample.cs b/Robots/Linear Regression Intercept Sample/Linear Regression Intercept Sample/Linear Regression Intercept Sample.cs
index 61099bb..fc14eb0 100644
--- a/Robots/Linear Regression Intercept Sample/Linear Regression Intercept Sample/Linear Regression Intercept Sample.cs
+++ b/Robots/Linear Regression Intercept Sample/Linear Regression Intercept Sample/Linear Regression Intercept Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Linear Regression R Squared Sample/Linear Regression R Squared Sample/Linear Regression R Squared Sample.cs b/Robots/Linear Regression R Squared Sample/Linear Regression R Squared Sample/Linear Regression R Squared Sample.cs
index 3398aa4..dc54fc6 100644
--- a/Robots/Linear Regression R Squared Sample/Linear Regression R Squared Sample/Linear Regression R Squared Sample.cs
+++ b/Robots/Linear Regression R Squared Sample/Linear Regression R Squared Sample/Linear Regression R Squared Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Linear Regression Slope Sample/Linear Regression Slope Sample/Linear Regression Slope Sample.cs b/Robots/Linear Regression Slope Sample/Linear Regression Slope Sample/Linear Regression Slope Sample.cs
index b0c2f00..578b523 100644
--- a/Robots/Linear Regression Slope Sample/Linear Regression Slope Sample/Linear Regression Slope Sample.cs
+++ b/Robots/Linear Regression Slope Sample/Linear Regression Slope Sample/Linear Regression Slope Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Macd Cross Over Sample/Macd Cross Over Sample/Macd Cross Over Sample.cs b/Robots/Macd Cross Over Sample/Macd Cross Over Sample/Macd Cross Over Sample.cs
index 2384a31..8250707 100644
--- a/Robots/Macd Cross Over Sample/Macd Cross Over Sample/Macd Cross Over Sample.cs
+++ b/Robots/Macd Cross Over Sample/Macd Cross Over Sample/Macd Cross Over Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -31,7 +31,7 @@ public class MacdCrossOverSample : Robot
[Parameter("Label", DefaultValue = "MacdCrossOverSample")]
public string Label { get; set; }
-
+
[Parameter("Source", Group = "Macd Crossover")]
public DataSeries Source { get; set; }
diff --git a/Robots/Macd Histogram Sample/Macd Histogram Sample/Macd Histogram Sample.cs b/Robots/Macd Histogram Sample/Macd Histogram Sample/Macd Histogram Sample.cs
index a76fc51..7de7a3a 100644
--- a/Robots/Macd Histogram Sample/Macd Histogram Sample/Macd Histogram Sample.cs
+++ b/Robots/Macd Histogram Sample/Macd Histogram Sample/Macd Histogram Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Mass Index Sample/Mass Index Sample/Mass Index Sample.cs b/Robots/Mass Index Sample/Mass Index Sample/Mass Index Sample.cs
index e9b62d8..5a95358 100644
--- a/Robots/Mass Index Sample/Mass Index Sample/Mass Index Sample.cs
+++ b/Robots/Mass Index Sample/Mass Index Sample/Mass Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Median Price Sample/Median Price Sample/Median Price Sample.cs b/Robots/Median Price Sample/Median Price Sample/Median Price Sample.cs
index 978961f..f5331de 100644
--- a/Robots/Median Price Sample/Median Price Sample/Median Price Sample.cs
+++ b/Robots/Median Price Sample/Median Price Sample/Median Price Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Momentum Oscillator Sample/Momentum Oscillator Sample/Momentum Oscillator Sample.cs b/Robots/Momentum Oscillator Sample/Momentum Oscillator Sample/Momentum Oscillator Sample.cs
index 0e829d3..01f44a9 100644
--- a/Robots/Momentum Oscillator Sample/Momentum Oscillator Sample/Momentum Oscillator Sample.cs
+++ b/Robots/Momentum Oscillator Sample/Momentum Oscillator Sample/Momentum Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Money Flow Index Sample/Money Flow Index Sample/Money Flow Index Sample.cs b/Robots/Money Flow Index Sample/Money Flow Index Sample/Money Flow Index Sample.cs
index f255c69..66e52a5 100644
--- a/Robots/Money Flow Index Sample/Money Flow Index Sample/Money Flow Index Sample.cs
+++ b/Robots/Money Flow Index Sample/Money Flow Index Sample/Money Flow Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Moving Average Sample/Moving Average Sample/Moving Average Sample.cs b/Robots/Moving Average Sample/Moving Average Sample/Moving Average Sample.cs
index a7b93a5..a4ace06 100644
--- a/Robots/Moving Average Sample/Moving Average Sample/Moving Average Sample.cs
+++ b/Robots/Moving Average Sample/Moving Average Sample/Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -64,8 +64,8 @@ protected override void OnStart()
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_fastMa = Indicators.MovingAverage(FastMaSource, FastMaPeriod, FastMaType);
- _slowMa = Indicators.MovingAverage(SlowMaSource, SlowMaPeriod, SlowMaType);
-
+ _slowMa = Indicators.MovingAverage(SlowMaSource, SlowMaPeriod, SlowMaType);
+
_fastMa.Result.Line.Color = Color.Blue;
_slowMa.Result.Line.Color = Color.Red;
}
diff --git a/Robots/On Balance Volume Sample/On Balance Volume Sample/On Balance Volume Sample.cs b/Robots/On Balance Volume Sample/On Balance Volume Sample/On Balance Volume Sample.cs
index 3f0c035..6ad955a 100644
--- a/Robots/On Balance Volume Sample/On Balance Volume Sample/On Balance Volume Sample.cs
+++ b/Robots/On Balance Volume Sample/On Balance Volume Sample/On Balance Volume Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Parabolic SAR Sample/Parabolic SAR Sample/Parabolic SAR Sample.cs b/Robots/Parabolic SAR Sample/Parabolic SAR Sample/Parabolic SAR Sample.cs
index 6dbe7a7..a42133c 100644
--- a/Robots/Parabolic SAR Sample/Parabolic SAR Sample/Parabolic SAR Sample.cs
+++ b/Robots/Parabolic SAR Sample/Parabolic SAR Sample/Parabolic SAR Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Partial Close Sample/Partial Close Sample/Partial Close Sample.cs b/Robots/Partial Close Sample/Partial Close Sample/Partial Close Sample.cs
index 5717418..b41887d 100644
--- a/Robots/Partial Close Sample/Partial Close Sample/Partial Close Sample.cs
+++ b/Robots/Partial Close Sample/Partial Close Sample/Partial Close Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Patterns Strategy Sample/Patterns Strategy Sample.sln b/Robots/Patterns Strategy Sample/Patterns Strategy Sample.sln
new file mode 100644
index 0000000..21695c8
--- /dev/null
+++ b/Robots/Patterns Strategy Sample/Patterns Strategy Sample.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}") = "Patterns Strategy Sample", "Patterns Strategy Sample\Patterns Strategy Sample.csproj", "{b757f66c-537d-4605-b428-bef6881d45a0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {b757f66c-537d-4605-b428-bef6881d45a0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {b757f66c-537d-4605-b428-bef6881d45a0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {b757f66c-537d-4605-b428-bef6881d45a0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {b757f66c-537d-4605-b428-bef6881d45a0}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.cs b/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.cs
new file mode 100644
index 0000000..170c2ac
--- /dev/null
+++ b/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.cs
@@ -0,0 +1,59 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 trades the hammer pattern for long entries and the hanging man pattern for short entries.
+//
+// For a detailed tutorial on creating this cBot, watch the video at: https://youtu.be/mEoIvP11Z1U
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Robots
+{
+ [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
+ public class PatternsStrategySample : Robot
+ {
+ [Parameter(DefaultValue = 1000)]
+ public double Volume { get; set; }
+
+ [Parameter(DefaultValue = 10)]
+ public double StopLoss { get; set; }
+
+ [Parameter(DefaultValue = 10)]
+ public double TakeProfit { get; set; }
+
+ protected override void OnStart()
+ {
+
+ }
+
+ protected override void OnBarClosed()
+ {
+ if (Bars.Last(0).Close == Bars.Last(0).High &&
+ (Bars.Last(0).Close - Bars.Last(0).Open) < (Bars.Last(0).Close - Bars.Last(0).Low) * 0.2)
+ {
+ ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, InstanceId, StopLoss, TakeProfit);
+ }
+
+ if (Bars.Last(0).Close == Bars.Last(0).Low &&
+ (Bars.Last(0).Open - Bars.Last(0).Close) < (Bars.Last(0).High - Bars.Last(0).Close) * 0.2)
+ {
+ ExecuteMarketOrder(TradeType.Sell, SymbolName, Volume, InstanceId, StopLoss, TakeProfit);
+ }
+
+ }
+
+ protected override void OnStop()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.csproj b/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/Patterns Strategy Sample/Patterns Strategy Sample/Patterns Strategy Sample.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Pending Order Cancelation Sample/Pending Order Cancelation Sample/Pending Order Cancelation Sample.cs b/Robots/Pending Order Cancelation Sample/Pending Order Cancelation Sample/Pending Order Cancelation Sample.cs
index 4c1ad03..03e5285 100644
--- a/Robots/Pending Order Cancelation Sample/Pending Order Cancelation Sample/Pending Order Cancelation Sample.cs
+++ b/Robots/Pending Order Cancelation Sample/Pending Order Cancelation Sample/Pending Order Cancelation Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Pending Order Events/Pending Order Events/Pending Order Events.cs b/Robots/Pending Order Events/Pending Order Events/Pending Order Events.cs
index 348d389..c81fc4e 100644
--- a/Robots/Pending Order Events/Pending Order Events/Pending Order Events.cs
+++ b/Robots/Pending Order Events/Pending Order Events/Pending Order Events.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Pending Order Modification Sample/Pending Order Modification Sample/Pending Order Modification Sample.cs b/Robots/Pending Order Modification Sample/Pending Order Modification Sample/Pending Order Modification Sample.cs
index 4f4c1e3..5789320 100644
--- a/Robots/Pending Order Modification Sample/Pending Order Modification Sample/Pending Order Modification Sample.cs
+++ b/Robots/Pending Order Modification Sample/Pending Order Modification Sample/Pending Order Modification Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Pending Order Placing Sample/Pending Order Placing Sample/Pending Order Placing Sample.cs b/Robots/Pending Order Placing Sample/Pending Order Placing Sample/Pending Order Placing Sample.cs
index f9a40e6..b02af6c 100644
--- a/Robots/Pending Order Placing Sample/Pending Order Placing Sample/Pending Order Placing Sample.cs
+++ b/Robots/Pending Order Placing Sample/Pending Order Placing Sample/Pending Order Placing Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample.cs b/Robots/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample.cs
index bd531d1..a40e12a 100644
--- a/Robots/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample.cs
+++ b/Robots/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample/PendingOrderCancellationReason Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/PendingOrders Sample/PendingOrders Sample/PendingOrders Sample.cs b/Robots/PendingOrders Sample/PendingOrders Sample/PendingOrders Sample.cs
index 8562407..38937c4 100644
--- a/Robots/PendingOrders Sample/PendingOrders Sample/PendingOrders Sample.cs
+++ b/Robots/PendingOrders Sample/PendingOrders Sample/PendingOrders Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample.cs b/Robots/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample.cs
index 60dfb8f..5db2509 100644
--- a/Robots/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample.cs
+++ b/Robots/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample/Polynomial Regression Channels Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Position Bars Passed Sample/Position Bars Passed Sample/Position Bars Passed Sample.cs b/Robots/Position Bars Passed Sample/Position Bars Passed Sample/Position Bars Passed Sample.cs
index 32e80b4..2974b29 100644
--- a/Robots/Position Bars Passed Sample/Position Bars Passed Sample/Position Bars Passed Sample.cs
+++ b/Robots/Position Bars Passed Sample/Position Bars Passed Sample/Position Bars Passed Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Position Closing Sample/Position Closing Sample/Position Closing Sample.cs b/Robots/Position Closing Sample/Position Closing Sample/Position Closing Sample.cs
index 27adf5d..562eaf2 100644
--- a/Robots/Position Closing Sample/Position Closing Sample/Position Closing Sample.cs
+++ b/Robots/Position Closing Sample/Position Closing Sample/Position Closing Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Position Events Sample/Position Events Sample/Position Events Sample.cs b/Robots/Position Events Sample/Position Events Sample/Position Events Sample.cs
index 19ce02c..a71d37f 100644
--- a/Robots/Position Events Sample/Position Events Sample/Position Events Sample.cs
+++ b/Robots/Position Events Sample/Position Events Sample/Position Events Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Position Execution Sample/Position Execution Sample/Position Execution Sample.cs b/Robots/Position Execution Sample/Position Execution Sample/Position Execution Sample.cs
index 818eac3..884befe 100644
--- a/Robots/Position Execution Sample/Position Execution Sample/Position Execution Sample.cs
+++ b/Robots/Position Execution Sample/Position Execution Sample/Position Execution Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Position Modification Sample/Position Modification Sample/Position Modification Sample.cs b/Robots/Position Modification Sample/Position Modification Sample/Position Modification Sample.cs
index 95b02f4..d39a188 100644
--- a/Robots/Position Modification Sample/Position Modification Sample/Position Modification Sample.cs
+++ b/Robots/Position Modification Sample/Position Modification Sample/Position Modification Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/PositionCloseReason Sample/PositionCloseReason Sample/PositionCloseReason Sample.cs b/Robots/PositionCloseReason Sample/PositionCloseReason Sample/PositionCloseReason Sample.cs
index 2d3023c..d10fa3c 100644
--- a/Robots/PositionCloseReason Sample/PositionCloseReason Sample/PositionCloseReason Sample.cs
+++ b/Robots/PositionCloseReason Sample/PositionCloseReason Sample/PositionCloseReason Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample.cs b/Robots/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample.cs
index 6808dc3..8497f06 100644
--- a/Robots/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample.cs
+++ b/Robots/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample/PositionModifiedEventArgs Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Price Oscillator Sample/Price Oscillator Sample/Price Oscillator Sample.cs b/Robots/Price Oscillator Sample/Price Oscillator Sample/Price Oscillator Sample.cs
index e77e6ea..22edb92 100644
--- a/Robots/Price Oscillator Sample/Price Oscillator Sample/Price Oscillator Sample.cs
+++ b/Robots/Price Oscillator Sample/Price Oscillator Sample/Price Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Price ROC Sample/Price ROC Sample/Price ROC Sample.cs b/Robots/Price ROC Sample/Price ROC Sample/Price ROC Sample.cs
index e944f5e..c4043f8 100644
--- a/Robots/Price ROC Sample/Price ROC Sample/Price ROC Sample.cs
+++ b/Robots/Price ROC Sample/Price ROC Sample/Price ROC Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Price Volume Trend Sample/Price Volume Trend Sample/Price Volume Trend Sample.cs b/Robots/Price Volume Trend Sample/Price Volume Trend Sample/Price Volume Trend Sample.cs
index 79c33bf..d7065a0 100644
--- a/Robots/Price Volume Trend Sample/Price Volume Trend Sample/Price Volume Trend Sample.cs
+++ b/Robots/Price Volume Trend Sample/Price Volume Trend Sample/Price Volume Trend Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.sln b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.sln
new file mode 100644
index 0000000..9499c64
--- /dev/null
+++ b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.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}") = "RSI Reversal Strategy Sample", "RSI Reversal Strategy Sample\RSI Reversal Strategy Sample.csproj", "{e72d7681-531b-4abe-8c9a-e2a74e52eb7a}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {e72d7681-531b-4abe-8c9a-e2a74e52eb7a}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {e72d7681-531b-4abe-8c9a-e2a74e52eb7a}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {e72d7681-531b-4abe-8c9a-e2a74e52eb7a}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {e72d7681-531b-4abe-8c9a-e2a74e52eb7a}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.cs b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.cs
new file mode 100644
index 0000000..cfbd0d5
--- /dev/null
+++ b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.cs
@@ -0,0 +1,67 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 implements a strategy based on the Relative Strength Index (RSI) indicator reversal.
+//
+// For a detailed tutorial on creating this cBot, watch the video at: https://youtu.be/mEoIvP11Z1U
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using System.Linq;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Robots
+{
+ [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
+ public class RSIReversalStrategySample : Robot
+ {
+ [Parameter(DefaultValue = 30)]
+ public int BuyLevel { get; set; }
+
+ [Parameter(DefaultValue = 70)]
+ public int SellLevel { get; set; }
+
+ private RelativeStrengthIndex _rsi;
+
+ protected override void OnStart()
+ {
+ _rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);
+ }
+
+ protected override void OnBarClosed()
+ {
+ if (_rsi.Result.LastValue < BuyLevel)
+ {
+ if (Positions.Count == 0)
+ ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000);
+ foreach (var position in Positions.Where(p => p.TradeType == TradeType.Sell))
+ {
+ position.Close();
+ }
+
+ }
+
+ else if (_rsi.Result.LastValue > SellLevel)
+ {
+ if (Positions.Count == 0)
+ ExecuteMarketOrder(TradeType.Sell, SymbolName, 1000);
+ foreach (var position in Positions.Where(p => p.TradeType == TradeType.Buy))
+ {
+ position.Close();
+ }
+ }
+ }
+
+ protected override void OnStop()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.csproj b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample/RSI Reversal Strategy Sample.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Rainbow Oscillator Sample/Rainbow Oscillator Sample/Rainbow Oscillator Sample.cs b/Robots/Rainbow Oscillator Sample/Rainbow Oscillator Sample/Rainbow Oscillator Sample.cs
index abf683e..c4f2819 100644
--- a/Robots/Rainbow Oscillator Sample/Rainbow Oscillator Sample/Rainbow Oscillator Sample.cs
+++ b/Robots/Rainbow Oscillator Sample/Rainbow Oscillator Sample/Rainbow Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Range Strategy Example/Range Strategy Example/Range Strategy Example.cs b/Robots/Range Strategy Example/Range Strategy Example/Range Strategy Example.cs
index c7f72f7..b84e2ef 100644
--- a/Robots/Range Strategy Example/Range Strategy Example/Range Strategy Example.cs
+++ b/Robots/Range Strategy Example/Range Strategy Example/Range Strategy Example.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -23,28 +23,28 @@ public class RangeStrategyExample : Robot
{
[Parameter(DefaultValue = 100000)]
public double Volume { get; set; }
-
+
[Parameter(DefaultValue = 20)]
public double StopLoss { get; set; }
-
+
[Parameter(DefaultValue = 20)]
public double TakeProfit { get; set; }
protected override void OnStart()
{
-
+
}
protected override void OnBarClosed()
{
- if(Bars.Last(0).Close > Bars.Last(0).Open && Bars.Last(1).Close < Bars.Last(1).Open &&
+ if (Bars.Last(0).Close > Bars.Last(0).Open && Bars.Last(1).Close < Bars.Last(1).Open &&
Bars.Last(0).Close > Bars.Last(1).Open)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, InstanceId, StopLoss, TakeProfit);
}
-
-
- if(Bars.Last(0).Close < Bars.Last(0).Open && Bars.Last(1).Close > Bars.Last(1).Open &&
+
+
+ if (Bars.Last(0).Close < Bars.Last(0).Open && Bars.Last(1).Close > Bars.Last(1).Open &&
Bars.Last(0).Close < Bars.Last(1).Open)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Volume, InstanceId, StopLoss, TakeProfit);
diff --git a/Robots/RefreshData Sample/RefreshData Sample/RefreshData Sample.cs b/Robots/RefreshData Sample/RefreshData Sample/RefreshData Sample.cs
index 60d97b8..abf326c 100644
--- a/Robots/RefreshData Sample/RefreshData Sample/RefreshData Sample.cs
+++ b/Robots/RefreshData Sample/RefreshData Sample/RefreshData Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Relative Strength Index Sample/Relative Strength Index Sample/Relative Strength Index Sample.cs b/Robots/Relative Strength Index Sample/Relative Strength Index Sample/Relative Strength Index Sample.cs
index c455423..c31cc6b 100644
--- a/Robots/Relative Strength Index Sample/Relative Strength Index Sample/Relative Strength Index Sample.cs
+++ b/Robots/Relative Strength Index Sample/Relative Strength Index Sample/Relative Strength Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Running Mode Sample/Running Mode Sample/Running Mode Sample.cs b/Robots/Running Mode Sample/Running Mode Sample/Running Mode Sample.cs
index 81ca92a..84314ed 100644
--- a/Robots/Running Mode Sample/Running Mode Sample/Running Mode Sample.cs
+++ b/Robots/Running Mode Sample/Running Mode Sample/Running Mode Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Simple Moving Average Sample/Simple Moving Average Sample/Simple Moving Average Sample.cs b/Robots/Simple Moving Average Sample/Simple Moving Average Sample/Simple Moving Average Sample.cs
index b42d065..d5336fe 100644
--- a/Robots/Simple Moving Average Sample/Simple Moving Average Sample/Simple Moving Average Sample.cs
+++ b/Robots/Simple Moving Average Sample/Simple Moving Average Sample/Simple Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -59,7 +59,7 @@ protected override void OnStart()
_fastSimpleMovingAverage = Indicators.SimpleMovingAverage(FastMaSource, FastMaPeriod);
_slowSimpleMovingAverage = Indicators.SimpleMovingAverage(SlowMaSource, SlowMaPeriod);
-
+
_fastSimpleMovingAverage.Result.Line.Color = Color.Blue;
_slowSimpleMovingAverage.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Standard Deviation Sample/Standard Deviation Sample/Standard Deviation Sample.cs b/Robots/Standard Deviation Sample/Standard Deviation Sample/Standard Deviation Sample.cs
index 35e6010..65094e0 100644
--- a/Robots/Standard Deviation Sample/Standard Deviation Sample/Standard Deviation Sample.cs
+++ b/Robots/Standard Deviation Sample/Standard Deviation Sample/Standard Deviation Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -41,7 +41,7 @@ public class StandardDeviationSample : Robot
public DataSeries SourceMovingAverage { get; set; }
[Parameter("Periods Moving Average", DefaultValue = 14, Group = "Moving Average", MinValue = 2)]
- public int PeriodsMovingAverage{ get; set; }
+ public int PeriodsMovingAverage { get; set; }
public Position[] BotPositions
diff --git a/Robots/Start cBot Sample/Start cBot Sample.sln b/Robots/Start cBot Sample/Start cBot Sample.sln
new file mode 100644
index 0000000..db909a9
--- /dev/null
+++ b/Robots/Start cBot Sample/Start cBot Sample.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}") = "Start cBot Sample", "Start cBot Sample\Start cBot Sample.csproj", "{1751be77-fe78-4e12-b558-7fb418ed6b44}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1751be77-fe78-4e12-b558-7fb418ed6b44}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.cs b/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.cs
new file mode 100644
index 0000000..1cbd613
--- /dev/null
+++ b/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.cs
@@ -0,0 +1,63 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 sample cBot adds and starts two other cBots based on a certain logic.
+//
+// For a detailed tutorial on creating this cBot, see this video: https://www.youtube.com/watch?v=DUzdEt30OSE
+//
+// -------------------------------------------------------------------------------------------------
+
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Robots
+{
+ [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
+ public class AddcBots : Robot
+ {
+
+ ChartRobot _robot1;
+ ChartRobot _robot2;
+
+ protected override void OnStart()
+ {
+ _robot1 = Chart.Robots.Add("Sample Trend cBot", 0.01, MovingAverageType.Simple, Bars.ClosePrices, 10, 5);
+ _robot2 = Chart.Robots.Add("Sample Trend cBot", 0.01, MovingAverageType.Simple, Bars.ClosePrices, 12, 7);
+
+ Chart.Robots.RobotStarted += ChartRobots_RobotStarted;
+ }
+
+ private void ChartRobots_RobotStarted(ChartRobotStartedEventArgs obj)
+ {
+ Print ("Robot Started");
+
+ }
+
+ protected override void OnBarClosed()
+ {
+ if (_robot1.State == RobotState.Stopped)
+ {
+ _robot1.Start();
+ _robot2.Stop();
+ }
+
+ else if (_robot1.State == RobotState.Running)
+ {
+ _robot2.Start();
+ _robot1.Stop();
+ }
+ }
+
+ protected override void OnStop()
+ {
+ // Handle cBot stop here
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.csproj b/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/Start cBot Sample/Start cBot Sample/Start cBot Sample.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Stochastic Oscillator Sample/Stochastic Oscillator Sample/Stochastic Oscillator Sample.cs b/Robots/Stochastic Oscillator Sample/Stochastic Oscillator Sample/Stochastic Oscillator Sample.cs
index f5850f0..212a2a5 100644
--- a/Robots/Stochastic Oscillator Sample/Stochastic Oscillator Sample/Stochastic Oscillator Sample.cs
+++ b/Robots/Stochastic Oscillator Sample/Stochastic Oscillator Sample/Stochastic Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/StopTriggerMethod Sample/StopTriggerMethod Sample/StopTriggerMethod Sample.cs b/Robots/StopTriggerMethod Sample/StopTriggerMethod Sample/StopTriggerMethod Sample.cs
index 1a3773e..cb7e25a 100644
--- a/Robots/StopTriggerMethod Sample/StopTriggerMethod Sample/StopTriggerMethod Sample.cs
+++ b/Robots/StopTriggerMethod Sample/StopTriggerMethod Sample/StopTriggerMethod Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Supertrend Sample/Supertrend Sample/Supertrend Sample.cs b/Robots/Supertrend Sample/Supertrend Sample/Supertrend Sample.cs
index 20b11bd..21befef 100644
--- a/Robots/Supertrend Sample/Supertrend Sample/Supertrend Sample.cs
+++ b/Robots/Supertrend Sample/Supertrend Sample/Supertrend Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Swing Index Sample/Swing Index Sample/Swing Index Sample.cs b/Robots/Swing Index Sample/Swing Index Sample/Swing Index Sample.cs
index 7bcba41..e45bc2c 100644
--- a/Robots/Swing Index Sample/Swing Index Sample/Swing Index Sample.cs
+++ b/Robots/Swing Index Sample/Swing Index Sample/Swing Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -31,7 +31,7 @@ public class SwingIndexSample : Robot
[Parameter("Label", DefaultValue = "SwingIndexSample")]
public string Label { get; set; }
- [Parameter("Limit Move Value", DefaultValue = 12, Group ="Swing Index", MinValue = 1)]
+ [Parameter("Limit Move Value", DefaultValue = 12, Group = "Swing Index", MinValue = 1)]
public int LimitMoveValue { get; set; }
diff --git a/Robots/Time Series Moving Average Sample/Time Series Moving Average Sample/Time Series Moving Average Sample.cs b/Robots/Time Series Moving Average Sample/Time Series Moving Average Sample/Time Series Moving Average Sample.cs
index 8919628..5c6845b 100644
--- a/Robots/Time Series Moving Average Sample/Time Series Moving Average Sample/Time Series Moving Average Sample.cs
+++ b/Robots/Time Series Moving Average Sample/Time Series Moving Average Sample/Time Series Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -60,7 +60,7 @@ protected override void OnStart()
_fastTimeSeriesMovingAverage = Indicators.TimeSeriesMovingAverage(FastMaSource, FastMaPeriod);
_slowTimeSeriesMovingAverage = Indicators.TimeSeriesMovingAverage(SlowMaSource, SlowMaPeriod);
-
+
_fastTimeSeriesMovingAverage.Result.Line.Color = Color.Blue;
_slowTimeSeriesMovingAverage.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Timer Sample/Timer Sample/Timer Sample.cs b/Robots/Timer Sample/Timer Sample/Timer Sample.cs
index f76395a..c2a5f17 100644
--- a/Robots/Timer Sample/Timer Sample/Timer Sample.cs
+++ b/Robots/Timer Sample/Timer Sample/Timer Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Trade Volume Index Sample/Trade Volume Index Sample/Trade Volume Index Sample.cs b/Robots/Trade Volume Index Sample/Trade Volume Index Sample/Trade Volume Index Sample.cs
index 6390206..827eecb 100644
--- a/Robots/Trade Volume Index Sample/Trade Volume Index Sample/Trade Volume Index Sample.cs
+++ b/Robots/Trade Volume Index Sample/Trade Volume Index Sample/Trade Volume Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/TradeOperation Sample/TradeOperation Sample/TradeOperation Sample.cs b/Robots/TradeOperation Sample/TradeOperation Sample/TradeOperation Sample.cs
index 34b2507..72f6945 100644
--- a/Robots/TradeOperation Sample/TradeOperation Sample/TradeOperation Sample.cs
+++ b/Robots/TradeOperation Sample/TradeOperation Sample/TradeOperation Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/TradeResult Sample/TradeResult Sample/TradeResult Sample.cs b/Robots/TradeResult Sample/TradeResult Sample/TradeResult Sample.cs
index 0f5e4c2..3073368 100644
--- a/Robots/TradeResult Sample/TradeResult Sample/TradeResult Sample.cs
+++ b/Robots/TradeResult Sample/TradeResult Sample/TradeResult Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/TradeType Sample/TradeType Sample/TradeType Sample.cs b/Robots/TradeType Sample/TradeType Sample/TradeType Sample.cs
index 8b13d5d..3199e5e 100644
--- a/Robots/TradeType Sample/TradeType Sample/TradeType Sample.cs
+++ b/Robots/TradeType Sample/TradeType Sample/TradeType Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Triangular Moving Average Sample/Triangular Moving Average Sample/Triangular Moving Average Sample.cs b/Robots/Triangular Moving Average Sample/Triangular Moving Average Sample/Triangular Moving Average Sample.cs
index 27c7e28..64417c0 100644
--- a/Robots/Triangular Moving Average Sample/Triangular Moving Average Sample/Triangular Moving Average Sample.cs
+++ b/Robots/Triangular Moving Average Sample/Triangular Moving Average Sample/Triangular Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -35,7 +35,7 @@ public class TriangularMovingAverageSample : Robot
[Parameter("Volume (Lots)", DefaultValue = 0.01, Group = "Trade")]
public double VolumeInLots { get; set; }
-
+
[Parameter("Stop Loss (Pips)", DefaultValue = 10, MaxValue = 100, MinValue = 1, Step = 1)]
public double StopLossInPips { get; set; }
@@ -59,7 +59,7 @@ protected override void OnStart()
_fastTriangularMovingAverage = Indicators.TriangularMovingAverage(FastMaSource, FastMaPeriod);
_slowTriangularMovingAverage = Indicators.TriangularMovingAverage(SlowMaSource, SlowMaPeriod);
-
+
_fastTriangularMovingAverage.Result.Line.Color = Color.Blue;
_slowTriangularMovingAverage.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Trix Sample/Trix Sample/Trix Sample.cs b/Robots/Trix Sample/Trix Sample/Trix Sample.cs
index 72ac730..4fffae8 100644
--- a/Robots/Trix Sample/Trix Sample/Trix Sample.cs
+++ b/Robots/Trix Sample/Trix Sample/Trix Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/True Range Sample/True Range Sample/True Range Sample.cs b/Robots/True Range Sample/True Range Sample/True Range Sample.cs
index 8bd647a..aa27f61 100644
--- a/Robots/True Range Sample/True Range Sample/True Range Sample.cs
+++ b/Robots/True Range Sample/True Range Sample/True Range Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Typical Price Sample/Typical Price Sample/Typical Price Sample.cs b/Robots/Typical Price Sample/Typical Price Sample/Typical Price Sample.cs
index 33f59a7..2005675 100644
--- a/Robots/Typical Price Sample/Typical Price Sample/Typical Price Sample.cs
+++ b/Robots/Typical Price Sample/Typical Price Sample/Typical Price Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Ultimate Oscillator Sample/Ultimate Oscillator Sample/Ultimate Oscillator Sample.cs b/Robots/Ultimate Oscillator Sample/Ultimate Oscillator Sample/Ultimate Oscillator Sample.cs
index 501d5fd..efabd0d 100644
--- a/Robots/Ultimate Oscillator Sample/Ultimate Oscillator Sample/Ultimate Oscillator Sample.cs
+++ b/Robots/Ultimate Oscillator Sample/Ultimate Oscillator Sample/Ultimate Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample.cs b/Robots/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample.cs
index 186e29a..b6fe6cd 100644
--- a/Robots/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample.cs
+++ b/Robots/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample/Vertical Horizontal Filter Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Vidya Sample/Vidya Sample/Vidya Sample.cs b/Robots/Vidya Sample/Vidya Sample/Vidya Sample.cs
index 909b93c..76baa09 100644
--- a/Robots/Vidya Sample/Vidya Sample/Vidya Sample.cs
+++ b/Robots/Vidya Sample/Vidya Sample/Vidya Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -65,7 +65,7 @@ protected override void OnStart()
_fastVidya = Indicators.Vidya(FastMaSource, FastMaPeriod, FastSigma);
_slowVidya = Indicators.Vidya(SlowMaSource, SlowMaPeriod, SlowSigma);
-
+
_fastVidya.Result.Line.Color = Color.Blue;
_slowVidya.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Volume Index Sample/Volume Index Sample/Volume Index Sample.cs b/Robots/Volume Index Sample/Volume Index Sample/Volume Index Sample.cs
index b1a92be..1f35627 100644
--- a/Robots/Volume Index Sample/Volume Index Sample/Volume Index Sample.cs
+++ b/Robots/Volume Index Sample/Volume Index Sample/Volume Index Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Volume Oscillator Sample/Volume Oscillator Sample/Volume Oscillator Sample.cs b/Robots/Volume Oscillator Sample/Volume Oscillator Sample/Volume Oscillator Sample.cs
index dc50ec8..726b08d 100644
--- a/Robots/Volume Oscillator Sample/Volume Oscillator Sample/Volume Oscillator Sample.cs
+++ b/Robots/Volume Oscillator Sample/Volume Oscillator Sample/Volume Oscillator Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Volume ROC Sample/Volume ROC Sample/Volume ROC Sample.cs b/Robots/Volume ROC Sample/Volume ROC Sample/Volume ROC Sample.cs
index be179c6..848f92b 100644
--- a/Robots/Volume ROC Sample/Volume ROC Sample/Volume ROC Sample.cs
+++ b/Robots/Volume ROC Sample/Volume ROC Sample/Volume ROC Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Web Sockets Sample/Web Sockets Sample.sln b/Robots/Web Sockets Sample/Web Sockets Sample.sln
new file mode 100644
index 0000000..94dc2d2
--- /dev/null
+++ b/Robots/Web Sockets Sample/Web Sockets Sample.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}") = "Web Sockets Sample", "Web Sockets Sample\Web Sockets Sample.csproj", "{cd5f4d41-2fe3-40da-b9b2-389ea0689fc4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {cd5f4d41-2fe3-40da-b9b2-389ea0689fc4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {cd5f4d41-2fe3-40da-b9b2-389ea0689fc4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {cd5f4d41-2fe3-40da-b9b2-389ea0689fc4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {cd5f4d41-2fe3-40da-b9b2-389ea0689fc4}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.cs b/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.cs
new file mode 100644
index 0000000..f86c35f
--- /dev/null
+++ b/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.cs
@@ -0,0 +1,53 @@
+// -------------------------------------------------------------------------------------------------
+//
+// 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 sample cBot subscribes to a symbol price feed and streams the prices.
+//
+// For a detailed tutorial on creating this cBot, see this video: https://www.youtube.com/watch?v=y5ARwEEXSLI
+//
+// -------------------------------------------------------------------------------------------------
+
+using System;
+using cAlgo.API;
+using cAlgo.API.Collections;
+using cAlgo.API.Indicators;
+using cAlgo.API.Internals;
+
+namespace cAlgo.Robots
+{
+ [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
+ public class WebSocketsExample : Robot
+ {
+ private WebSocketClient _webSocketClient = new WebSocketClient();
+ private readonly Uri _targetUri = new Uri("wss://marketdata.tradermade.com/feedadv");
+
+ protected override void OnStart()
+ {
+ _webSocketClient.Connect(_targetUri);
+
+ _webSocketClient.TextReceived += _webSocketClient_TextReceived;
+
+ var data = "{\"userKey\":\"PasteStreamingKeyHere\", \"symbol\":\"EURUSD\"}";
+
+ _webSocketClient.Send(data);
+ }
+
+ private void _webSocketClient_TextReceived(WebSocketClientTextReceivedEventArgs obj)
+ {
+ Print(obj.Text.Replace("{", "").Replace("}", "").ToString());
+ }
+
+ protected override void OnTick()
+ {
+ // Handle price updates here
+ }
+
+ protected override void OnStop()
+ {
+ _webSocketClient.Close(WebSocketClientCloseStatus.NormalClosure);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.csproj b/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.csproj
new file mode 100644
index 0000000..51ac844
--- /dev/null
+++ b/Robots/Web Sockets Sample/Web Sockets Sample/Web Sockets Sample.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+
+
+
+
+
+
diff --git a/Robots/Weighted Close Sample/Weighted Close Sample/Weighted Close Sample.cs b/Robots/Weighted Close Sample/Weighted Close Sample/Weighted Close Sample.cs
index 96827fe..2bb30cc 100644
--- a/Robots/Weighted Close Sample/Weighted Close Sample/Weighted Close Sample.cs
+++ b/Robots/Weighted Close Sample/Weighted Close Sample/Weighted Close Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/Weighted Moving Average Sample/Weighted Moving Average Sample/Weighted Moving Average Sample.cs b/Robots/Weighted Moving Average Sample/Weighted Moving Average Sample/Weighted Moving Average Sample.cs
index e2a1f56..733fb0a 100644
--- a/Robots/Weighted Moving Average Sample/Weighted Moving Average Sample/Weighted Moving Average Sample.cs
+++ b/Robots/Weighted Moving Average Sample/Weighted Moving Average Sample/Weighted Moving Average Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -59,7 +59,7 @@ protected override void OnStart()
_fastWeightedMovingAverage = Indicators.WeightedMovingAverage(FastMaSource, FastMaPeriod);
_slowWeightedMovingAverage = Indicators.WeightedMovingAverage(SlowMaSource, SlowMaPeriod);
-
+
_fastWeightedMovingAverage.Result.Line.Color = Color.Blue;
_slowWeightedMovingAverage.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample.cs b/Robots/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample.cs
index 42224a7..1622ed4 100644
--- a/Robots/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample.cs
+++ b/Robots/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample/Welles Wilder Smoothing Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
@@ -59,7 +59,7 @@ protected override void OnStart()
_fastWellesWilderSmoothing = Indicators.WellesWilderSmoothing(FastMaSource, FastMaPeriod);
_slowWellesWilderSmoothing = Indicators.WellesWilderSmoothing(SlowMaSource, SlowMaPeriod);
-
+
_fastWellesWilderSmoothing.Result.Line.Color = Color.Blue;
_slowWellesWilderSmoothing.Result.Line.Color = Color.Red;
}
diff --git a/Robots/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample.cs b/Robots/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample.cs
index 9143a60..1d4785b 100644
--- a/Robots/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample.cs
+++ b/Robots/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample/Williams Accumulation Distribution Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
diff --git a/Robots/WilliamsPctR Sample/WilliamsPctR Sample/WilliamsPctR Sample.cs b/Robots/WilliamsPctR Sample/WilliamsPctR Sample/WilliamsPctR Sample.cs
index 5dd72d0..1e57834 100644
--- a/Robots/WilliamsPctR Sample/WilliamsPctR Sample/WilliamsPctR Sample.cs
+++ b/Robots/WilliamsPctR Sample/WilliamsPctR Sample/WilliamsPctR Sample.cs
@@ -1,6 +1,6 @@
// -------------------------------------------------------------------------------------------------
//
-// This code is a cTrader Automate API example.
+// This code is a cTrader Algo API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.