Category Trend  Published on 04/07/2023

Mwabuka Free optimizable bot

Description

Comment and ENjoy optimizing this bot its higly optimizable. its a simple but effective price action bot i build a couple of months ago. I share to u free. comment please. check me on TELEGRAM:


// copyright: Lawrence
// RUSSIAN STRATEGY, JUST 2MA AND RSI
// GOOD PERFOORMANCE

using System;
using System.Collections.Generic;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class MyBot : Robot
    {
        [Parameter("Take Profit", Group = "Risk Management", DefaultValue = 0)]
        public int takeProfit { get; set; }

        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1000, MinValue = 1000, Step = 1000)]
        public double Quantity { get; set; }

        [Parameter("Stop Loss", Group = "Risk Management", DefaultValue = 5)]
        public int stopLoss { get; set; }

        [Parameter("Percent K", Group = "Stochastic", DefaultValue = 5, MinValue = 0, Step = 1, MaxValue = 1000)]
        public int percentK { get; set; }

        [Parameter("Percent K Slowing", Group = "Stochastic", DefaultValue = 3, MinValue = 0, Step = 1, MaxValue = 1000)]
        public int percentKSlow { get; set; }

        [Parameter("Percent D", Group = "Stochastic", DefaultValue = 3, MinValue = 0, Step = 1, MaxValue = 1000)]
        public int percentD { get; set; }

        [Parameter("stoch MA Type", Group = "Stochastic")]
        public MovingAverageType stochMAType { get; set; }

        [Parameter("Stoch-sell threshold", Group = "Stochastic", DefaultValue = 75)]
        public int sellingstoch { get; set; }

        [Parameter("Stoch-buy threshold", Group = "Stochastic", DefaultValue = 35)]
        public int buyingstoch { get; set; }
        //MA       
        [Parameter("MA Type", Group = "Moving Average")]
        public MovingAverageType MAType { get; set; }
        //MA SOURCE
        [Parameter("Source", Group = "Moving Average")]
        public DataSeries SourceSeries { get; set; }

        [Parameter("Slow Periods", Group = "Moving Average", DefaultValue = 100)]
        public int SlowPeriods { get; set; }

        [Parameter("Fast Periods", Group = "Moving Average", DefaultValue = 5)]
        public int FastPeriods { get; set; }
        //MA      
        [Parameter("Stoch-k index", Group = "Stochastic", DefaultValue = 1, MinValue = 0, Step = 1)]
        public int indexK { get; set; }

        [Parameter("Number of bars to consider", DefaultValue = 2, MinValue = 0, Step = 1)]
        public int BarsToConsider { get; set; }

        private MovingAverage slowMa;
        private MovingAverage fastMa;
        private const string label = "Kilimanjaro peaks cBot";
        private StochasticOscillator stochasticOscillator;

        protected override void OnStart()
        {
            fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
            slowMa = Indicators.MovingAverage(SourceSeries, 50, MAType);
            stochasticOscillator = Indicators.StochasticOscillator(percentK, percentKSlow, percentD, stochMAType);
        }

        protected override void OnTick()
        {



        }

        protected override void OnBar()
        {
            var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);
            var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);
            var currentSlowMa = slowMa.Result.Last(0);
            var currentFastMa = fastMa.Result.Last(0);
            var previousSlowMa = slowMa.Result.Last(1);
            var previousFastMa = fastMa.Result.Last(1);
            if (Positions.Count < 1)
            {
                ///my algo
                if (currentFastMa > currentSlowMa && longPosition == null)
                {
                    if (Bars.ClosePrices.Last(2) < Bars.HighPrices.Last(BarsToConsider + 1) && Bars.LowPrices.Last(2) < Bars.LowPrices.Last(BarsToConsider + 1))
                    {
                        // Higher highs and higher lows, check for sell signal
                        if (Bars.ClosePrices.Last(1) > Bars.OpenPrices.Last(1) && stochasticOscillator.PercentK.Last(1) < buyingstoch && stochasticOscillator.PercentK.Last(indexK) <= buyingstoch)
                        //&& rsi.Result.LastValue < buyRSI 
                        {
                            if (shortPosition != null)
                                ClosePosition(shortPosition);
                            ExecuteMarketOrder(TradeType.Buy, SymbolName, Quantity, "Scalp", stopLoss, takeProfit);
                        }

                    }

                    if (currentFastMa < currentSlowMa && shortPosition == null)
                    {
                        if (Bars.ClosePrices.Last(2) > Bars.HighPrices.Last(BarsToConsider + 1) && Bars.LowPrices.Last(2) > Bars.LowPrices.Last(BarsToConsider + 1))
                        {
                            // lower lows and lower high, check for sell signal
                            if (Bars.ClosePrices.Last(1) < Bars.OpenPrices.Last(1) && stochasticOscillator.PercentK.Last(1) > sellingstoch && stochasticOscillator.PercentK.Last(indexK) >= sellingstoch)
                            //&& rsi.Result.LastValue > sellRSI && stochasticOscillator.PercentK.Last(2) > sellingstoch
                            {
                                if (longPosition != null)
                                    ClosePosition(longPosition);
                                ExecuteMarketOrder(TradeType.Sell, SymbolName, Quantity, "Scalp", stopLoss, takeProfit);
                            }
                        }
                    }
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////





DA
davidmwabuka

Joined on 07.03.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: pata pata BOT.algo
  • Rating: 5
  • Installs: 831
  • Modified: 04/07/2023 15:13
Comments
Log in to add a comment.
AL
algoprotocol · 1 year ago

Looks interesting. Can you post some tweaked parameters?