Description
The fastest way to switch between favourite symbols.
Symbols list can be set with input parameter separated by comma.
[Update]
Added position parameter
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Linq;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SwitchSymbol : Indicator
{
[Parameter("Symbols", DefaultValue = "EURUSD, GBPUSD, USDJPY, AUDUSD")]
public string SymbolsText { get; set; }
[Parameter()]
public Position Position { get; set; }
protected override void Initialize()
{
var symbolNames = SymbolsText.Split(new[]
{
','
}).Select(s => s.Trim()).Where(s => string.IsNullOrWhiteSpace(s) == false).ToArray();
var verticalAlignment = (Position == Position.TopLeft || Position == Position.TopRight) ? VerticalAlignment.Top : VerticalAlignment.Bottom;
var horizontalAlignment = (Position == Position.TopLeft || Position == Position.BottomLeft) ? HorizontalAlignment.Left : HorizontalAlignment.Right;
var stackPanel = new StackPanel
{
VerticalAlignment = verticalAlignment,
HorizontalAlignment = horizontalAlignment,
Margin = 8,
Orientation = Orientation.Vertical
};
foreach (var symbolName in symbolNames)
{
var button = new Button
{
Text = symbolName,
Margin = 2,
IsEnabled = symbolName != SymbolName,
FontSize = 9
};
button.Click += Button_Click;
stackPanel.AddChild(button);
}
Chart.AddControl(stackPanel);
}
private void Button_Click(ButtonClickEventArgs obj)
{
var symbolName = obj.Button.Text;
Chart.TryChangeTimeFrameAndSymbol(TimeFrame, symbolName);
}
public override void Calculate(int index)
{
}
}
public enum Position
{
TopLeft,
TopRight,
BottomLeft,
BottomRight
}
}
![bart1's avatar](/uploads/user-16327/avatar/491513bcab0bdb93f012754771fa6a08d50e92be.png)
bart1
Joined on 03.08.2017
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: SwitchSymbol.algo
- Rating: 5
- Installs: 2514
Comments
![bart1's avatar](/uploads/user-16327/avatar/491513bcab0bdb93f012754771fa6a08d50e92be.png)
New indicator with symbols and periods
https://ctrader.com/algos/indicators/show/2562
![bart1's avatar](/uploads/user-16327/avatar/491513bcab0bdb93f012754771fa6a08d50e92be.png)
It just needs on chart location changing option.
Added
So easy and so usefull!
Cool gadget, thank you.
It just needs on chart location changing option.
NON funziona...
![Symposium's avatar](/uploads/user-19097/avatar/22f78a3c1f3f758e152619fc5c1cd70e44fc5cbc.jpeg)
This is a great utility for Ctrader, I can display a column of 28 crosses plus oil and metals on a 43" Monitor which requires me to only have 1 or 2 Charts open..... Very creative utility.
![jani's avatar](/uploads/user-23066/avatar/fa7d72017d2e7b7d478679e551880ee147be114e.jpeg)
Great Script, thanks a lot! This is really helping as cTrader has quite a bit memory leakage and seems not to be able to handle well multiple (over 12 or so) open charts without crashing.
Thank you, it's a very useful tool.
With the latest platform update (4.2.18), the indicator has lost some compatibility. Its graphical interface disappears for a few seconds every time the chart is switched.