Acumulative Swing Index Bot free

by jorgearteaga in category Trend at 16/11/2021
Description

Acumulative Swing Index Bot

Este bot usa el indicador de Acumulative Swing Index para determinar si se realizan compras o ventas, este ejemplo fue realizado en el EURUSD | h6

Cualquier duda o aclaración pueden contactarme: @arteagagalicia

 

   Autor: Jorge Eduardo Arteaga Galicia
   @arteagagalicia

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 ASIBOT : Robot
    {
        private double _volumeInUnits;
        private AccumulativeSwingIndex _accumulativeSwingIndex;
        private const string Label = "Acumulative Swing Index";

        [Parameter("Lots", DefaultValue = 1, Group = "Autor: Jorge Arteaga\n@arteagagalicia\n\nLots")]
        public double Lots { get; set; }

        [Parameter("Periods", DefaultValue = 12, Group = "ASI Indicator")]
        public int Periods { get; set; }

        [Parameter("Equity", DefaultValue = 0, Group = "ASI Indicator")]
        public int Equity { get; set; }

        protected override void OnStart()
        {
            // Put your initialization logic here
            _volumeInUnits = Symbol.QuantityToVolumeInUnits(Lots);
            _accumulativeSwingIndex = Indicators.AccumulativeSwingIndex(Periods);
        }

        protected override void OnTick()
        {
            // Put your core logic here
            var shortPosition = Positions.Find(Label, SymbolName, TradeType.Sell);
            var longPosition = Positions.Find(Label, SymbolName, TradeType.Buy);

            if (_accumulativeSwingIndex.Result.Last(1) > Equity && _accumulativeSwingIndex.Result.Last(2) <= Equity && longPosition == null)
            {
                ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label);
                if (shortPosition != null)
                {
                    ClosePosition(shortPosition);
                }
            }
            else if (_accumulativeSwingIndex.Result.Last(1) < Equity && _accumulativeSwingIndex.Result.Last(2) >= Equity && shortPosition == null)
            {
                ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label);
                if (longPosition != null)
                {
                    ClosePosition(longPosition);
                }
            }

        }

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

galafrin - November 23, 2021 @ 21:18

Hola, sencillo pero eficaz robot sin embargo la pregunta de confirmar la señal antes de abrir queda por resolver.

5