Warning! This section will be deprecated on February 1st 2025. Please move all your Indicators to the cTrader Store catalogue.
Description
private void DrawRectangle(string objectName, int x, double y, int width, double height, Colors color, int thickness, LineStyle style) { ChartObjects.DrawLine(objectName + "a", x, y, x + width, y, color, thickness, style); ChartObjects.DrawLine(objectName + "b", x + width, y, x + width, y + height, color, thickness, style); ChartObjects.DrawLine(objectName + "c", x + width, y + height, x, y + height, color, thickness, style); ChartObjects.DrawLine(objectName + "d", x, y + height, x, y, color, thickness, style); } private void RemoveRectangle(string objectName) { ChartObjects.RemoveObject(objectName + "a"); ChartObjects.RemoveObject(objectName + "b"); ChartObjects.RemoveObject(objectName + "c"); ChartObjects.RemoveObject(objectName + "d"); }
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class AWVLine : Indicator
{
ChartVerticalLine vl;
[Parameter("Horizental Alignment", DefaultValue = HorizontalAlignment.Left, Group = "Button")]
public HorizontalAlignment HAlignment { get; set; }
[Parameter("Vertical Alignment", DefaultValue = VerticalAlignment.Top, Group = "Button")]
public VerticalAlignment VAlignment { get; set; }
[Parameter("Backgroun Color", DefaultValue = "", Group = "Button")]
public string Colorb { get; set; }
[Parameter("Foreground Color", DefaultValue = "Black", Group = "Button")]
public string Colorf { get; set; }
[Parameter("Opacity", DefaultValue = 0.7, MinValue = 0.1, MaxValue = 1, Group = "Button")]
public double Opacity { get; set; }
[Parameter("Line Color", DefaultValue = "Red", Group = "Line")]
public string LineColor { get; set; }
[Parameter("LineStyle", DefaultValue = LineStyle.LinesDots, Group = "Line")]
public LineStyle ls { get; set; }
[Parameter("Thickness", DefaultValue = 2, Group = "Line")]
public int Thickness { get; set; }
protected override void Initialize()
{
var toggleButton = new ToggleButton
{
Text = "Vline",
Margin = 10,
VerticalAlignment = VAlignment,
HorizontalAlignment = HAlignment,
MaxWidth = 70,
MaxHeight = 40,
BackgroundColor = Colorb,
Opacity = Opacity,
ForegroundColor = Colorf,
BorderThickness = 1,
BorderColor = Colorf
};
toggleButton.Checked += ToggleButton_Checked;
toggleButton.Unchecked += ToggleButton_Unchecked;
Chart.AddControl(toggleButton);
foreach (ChartObject obj in Chart.Objects)
{
if (obj.ObjectType == ChartObjectType.VerticalLine)
{
ChartVerticalLine line = (ChartVerticalLine)obj;
if (line.Name == "scrollLine")
{
Bars bars = MarketData.GetBars(Chart.TimeFrame, SymbolName);
int ind = bars.OpenTimes.GetIndexByTime(line.Time);
Chart.ScrollXTo(ind - 20);
}
}
}
}
public override void Calculate(int index)
{
}
protected void ToggleButton_Checked(ToggleButtonEventArgs obj)
{
vl = Chart.DrawVerticalLine("scrollLine", (Chart.LastVisibleBarIndex + Chart.FirstVisibleBarIndex) / 2, Color.FromName(LineColor), Thickness, ls);
vl.IsInteractive = true;
}
private void ToggleButton_Unchecked(ToggleButtonEventArgs obj)
{
Chart.RemoveObject(vl.Name);
}
}
}
ES
esmaeilalizadeh26
Joined on 20.05.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: AW VLine.algo
- Rating: 0
- Installs: 1379
- Modified: 18/01/2022 08:50
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
I've been looking for ways to deal with depression after breaking up with my partner for a long time. Luckily I found the "Stop list: What Not to Do After a Breakup" article.