Topics
17 Oct 2020, 14:17
 2
 990
 1
Replies

GoldFishTrader
19 Aug 2021, 12:54 ( Updated at: 19 Aug 2021, 12:55 )

Simple BOT

Below is a simple bot that sends an email for every position opened and closed.

Just replace the me@email.com (from/to) with your own email address and the Email body if required. I strongly advise to use your own email server which works best.


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 PositionEmailAlert : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            // Put your initialization logic here
            Positions.Opened += OnPositionsOpened;
            Positions.Closed += OnPositionsClosed;
        }

        void OnPositionsOpened(PositionOpenedEventArgs args)
        {
            Notifications.SendEmail("me@email.com", "me@email.com", "OPEN TRADE", "Email body");
        }

        void OnPositionsClosed(PositionClosedEventArgs args)
        {
            Notifications.SendEmail("me@email.com", "me@email.com", "CLOSE TRADE", "Email body");
        }
    }

}


@GoldFishTrader