QuantNomad

Custom Multi-Timeframe Screener with Alerts

This is a multi-timeframe screener with alerts. Use this way you can create a screener on indicators using 2 or more timeframes.
In TradingView there is a limit of 40 security function calls. Every timeframe requires another security call so you can screen fewer symbols with any additional timeframe.
In this example, I use 2 timeframes, so the maximum amount of symbols you can scan is 40 /2 = 20.
For 3 timeframes - 13, 4tfs - 10, 5tfs - 8 symbols and so on.

In this simplistic example, I require a cross of EMAs on the current timeframe and confirmation that one EMA above/below another from the second timeframe.
Of course, you can create much more complicated functions for this screener.

Params
- higher timeframe
- ema params
- 20 symbol inputs for instruments you want to use in this screener

Alerts
You can create an alert from it easily by selecting the screener name from the list and then selecting "Any alert() function call".
No additional configuration is required, message and alert on close is generated in the code.
You should better change the default name for your alert. Sometimes because of big amount of inputs you might receive an error.

Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as good as in historical backtesting.
This post and the script don’t provide any financial advice.
開源腳本

秉持真正的TradingView精神,該腳本的作者將其開源發佈,因此交易者可以理解和驗證它。為作者加油!您可以免費使用它,但是在發佈中重複使用此程式碼受網站規則的約束。您可以把它加入到常用以在圖表上使用它。

想在圖表上使用此腳本?
Courses:
Pine Programming: https://qntly.com/pineprog
Advanc. Pine Use-Cases: https://qntly.com/advpine

Access to Pro Indic.: https://qntly.com/proind

YouTube: https://qntly.com/youtube
Discord: https://qntly.com/discord
Telegram: https://qntly.com/tel

評論

Since we can use only 20 companies after calling security function to get higher time frame data, I am trying to filter stocks sectorwise by selecting and changing sectors from settings
using 'input function'. But while trying to do so, getting different kinds of errors.

string varSector = input("Custom", "Sector Selection", inline = "11", options = ) ) // <<This comment section is automatically removing 'sector names' from options of input function so please consider different sectors as options

if varSector == "Auto"
s01 := input('Auto_stock1', type=input.symbol, group = "Symbols")
s02 := input(' Auto_stock2', type=input.symbol, group = "Symbols")
.
.
s20 := input(' Auto_stock20', type=input.symbol, group = "Symbols")

else if varSector == "Banks"
s01 := input('Bank_stock1', type=input.symbol, group = "Symbols")
s02 := input(' Bank_stock2', type=input.symbol, group = "Symbols")
.
.
s20 := input(' Bank_stock20', type=input.symbol, group = "Symbols")

//Calling screener function
= security(s01, timeframe.period, screenerFunc(h1,l1,pc1) )
= security(s02, timeframe.period, screenerFunc(h2,l2,pc2) )

It shows ‘Undeclared Identifier’ msg for s01, s02….s20 when I use them inside IF condition.If I declare them first and use, it shows ‘Cannot modify global variable 's01, s02..' in function’. Even tried to use those IF..Else conditions inside a function but it shows either ‘Undeclared Identifier’ or ‘Cannot use a mutable variable as an argument of the security function’. Can you please help me to resolve this issue?

Thanks
+2 回覆
This doesn't work,
I did not gent any of the alerts or po-pup's
回覆
Great Work! Thank you for sharing!
It seems the code is looking into the regular session only, How I can include extended session ?
Can someone point me the right direction please?
Much appreciated and thank you in advance :-)
回覆
Hi, I am trying to build an MTF screener with 2 rsi. I wrote the function like this but I get the error "Syntax error: Variables of array type are not supported!"

The error appears on this line:

j01 = c01 == 1 and ch01 == 1 ? 1 : c01 == -1 and ch01 == -1 ? -1 : 0

Here is the code snippet:

///////////////
// FUNCTIONS //

// Rounding Function
roundn(x, n) =>
mult = 1
if n != 0
for i = 1 to abs(n)
mult := mult * 10

n >= 0 ? round(x * mult) / mult : round(x / mult) * mult

screenerFunc() =>

rsiL = rsii >= Ob
rsiS = rsii <= Ov
value = rsii

long = rsiL
short = rsiS

cond1 = long ? 1 : short ? -1 :0

L= cond1 < 1 and cond1 >= 1
S= cond1 > -1 and cond1 <= -1

cond = L ? 1 :
S ? -1 :
na



screenerFuncHTF() =>

rsiL1 = rsii1 >= Overbought
rsiS1 = rsii1 <= Oversold
value1 = rsii1

cond2 = rsiL1 ? 1 : rsiS1 ? -1 :0

