'TradingView Pinescript - I am not able to draw all my main supports and resistances levels from monthly timeframe to intraday timeframe. Just 2levels
with pinescript v5 in tradingview I have two issues when I try to draw all my preferred supports and resistances levels in the monthly timeframe, and when I try to have the same levels at the 30 minutes timeframe. Snapshots and code below Thanks
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © giancarlopagliaroli
//@version=5
strategy(title='s_support&resistance', pyramiding = 0, initial_capital=100, currency=currency.EUR,
commission_value=0.16, commission_type=strategy.commission.percent, slippage=1,
default_qty_type=strategy.cash, default_qty_value=100, overlay=true)
////////////////////////////////////////////////////////////////////////////////
isess = session.regular
t = ticker.new(syminfo.prefix, syminfo.ticker, session=isess)
igaps = barmerge.gaps_off
lookaheads = barmerge.lookahead_on
//get volume from monthly timeframe
volume1 = request.security(t, 'M', volume, gaps=igaps, lookahead=lookaheads)
//get simple moving avarage of volume from monthly timeframe
sma1 = request.security(t, 'M', ta.sma(volume, 12), gaps=igaps, lookahead=lookaheads)
//Hystorical supports and resistances: get highs and lows bar values from monthly timeframe only if volume over the sma
h1 = request.security(t, 'M', expression = volume1 > sma1 ? high: na, gaps=igaps, lookahead=lookaheads)
l1 = request.security(t, 'M', expression = volume1 > sma1 ? low: na, gaps=igaps, lookahead=lookaheads)
//a = plot(timeframe.ismonthly ? na : h1, color= close < h1 ? color.new(color.red, 0) : color.new(color.lime, 0), linewidth =1 , style=plot.style_circles)
//b = plot(timeframe.ismonthly ? na : l1, color= close < l1 ? color.new(color.red, 0) : color.new(color.lime, 0), linewidth=1, style=plot.style_circles)
//my arrays for storing all lines of supports and resistances
arrayh = array.new_line()
arrayl = array.new_line()
//tradingview give me 5000 bars
for i = 0 to 4999
if not na(h1[i]) //h1 series could have some NaN values
array.push(arrayh,line.new(bar_index - 1, h1[i], bar_index, h1[i], width=1, color=color.red, extend=extend.right, style=line.style_solid))
if not na(l1[i]) //l1 series could have some NaN values
array.push(arrayl,line.new(bar_index - 1, l1[i], bar_index, l1[i], width=1, color=color.red, extend=extend.right, style=line.style_solid))
Solution 1:[1]
solved by creating a python script which is getting montly highs and lows from yahoo finance and creating a txt file in pinescript code to be imported into tradingview . Here the result for the Natural gas future Finally having all montly highs and lows on day timeframe but will I have apply further filters and improvements on this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Giancarlo Pagliaroli |



