Category Trend  Published on 16/11/2021

Acumulative Swing Index Bot

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


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
        }
    }
}


jorgearteaga's avatar
jorgearteaga

Joined on 12.02.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: ASIBOT.algo
  • Rating: 5
  • Installs: 1896
  • Modified: 16/11/2021 19:31
Comments
Log in to add a comment.
SE
seceton233 · 2 years ago

Is this bot working on my Jojoy app because this app provide modded version of app.

GA
galafrin · 2 years ago

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