KY
Topics
24 Jan 2014, 05:31
9075
11
Replies
Kyriakos
27 Jan 2014, 11:10
RE:
Thank you for your help but it still doesn't trade after changing the indicator:
namespace cAlgo.Indicators { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)] public class HeikenAshiJohn : Indicator { [Parameter("Period", DefaultValue = 1, MinValue = 1, MaxValue = 2147483647)] public int ParameterPeriod { get; set; } [Output("xClose")] public IndicatorDataSeries xClose { get; set; } [Output("xHigh")] public IndicatorDataSeries xHigh { get; set; } [Output("xLow")] public IndicatorDataSeries xLow { get; set; } [Output("xOpen")] public IndicatorDataSeries xOpen { get; set; }
@Kyriakos
Kyriakos
27 Jan 2014, 08:23
HA Indicator
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)] public class HeikenAshiJohn : Indicator { [Parameter("Period", DefaultValue = 1, MinValue = 1, MaxValue = 2147483647)] public int ParameterPeriod { get; set; } public IndicatorDataSeries xClose; public IndicatorDataSeries xHigh; public IndicatorDataSeries xLow; public IndicatorDataSeries xOpen; protected override void Initialize() { xClose = CreateDataSeries(); xHigh = CreateDataSeries(); xLow = CreateDataSeries(); xOpen = CreateDataSeries(); } public override void Calculate(int index) { if (index <= ParameterPeriod) { xOpen[index] = Math.Round((MarketSeries.Open[index] + MarketSeries.Close[index]) / 2, Symbol.Digits); xClose[index] = Math.Round((MarketSeries.Open[index] + MarketSeries.Low[index] + MarketSeries.High[index] + MarketSeries.Close[index]) / 4, Symbol.Digits); xHigh[index] = MarketSeries.High[index]; xLow[index] = MarketSeries.Low[index]; return; } xOpen[index] = Math.Round((xOpen[index - 1] + xClose[index - 1]) / 2, Symbol.Digits); xClose[index] = Math.Round((MarketSeries.Open[index] + MarketSeries.Low[index] + MarketSeries.High[index] + MarketSeries.Close[index]) / 4, Symbol.Digits); xHigh[index] = Math.Max(MarketSeries.High[index], Math.Max(xOpen[index], xClose[index])); xLow[index] = Math.Min(MarketSeries.Low[index], Math.Min(xOpen[index], xClose[index])); if (xClose[index] < xOpen[index]) { ChartObjects.DrawLine("OpenClose-" + index.ToString(), index, xOpen[index], index, xClose[index], Colors.Red, 5, LineStyle.Solid); ChartObjects.DrawLine("HighLow-" + index.ToString(), index, xHigh[index], index, xLow[index], Colors.Red, 1, LineStyle.Solid); } else { ChartObjects.DrawLine("OpenClose-" + index.ToString(), index, xOpen[index], index, xClose[index], Colors.Yellow, 5, LineStyle.Solid); ChartObjects.DrawLine("HighLow-" + index.ToString(), index, xHigh[index], index, xLow[index], Colors.Yellow, 1, LineStyle.Solid); } } } }
@Kyriakos
Kyriakos
27 Jan 2014, 12:47
RE:
You are amazing thank you. :)
adaled said:
@Kyriakos