回覆
why i am not getting alerts when EMA cross happen for long strategy. I want separate alert for each pair when EMA cross happened. Anyone can please look into where i am wrong, why my alert script is not working

//@version=4
strategy("Alerts for Multipairs EMA Cross", shorttitle = 'EMA Cross alert', overlay = false)

// INPUTS //

fastemalength = input(title="Fast EMA", type=input.integer, defval=8)
slowemalength = input(title="Slow EMA", type=input.integer, defval=21)

// Screener Function
screenerFunc() =>

emafast = ema(close, fastemalength)
emaslow = ema(close, slowemalength)

long = emafast > emaslow

// Running Functions for all sybmols //

s1 = security('BTCUSDT', timeframe.period, screenerFunc())
s2 = security('ETHUSDT', timeframe.period, screenerFunc())
s3 = security('BNBUSDT', timeframe.period, screenerFunc())
s4 = security('LTCUSDT', timeframe.period, screenerFunc())
s5 = security('ADAUSDT',timeframe.period, screenerFunc())
s6 = security('UNIUSDT', timeframe.period, screenerFunc())
s7 = security('ATOMUSDT',timeframe.period, screenerFunc())
s8 = security('BATUSDT', timeframe.period, screenerFunc())
s9 = security('RUNEUSDT',timeframe.period, screenerFunc())

// Screener label //

scr_label = 'Screener: \n##########\n'

scr_label := s1 ? scr_label + 'BTCUSDT\n' : scr_label
scr_label := s2 ? scr_label + 'ETHUSDT\n' : scr_label
scr_label := s3 ? scr_label + 'BNBUSDT\n' : scr_label
scr_label := s4 ? scr_label + 'LTCUSD\n' : scr_label
scr_label := s5 ? scr_label + 'ADAUSDT\n' : scr_label
scr_label := s6 ? scr_label + 'UNIUSDT\n' : scr_label
scr_label := s7 ? scr_label + 'ATOMUSDT\n' : scr_label
scr_label := s8 ? scr_label + 'BATUSDT\n' : scr_label
scr_label := s9 ? scr_label + 'RUNEUSDT\n' : scr_label

lab_l = label.new(
bar_index, 0, scr_label,
color=color.gray,
textcolor=color.black,
style = label.style_labeldown,
yloc = yloc.price)
// This will keep screener only for the last bar
label.delete(lab_l)

//Long Strategy when emafast > emaslow

strategy.entry("Long",strategy.long, when = s1, alert_message = "USDT_BTC Alert")
strategy.entry("Long",strategy.long, when = s2, alert_message = "USDT_ETH Alert")
strategy.entry("Long",strategy.long, when = s3, alert_message = "USDT_BNB Alert")
strategy.entry("Long",strategy.long, when = s4, alert_message = "USDT_LTC Alert")
strategy.entry("Long",strategy.long, when = s5, alert_message = "USDT_ADA Alert")
strategy.entry("Long",strategy.long, when = s6, alert_message = "USDT_UNI Alert")
strategy.entry("Long",strategy.long, when = s7, alert_message = "USDT_ATOM Alert")
strategy.entry("Long",strategy.long, when = s8, alert_message = "USDT_BAT Alert")
strategy.entry("Long",strategy.long, when = s9, alert_message = "USDT_RUNE Alert")
回覆
hi
your excellent work has helped me a lot to understand pine script.I am not so expert to pine coding.
Hi, can you please help me to modify this script. i want to create a lists based on price action strategy or VWAP and WMA crossover/crossunder.
I want to create two different lists based on price action or VWAP and WMA crossover/crossunder like (1) BULLISH (2) BEARISH.
Please guide which part to modify and what to add. For example I have two symbols NSE:ADANIPORTS1! and NSE:ASIANPAINT1!
Please guide and help

Thanks
回覆
... maximum number of symbols...
回覆
Thanks a lot for this. I want to do the following but am not sure how and if this can be done. could you please help. I want to look at 8 symbols and an alert when they are above the EMA(9) on the 5 min, 10 min, 30 min, 60 min and the alert must be triggered when it crosses the EMA(9) on the 240 min i.e. 4h time frame. Is this doable?
回覆
QuantNomad tugga82
@tugga82, So cross on higher timeframe and above EMA on lower timeframes?
It's possible. Create one function for cross (like screenerFunc in my code), calculate it for 240m timeframe. Create a function for above EMA (like screenerFuncHTF in my code), compute it for all other timeframes. Join all 5 condition together with "and" operator like I do for "j01-j20" vars.
回覆
tugga82 QuantNomad
@QuantNomad, yes cross on higher timeframe and above EMA on lower timeframes? I shall try this based on what you are suggesting and see if it works. Will keep you posted. Thanks for everything that you do. Cheers,
回覆