I am new to TradingView - the main reason I want to use it is to create my own custom scan using moving averages that I cannot seem to be able to use on Interactive Brokers scanner - the 13 and 30 Simple moving averages on the hourly chart.
On the Stock Screener in Trading View filters it doesn't seem to give the option to change the moving averages.
I have tried a pine editor code but after writing it into the editor the only things it seemed to be able to do was save it and nothing else.
You can't currently scan based on Pine. You can however create a script that you can input symbols to and have it return if they meet your MA criteria like mentioned in the answer above.
Here's an example that will test if the 60 minute close is greater than both moving averages and then return true or false in a table. You can add more symbols, I only used two for the example.
//@version=5
indicator("My script", overlay = true)
sym1 = input.symbol('TSLA', 'Symbol 1')
sym2 = input.symbol('NVDA', 'Symbol 2')
method mas(string symbol) =>
ma1 = request.security(symbol, '60', ta.sma(close,13))
ma2 = request.security(symbol, '60', ta.sma(close,30))
price = request.security(symbol, '60', close)
priceLow = request.security(symbol, '60', low)
[ma1, ma2, price, priceLow]
[sym1MA13, sym1MA30, sym1Close, sym1Low] = sym1.mas()
[sym2MA13, sym2MA30, sym2Close, sym2Low] = sym2.mas()
sym1lower = false
sym2lower = false
for i = 0 to 9
if sym1Low < sym1MA13 or sym1Low < sym1MA30
sym1lower := true
for i = 0 to 9
if sym2Low < sym2MA13 or sym2Low < sym2MA30
sym2lower := true
var table screener = table.new(position.top_right, 3, 2, bgcolor = color.white, border_color = color.black, border_width = 2, frame_color = color.black, frame_width = 2)
if barstate.islast
screener.cell(0,0, str.tostring(sym1))
screener.cell(0,1, str.tostring(sym2))
screener.cell(1,0, str.tostring(sym1Close > sym1MA13 and sym1Close > sym1MA30), bgcolor = (sym1Close > sym1MA13 and sym1Close > sym1MA30 ? color.green : color.red))
screener.cell(1,1, str.tostring(sym2Close > sym2MA13 and sym2Close > sym2MA30), bgcolor = (sym2Close > sym2MA13 and sym2Close > sym2MA30 ? color.green : color.red))
screener.cell(2,0, str.tostring(sym1lower), bgcolor = sym1lower == false ? color.green : color.red)
screener.cell(2,1, str.tostring(sym2lower), bgcolor = sym2lower == false ? color.green : color.red)