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
Joined on 03.08.2017
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: SwitchSymbol.algo
- Rating: 5
- Installs: 2670
- Modified: 13/10/2021 09:54
Comments
New indicator with symbols and periods
https://ctrader.com/algos/indicators/show/2562
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...
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.
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.