Reputation: 1
This is my first post and I am a beginner with pinescript.
For Indicators like EMA, under settings there is a tab for "Visibility" where it can be selected which timeframes that the indicator is displayed. By default it is set to have visibility on all timeframes, and everytime the indicator is modified, the Visibiltiy resets to All timeframes.
Is there a pinescript that will set default Visiblity to only Minutes?
Upvotes: 0
Views: 2277
Reputation: 1
//@version=5
indicator('hide indicator by specific timeframe', overlay=true)
basePeriods = input.int(15, minval=1, title='Base Line Length')
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
baseLine = donchian(basePeriods)
hourly = request.security(syminfo.tickerid, '240', baseLine , lookahead=barmerge.lookahead_on)
daily = request.security(syminfo.tickerid, 'D', baseLine , lookahead=barmerge.lookahead_on)
weekly = request.security(syminfo.tickerid, 'W', baseLine , lookahead=barmerge.lookahead_on)
plot(timeframe.multiplier==240 ? hourly : na, title='Base Line', trackprice=true, color=color.new(#991515, 0), linewidth=2)
plot(timeframe.isdaily ? daily : na, title='Base Line', trackprice=true, color=color.new(#149a1b, 0), linewidth=2)
plot(timeframe.isweekly ? weekly : na, title='Base Line', trackprice=true, color=color.new(#341599, 0), linewidth=2)
Upvotes: 0
Reputation: 3803
You can do this manually by testing for timeframe values. You could also optionally add inputs to be able to toggle it on/off or have other options.
display_only_minutes = timeframe.isintraday and timeframe.multiplier <= 60
ma = sma(close, 50)
plot(display_only_minutes ? ma : na)
Upvotes: 1