I want a simple indicator but can't find it anywhere, any help welcome.

Created at 31 Aug 2018, 06:33
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

oneb700d@gmail.com

Joined 02.04.2018

I want a simple indicator but can't find it anywhere, any help welcome.
31 Aug 2018, 06:33


How hard is it to write a simple RSI indicator? I want to return the value of the RSI and display it as a number at the top of my chart without the graphical representation. I have zero knowledge of how to write ctrader bots / indicators.

I can't seem to find what I'm looking for by searching, so looks like i need to learn the API and write my own but i have no idea where to start.

I have no knowledge of C#, just know Javascript, but id rather just use someones elses code rather than learning a new language and a new API for what seems like it would be a few lines of code.

Does anyone know if this is possible or should i just start learning?

Thanks in advance!

 


@oneb700d@gmail.com
Replies

PanagiotisCharalampous
31 Aug 2018, 10:59

Hi oneb700d@gmail.com,

Is this what you are looking for?

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {

        RelativeStrengthIndex _rsi;
        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }
        protected override void OnTick()
        {
            Chart.DrawText("RSI", _rsi.Result.LastValue.ToString(), Server.Time, Symbol.Ask, Color.Red);
        }

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

Best Regards,

Panagiotis


@PanagiotisCharalampous

oneb700d@gmail.com
31 Aug 2018, 11:35

RE:

Panagiotis Charalampous said:

Hi oneb700d@gmail.com,

Is this what you are looking for?

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {

        RelativeStrengthIndex _rsi;
        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }
        protected override void OnTick()
        {
            Chart.DrawText("RSI", _rsi.Result.LastValue.ToString(), Server.Time, Symbol.Ask, Color.Red);
        }

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

Best Regards,

Panagiotis

Hey thanks for the reply, when i try build that code I'm getting 2 errors, is there something I'm missing? 


@oneb700d@gmail.com

PanagiotisCharalampous
31 Aug 2018, 11:41

Hi oneb700d@gmail.com,

The code was written with the new version of the API, 3.01. Have you tried it on Spotware cTrader Public Beta?

Best Regards,

Panagiots


@PanagiotisCharalampous

oneb700d@gmail.com
31 Aug 2018, 14:37

I manged to get it working and that is exactly what i want, but not as a bot! Is it possible to just do that sort of thing without a bot? and just an indicator on its own?

 

Thanks again, sorry for being a pain.


@oneb700d@gmail.com

PanagiotisCharalampous
31 Aug 2018, 14:43

Hi,

Here is the indicator equivalent

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {

        RelativeStrengthIndex _rsi;
        protected override void Initialize()
        {
            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }

        public override void Calculate(int index)
        {
            Chart.DrawText("RSI", _rsi.Result.LastValue.ToString(), Server.Time, Symbol.Ask, Color.Red);
        }
    }
}

 


@PanagiotisCharalampous