Replies

d.asteriti
22 Jun 2023, 16:21

RE:

PanagiotisChar said:

Hi there,

Are you running your cBot on any virtualization technology (VPS, Parallels etc)? Try giving full access to your code and see if it solves the problem

Aieden Technologies

Need help? Join us on Telegram

 

I'm not running my cBot on any virtualization technology. I'snt a good solution giving full access at cBots, Do you suggest another solution?


@d.asteriti

d.asteriti
22 Jun 2023, 12:50

RE:

PanagiotisChar said:

Hi there,

You need to share the cBot code and your cTrader's version to get further assistance.

Aieden Technologies

Need help? Join us on Telegram

 

 

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleRSIcBot : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        [Parameter("Source", Group = "RSI")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", Group = "RSI", DefaultValue = 14)]
        public int Periods { get; set; }

        private RelativeStrengthIndex rsi;

        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);
        }

        protected override void OnTick()
        {
            if (rsi.Result.LastValue < 30)
            {
                Close(TradeType.Sell);
                Open(TradeType.Buy);
            }
            else if (rsi.Result.LastValue > 70)
            {
                Close(TradeType.Buy);
                Open(TradeType.Sell);
            }
        }

        private void Close(TradeType tradeType)
        {
            foreach (var position in Positions.FindAll("SampleRSI", SymbolName, tradeType))
                ClosePosition(position);
        }

        private void Open(TradeType tradeType)
        {
            var position = Positions.Find("SampleRSI", SymbolName, tradeType);
            var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);

            if (position == null)
                ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
        }
    }
}

 

cTrader Version 4.7.12.17878


@d.asteriti