OPEN-SOURCE SCRIPT
Cập nhật Oscillators with Divergences

If you do enjoy this indicator, check out my Ultimate Indicator! It is another collection of indicators all into one but that is for price chart indicators like Donchian, Keltner, EMAs, VWAP, Super Trend, etc.
This is a culmination of hundreds of hours (maybe even a thousand, honestly) of work spent working with dozens of indicators and now taking all of the ones I like the most and combining them into one so you can easily switch between them. On top of that, I have my own custom divergence code that can look back up to five pivots!
There's the following indicators all wrapped into this one:
MACD
RSI
CCI
Volume-Weighted MACD
MFI
Stochastic
Stochastic RSI
I could not get a working method of looking back several pivots from other people's code so I took a 1-pivot lookback method and copied out several times and made necessary changes to work properly. It will also draw an "early divergence" the moment it's happening rather than waiting the normal 5 candles to show. Once the 5 candles have passed, it will pick the furthest back divergence as the one to stay.
Let's say you have the divergences set to 3 pivot points. If a divergence happens that goes back 1 pivot point, but later a 3 pivot divergence overlaps it, the 1 pivot will get removed after the 3 pivot early divergence is confirmed after its 5 candles have passed. Just put it on the chart and you'll see, it sounds crazy to explain.
I've added a bunch of tooltips to explain each setting. Please read them if you have questions. I've also added notes into my code if you do choose to use it for your own purposes or make changes. I wish you luck haha, it's a bit of a mess. Some things were commented out but elft in there just beacuse I never know when I want to re-enable it or just see what the original code was.
This is a culmination of hundreds of hours (maybe even a thousand, honestly) of work spent working with dozens of indicators and now taking all of the ones I like the most and combining them into one so you can easily switch between them. On top of that, I have my own custom divergence code that can look back up to five pivots!
There's the following indicators all wrapped into this one:
MACD
RSI
CCI
Volume-Weighted MACD
MFI
Stochastic
Stochastic RSI
I could not get a working method of looking back several pivots from other people's code so I took a 1-pivot lookback method and copied out several times and made necessary changes to work properly. It will also draw an "early divergence" the moment it's happening rather than waiting the normal 5 candles to show. Once the 5 candles have passed, it will pick the furthest back divergence as the one to stay.
Let's say you have the divergences set to 3 pivot points. If a divergence happens that goes back 1 pivot point, but later a 3 pivot divergence overlaps it, the 1 pivot will get removed after the 3 pivot early divergence is confirmed after its 5 candles have passed. Just put it on the chart and you'll see, it sounds crazy to explain.
I've added a bunch of tooltips to explain each setting. Please read them if you have questions. I've also added notes into my code if you do choose to use it for your own purposes or make changes. I wish you luck haha, it's a bit of a mess. Some things were commented out but elft in there just beacuse I never know when I want to re-enable it or just see what the original code was.
Phát hành các Ghi chú
Added in the Atermis Oscillator or otherwise called the Directional Range Momentum (DRM) oscillator as an option.Credits to a_jabbaroff for this one
I sort of like this more than RSI. Instead of measuring green candles vs all candles like the RSI, it is supposed to measure range (high and low) expansions.
His version also adds in a few further things but I didn't find them super useful. I do like his Volume Pressure option which takes a long and short MFI calculaiton, blends them together and plots on the same oscillator. It shows volume balance to compare with oscillator and is supposed to show whether the movement is backed by buyers/sellers. I haven't added it here, I may later.
Heads up, the default values for this to line up with his would be 14 length, 1 smoothing, 7 signal length, 80 overbought, 20 oversold.
Phát hành các Ghi chú
Added buy/sell signals for the newly added DRM indicator selection. Added those here. Phát hành các Ghi chú
Forgot to add in the option for smoothing the DRM oscillator. I made the necessary change for that to start working.Note to self, should really setup the code so that it adds the smoothing option always so it doesn't get missed when I add a new indicator and need to add it manually each time.
Phát hành các Ghi chú
I've cleaned up a few of my higher timeframe calls (which I already have disabled, they remain in the code incase someone takes it and wants to enable them).Added in the Volume Pressure option. Doesn't work on MACD, I'll look into this, but for now it does work on all the other oscillators.
I've updated the way that the signals are generated when you turn on the Trend option (whether you set it to 200 EMA, VWAP, or Range setting).
Before, it went as follows for all oscillators besides MACD:
Buy Signal = Oscillator is in the oversold area, if oscillator comes up from the extreme oversold back to regular oversold OR if oscillator comes up from oversold into non-oversold area, trigger a buy signal (green highlight). If you set the Trend option to 200 EMA or VWAP, price must be above the trend line. Ranging will show even if it doesn't agree with long term trend. Sell signals work in the same way but for overbought area, respectively.
Now it goes as follows for all oscillators besides MACD:
Oscillator is in the oversold area, if oscillator crosses over signal line OR if oscillator comes up from extreme oversold back to regular oversold OR if oscillator comes up from oversold into non-oversold area, trigger a buy signal (green highlight).
On top of adding the signal line cross as a signal generator, there is now a cooldown period of 5 candles and 10 candles explained here:
If a buy signal occurs for either the signal line crossing or going from extreme oversold to regular oversold, another signal will not be drawn for at least 5 more candles.
Buy signals that occur from crossing from oversold into non-oversold area can only happen if no other buy signal has occured in the past 10 candles.
Trend / Range still works the same way. Sell signals work the same way but for overbought area, respectively.
This may seem complicated but the purpose of the cooldown is so you don't get signal overload. I want a signal to occur and stick with it, I don't need to see 3+ signals within 5 candles, that's silly. The reason for the 10 candle requirement on crossing from overbought/oversold into non-extended area is based on pesronal experience: usually, if the oscillator has crossed back from extreme or crossed its own signal line, it more than likely will cross back into non-extended area shortly. In the cases where it does not do it within 10 candles, it usually isn't a reliable signal, that's the reason this has a 10 candle cooldown. Just go look for yourself and you'll see what I'm talking about. Find a spot where the oscillator is overbought or oversold, then it crossed it's own signal line but stayed overbought or oversold for about 5+ candles, it's almost always a bad setup by that time or the move has already happened you were trying to catch.
Phát hành các Ghi chú
I've added an option to set the trend direction as only Up or only Down.The divergences can also respect this if you filter those by trend as well.
VWAP now resets at 9:30am New York time instead of at "Session".
Added an indicator option "DRM = RSI" whixh calculates both and then takes the average pf the two.
Phát hành các Ghi chú
I've added in my Trend/Range screener that I created on my Ultimate Indicator. If you want more details on how it works, please go to that indicator of mine and read the patch notes. I've made way too many to really changes to explain them all here.Basically how it works:
Uses the 100 EMA Keltner Channel with a 4x ATR band multiplier.
Price above channel = +2
Price in an up trend = +1
Price in a range = 0
Price in a down trend = -1
Price below channel = -2
Do that for each given timeframe (1/5/15/60/240) and then take the sum of all scores. Use that sum value to dictate if you should take a trade in a given direction (Long/Short/Range).
Phát hành các Ghi chú
This update looks to make tons of changes to the Screener:- Screener now uses the Trend Length as the Screener Length instead of being stuck at my defined 100 or 200 lengths.
- Also added an option to change the Screener's multiplier which is used for the Keltner options. By default, I've always used a value of 4.0; I do still like 4.0 but I thought some people might like to change it.
- Added a new option called "Keltner 200 vs Trend". This option will calculate the trend values for each timeframe usng the 200 length as well as whatever length you have the "Trend Length" set to. Then it will take the average of both of those scores for each timeframe. It can be worth looking at. I tend not to use it but I was doing some testing with it while trying to decide if I like the 200 or 100 length better. Ended up just adding an option that takes the average of both instead of settling for using the 150 length.
- Added Custom Weighting - The default scoring gives each timeframe a score of -2 to +2, scoring notes are in previous update notes above. The new weighting system uses the same -2 to +2 score calculates but adds more to them afterwards: If there are LTF or HTF agreements, extra points will be added to select timeframes. The purpose is that during a move that multiple timeframes agree on (for example, the 1/5/15m timeframes all align), they will be given extra points to indicate that something is happening right now and deserves extra attention.
- Added the ability to show the scores for each timeframe and the total using the "Scores" option. The trend analysis for each timeframe and overall status already give statuses by using text and color displays. Showing the scores is more of a formality if you would rather just see how everything is working quickly. The trend score required to hit certain trend analysis is adjusted to fit the new custom weighted scoring system if you enable it.
- Added an option to include or remove the 4-hour timeframe from the screener. Since I day trade (only during NY session and trades last minutes to a couple hours), I found the 4-hour timeframe to just be so far lagging it was throwing off my screener analysis. For example, I've been liking the 100 length for the screener, that's 3-4 weeks on the 4-hour timeframe.
- Added an option to include 5m Structural Scoring. The reason for picking 5m timeframe for the structural analysis is that 5m at 100 length is a little over 8 hours. During the opening time, this inclues the morning and pre-market price action. By the end of the day, around 3:30pm, this includes everything from pre-market to almost close so it's perfect for my day trading style. The 5m Structure looks for Higher Highs with Higher Lows or Lower Highs with Lower Lows. If price structure is showing bullish or bearish, it will give a respective -2 to +2 score added to the final score.
- Cleaned up a few functions to be a little more efficient or at least look cleaner in the code.
- Removed the bFlip variable completely - I already had this hardcoded as disabled but now I simply removed it from the script code and any affected functions that used it.
Also note that if you have any questions, I did put TONS of info in tooltips next to any new or existing options within the settings of the indicator.
See my notes in my Ultimate Indicator for any additional info regarding updates on the Screener.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.