TradingView
Nakitxu
Aug 9, 2019 7:45 AM

Ema Weekly In current Timeframe 

Bitcoin / DollarBitfinex

描述

This simple indicator shows the Ema with data extracted from weekly timeframe in your current displayed timeframe.

Due to Tradingview working restrictions, this indicator only works if is used in a timeframe lower (or equal) to one week, otherways shows an error red label showing this error.


All my scripts:

es.tradingview.com/u/Nakitxu/

版本注释

Bug correction...

版本注释

09/2018 Update:

- Corrected the method to detect > weekly timeframe
- Deactivate the SMA if current timeframe is > Week
- Show errors or not definable with switch
评论
osakaboy
Hi. This is good, thanks. I am using the EMA 200 weekly while I am in the daily chart. It was defaulted to "close" and I changed it to "hl2". Do you think that matters? I don't think it make a difference in the big picture on long time frames. Maybe I'm wrong. I was wondering why it is easy to find SMA weekly indicators but not EMA weekly indicators. I customized some other scripts, but in the end, yours was simplest to work with. Lastly, which part of the script forces the weekly regardless of timeframe? Is it because the API uses "(syminfo.tickerid, "W""? I'd like to create a script that plots both the 200 W SMA & 200 W EMA. I guess I can just add something like, "sma = security(syminfo.tickerid, "W", sma(src, Period))"?
Nakitxu
@osakaboy, Yes, you can use that line to calculate the sma.
What is forcing to use weekly data is the function security. With security you can evaluate a function (in this case the function is ema or sma) using the requested symbol, in the requested period instead of use the current symbol in the current timeframe. FOr example, you can ask for other symbols... you can plot bitcoin data while you are in ethereum chart...
osakaboy
@Nakitxu, yes so "W" is actually a resolution parameter of the API function 'security'. Pine Editor gives method definitions on hover like other IDE's so that's useful. Oh, and what about close vs hl2? It seems to barely make a difference. Thanks.
danchanner
Hi, do you know how to smooth the line to avoid the steps?
Nakitxu
@danchanner, I think you dont understand the script :? It shows the weekly SMA in your current tiemframe. For example, if you are in daily, you can see the same value of SMA during 7 bars (7 days).
danchanner
@Nakitxu, I understand the script. I think it's a limitation with the plot function as it plots them as linked straight lines rather than a smoothed line like Excel can. I wondered if you knew a way around this limitation.
coininvestor
Very nice work.
更多