multi-symbols on one chart
Created at 02 Jan 2018, 19:51
multi-symbols on one chart
02 Jan 2018, 19:51
I want to draw multi symbols in one chart but there are no outputs.
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 MultiCurrency : Indicator { [Parameter(DefaultValue = "EURUSG")] public string Symboleu { get; set; } [Parameter(DefaultValue = "USDJPY")] public string Symboluj { get; set; } [Parameter(DefaultValue = "XAUUSD")] public string Symbolxu { get; set; } [Output("Correlation1", Color = Colors.Goldenrod)] public IndicatorDataSeries Result1 { get; set; } [Output("Correlation2", Color = Colors.Blue)] public IndicatorDataSeries Result2 { get; set; } [Output("Correlation3", Color = Colors.GhostWhite)] public IndicatorDataSeries Result3 { get; set; } MarketSeries series1; MarketSeries series2; MarketSeries series3; protected override void Initialize() { series1 = MarketData.GetSeries(Symboleu, this.TimeFrame); series2 = MarketData.GetSeries(Symboluj, this.TimeFrame); series3 = MarketData.GetSeries(Symbolxu, this.TimeFrame); } public override void Calculate(int index) { // Calculate value at specified index //Result1[index] = MarketData.GetSeries(Symboleu, TimeFrame.Hour).Close[index]; int index1 = series1.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); int index2 = series2.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); int index3 = series3.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); Result1[index] = series1.Close[index1]; Result2[index] = series2.Close[index2]; Result3[index] = series3.Close[index3]; } } }
Replies
itmfar
06 Feb 2018, 10:03
RE:
Panagiotis Charalampous said:
Hi itmfar,
Did you mean EURUSD instead of EURUSG? In any case, please try the code sample below
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 MultiCurrency : Indicator { [Parameter(DefaultValue = "EURUSG")] public string Symboleu { get; set; } [Parameter(DefaultValue = "USDJPY")] public string Symboluj { get; set; } [Parameter(DefaultValue = "XAUUSD")] public string Symbolxu { get; set; } [Output("Correlation1", Color = Colors.Goldenrod)] public IndicatorDataSeries Result1 { get; set; } [Output("Correlation2", Color = Colors.Blue)] public IndicatorDataSeries Result2 { get; set; } [Output("Correlation3", Color = Colors.GhostWhite)] public IndicatorDataSeries Result3 { get; set; } MarketSeries series1; MarketSeries series2; MarketSeries series3; protected override void Initialize() { series1 = MarketData.GetSeries(Symboleu, this.TimeFrame); series2 = MarketData.GetSeries(Symboluj, this.TimeFrame); series3 = MarketData.GetSeries(Symbolxu, this.TimeFrame); } public override void Calculate(int index) { // Calculate value at specified index //Result1[index] = MarketData.GetSeries(Symboleu, TimeFrame.Hour).Close[index]; if (series1 != null) { int index1 = series1.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); Result1[index] = series1.Close[index1]; } if (series2 != null) { int index2 = series2.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); Result2[index] = series2.Close[index2]; } if (series3 != null) { int index3 = series3.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index]); Result3[index] = series3.Close[index3]; } } } }You need to check first if the series have any values before invoking them to avoid any unexpected issues.
Let me know if this solves your problem.
Best Regards,
Panagiotis
Thanks alot
@itmfar
PanagiotisCharalampous
03 Jan 2018, 16:51
Hi itmfar,
Did you mean EURUSD instead of EURUSG? In any case, please try the code sample below
You need to check first if the series have any values before invoking them to avoid any unexpected issues.
Let me know if this solves your problem.
Best Regards,
Panagiotis
@PanagiotisCharalampous