Information

Username: Mr4x
Member since: 12 Apr 2019
Last login: 30 Jun 2024
Status: Active

Activity

Where Created Comments
Algorithms 1 8
Forum Topics 14 19
Jobs 0 0

Last Algorithm Comments

MR
Mr4x · 6 months ago

What parameters have you set to get that win/loss ratio and also that a amount of profit?

I have tried optimisation on ICMarkets and I can't get anything close to the results you get - especially on a $1K account…

MR
Mr4x · 2 years ago

Feel free to share successful parameters and trading instruments if anybody manages to make this work for them ;)

MR
Mr4x · 2 years ago

Here is the code with SL and TP. Just be aware that if SL or TP is hit whilst RSI value is still under "oversold" or over "overbought" then it will add a new position when the old one is closed out. To disable SL and TP just set a very high SL and TP like 10000.

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

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class RSIBotwithMA : Robot
    {
        private Position _position;
        private MovingAverage ma;
        private RelativeStrengthIndex rsi;

        [Parameter("Source")]
        public DataSeries Source { get; set; }

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

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

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

        [Parameter("MA Period", DefaultValue = 200)]
        public int MAPeriod { get; set; }

        [Parameter("Volume", DefaultValue = 1000, MinValue = 0)]
        public int Volume { get; set; }

        [Parameter("Take Profit", DefaultValue = 100, MinValue = 1)]
        public int TP { get; set; }

        [Parameter("Stop Loss", DefaultValue = 100, MinValue = 1)]
        public int SL { get; set; }

        [Parameter("MA Type")]
        public MovingAverageType MAType { get; set; }

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

        protected override void OnBar()
        {
            if (Trade.IsExecuting)
                return;

            if (rsi.Result.LastValue < Oversold && (ma.Result.LastValue < MarketSeries.Close.LastValue) && _position == null)
            {
                OpenPosition(TradeType.Buy);
            }

            if (rsi.Result.LastValue > Overbought && (ma.Result.LastValue > MarketSeries.Close.LastValue) && _position == null)
            {
                OpenPosition(TradeType.Sell);
            }
            if (_position != null)
            {
                if (_position.TradeType == TradeType.Buy && rsi.Result.LastValue > Overbought)
                {
                    Trade.Close(_position);
                }

                if (_position.TradeType == TradeType.Sell && rsi.Result.LastValue < Oversold)
                {
                    Trade.Close(_position);
                }
            }
        }

        private void OpenPosition(TradeType command)
        {
            ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, null, SL, TP);
        }

        protected override void OnPositionOpened(Position openedPosition)
        {
            _position = openedPosition;
        }

        protected override void OnPositionClosed(Position closedPosition)
        {
            _position = null;
        }
    }
}

MR
Mr4x · 2 years ago

I have modified this bot to make the MA function work

https://ctrader.com/algos/cbots/show/2926

 

MR
Mr4x · 4 years ago

CoreTradingHouse,

A couple more observations too:

First Volume is always 1000, regardless of what number you put in the field.

Volume Exponent isn't accurate, and sometimes places the highest volume trade on starting a new grid even once the grid restarted. Eg: previous grid may get to 12 lots, then grid closes, then new grid starts at 12 lots instead of 0.1.

Just some hopefully helpful observations so far :)

Mr4x

MR
Mr4x · 4 years ago

CoreTradingHouse,

I compiled your version of the grid trade and definitely very interesting results. 20% profit over a 3 year period on EURUSD but one thing I noticed is that it only places sell trades? Anyway thought you should know :)

Another idea I have, but my bot-building skills are basic at best, is to incorporate a moving average to smartgrid V3 that can be defined by the user, and have the bot only grid in the direction of the moving average, with an overall take profit that closes all long and short positions when x amount in profit. What do you think?

Mr4x

MR
Mr4x · 4 years ago

Basic adjustment to code to make all parameters configurable, including upper and lower RSI range and stop-loss / take-profit.

// -------------------------------------------------------------------------------------------------
//
//    This code is a cTrader Automate API example.
//
//    This cBot is intended to be used as a sample and does not guarantee any particular outcome or
//    profit of any kind. Use it at your own risk.
//    
//    All changes to this file might be lost on the next application update.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
//    The "Sample RSI cBot" will create a buy order when the Relative Strength Index indicator crosses the  level 30, 
//    and a Sell order when the RSI indicator crosses the level 70. The order is closed be either a Stop Loss, defined in 
//    the "Stop Loss" parameter, or by the opposite RSI crossing signal (buy orders close when RSI crosses the 70 level 
//    and sell orders are closed when RSI crosses the 30 level). 
//
//    The cBot can generate only one Buy or Sell order at any given time.
//
// -------------------------------------------------------------------------------------------------

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.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; }

        [Parameter("Lower RSI Level", Group = "RSI", DefaultValue = 30, MinValue = 0, MaxValue = 50)]
        public int LRL { get; set; }

        [Parameter("Upper RSI Level", Group = "RSI", DefaultValue = 70, MinValue = 50, MaxValue = 100)]
        public int URL { get; set; }

        [Parameter("Take Profit in pips", Group = "TP SL", DefaultValue = 100)]
        public int TP { get; set; }

        [Parameter("Stop Loss in pips", Group = "TP SL", DefaultValue = 100)]
        public int SL { get; set; }

        private RelativeStrengthIndex rsi;

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

        protected override void OnTick()
        {
            if (rsi.Result.LastValue < LRL)
            {
                Close(TradeType.Sell);
                Open(TradeType.Buy);
            }
            else if (rsi.Result.LastValue > URL)
            {
                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", SL, TP);
        }
    }
}

MR
Mr4x · 5 years ago

Friends,

I feel like I have almost honed in on something worthy. I have figured that USDJPY and CHFJPY are very highly correlated most of the time, so therefor being long USDJPY and short CHFJPY at the same time can quite often yield good results, the swap is also positive overall this way.

The method I am using so far, with positive returns on both days after 2 days, cannot be backtested as it relies on running 2 instances of this bot on the same account at the same time (which also keeps your equity somewhat in balance). This means it has to be used in a demo account, unless one of you smart cookies can figure out a way to cross-test and share the best results. Here are my settings so far, please try to optimise them for better return / lower drawdown and get back to me:

Chart : USDJPY

Timeframe : 15 min

Buy : Yes

Sell : No

Pipstep : 5

Volume Exponent : 1.1

Average TP : 4

First Volume : 2000 (0.20 LOT)

Max Spread : 2

Account Margin : 40000 US DOLLAR

Leverage : 1/500

 

---AND---

 

Chart : CHFJPY

Timeframe : 15 min

Buy : No

Sell : Yes

Pipstep : 5

Volume Exponent : 1.1

Average TP : 4

First Volume : 2000 (0.20 LOT)

Max Spread : 2

Account Margin : 40000 US DOLLAR

Leverage : 1/500