Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
2
Indexable
Never
using System;
using cAlgo.API;

namespace RSIcBot
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class RSIcBot : Robot
    {
        [Parameter("RSI Period", DefaultValue = 14)]
        public int RsiPeriod { get; set; }

        [Parameter("Overbought Level", DefaultValue = 70)]
        public int OverboughtLevel { get; set; }

        [Parameter("Oversold Level", DefaultValue = 30)]
        public int OversoldLevel { get; set; }

        private RelativeStrengthIndex rsi;

        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(RsiPeriod);
        }

        protected override void OnBar()
        {
            double rsiValue = rsi.Result.LastValue;

            if (rsiValue > OverboughtLevel)
            {
                // Execute a sell or short trade here
                // Replace this with your actual trading logic
            }
            else if (rsiValue < OversoldLevel)
            {
                // Execute a buy or long trade here
                // Replace this with your actual trading logic
            }
        }
    }
}