Description
hi
With this control you can draw zigzag manually
First Press َ ALT+ Z to enable
Then a trend line is drawn with each left mouse click
Press َ ALT+ Z to disable again
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ZigZagManual : Indicator
{
[Parameter("Modifier Key", DefaultValue = ModifierKeys.Alt)]
public ModifierKeys ModifierKeyAlt { get; set; }
[Parameter("Key", DefaultValue = Key.Z)]
public Key KeyA { get; set; }
[Parameter("Color", DefaultValue = "Red")]
public Color ColorValue { get; set; }
[Parameter("LineStyle", DefaultValue = LineStyle.Dots)]
public LineStyle LineStyleValue { get; set; }
[Parameter("Thickness", DefaultValue = 2, MinValue = 1, MaxValue = 5)]
public int ThicknessValue { get; set; }
private bool start = false;
private DateTime time1;
private double y1;
private DateTime time2;
private double y2;
private int counter = 1;
public override void Calculate(int index)
{
}
protected override void Initialize()
{
Chart.AddHotkey(() => KeyHandler(), KeyA, ModifierKeyAlt);
Chart.MouseDown += Chart_MouseDown;
}
private void Chart_MouseDown(ChartMouseEventArgs obj)
{
if (start == true)
{
if (counter == 1)
{
time1 = obj.TimeValue;
y1 = obj.YValue;
counter++;
}
else
{
time2 = obj.TimeValue;
y2 = obj.YValue;
counter++;
var trendLine = Chart.DrawTrendLine("trendLine" + y1 + counter, time1, y1, time2, y2, ColorValue, ThicknessValue, LineStyleValue);
trendLine.IsInteractive = true;
time1 = time2;
y1 = y2;
}
}
}
private void KeyHandler()
{
start = start == false ? true : false;
counter = 1;
}
}
}
MA
ma.norouzifar
Joined on 12.09.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: ZigZag-Manual.algo
- Rating: 5
- Installs: 1075
- Modified: 22/02/2023 20:23
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.
Why did I press َ ALT+ Z again and still not get the same result as you. hurdle