Skip to content

Commit 570be99

Browse files
authored
Merge branch 'main' into CNT-677--Custom-Toolbar-Button-Sample
2 parents 82d81de + a4925e4 commit 570be99

File tree

7 files changed

+192
-0
lines changed

7 files changed

+192
-0
lines changed

Plugins/.samples.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
},
3535
{
3636
"name": "Custom Toolbar Button"
37+
},
38+
{
39+
"name": "Custom Window Plugin"
3740
},
3841
{
3942
"name": "IndicatorTitles Sample"
@@ -44,6 +47,9 @@
4447
{
4548
"name": "My ASP Example"
4649
},
50+
{
51+
"name": "My Custom Frame Example"
52+
},
4753
{
4854
"name": "Order by Margin"
4955
},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom Window Plugin", "Custom Window Plugin\Custom Window Plugin.csproj", "{65dfd7f6-65ba-4aed-bc96-051f978f3662}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{65dfd7f6-65ba-4aed-bc96-051f978f3662}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{65dfd7f6-65ba-4aed-bc96-051f978f3662}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{65dfd7f6-65ba-4aed-bc96-051f978f3662}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{65dfd7f6-65ba-4aed-bc96-051f978f3662}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// -------------------------------------------------------------------------------------------------
2+
//
3+
// This code is a cTrader Algo API example.
4+
//
5+
// 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.
6+
//
7+
// This example plugin adds a new custom window containing a 'Add Take Profit' button, which adds Take Profit to open positions when clicked.
8+
//
9+
// For a detailed tutorial on creating this plugin, watch the video at: [to:do]
10+
//
11+
// -------------------------------------------------------------------------------------------------
12+
13+
14+
using System;
15+
using cAlgo.API;
16+
using cAlgo.API.Collections;
17+
using cAlgo.API.Indicators;
18+
using cAlgo.API.Internals;
19+
20+
namespace cAlgo.Plugins
21+
{
22+
[Plugin(AccessRights = AccessRights.None)]
23+
public class CustomWindowPlugin : Plugin
24+
25+
{
26+
private Button _buttonAddTakeProfit;
27+
private Window _window;
28+
29+
protected override void OnStart()
30+
{
31+
_buttonAddTakeProfit = new Button
32+
{
33+
BackgroundColor = Color.SeaGreen,
34+
Height = 50,
35+
Text = "Add Take Profit"
36+
};
37+
38+
_buttonAddTakeProfit.Click += _buttonAddTakeProfit_Click;
39+
40+
_window = new Window
41+
{
42+
Height = 150,
43+
Width = 150,
44+
Padding = new Thickness(5, 10, 10, 5)
45+
};
46+
47+
_window.Child = _buttonAddTakeProfit;
48+
_window.Show();
49+
}
50+
51+
private void _buttonAddTakeProfit_Click(ButtonClickEventArgs args)
52+
{
53+
foreach (var position in Positions)
54+
{
55+
if (position.TakeProfit is null)
56+
{
57+
position.ModifyTakeProfitPips(20);
58+
}
59+
}
60+
}
61+
62+
protected override void OnStop()
63+
{
64+
// Handle Plugin stop here
65+
}
66+
}
67+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<PackageReference Include="cTrader.Automate" Version="*" />
8+
</ItemGroup>
9+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My Custom Frame Example", "My Custom Frame Example\My Custom Frame Example.csproj", "{bcac2c14-878a-4dff-aea7-df2f6d634f09}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{bcac2c14-878a-4dff-aea7-df2f6d634f09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{bcac2c14-878a-4dff-aea7-df2f6d634f09}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{bcac2c14-878a-4dff-aea7-df2f6d634f09}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{bcac2c14-878a-4dff-aea7-df2f6d634f09}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// -------------------------------------------------------------------------------------------------
2+
//
3+
// This code is a cTrader Algo API example.
4+
//
5+
// 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.
6+
//
7+
// This example plugin adds two custom frames to the charts area, displaying two different websites.
8+
//
9+
// For a detailed tutorial on creating this plugin, watch the video at: [to:do]
10+
//
11+
// -------------------------------------------------------------------------------------------------
12+
13+
using System;
14+
using cAlgo.API;
15+
using cAlgo.API.Collections;
16+
using cAlgo.API.Indicators;
17+
using cAlgo.API.Internals;
18+
19+
namespace cAlgo.Plugins
20+
{
21+
[Plugin(AccessRights = AccessRights.None)]
22+
public class MyCustomFrameExample : Plugin
23+
{
24+
WebView _cTraderWebView = new WebView();
25+
WebView _cTraderWebViewSite = new WebView();
26+
27+
protected override void OnStart()
28+
{
29+
_cTraderWebView.Loaded += _cTraderWebView_Loaded;
30+
var webViewFrame = ChartManager.AddCustomFrame("Forum");
31+
webViewFrame.Child = _cTraderWebView;
32+
webViewFrame.ChartContainer.Mode = ChartMode.Multi;
33+
webViewFrame.Attach();
34+
35+
_cTraderWebViewSite.Loaded += _cTraderWebViewSite_Loaded;
36+
var webViewFrameSite = ChartManager.AddCustomFrame("Site");
37+
webViewFrameSite.Child = _cTraderWebViewSite;
38+
webViewFrameSite.ChartContainer.Mode = ChartMode.Multi;
39+
webViewFrameSite.Attach();
40+
}
41+
42+
private void _cTraderWebView_Loaded(WebViewLoadedEventArgs args)
43+
{
44+
_cTraderWebView.NavigateAsync("https://www.ctrader.com/forum");
45+
}
46+
47+
private void _cTraderWebViewSite_Loaded(WebViewLoadedEventArgs args)
48+
{
49+
_cTraderWebViewSite.NavigateAsync("https://www.spotware.com");
50+
}
51+
52+
protected override void OnStop()
53+
{
54+
// Handle Plugin stop here
55+
}
56+
}
57+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
</PropertyGroup>
5+
6+
<ItemGroup>
7+
<PackageReference Include="cTrader.Automate" Version="*" />
8+
</ItemGroup>
9+
</Project>

0 commit comments

Comments
 (0)