Category Other  Published on 03/03/2021

OrglobalFx Simple RSI cBOT

Description

OrglobalFx Simple RSI cBOT v1.0

Contact: orglobalng@gmail.com

 

Logic:

  • Buy = rsi > 50  and < 70 and is rising.
  • Sell = rsi >30 and < 50 and is falling

 

 


//OrglobalFx Simple RSI cBOT
// orglobalng@gmail.com
// Buy = rsi > 50  and < 70 and is rising.
// Sell = rsi >30 and < 50 and is falling
//////////////////////////////////////////////////////////////////////////

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.EasternStandardTime, AccessRights = AccessRights.None)]
    public class OrglobalFx_Simple_RSIBOT_v1_0 : Robot
    {

        private RelativeStrengthIndex _rsi;


        [Parameter("Instance Name", DefaultValue = "OrglobalFx_3MAwae")]
        public string InstanceName { get; set; }

        [Parameter("Volume", DefaultValue = 1000, Group = "Protection")]
        public double volume { get; set; }

        [Parameter("Stop Loss (pips)", Group = "Protection", DefaultValue = 20)]
        public double StopLossInPips { get; set; }

        [Parameter("Take Profit (pips)", Group = "Protection", DefaultValue = 40)]
        public double TakeProfitInPips { get; set; }

        [Parameter(Group = "Moving Averages")]
        public DataSeries rsiSource { get; set; }

        [Parameter("RSI Periods", DefaultValue = 10, Group = "Moving Averages")]
        public int rsiPeriod { get; set; }

        #region onstart
        protected override void OnStart()
        {
            // Put your initialization logic here
            _rsi = Indicators.RelativeStrengthIndex(rsiSource, rsiPeriod);
            InstanceName = InstanceName + "_" + SymbolName;
        }
        #endregion

        #region onBar
        protected override void OnBar()
        {
            var position = Positions.Find(InstanceName, SymbolName);

            if (_rsi.Result.Last(1) > 50 && _rsi.Result.Last(1) < 70 && _rsi.Result.IsRising())
            {
                if (position == null)
                    ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, InstanceName, StopLossInPips, TakeProfitInPips);
            }

            if (_rsi.Result.Last(1) < 50 && _rsi.Result.Last(1) > 30 && _rsi.Result.IsFalling())
            {
                if (position == null)
                    ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, InstanceName, StopLossInPips, TakeProfitInPips);
            }
        }
        #endregion

    }
}


Orglobalfx01's avatar
Orglobalfx01

Joined on 03.03.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: OrglobalFx_Simple_RSIBOT_v1_0.algo
  • Rating: 0
  • Installs: 1588
Comments
Log in to add a comment.
No comments found.