Coloring bars
Created at 12 Mar 2016, 00:18
Ма
Coloring bars
12 Mar 2016, 00:18
Hi All!
Can I change color of bars?
like in Alex Elder impulse system.
Replies
Максим_Коваленко
13 Mar 2016, 21:24
Here is complete indicator Elders impulse system:
using cAlgo.API; using cAlgo.API.Indicators; namespace ImpulseSystem { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class ImpulseSystem : Indicator { private MovingAverage ema; private MacdCrossOver macdCrossOver; /// <summary> /// Период скользящей средней /// </summary> [Parameter(DefaultValue = 13)] public int EmaPeriod { get; set; } /// <summary> /// Главный индикатор EMA /// </summary> [Output("EMA")] public IndicatorDataSeries Ema { get; set; } public override void Calculate(int index) { this.Ema[index] = this.ema.Result[index]; if (this.ema.Result.IsRising() && this.macdCrossOver.Histogram.IsRising()) { this.DrawBar(index, Colors.Green); } else if (this.ema.Result.IsFalling() && this.macdCrossOver.Histogram.IsFalling()) { this.DrawBar(index, Colors.Red); } else { this.DrawBar(index, Colors.Aqua); } } /// <inheritdoc /> protected override void Initialize() { this.ema = Indicators.MovingAverage(this.MarketSeries.Close, this.EmaPeriod, MovingAverageType.Exponential); this.macdCrossOver = Indicators.MacdCrossOver(this.MarketSeries.Close, 26, 12, 9); } private void DrawBar(int index, Colors color) { this.ChartObjects.DrawLine("candle" + index, index, MarketSeries.Open[index], index, MarketSeries.Close[index], color, 5); this.ChartObjects.DrawLine("wick" + index, index, MarketSeries.High[index], index, MarketSeries.Low[index], color); } } }
@Максим_Коваленко
... Deleted by UFO ...
... Deleted by UFO ...
croucrou
12 Mar 2016, 19:24
RE:
You can do this like this:
@croucrou