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:
1
Create a PineScript and attach the code below

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// author © KivancOzbilgic
// developer © KivancOzbilgic
//@version=5

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(ta.tr, 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, color=color.new(#0022FC, 0), linewidth=3)
k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 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, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 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, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))

plotshape(buySignalk and showsignalsk and O1 > K2 and AlphaTrend[2] * 0.9999, style=shape.labelup, location=location.belowbar, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Buy', textcolor=color.new(color.white, 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, color=color.new(#046ff9, 0), size=size.large, text='PineConnector \n Sell', textcolor=color.new(color.white, 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



        
2
Save the code, and click "Add to Chart"
3

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:
1
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.
2
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

3 comments

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

Dileep

What is “changetoyourLICENSEID” doing?

Matis

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 ??

kathan

Leave a comment

Back To PineConnector Script Library