Replies

uwyness
14 Feb 2019, 05:20

Solved : multi currency indicator

Solved my own problem, though it isn't an elegant solution.

Created a simple Close indicator. Passed the new indicator to the Indicators.RelativeStrengthIndex method.

CloseIndicator:

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 CloseIndicator : Indicator
    {
        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

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

        private MarketSeries series;

        protected override void Initialize()
        {
            series = MarketData.GetSeries(symbolInput, TimeFrame);
        }

        public override void Calculate(int index)
        {
            Result[index] = series.Close[series.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index])];
        }
    }
}

Getting RSI of another currency:

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

        private CloseIndicator closeInd;

        closeInd = Indicators.GetIndicator<CloseIndicator>(symbolInput);
        _Rsi = Indicators.RelativeStrengthIndex(closeInd.Result, RSI_Period);

Please let me know if you any other suggestions.


@uwyness

uwyness
14 Feb 2019, 03:52

multi currency for Indicators.RelativeStrengthIndex

Thanks. I would've never guessed from the examples in previous threads.

How would I pass the close prices series to an indicator?

series = MarketData.GetSeries("AUDUSD", TimeFrame);

_Rsi = Indicators.RelativeStrengthIndex(series.Close, RSI_Period);

Is there a page somewhere that explains how the Results and series.Close indexes differ?


@uwyness

uwyness
13 Feb 2019, 00:15

MarketData.GetSeries returns incorrect data

Looks like MarketData.GetSeries returns incorrect data

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 NewIndicator : Indicator
    {
        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        private MarketSeries series;

        protected override void Initialize()
        {
            series = MarketData.GetSeries("AUDUSD", TimeFrame.Hour);
        }

        public override void Calculate(int index)
        {
            Result[index] = series.Close[index];
        }
    }
}

the AUDUSD H1 12/02/2019 10:00 UTC+2 close should be 0.70804. However, the above code is giving 0.76245.


@uwyness

uwyness
08 Feb 2019, 04:51

Balance: https://ctrader.com/api/reference/internals/iaccount/balance

Equity: https://ctrader.com/api/reference/internals/iaccount/equity


@uwyness