USD index

Created at 11 Jan 2018, 22:34
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ON

oneplusoc

Joined 09.03.2015

USD index
11 Jan 2018, 22:34


hello 

this indecator show all rsi for 7  Symbo is there any way to show onle one line for index i mean rsi of usd index  one line only for out put 

thanks 

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Levels(30, 70, 80, 50, 20)]

    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
    public class aarsiforall : Indicator
    {
        private RelativeStrengthIndex ma1, ma2, ma3, ma4, ma5, ma6, ma7;
        private MarketSeries series1, series2, series3, series4, series5, series6, series7;
        private Symbol symbol1, symbol2, symbol3, symbol4, symbol5, symbol6, symbol7;

        [Parameter(DefaultValue = "AUDUSD")]
        public string Symbol1 { get; set; }

        [Parameter(DefaultValue = "USDCHF")]
        public string Symbol2 { get; set; }

        [Parameter(DefaultValue = "NZDUSD")]
        public string Symbol3 { get; set; }

        [Parameter(DefaultValue = "EURUSD")]
        public string Symbol4 { get; set; }
        [Parameter(DefaultValue = "GBPUSD")]
        public string Symbol5 { get; set; }
        [Parameter(DefaultValue = "USDJPY")]
        public string Symbol6 { get; set; }
        [Parameter(DefaultValue = "USDCAD")]
        public string Symbol7 { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Output("MA Symbol 1", Color = Colors.Red, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result1 { get; set; }

        [Output("MA Symbol 2", Color = Colors.Magenta, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result2 { get; set; }

        [Output("MA Symbol 3", Color = Colors.Yellow, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result3 { get; set; }

        [Output("MA Symbol 4", Color = Colors.Brown, PlotType = PlotType.Line, Thickness = 1, LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Result4 { get; set; }
        [Output("MA Symbol 5", Color = Colors.White, PlotType = PlotType.Line, Thickness = 1, LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Result5 { get; set; }
        [Output("MA Symbol6", Color = Colors.Brown, PlotType = PlotType.Line, Thickness = 1, LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Result6 { get; set; }
        [Output("MA Symbol7", Color = Colors.BurlyWood, PlotType = PlotType.Line, Thickness = 1, LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Result7 { get; set; }

        protected override void Initialize()
        {
            symbol1 = MarketData.GetSymbol(Symbol1);
            symbol2 = MarketData.GetSymbol(Symbol2);
            symbol3 = MarketData.GetSymbol(Symbol3);
            symbol4 = MarketData.GetSymbol(Symbol4);
            symbol5 = MarketData.GetSymbol(Symbol5);

            symbol6 = MarketData.GetSymbol(Symbol6);

            symbol7 = MarketData.GetSymbol(Symbol7);


            series1 = MarketData.GetSeries(symbol1, TimeFrame);
            series2 = MarketData.GetSeries(symbol2, TimeFrame);
            series3 = MarketData.GetSeries(symbol3, TimeFrame);
            series4 = MarketData.GetSeries(symbol4, TimeFrame);
            series5 = MarketData.GetSeries(symbol5, TimeFrame);
            series6 = MarketData.GetSeries(symbol6, TimeFrame);
            series7 = MarketData.GetSeries(symbol7, TimeFrame);

            ma1 = Indicators.RelativeStrengthIndex(series1.Close, Period);
            ma2 = Indicators.RelativeStrengthIndex(series2.Close, Period);
            ma3 = Indicators.RelativeStrengthIndex(series3.Close, Period);
            ma4 = Indicators.RelativeStrengthIndex(series4.Close, Period);
            ma5 = Indicators.RelativeStrengthIndex(series5.Close, Period);
            ma6 = Indicators.RelativeStrengthIndex(series6.Close, Period);
            ma7 = Indicators.RelativeStrengthIndex(series7.Close, Period);


        }

        public override void Calculate(int index)
        {
            ShowOutput(symbol1, Result1, ma1, series1, index);
            ShowOutput(symbol2, Result2, ma2, series2, index);
            ShowOutput(symbol3, Result3, ma3, series3, index);
            ShowOutput(symbol4, Result4, ma4, series4, index);
            ShowOutput(symbol5, Result5, ma5, series5, index);
            ShowOutput(symbol6, Result6, ma6, series6, index);
            ShowOutput(symbol7, Result7, ma7, series7, index);
        }

        private void ShowOutput(Symbol symbol, IndicatorDataSeries result, RelativeStrengthIndex RelativeStrengthIndex, MarketSeries series, int index)
        {

            int index2 = GetIndexByDate(series, MarketSeries.OpenTime[index]);

            result[index] = RelativeStrengthIndex.Result[index2];

            string text = string.Format("{0} {1}", symbol.Code, Math.Round(result[index], 0));

            ChartObjects.DrawText(symbol.Code, text, index + 1, result[index], VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Yellow);

        }
        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i >= 0; i--)
                if (time == series.OpenTime[i])
                    return i;
            return -1;
        }
    }
}


@oneplusoc
Replies

PanagiotisCharalampous
12 Jan 2018, 11:42

Hi oneplusoc,

See below

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Levels(30, 70, 80, 50, 20)]

    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
    public class aarsiforall : Indicator
    {
        private RelativeStrengthIndex ma1;
        private MarketSeries series1;
        private Symbol symbol1;

        [Parameter(DefaultValue = "AUDUSD")]
        public string Symbol1 { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Output("MA Symbol 1", Color = Colors.Red, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result1 { get; set; }

        protected override void Initialize()
        {
            symbol1 = MarketData.GetSymbol(Symbol1);
            series1 = MarketData.GetSeries(symbol1, TimeFrame);
            ma1 = Indicators.RelativeStrengthIndex(series1.Close, Period);
        }

        public override void Calculate(int index)
        {
            ShowOutput(symbol1, Result1, ma1, series1, index);
        }

        private void ShowOutput(Symbol symbol, IndicatorDataSeries result, RelativeStrengthIndex RelativeStrengthIndex, MarketSeries series, int index)
        {
            int index2 = GetIndexByDate(series, MarketSeries.OpenTime[index]);
            result[index] = RelativeStrengthIndex.Result[index2];
            string text = string.Format("{0} {1}", symbol.Code, Math.Round(result[index], 0));
            ChartObjects.DrawText(symbol.Code, text, index + 1, result[index], VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Yellow);
        }
        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i >= 0; i--)
                if (time == series.OpenTime[i])
                    return i;
            return -1;
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

oneplusoc
12 Jan 2018, 12:24

RE:

Panagiotis Charalampous said:

Hi oneplusoc,

See below

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Levels(30, 70, 80, 50, 20)]

    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
    public class aarsiforall : Indicator
    {
        private RelativeStrengthIndex ma1;
        private MarketSeries series1;
        private Symbol symbol1;

        [Parameter(DefaultValue = "AUDUSD")]
        public string Symbol1 { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Output("MA Symbol 1", Color = Colors.Red, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Result1 { get; set; }

        protected override void Initialize()
        {
            symbol1 = MarketData.GetSymbol(Symbol1);
            series1 = MarketData.GetSeries(symbol1, TimeFrame);
            ma1 = Indicators.RelativeStrengthIndex(series1.Close, Period);
        }

        public override void Calculate(int index)
        {
            ShowOutput(symbol1, Result1, ma1, series1, index);
        }

        private void ShowOutput(Symbol symbol, IndicatorDataSeries result, RelativeStrengthIndex RelativeStrengthIndex, MarketSeries series, int index)
        {
            int index2 = GetIndexByDate(series, MarketSeries.OpenTime[index]);
            result[index] = RelativeStrengthIndex.Result[index2];
            string text = string.Format("{0} {1}", symbol.Code, Math.Round(result[index], 0));
            ChartObjects.DrawText(symbol.Code, text, index + 1, result[index], VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Yellow);
        }
        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i >= 0; i--)
                if (time == series.OpenTime[i])
                    return i;
            return -1;
        }
    }
}

Best Regards,

Panagiot

Thank you Sir  for reply 

but the indecator show only rsi value  of one Currency only

what i need to show 7 value of input  in one line call it line index of the 7 weight  input  

it mean if i need weight  USD RSI  from : AUD/USDEUR/USD GBP/USD NZD/USD USD/CAD USD/CHF USD/JPY show only value of USD 
Currency: weight  EUR RSI  from : EURAUD EURCAD EURCHF EURGBP EURJPY EURNZD EURUSD show only value of EUR

or chang like this 

Parameter(DefaultValue = "AUDUSD") to 
Parameter(DefaultValue = "USD"

thanks 


@oneplusoc