Hi All,
I am VERY new to pinescript and im trying to set up an alert to trigger each time a group of indicator parameters are met from different time frames on Tradingview.
So far all i have done is make a mess of a script that i tried to modify.
I have added some lines in which i know are not going to work but just wanted to show an idea of what i am trying to achieve.
I just want it to send me an alert on my pc or phone each time the conditions are met for each ticker.
strategy(title=Buy Sell Stategy
, shorttitle=Buy Sell Stategy
, overlay=true)
// Input
fastMAlen = input(12, minval=1, title=MACD fast moving average
)
slowMAlen=input(26,minval=1, title=MACD slow moving average
)
signalMACDlen = input(9,minval=1, title=MACD signal line moving average
)
StochLength = input(14, minval=1, title=Stochastic Length
)
switch=input(true, title=Enable MACD Bar Color?
)
// MACD Calculation
1hrMACD = GetTickValueSymbol(symbol) =>
request.security(symbol, 60
, (syminfo.MACD),
1hrsignalMACD = GetTickValueSymbol(symbol) =>
request.security(symbol, 60
, (syminfo.signalMACD),
12hrMACD = GetTickValueSymbol(symbol) =>
request.security(symbol, 720
, (syminfo.MACD),
12hrsignalMACD = GetTickValueSymbol(symbol) =>
request.security(symbol, 720
, (syminfo.signalMACD),
MACD = ema(close, fastMAlen) - ema(close, slowMAlen)
signalMACD = ema(MACD, signalMACDlen)
delta = MACD - signalMACD
fastMA = ema(close,fastMAlen)
slowMA = ema(close,slowMAlen)
// Stochastic Calculation
1hrsmoothK = GetTickValueSymbol(symbol) =>
request.security(symbol, 60
, (syminfo.smoothK)[1],
1hrsmoothD = GetTickValueSymbol(symbol) =>
request.security(symbol, 60
, (syminfo.smoothD)[1],
4hrsmoothK = GetTickValueSymbol(symbol) =>
request.security(symbol, 240
, (syminfo.smoothK)[1],
4hrsmoothD = GetTickValueSymbol(symbol) =>
request.security(symbol, 240
, (syminfo.smoothD)[1],
12hrsmoothK = GetTickValueSymbol(symbol) =>
request.security(symbol, 720
, (syminfo.smoothK)[1],
12hrsmoothK = GetTickValueSymbol(symbol) =>
request.security(symbol, 720
, (syminfo.smoothD)[1],
smoothK = input(3, title=Smoothing of Stochastic %K
)
smoothD = input(3, title=Moving Average of Stochastic %K
)
k = sma(stoch(close, high, low, StochLength), smoothK)
d = sma(k, smoothD)
//RSI Calculation
xRSI = rsi(close, 10)
// Colors
bartrendcolor = 1hrMACD > 1hrsignalMACD and 4hrsmoothK > 4hrsmoothD and 12hrMACD > 12hrsignalMACD and 12hrsmoothK > 12hrsmoothD? lime : MACD < signalMACD and k < d and xRSI < 50? red : MACD < signalMACD? yellow : gray
barcolor(switch?bartrendcolor:na)
// === STRATEGY ===
// conditions
calc_on_every_tick
longCond = 1hrMACD > 1hrsignalMACD and 4hrsmoothK > 4hrsmoothD and 12hrMACD > 12hrsignalMACD and 12hrsmoothK > 12hrsmoothD
shortCond = (charttimeframe = (60) k < d)
strategy.entry(long
, strategy.long, when=longCond==true)
strategy.close(long
, when=shortCond==true)
// === /STRATEGY ===
timeframe_gaps
Thanks for any help
Juz