Information
Username: | iForex2015 |
Member since: | 17 Mar 2015 |
Last login: | 07 Oct 2024 |
Status: | Active |
Activity
Where | Created | Comments |
---|---|---|
Algorithms | 1 | 4 |
Forum Topics | 20 | 19 |
Jobs | 0 | 0 |
Last Algorithm Comments
Changing candle color algorithmically is possible now .
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class BreakOutCandles : Indicator
{
[Parameter("How Many Break Out Bars", DefaultValue = 5)]
public int HowManyBreakOutCandles { get; set; }
[Parameter("Breakout up color", DefaultValue = "Green")]
public string UpColor { get; set; }
[Parameter("Breakout down color", DefaultValue = "Red")]
public string DownColor { get; set; }
[Parameter("Range color", DefaultValue = "LightGray")]
public string RangeColor { get; set; }
private Color color;
protected override void Initialize()
{
}
public override void Calculate(int index)
{
try
{
var open = MarketSeries.Open[index];
var close = MarketSeries.Close[index];
var high = MarketSeries.High[index];
var low = MarketSeries.Low[index];
var highest = MarketSeries.High[index - 1];
var lowest = MarketSeries.Low[index - 1];
for (int i = 2; i <= HowManyBreakOutCandles; i++)
{
if (highest < MarketSeries.High[index - i])
highest = MarketSeries.High[index - i];
if (lowest > MarketSeries.Low[index - i])
lowest = MarketSeries.Low[index - i];
}
if (close > highest && close > open)
color = Color.FromName(UpColor);
else if (close < lowest && close < open)
color = Color.FromName(DownColor);
else if (close > open)
color = Color.FromName(RangeColor);
else if (close <= open)
color = Color.FromName(RangeColor);
Chart.SetBarColor(index, color);
} catch (Exception)
{
}
}
}
}
@ M_Anjom You are right, pitchfork wont disappear without Chart.RemoveObject("AndrewsPitchFork");
I will edit ASAP. I would also like to add a few more options like option to change fork color, switch zigzag on/off etc. Let me see.
Thanks btw.