Category Trend  Published on 11/12/2020

1000%/year BOLLINGER BANDS EUR-USD H8

Description

This bot use Bollinger bands to trade, After many time backtest I have  good parameters to take profit on this trading system.

The following show the result on Free Version And Pro version (Now pro version is free and and post on these now)

Donation via Paypal

Email: nghiand.amz@gmail.com

Facebook: https://www.facebook.com/nghiand.amz

Telegram: +84 969228100

Free version:

Parameter:

-Source, BandPeriods,Std,MAType: Is Bollinger Bands parameters,

-Initial Volume Percent: % money you trade (default 1% balance)

-Stop Loss: Stop Loss on Pip

-Take Profit: Take Profit by Pip


 


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.UTC, AccessRights = AccessRights.None)]
    public class DragonBollingerBandsPro : Robot
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }
        [Parameter("BandPeriods", DefaultValue = 19)]
        public int BandPeriod { get; set; }
        [Parameter("Std", DefaultValue = 1.6)]
        public double std { get; set; }
        [Parameter("MAType")]
        public MovingAverageType MAType { get; set; }
        [Parameter("Initial Volume Percent", DefaultValue = 1, MinValue = 0)]
        public double InitialVolumePercent { get; set; }
        [Parameter("Stop Loss", DefaultValue = 80)]
        public int StopLoss { get; set; }
        [Parameter("Take Profit", DefaultValue = 60)]
        public int TakeProfit { get; set; }
        [Parameter("MaxFail", DefaultValue = 1)]
        public int MaxFail { get; set; }
        [Parameter(DefaultValue = 1)]
        public int MaxPosition { get; set; }
        [Parameter("Trailing Stop", DefaultValue = false)]
        public bool TrailingStop { get; set; }

        private Position lastPosition;

        private int countFalse = 0;

        private BollingerBands boll;
        private double lastVolume;

        private string _label;

        protected override void OnStart()
        {
            // Put your initialization logic here
            boll = Indicators.BollingerBands(Source, BandPeriod, std, MAType);
            _label = string.Format("DragonBollingerPro{0}", Guid.NewGuid());
        }

        protected override void OnBar()
        {

            if (Positions.FindAll(_label).Length >= MaxPosition)
            {
                return;
            }



            if (Bars.Last(2).Close > boll.Top.Last(2))
            {
                if (Bars.Last(1).Close > boll.Top.Last(1))
                {
                    CreateOrder(TradeType.Buy);

                }
                else
                {
                    CreateOrder(TradeType.Sell);

                }
            }
            else if (Bars.Last(2).Close < boll.Bottom.Last(2))
            {
                if (Bars.Last(1).Close < boll.Bottom.Last(1))
                {
                    CreateOrder(TradeType.Sell);
                }
                else
                {

                    CreateOrder(TradeType.Buy);
                }
            }


        }

        private void CreateOrder(TradeType type)
        {
            var volumne = Math.Floor(Account.Balance * 10 * InitialVolumePercent / 1000) * 1000;


            if (lastPosition != null)
            {
                Print("countFalse: {0}", countFalse);
                if (lastPosition.NetProfit < 0 && countFalse < MaxFail)
                {
                    volumne = lastVolume * 2;
                    countFalse = countFalse + 1;
                }
                else
                {
                    countFalse = 0;
                }
            }

            var result = ExecuteMarketOrder(type, Symbol.Name, volumne, _label, StopLoss, TakeProfit, "new Order", TrailingStop);
            if (result.IsSuccessful)
            {
                lastPosition = result.Position;
                lastVolume = volumne;
                Print("volume:" + volumne);
            }
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}


nghiand.amz's avatar
nghiand.amz

Joined on 06.07.2020

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: DragonBollingerBands Pro.algo
  • Rating: 0
  • Installs: 4390
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
nghiand.amz's avatar
nghiand.amz · 3 years ago

I removed Proversion on GUMROAD and add it here. You can download it for free, if you like it  you can

Donate via Paypal

AH
ahnmaak · 3 years ago

Is the Pro Version Still Available? Gumroad link is no longer up.

DM
dm1988air · 3 years ago

Waste of time. At least free version and parameters from description. -99% of cash in my demo account disapeared :D

nghiand.amz's avatar
nghiand.amz · 4 years ago

Hi trading.ternet ,

I've just fixed it,

Thank you.

TR
trading.ternet · 4 years ago

Thank you  nghiand for cBot
Just a suggestion on this script :
On initialization : Chart.DrawStaticText ... crashes Optimization and backtest without visual mode test
Just add

if (RunningMode == RunningMode.RealTime || RunningMode == RunningMode.VisualBacktesting)
    Chart.DrawStaticText("download_PRO"...........
Without this, optimization gives all the line with zero result.
Have a good day
Michel