You need to enable JavaScript in order to visit our site!
 
Logo PTMC
NAVIGATION
CANCEL
 
or via PTMC account
Restore password
or via PTMC account
Logo PTMC
NAVIGATION
or via PTMC account
Restore password
or via PTMC account
or via PTMC account
Restore password
or via PTMC account
Burhay Vlad Burhay Vlad 19.08 2016

Send free PTMC notifications to your Slack channel via gmail

In day to day trading an optimization process of a routine work takes an important role. Sometimes it is really a challenge, but today our team is glad to present easy setups for PTMC community to make tradings more convenient than back in past days. If you are using Slack messenger you are probably already aware of its functionality and politics of bots provided within this handy tool. It is multitask and reliable notification system which could not pass away from our attention.

By using any trading strategy, add-on or indicator in PTMC, a coder can use API's SendEmail() method to notify yourself with trading signals, events, news etc. But going even further all incoming messages from terminal now can be forwarded to your Slack channel to notify your team or just yourself without any penny charge. All you need to do is to spare up to 10 minutes and follow this guide.

First let's create simple trading system, which would invoke some text for us in PTMC. Launch AlgoStudio and create New Module (C#, Trading System), place any name for instance “Slack_it”.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using PTLRuntime.NETScript;

namespace Slack_it
{
    /// <summary>
    /// Slack_it
    /// In Init() method we enter market with buy operation and trigger flag for short trade on next bar.  
    /// Once we have next bar a sell position would be opened and flag to close both positions arise. 
    /// Even thought there are four operation only three emails would be send, because closing method would be invoked simultaneously.
    /// </summary>
    public class Slack_it : NETStrategy
    {
        public Slack_it()
            : base()
        {
            #region Initialization
            base.Author = "";
            base.Comments = "";
            base.Company = "";
            base.Copyrights = "";
            base.DateOfCreation = "19.08.2016";
            base.ExpirationDate = 0;
            base.Version = "";
            base.Password = "66b4a6416f59370e942d353f08a9ae36";
            base.ProjectName = "Slack_it";
            #endregion 
        }
        private State state;
        private double amount;
        private string orderId1;
        private string orderId2;
        bool AllowSell, AllowExit;
               
        /// <summary>
        /// This function will be called after creating
        /// </summary>
        public override void Init()
        {
            state = State.EnterMarket;
            amount = 1;
            if (state == State.EnterMarket)
            {
                NewOrderRequest request = new NewOrderRequest
                  {
                    Instrument = Instruments.Current,
                    Account = Accounts.Current,
                    Type = OrdersType.Market,
                    Side = Operation.Buy,
                    Amount = amount,
                    Price = Instruments.Current.LastQuote.Ask
                   };
                orderId1 = Orders.Send(request);
                state = State.EnteredBuy;
                AllowSell = false;
                AllowExit = false;
                SendEmail("ptmctoslack@gmail.com", "#slack_it", request.Side + " Market is entered at: " + Instruments.Current.LastQuote.Ask);
            }
        }
        public override void NextBar()
        {
            AllowSell = true;
            if (AllowExit && state == State.EnteredShort)
            {
                Position position1 = Positions.GetPositionByOpenOrderId(orderId1);
                Position position2 = Positions.GetPositionByOpenOrderId(orderId2);
                position1.Close();
                position2.Close();
                AllowExit = false;
                state = State.EnterMarket;
                SendEmail("ptmctoslack@gmail.com", "#slack_it", "Buy ans Sell positions are closed on " + position1.CloseTime+" and "+ position2.CloseTime + ", respectively");
            }
            if (AllowSell && state == State.EnteredBuy)
            {
                NewOrderRequest request = new NewOrderRequest
                {
                    Instrument = Instruments.Current,
                    Account = Accounts.Current,
                    Type = OrdersType.Market,
                    Side = Operation.Sell,
                    Amount = amount,
                    Price = Instruments.Current.LastQuote.Bid
                };
                orderId2 = Orders.Send(request);
                state = State.EnteredShort;
                AllowSell = false;
                AllowExit = true;
                SendEmail("ptmctoslack@gmail.com", "#slack_it", request.Side + " Market is entered at: " + Instruments.Current.LastQuote.Bid);
            }
        }
        internal enum State
        {
            EnteredBuy = 1,
            EnteredShort = -1,
            EnterMarket = 0,
        }        
     }
}


To do it simple our strategy just enters market with buy operation first on initialization and later with sell (on next bar) and both would be closed on second bar, but all three steps would be notified to our dedicated Slack channel with type and price strings.

Now, use your gmail or create a new account. For testing we are going to use ptmctoslack@gmail.com. It is also important to add to contacts info@protrader.org, otherwise all incoming text would be in spam.

Once you are done add/create team in slack messenger.

ptmc_slack_team
After simple steps above, it is time to use third party service which would build up bridge for us to push notification from email to slack. For sure there are plenty options in internet or it is possible to create your own bot with tutorials around, however this review is meant to be helpful to arrange bridge without strong coding knowledge. That is why we use IFTTT recipe


ptmc_to_slack_via_gmail

During really quick account registration there you need to simply specify your gmail and slack details. Just follow instructions on ifttt.com and you will be good.

ptmc_slack_setups

Basically those are all setups market-mates, now it is time to launch a trading strategy and see how it goes.

ptmc_notification_in_Slack

It works just fine, however IFTTT updates you channel once in 5-15 minutes but of course free of charge. Anyways hope this quick review will ease daily trivial rounds for trader or even inspire our users to do something more geek and trade sound.


Have not tried PTMC yet? There is no better way to boost knowledge than to use it! Start trading with PTMC now!

Discussion
Join PTMC community to post your comments
No comments yet. Be the first.
PTMC is a professional trading platform that combines all the best charting and analytical tools to trade on different financial markets. It is developed by PFSOFT UK LTD, a global provider of trading technology for banks & brokers
© 2024. PTMC is based on Protrader technology
PFSOFT UK LTD
71-75, Shelton Street,
Covent Garden,
London, WC2H9SQ,
United Kingdom
Support & Development
PFSOFT Ukraine
Office #701
Mechnikova Street, 10B
49000, Dnipro, Ukraine
Contact us
Phone: +380 56 740 30 01
E-mail: info@protrader.org
Skype: PTMC_support
Find more ways to contact
Join us in social networks