Modify cBot

50 USD  Payment method:  Direct Payment
Open

OK, so I'll try to describe it with the help of google translator. the existing cbot works well, but like any martingale system it has its problems, it earns significantly and then flushes the entire bill. I want to eliminate as many of these risks as possible. Therefore I have the following improvements: 1- adjustable number of multiplied trades (now it is unlimited) 2- possibility to set the multiplier (now it is only double), 3- possibility to set the multiplier manually from the first to the sixth (the first would be 0.05, the second not double, but maybe only 0.08, the third not 0.16, but maybe 0.12, etc.). Would you handle it?

 

// -------------------------------------------------------------------------------------------------

//

//    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 Martingale cBot" creates a random Sell or Buy order. If the Stop loss is hit, a new 

//    order of the same type (Buy / Sell) is created with double the Initial Volume amount. The cBot will 

//    continue to double the volume amount for  all orders created until one of them hits the take Profit. 

//    After a Take Profit is hit, a new random Buy or Sell order is created with the Initial Volume amount.

//

// -------------------------------------------------------------------------------------------------

 

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 SampleMartingalecBot : Robot

    {

        [Parameter("Initial Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]

        public double InitialQuantity { get; set; }

 

        [Parameter("Stop Loss", Group = "Protection", DefaultValue = 40)]

        public int StopLoss { get; set; }

 

        [Parameter("Take Profit", Group = "Protection", DefaultValue = 40)]

        public int TakeProfit { get; set; }

 

 

        private Random random = new Random();

 

        protected override void OnStart()

        {

            Positions.Closed += OnPositionsClosed;

 

            ExecuteOrder(InitialQuantity, GetRandomTradeType());

        }

 

        private void ExecuteOrder(double quantity, TradeType tradeType)

        {

            var volumeInUnits = Symbol.QuantityToVolumeInUnits(quantity);

            var result = ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "Martingale", StopLoss, TakeProfit);

 

            if (result.Error == ErrorCode.NoMoney)

                Stop();

        }

 

        private void OnPositionsClosed(PositionClosedEventArgs args)

        {

            Print("Closed");

            var position = args.Position;

 

            if (position.Label != "Martingale" || position.SymbolName != SymbolName)

                return;

 

            if (position.GrossProfit > 0)

            {

                ExecuteOrder(InitialQuantity, GetRandomTradeType());

            }

            else

            {

                ExecuteOrder(position.Quantity * 2, position.TradeType);

            }

        }

 

        private TradeType GetRandomTradeType()

        {

            return random.Next(2) == 0 ? TradeType.Buy : TradeType.Sell;

        }

    }

}

Hi. I can do that.

Email: Bienve.pf@hotmail.com 
Whatsapp/Telegram: +34654115547
 

Regards

Hi there,

We can help you with your project. You can contact us at contact@clickalgo.com for more information.

Best Regards,

Donald