Skip to content
pineconnector alphatrend strategy pine script

We adapted a popular PineScript on TradingView, created by KivancOzbilgic, to be compatible to our platform. The strategy can be used for forex trading, stock trading, futures trading, crypto trading and trading of other instruments.

Nevertheless, we recommend that paper trading should be done first, before running on your live trading accounts. 

With this script, an alert will be automatically trigger and will execute a trade on your 
MT4/5 terminal when your terminal is connected to our server – ideal if you are day trading or swing trading.

Looking to automate your TradingView strategies while your broker is on MetaTrader?
Try PineConnector for 7 days – credit card not required.

Steps to use this AlphaTrend Strategy:
Create a PineScript and attach the code below

// This source code is subject to the terms of the Mozilla Public License 2.0 at
// author © KivancOzbilgic
// developer © KivancOzbilgic

indicator('PineConnector x AlphaTrend', shorttitle='PineConnector x AlphaTrend', overlay=true, format=format.price, precision=2)

coeff = input.float(1, 'Multiplier', step=0.1)
AP = input(14, 'Common Period')
ATR = ta.sma(, AP)
src = input(close)
showsignalsk = input(title='Show Signals?', defval=true)
novolumedata = input(title='Change calculation (no volume data)?', defval=false)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, 14) >= 50 : ta.mfi(hlc3, 14) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT

color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
k1 = plot(AlphaTrend,, 0), linewidth=3)
k2 = plot(AlphaTrend[2],, 0), linewidth=3)

fill(k1, k2, color=color1)

alertcondition(ta.cross(close, AlphaTrend), title='Cross Alert', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low, AlphaTrend), title='CrossOver Alarm', message='BUY SIGNAL!')
alertcondition(ta.crossunder(high, AlphaTrend), title='CrossUnder Alarm', message='SELL SIGNAL!')

alertcondition(ta.cross(close[1], AlphaTrend[1]), title='Cross Alert After Bar Close', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low[1], AlphaTrend[1]), title='CrossOver Alarm After Bar Close', message='BUY SIGNAL!')
alertcondition(ta.crossunder(high[1], AlphaTrend[1]), title='CrossUnder Alarm After Bar Close', message='SELL SIGNAL!')

buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2])
sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2])

K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk[1])
O2 = ta.barssince(sellSignalk[1])

// plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny,, 0),, 0))
// plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny,, 0),, 0))

plotshape(buySignalk and showsignalsk and O1 > K2 and AlphaTrend[2] * 0.9999, style=shape.labelup, location=location.belowbar,, 0), size=size.large, text='PineConnector \n Buy',, 0))       //plotting up arrow when buy/long conditions met 
plotshape(sellSignalk and showsignalsk and O2 > K1 and AlphaTrend[2] * 1.0001, style=shape.labeldown, location=location.abovebar,, 0), size=size.large, text='PineConnector \n Sell',, 0))   //plotting down arrow when sell/short conditions met

// Option 1: Basic (only risk paramter, static)
if buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na
    alert('changetoyourLICENSEID,buy,' +syminfo.ticker+ ',risk=1', alert.freq_once_per_bar_close)

if sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na
    alert('changetoyourLICENSEID,sell,' +syminfo.ticker+ ',risk=1', alert.freq_once_per_bar_close)
// end of Option 1

Save the code, and click "Add to Chart"

Guide to create alerts: Create alerts

● After changing values from 3, please delete the old alert(s) if any and create a new alert
● Please ensure you select PineConnector x AlphaTrend strategy when creating an alert, and select alert() function calls only

alphatrend strategy pineconnector

Recommended EA settings:
Volume Type: Percentage of account balance
● Assuming risk=1 and $1000 account,
the EA will compute the position size whereby when the trade hits SL, you will lose 1% or $10.
Close on reverse: TRUE
● Then open buy position will be closed first followed by the open of a sell, upon receipt of a sell signal - and vice versa


Tradingview does not give webhook url on free account. they are asking for premium account. is there any workaround?


What is “changetoyourLICENSEID” doing?


hey there,
i just donwloaded a free script (alpha trend) available on website. i changed the license id in source code and changed my risk percenatge as well. but how to include tp and sl in the pinescript ??


Leave a comment

Back To PineConnector Script Library