Use EMA on RSI chart

Created at 19 Sep 2017, 17:46
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!
irmscher9's avatar

irmscher9

Joined 22.12.2016

Use EMA on RSI chart
19 Sep 2017, 17:46


Hey guys

I would like to use Exponential Moving average on an RSI chart like this:

 

So I did this:

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter("Source")]
        public DataSeries SourceSeries { get; set; }

        [Parameter("Initial Volume", DefaultValue = 100000, MinValue = 1000)]
        public int InitialVolume { get; set; }

        private RelativeStrengthIndex _rsi;
         private ExponentialMovingAverage _ema17rsi;
   

        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(SourceSeries, 14);
            _ema17rsi = Indicators.ExponentialMovingAverage(_rsi, 17);
                 }

        protected override void OnTick()
        {
            if (_ema17rsi.Result.HasCrossedAbove(_rsi.Result.LastValue, 0))
            {   
                //do something
            }
        }

      
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

So as you can see I would like to use EMA and RSI crossover as a trigger within the RSI chart. But the above example doesn't.

Could you please show me what I did wrong?

 

Cheers :)


@irmscher9
Replies

PanagiotisCharalampous
20 Sep 2017, 10:37

Hi irmscher9,

In the HasCrossedAbove() function you should pass as parameter _rsi.Result and not _rsi.Result.Value. See example below

        protected override void OnTick()
        {
            if (_ema17rsi.Result.HasCrossedAbove(_rsi.Result, 0))
            {             
            }
        }

Let me know if this is what you are looking for

Best Regards,

Panagiotis


@PanagiotisCharalampous

irmscher9
20 Sep 2017, 19:20

Yes, right, but this part though:

_ema17rsi = Indicators.ExponentialMovingAverage(_rsi.Result, 17);

Thanks for the prompt reply! :)


@irmscher9