OrglobalFx Simple RSI cBOT free

by orglobalng in category Other at 03/03/2021
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

 

 

Warning! Executing the following cBot may result in loss of funds. Use it at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgo
//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

    }
}
Comments
0