Awesome Oscillator cBot free

by evgrinaus in category Trend at 14/02/2021

Using the Bill Williams Awesome Indicator, Hull MA, and ATR combined with Renko to give good results.

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

namespace cAlgo.Robots
    //Set time zone to Eastern Standard Time Best time to trade
    [Robot(TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.None)]
    public class AOBot : Robot
        //Functions and Parameters
        [Parameter("Risk %", DefaultValue = 0.02)]
        public double RiskPct { get; set; }

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

        [Parameter("MA Type", DefaultValue = MovingAverageType.Hull)]
        public int MAType { get; set; }

        [Parameter("Stop Loss (Pips)", DefaultValue = 3)]
        public int SL { get; set; }

        [Parameter("Take Profit (Pips)", DefaultValue = 3)]
        public int TP { get; set; }

        //Create indicator variables
        private AverageTrueRange atr;
        private MovingAverage ma;
        public AwesomeOscillator AO;

        protected override void OnStart()
            //Load indicators on start up EP5-ATR
            atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
            ma = Indicators.MovingAverage(Bars.MedianPrices, MAPeriods, MovingAverageType.Hull);
            AO = Indicators.AwesomeOscillator();


        protected override void OnTick()
            // Put your core logic here and Custom Indicators

            var Baseline = ma.Result.Last(0);
            var lastValue = AO.Result.Last(0);
            var prevValue = AO.Result.Last(1);

            // Check Entry signal

            if (lastValue > prevValue & Symbol.Bid > Baseline)
                Open(TradeType.Buy, "AO Long");
                Close(TradeType.Sell, "AO Short");
            else if (lastValue < prevValue & Symbol.Bid < Baseline)
                Open(TradeType.Sell, "AO Short");
                Close(TradeType.Buy, "AO Long");


        //Function for opening a new trade
        private void Open(TradeType tradeType, string Label)
            //Calculate trade amount based on ATR
            var ATR = atr.Result.Last(0) / Symbol.PipSize;
            var TradeAmount = (Account.Equity * RiskPct) / (1.5 * ATR * Symbol.PipValue);
            TradeAmount = Symbol.NormalizeVolumeInUnits(TradeAmount, RoundingMode.Down);
            ATR = Symbol.NormalizeVolumeInUnits(ATR, RoundingMode.Down);

            //Check there's no existing position before entering a trade
            var position = Positions.Find(Label, SymbolName);

            if (position == null)
                ExecuteMarketOrder(tradeType, SymbolName, TradeAmount, Label, SL, TP);

        //Function for closing trades
        private void Close(TradeType tradeType, string Label)
            foreach (var position in Positions.FindAll(Label, SymbolName, tradeType))