Topics
Replies
Singleton
19 Mar 2018, 12:03
RE: RE:
I tried changing width and colors, but to no avail. I think the issue is that in "ChartObjects.DrawLine," the starting point and finishing point of line is the same. I just need to see open and close of actual price on top of a heiken ashi chart.
This would have been no issue if I can have a main bar chart on the foreground - on the top of the layer, as in MT4 and MT5. but it seems that I cannot put indicators back to the original price chart; indicators always get plotted on the top of charts.
Thank you
@Singleton
Singleton
19 Mar 2018, 11:57
RE:
Panagiotis Charalampous said:
Hi Singleton,
It would be easier for us to help you if you shared with us the complete indicator code.
Best Regards,
Panagiotis
Thank you for a comment. I am seeking the way to mark open and close price on heiken ashi candles. I came up with the idea of drawing a line at open and close price, with its width big enough to denote actual open and close.
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AccessRights = AccessRights.None)] public class HeikenAshiSmoothed : Indicator { [Parameter(DefaultValue = 5, MinValue = 1)] public int Periods { get; set; } [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)] public MovingAverageType MAType { get; set; } [Parameter("Candle width", DefaultValue = 5)] public int CandleWidth { get; set; } private MovingAverage maOpen; private MovingAverage maClose; private MovingAverage maHigh; private MovingAverage maLow; private IndicatorDataSeries haClose; private IndicatorDataSeries haOpen; protected override void Initialize() { maOpen = Indicators.MovingAverage(MarketSeries.Open, Periods, MAType); maClose = Indicators.MovingAverage(MarketSeries.Close, Periods, MAType); maHigh = Indicators.MovingAverage(MarketSeries.High, Periods, MAType); maLow = Indicators.MovingAverage(MarketSeries.Low, Periods, MAType); haOpen = CreateDataSeries(); haClose = CreateDataSeries(); } public override void Calculate(int index) { double haHigh; double haLow; Colors Color; if (index > 0 && !double.IsNaN(maOpen.Result[index - 1])) { haOpen[index] = (haOpen[index - 1] + haClose[index - 1]) / 2; haClose[index] = (maOpen.Result[index] + maClose.Result[index] + maHigh.Result[index] + maLow.Result[index]) / 4; haHigh = Math.Max(maHigh.Result[index], Math.Max(haOpen[index], haClose[index])); haLow = Math.Min(maLow.Result[index], Math.Min(haOpen[index], haClose[index])); Color = (haOpen[index] > haClose[index]) ? Colors.Red : Colors.Blue; ChartObjects.DrawLine("BarHA" + index, index, haOpen[index], index, haClose[index], Color, 5, LineStyle.Solid); ChartObjects.DrawLine("LineHA" + index, index, haHigh, index, haLow, Color, 1, LineStyle.Solid); ChartObjects.DrawLine("LineHA2" + index, index, MarketSeries.Open[index], index, MarketSeries.Close[index], Color, CandleWidth, LineStyle.Solid); ChartObjects.DrawLine("LineHA3" + index, index, MarketSeries.Close[index], index, MarketSeries.Close[index], Color, CandleWidth, LineStyle.Solid); } else if (!double.IsNaN(maOpen.Result[index])) { haOpen[index] = (maOpen.Result[index] + maClose.Result[index]) / 2; haClose[index] = (maOpen.Result[index] + maClose.Result[index] + maHigh.Result[index] + maLow.Result[index]) / 4; haHigh = maHigh.Result[index]; haLow = maLow.Result[index]; } } } }
@Singleton
Singleton
02 Mar 2017, 05:07
( Updated at: 02 Mar 2017, 09:25 )
Allow charts on foreground, above all indicators.
I have some indicators on charts which makes charts less clear and visible.
Or give options to arrange the order of layers of each study
@Singleton
Singleton
01 Mar 2017, 05:42
( Updated at: 01 Mar 2017, 07:22 )
Let us plot indicators to the background of a chart or have a chart front of indicators.
Currently multiple moving averages, for example. clutter a chart, mkaing it diffcult to distinguish chart patterns
Users should have options to have a chart on foreground or modify the order of layers on which each indicator is plotted.
@Singleton
Singleton
30 Jul 2016, 14:25
RE: RE:
Thank you so much
msforex said:
Here you go
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(ScalePrecision = 5, AccessRights = AccessRights.None)] public class OSMAMACD : Indicator { private MovingAverage longperiod; private MovingAverage shortperiod; private MovingAverage signal; [Parameter("Long Cycle", DefaultValue = 20)] public int LongCycle { get; set; } [Parameter("Short Cycle", DefaultValue = 5)] public int ShortCycle { get; set; } [Parameter("Signal Periods", DefaultValue = 3)] public int SignalPeriods { get; set; } [Output("MACD", Color = Colors.Blue)] public IndicatorDataSeries MACD { get; set; } [Output("Signal", Color = Colors.Red, LineStyle = LineStyle.Lines)] public IndicatorDataSeries Signal { get; set; } protected override void Initialize() { longperiod = Indicators.MovingAverage(MarketSeries.Close, LongCycle, MovingAverageType.Simple); shortperiod = Indicators.MovingAverage(MarketSeries.Close, ShortCycle, MovingAverageType.Simple); signal = Indicators.SimpleMovingAverage(MACD, SignalPeriods); } public override void Calculate(int index) { MACD[index] = shortperiod.Result[index] - longperiod.Result[index]; Signal[index] = signal.Result[index]; } } }
@Singleton
Singleton
13 Mar 2016, 19:19
RE: RE:
croucrou said:
You can do it like this:
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 NewIndicator : Indicator { private DirectionalMovementSystem adx; protected override void Initialize() { adx = Indicators.DirectionalMovementSystem(yourPeriod); } public override void Calculate(int index) { if (adx.ADX.LastValue > 20) { ChartObjects.DrawText("Alert", "ADX above 20!", StaticPosition.BottomLeft, Colors.Yellow); } } } }
Thank you so much for writing it. I appreciate it. Is it easy to learn c# for cTrader Algo only?
@Singleton
Singleton
23 Mar 2018, 11:27
RE:
Sorry for a late reply
I tried your suggestion, but I was disappointed that it did not solve the problem. result in the same as having a original bar chart behind heiken ashi. The objects "Points" are drawn behind heiken ashi. This was, regrettably, no better than having a original bar chart behind heiken ashi, in which open and close of bars occasionally get covered behind heiken ashi bars.
May I seek another suggestion from you?
Incidentally, I think it is critical to allow original charts, whether bars or candlesticks, to be drawn on the top of indicators, ideally with options of choosing layers on which indicators are plotted, imaginably by way of an object tree.
Thank you
@Singleton