Ten Moving Average Bot free

Description

This robot performs operations when the candlestick opens with a value or equal to the simple average of 10 periods based on the lows, and closes orders with the same average only calculated with the lows.

Good results with larger H1 graphics

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
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TenMovingAverage : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        private MovingAverage tenMinimum;
        private MovingAverage tenMaximum;

        private double volumeInUnits;

        protected override void OnStart()
        {
            volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
            tenMinimum = Indicators.MovingAverage(Bars.LowPrices, 10, MovingAverageType.Simple);
            tenMaximum = Indicators.MovingAverage(Bars.HighPrices, 10, MovingAverageType.Simple);
        }

        protected override void OnBar()
        {
            if (Positions.Count() > 0)
            {
                if (Bars.LastBar.High >= tenMaximum.Result.LastValue)
                {
                    foreach (var position in Positions)
                    {
                        ClosePosition(position);
                    }
                }
            }

            if (Bars.LastBar.Close <= tenMinimum.Result.LastValue)
            {
                ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, "");
            }
        }
    }
}
Comments

udabinabah - August 17, 2020 @ 23:26

I've been inspired from your bot, which i've made some change on it. And here it is, 

A 100% Winning Bots and a '0' Losing Trade...


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 FourMovingAverage : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }
        public double LastValue { get; set; }

        private MovingAverage FourMinimum;
        private MovingAverage FourMaximum;

        private double volumeInUnits;

        protected override void OnStart()
        {
            volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
            FourMinimum = Indicators.MovingAverage(Bars.LowPrices, 4, MovingAverageType.Simple);
            FourMaximum = Indicators.MovingAverage(Bars.HighPrices, 4, MovingAverageType.Simple);
        }

        protected override void OnBar()
        {
            if (Positions.Count() > 1)
            {
                if (Bars.LastBar.High >= FourMaximum.Result.LastValue)
                {
                    foreach (var position in Positions)
                    {
                        if (position.Pips > 0)
                        {
                            ClosePosition(position);
                        }
                    }
                }
            }

            if (Bars.LastBar.Close >= FourMinimum.Result.LastValue)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "Buy");
            }
            else if (Bars.LastBar.Low <= FourMaximum.Result.LastValue)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "Sell");
            }
            {
                foreach (var position in Positions)
                {
                    if (position.Pips > 0)
                    {
                        ClosePosition(position);
                    }
                }
            }
        }
    }
}

 

 

(^_^)