Hi, I did this customized USDX indicator but sometimes doesn't work, it gets stuck. Can you tell me how to fix it?
Thanks
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class USDXMajors : Indicator
{
//[Parameter()]
//public TimeFrame TF { get; set; }
[Parameter("Body Width", DefaultValue = 6)]
public int BodyWidth { get; set; }
[Parameter("Symbol 1", DefaultValue = "EURUSD")]
public string sim1 { get; set; }
[Parameter("Symbol 2", DefaultValue = "USDJPY")]
public string sim2 { get; set; }
[Parameter("Symbol 3", DefaultValue = "GBPUSD")]
public string sim3 { get; set; }
[Parameter("Symbol 4", DefaultValue = "AUDUSD")]
public string sim4 { get; set; }
[Parameter("Symbol 5", DefaultValue = "USDCAD")]
public string sim5 { get; set; }
[Parameter("Symbol 6", DefaultValue = "USDCHF")]
public string sim6 { get; set; }
[Parameter("Symbol 7", DefaultValue = "NZDUSD")]
public string sim7 { get; set; }
[Output("Open", Color = Colors.Black, PlotType = PlotType.Points)]
public IndicatorDataSeries Open { get; set; }
[Output("High", Color = Colors.Black, PlotType = PlotType.Points)]
public IndicatorDataSeries High { get; set; }
[Output("Low", Color = Colors.Black, PlotType = PlotType.Points)]
public IndicatorDataSeries Low { get; set; }
[Output("Close", Color = Colors.Black, PlotType = PlotType.Points)]
public IndicatorDataSeries Close { get; set; }
private MarketSeries MS1;
private MarketSeries MS2;
private MarketSeries MS3;
private MarketSeries MS4;
private MarketSeries MS5;
private MarketSeries MS6;
private MarketSeries MS7;
protected override void Initialize()
{
MS1 = MarketData.GetSeries(sim1, TimeFrame);
MS2 = MarketData.GetSeries(sim2, TimeFrame);
MS3 = MarketData.GetSeries(sim3, TimeFrame);
MS4 = MarketData.GetSeries(sim4, TimeFrame);
MS5 = MarketData.GetSeries(sim5, TimeFrame);
MS6 = MarketData.GetSeries(sim6, TimeFrame);
MS7 = MarketData.GetSeries(sim7, TimeFrame);
}
public override void Calculate(int index)
{
Open[index] = Math.Pow(MS1.Open[index], -0.384) * Math.Pow(MS2.Open[index], 0.183) * Math.Pow(MS3.Open[index], -0.155) * Math.Pow(MS4.Open[index], -0.087) * Math.Pow(MS5.Open[index], 0.072) * Math.Pow(MS6.Open[index], 0.063) * Math.Pow(MS7.Open[index], -0.056);
High[index] = Math.Pow(MS1.High[index], -0.384) * Math.Pow(MS2.High[index], 0.183) * Math.Pow(MS3.High[index], -0.155) * Math.Pow(MS4.High[index], -0.087) * Math.Pow(MS5.High[index], 0.072) * Math.Pow(MS6.High[index], 0.063) * Math.Pow(MS7.High[index], -0.056);
Low[index] = Math.Pow(MS1.Low[index], -0.384) * Math.Pow(MS2.Low[index], 0.183) * Math.Pow(MS3.Low[index], -0.155) * Math.Pow(MS4.Low[index], -0.087) * Math.Pow(MS5.Low[index], 0.072) * Math.Pow(MS6.Low[index], 0.063) * Math.Pow(MS7.Low[index], -0.056);
Close[index] = Math.Pow(MS1.Close[index], -0.384) * Math.Pow(MS2.Close[index], 0.183) * Math.Pow(MS3.Close[index], -0.155) * Math.Pow(MS4.Close[index], -0.087) * Math.Pow(MS5.Close[index], 0.072) * Math.Pow(MS6.Close[index], 0.063) * Math.Pow(MS7.Close[index], -0.056);
var colorWick = Open[index] < Close[index] ? Colors.Green : Colors.Red;
var colorBody = Open[index] < Close[index] ? Colors.Green : Colors.Red;
ChartObjects.DrawLine("wick" + index, index, High[index], index, Low[index], colorWick);
ChartObjects.DrawLine("body" + index, index, Open[index], index, Close[index], colorBody, BodyWidth);
}
}
}