TradingView

Prefer a video? Here is a quick video that shows you how to get started with TradersPost and TradingView. Or continue reading to learn more.

Automating Trading Strategies with TradersPost and TradingView

The TradersPost webhook system lets you easily integrate alerts from platforms like TradingView with TradersPost. Webhooks can receive JSON like the following:

{
    "ticker": "{{ticker}}",
    "action": "buy",
    "price": "{{close}}",
    "time": "{{timenow}}",
    "interval": "{{interval}}",
    "open": "{{open}}",
    "high": "{{high}}",
    "low": "{{low}}",
    "close": "{{close}}"
}

The values inside of the {{ and }} will be dynamically replaced by TradingView when the alert triggers.

When you create an alert in TradingView, you only need to enter the above JSON in the Message field and the URL of your webhook in the Webhook URL field. Here is a screenshot of a simple example that would send a signal to buy SQ when the price crosses above 241.94.

This is a simple example to demonstrate the basics of how you can integrate TradingView alerts with TradersPost but the same principals apply if you are doing something more advanced with a Pinescript indicator. Continue reading to learn how you can integrate your Pinescript indicators and alerts with TradersPost.

Pinescript

Here is a simple trend following momentum based indicator called MOMO that was created by Matt DeLong from RealLifeTrading.com. It uses the EMA8 and EMA21 and the signal is when those two values cross each other.

//@version=4
//author = https://www.tradingview.com/u/MattDeLong/

study("Trend Following MOMO", overlay=true)

ema8 = ema(close, 8)
ema21 = ema(close, 21)

isUptrend = ema8 >= ema21
isDowntrend = ema8 <= ema21
trendChanging = cross(ema8, ema21)

tradersPostBuy = trendChanging and isUptrend
tradersPostSell = trendChanging and isDowntrend

plotshape(tradersPostBuy, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, text='Buy')
plotshape(tradersPostSell, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, text='Sell')

aa = plot(ema8, linewidth=3, color=color.green, editable=true, title="ema8")
bb = plot(ema21,linewidth=3, color=color.red, editable=true, title="ema21")
fill(aa, bb, color=isUptrend ? color.green : color.red)

alertcondition(tradersPostBuy, title="TradersPost Buy Alert", message="{\"time\": \"{{timenow}}\", \"interval\": \"{{interval}}\", \"ticker\": \"{{ticker}}\", \"action\": \"buy\", \"open\": {{open}}, \"high\": {{high}}, \"low\": {{low}}, \"close\": {{close}}}")
alertcondition(tradersPostSell, title="TradersPost Sell Alert", message="{\"time\": \"{{timenow}}\", \"interval\": \"{{interval}}\", \"ticker\": \"{{ticker}}\", \"action\": \"sell\", \"open\": {{open}}, \"high\": {{high}}, \"low\": {{low}}, \"close\": {{close}}}")

Once you have the Trend Following MOMO indicator in your TradingView you can add it to your charts and it will look like the following with visual buy and sell indicators overlayed on top of your chart.

Next, you can create alerts for the buy and sell signals and send them to TradersPost via webhooks. Follow these steps to setup the alerts as webhooks.

  1. Open the Alerts pane in TradingView
  2. Click Create Alert at the top right of the Alerts pane
  3. Select Trend Following MOMO from the Condition dropdown
  4. Select TradersPost Buy Alert or TradersPost Sell Alert under the Condition dropdown.
  5. Click Once Per Bar Close next to Options
  6. Paste your TradersPost webhook URL in the Webhook URL field.
  7. Give your alert a name like HD MOMO 1D Buy

Here is what your alert should look like.

Notice how the Message field in the alert was automatically filled in with the JSON that is required for TradersPost? This is made available to us by these two lines of code in the Pinescript.

alertcondition(tradersPostBuy, title="TradersPost Buy Alert", message="{\"time\": \"{{timenow}}\", \"interval\": \"{{interval}}\", \"ticker\": \"{{ticker}}\", \"action\": \"buy\", \"open\": {{open}}, \"high\": {{high}}, \"low\": {{low}}, \"close\": {{close}}}")
alertcondition(tradersPostSell, title="TradersPost Sell Alert", message="{\"time\": \"{{timenow}}\", \"interval\": \"{{interval}}\", \"ticker\": \"{{ticker}}\", \"action\": \"sell\", \"open\": {{open}}, \"high\": {{high}}, \"low\": {{low}}, \"close\": {{close}}}")

If you are interested automating your TradingView strategies, give TradersPost a try and Register your free account today! If you have any questions, join our Community or email us at [email protected].