Description
Follow my cTrader Telegram group at https://t.me/cTraderCommunity; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp and an Instagram page https://www.instagram.com/ctrader_community/
This is a multi currency Rate of Change. It will show the strength of every major currency without the influence of another as happens in regular crosses.
This indicator will take a while to load, to make it faster use the "Only Chart Currencies" option.
It is also MTF, because why not!?
For any bug report or suggestion, follow my telegram group or comment below
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Threading;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class _indexes_ROC : Indicator
{
[Parameter("TimeFrame")]
public TimeFrame tf { get; set; }
[Parameter("Snoothing", DefaultValue = 1)]
public int smt { get; set; }
[Parameter("Periods", DefaultValue = 48)]
public int per { get; set; }
[Parameter("Only Chart Currencies", DefaultValue = true)]
public bool onlyCC { get; set; }
public IndicatorDataSeries[] dataCalc = new IndicatorDataSeries[8];
[Output("EUR", Color = Colors.Cyan)]
public IndicatorDataSeries _EUR { get; set; }
[Output("USD", Color = Colors.Red)]
public IndicatorDataSeries _USD { get; set; }
[Output("GBP", Color = Colors.Blue)]
public IndicatorDataSeries _GBP { get; set; }
[Output("AUD", Color = Colors.Yellow)]
public IndicatorDataSeries _AUD { get; set; }
[Output("CAD", Color = Colors.Orange)]
public IndicatorDataSeries _CAD { get; set; }
[Output("CHF", Color = Colors.White)]
public IndicatorDataSeries _CHF { get; set; }
[Output("JPY", Color = Colors.Green)]
public IndicatorDataSeries _JPY { get; set; }
[Output("NZD", Color = Colors.Purple)]
public IndicatorDataSeries _NZD { get; set; }
private MarketSeries[] series = new MarketSeries[28];
private SimpleMovingAverage[] smas = new SimpleMovingAverage[28];
private int[] indexes = new int[28];
protected override void Initialize()
{
for (int i = 0; i < 8; i++)
{
dataCalc[i] = CreateDataSeries();
}
loadCrosses();
IndicatorArea.MouseWheel += OnIndicatorAreaMouseWheel;
Chart.DrawHorizontalLine("0", 0, Color.Gray);
}
void OnIndicatorAreaMouseWheel(ChartMouseWheelEventArgs obj)
{
if (obj.CtrlKey && obj.Delta > 0)
smt++;
else if (obj.CtrlKey && obj.Delta < 0)
{
smt--;
smt = smt <= 0 ? 1 : smt;
}
if (obj.ShiftKey && obj.Delta > 0)
per++;
else if (obj.ShiftKey && obj.Delta < 0)
{
per--;
per = per <= 0 ? 1 : per;
}
smaChangePeriod();
for (int i = 0; i < Chart.BarsTotal; i++)
Calculate(i);
}
public override void Calculate(int index)
{
setIndexes(index);
for (int i = 0; i < 8; i++)
{
dataCalc[i][index] = 0;
for (int k = 0; k < 28; k++)
{
if (series[k] == null)
continue;
if (onlyCC && currencies[i] != Symbol.Name.Substring(0, 3) && currencies[i] != Symbol.Name.Substring(0, 3) && currencies[i] != Symbol.Name.Substring(3, 3) && currencies[i] != Symbol.Name.Substring(3, 3))
continue;
if (series[k].SymbolCode.Substring(0, 3) == currencies[i])
{
dataCalc[i][index] += (smas[k].Result[indexes[k]] - smas[k].Result[indexes[k] - per]) / smas[k].Result[indexes[k] - per];
}
else if (series[k].SymbolCode.Substring(3, 3) == currencies[i])
{
dataCalc[i][index] += -(smas[k].Result[indexes[k]] - smas[k].Result[indexes[k] - per]) / smas[k].Result[indexes[k] - per];
}
}
dataCalc[i][index] /= 7;
}
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "EUR" || Symbol.Name.Substring(3, 3) == "EUR")) || !onlyCC)
_EUR[index] = dataCalc[0][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "USD" || Symbol.Name.Substring(3, 3) == "USD")) || !onlyCC)
_USD[index] = dataCalc[1][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "GBP" || Symbol.Name.Substring(3, 3) == "GBP")) || !onlyCC)
_GBP[index] = dataCalc[2][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "AUD" || Symbol.Name.Substring(3, 3) == "AUD")) || !onlyCC)
_AUD[index] = dataCalc[3][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "CAD" || Symbol.Name.Substring(3, 3) == "CAD")) || !onlyCC)
_CAD[index] = dataCalc[4][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "CHF" || Symbol.Name.Substring(3, 3) == "CHF")) || !onlyCC)
_CHF[index] = dataCalc[5][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "JPY" || Symbol.Name.Substring(3, 3) == "JPY")) || !onlyCC)
_JPY[index] = dataCalc[6][index];
if ((onlyCC && (Symbol.Name.Substring(0, 3) == "NZD" || Symbol.Name.Substring(3, 3) == "NZD")) || !onlyCC)
_NZD[index] = dataCalc[7][index];
}
public string[] currencies =
{
"EUR",
"USD",
"GBP",
"AUD",
"CAD",
"CHF",
"JPY",
"NZD"
};
private void loadCrosses()
{
int i = 0;
foreach (var firstCurr in currencies)
{
foreach (var secondCurr in currencies)
{
if (onlyCC && firstCurr != Symbol.Name.Substring(0, 3) && firstCurr != Symbol.Name.Substring(3, 3) && secondCurr != Symbol.Name.Substring(0, 3) && secondCurr != Symbol.Name.Substring(3, 3))
{
i++;
continue;
}
if (firstCurr == secondCurr)
continue;
try
{
series[i] = MarketData.GetSeries(firstCurr + secondCurr, tf);
smas[i] = Indicators.SimpleMovingAverage(series[i].Close, smt);
} catch (Exception e)
{
i--;
}
i++;
}
}
}
private void setIndexes(int currIndex)
{
for (int i = 0; i < 28; i++)
{
try
{
indexes[i] = series[i].OpenTime.GetIndexByTime(MarketSeries.OpenTime[currIndex]);
} catch (Exception e)
{
}
}
}
private void smaChangePeriod()
{
for (int i = 0; i < 28; i++)
{
try
{
smas[i] = smas[i] = Indicators.SimpleMovingAverage(series[i].Close, smt);
} catch (Exception e)
{
}
}
}
private void normalizeDataSeries(IndicatorDataSeries series, IndicatorDataSeries targetSeries)
{
double max = 0;
double min = double.PositiveInfinity;
for (int i = 0; i < series.Count; i++)
{
min = Math.Min(series[i], min);
max = Math.Max(series[i], max);
}
max = max - min;
for (int i = 0; i < series.Count; i++)
{
targetSeries[i] = (series[i] - min) / max;
}
}
}
}
cysecsbin.01
Joined on 10.11.2018 Blocked
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: !_indexes_ROC.algo
- Rating: 0
- Installs: 1666
- Modified: 13/10/2021 09:54
Comments
great indicator!
it should be possible to use RSI instead of ROC?
thanks for your hard work!
Hi everyone, with the last update this indicator stopped working. Do you know how I could make it work again? Thank you in advance