Email Bot

From Haasonline Software Wiki
Jump to: navigation, search

The Email Bot can be used to integrate with TradingView's email alerts. It will fetch emails and compare them with predefined messages. If there is a match it will execute a defined action.

Restriction

None

Email Provider setup guide:

  1. Prepare subscription and a main account that you use to login to TradingView
  2. Create a new Gmail address dedicated for the bots.
    (important step, because using your main email for this would cause lots of inconvenience)
  3. Enable "Less secure apps" in your new account
    (make sure that you are logged in the correct Gmail account when doing this)
  4. Add the dedicated email credentials as a provider in Settings - Email Providers:
    • Name: name of this Email Provider (can be anything)
    • Email: your new Gmail address (e.g. [email protected])
    • Password: the password of Gmail account above
    • Approved Contacts: sender emails which are allowed to be used as signals (e.g. [email protected])
      (if left empty, emails from any sender will be used as potential signals)
  5. Create a filter on your main email account to forward emails from TradingView to your new dedicated account.
  6. Restart the HTS.
  7. You are ready to setup alerts and bots.

Important note: adding an Email Provider creates a "Processed Signals" label in that email.
Deleting this label will make the bot work incorrect which will lead to losses. Do not delete this label.

Positive Notes

  • Multiple emails coming in for different Email Bots simultaneously are handled just fine (tested max - 9, but potentially there is no limit)
  • You can combine multiple signals for 1 action. If all the signal are received within X seconds, the action will be executed.
  • Can be used with any signal provider (not only TradingView) as long as they can send emails
  • You can run multiple bots on the same signal email.
  • No limit on the number of signals per bot.
  • Spot, Margin & Leverage.

Negative Notes

  • You need to enable "less secure apps" on your account. Hence the recommendation for creating new Email specifically for the bot.
  • You can't use the same alert for triggering 2 different bots. Use different alert text for each bot.

Performance

Parameters

EmailParameters.png


Minimum Price Change To Buy When the bot has sold, the price needs to drop a determined percentage in order to buy again. When set on 0% this safety is ignored.

Maximum Price Change To Sell After the bot has bought, the price needs to rise to a determined percentage in order to sell again. When set on 0% this safety is ignored.

Stop Loss After the bot has bought, and the price drops a determined percentage, the bot will execute a sell order. When set on 0% this safety is ignored.

Email Actions

EmailActions.png


EditActions.png


Providers HTS support emails from multiple email addresses. With the provider filter you can specify which email address the bot reacts to.

Action Action to perform when an email is a match.

Timeout When using multiple signals, the timeout allows a certain timespan between the emails. If all the messages are received before the timeout, the action is executed.

Message A message can be defined in 3 way:

- Exact match (case insensitive)
- Wildcard. Use an * as a wild card. For example: *Sell_BTC_USDT_1
- Regular expressions. For example: .*Sell_BTC_USDT_1

Tradingview Alert Guide

TradingView has a great collection of alerts users can utilize. Ranging from simple price alerts to indicator crosses. This guide will show you how to create a price alert and a indicator alert for the bot to act on.

Price alerts

  1. Go to www.tradingview.com and select the market you wish to trade on (Bitstamp BTC/USD for example)..
  2. Click on alert in the header. A new popup will show with the configuration settings.
  3. In the Condition section, change “Crossing” to “Crossing up” and change the value to the price on which the alert should fire. $10.000 for example.
  4. Make sure “Send Email” is enabled.
  5. Change the message to something unique. BOT_1_BUY_BTC for example and hit save. When the price break 10.000 USD, Tradingview will send you a email with this a subject: TradingView Alert: BOT_1_BUY_BTC
  6. Go to the Email bot in HTS and add an action. Select the action you want to perform once the price reached 10.000 USD (buy for example). In the message section add the subject defined in 5.
  7. Save the action and start the bot.

The bot will wait for an email to be received where the subject matched the one we have defined. Once that email is received the bot will place a buy order at the current price.

Indicator alerts

  1. Go to www.tradingview.com and select the market you wish to trade on (Bitstamp BTC/USD for example).
  2. Click on “Indicator” in the header and add an indicator (MA for example). Modify the indicator settings if needed.
  3. Click on alert in the header. A new popup will show with the configuration settings.
  4. In the Condition section, change “Crossing” to “Crossing up” and select the indicator in the “Value” dropdown.
  5. Make sure “Send Email” is enabled.
  6. Change the message to something unique. BOT_1_MA_UP_BTC for example and hit save. When the MA crossed over, Tradingview will send you an email with this a subject: TradingView Alert: BOT_1_MA_UP_BTC
  7. Add a second alert, but change “Crossing” to “Crossing down”. Make sure the message is unique again. BOT_1_MA_DOWN_BTC for example.
  8. Go to the Email bot in HTS and add an action. Select the action you want to perform once the MA has crossed over (buy for example). In the message section, add the subject defined in 5.
  9. Save the action and add a second action to sell once the MA has crossed down.
  10. Start the bot.

The bot will wait for an email to be received where the subject matched the one we have defined. Once that email is received the bot will place a buy or sell order at the current price depending on the coin position of the bot and the email received.

Troubleshooting

If you are running your HTS on Linux and the Email Bot does not take any action towards the signals that it has been processed, please ensure that you have installed mono-vbnc on your machine.

sudo apt install mono-vbnc