Recent High/Low Dots by Alejandro PSimple indicator that plots a dot in the chart when a candle breaks the high of the past X candles.
This is useful to easily visualize when the market is coming out of a range and making fresh highs or lows relative to the past X candles.
It can be used in trend following systems as an additional filter for validation.
廣量指標
Arms Index TRIN [DM]Hello colleagues""
Here I share today Arms Index!!!
-Avalilables settings and options:
- Switcheable Index NASDAQ and S&P
- Switcheable Alerts "crossover, crossunder, change and main ones"
-Fill Color Customizables
-Signal Color Customizables
-Signal Smooth Customizable
Enjoy!!!
Arms Index (TRIN)
The Arms Index (TRIN) is a market breadth oscillator that was developed by Richard Arms. It is also known as the Trading Index, hence the abbreviation TRIN. It relates advancing and declining stocks to their respective volume flows by dividing the Advance/Decline Ratio by the volume ratio. When it rises the market is said to be weak and vice versa. The value 1 is key and crossing it generates a signal. A value above 1 indicates declining stocks have the upperhand in the volume flow and vice versa. The indicator can be used to spot overbought and oversold situations and is best used in combination with other analysis techniques.
On Balance VolumeEnhanced the original OBV (On Balance Volume) indicator:
- Draw max lines of OBV in the last 30 candles so that we can notice the trend, as well as divergences easier.
- If you use fiat as base currency (USDT in cryptocurrency for example), we can display the OBV in fiat, so that we can compare total trading volume across a list of symbols to find healthy symbols to trade easier.
Price density [Measuring Market Noise:Take advantage]$$ Market noise can be problematic to some types of trading strategies yet beneficial to others.
By measuring noise using the 'Price Density' can enable us to improve our
trading edge and turn noise to our advantage.
Robust analysis of noise can inform us when it is best to avoid trend-following
systems (when noise is too high), and vice versa for systems based on a
mean-reverting trading premise (when market noise is low).
__________________________________________________________________________
Using Noise to our advantage
* Two techniques:
-Measure Noise and trade when suitable for the system
~ High noise = avoid trend-following
~ Low noise = avoid mean-reversion
-Match assets to strategies
~ Only trade 'noisy assets' with Mean-reversion Strategies
~ Only trade 'efficient assests' with Trend-following Strategies
## Price density:-
High values = High noise
Low values = Low noise
___________________________________________________________________________
Disclaimer!! Do your own research
Moving Average Support and Resistance ChannelThe Moving Average Support and Resistance Channel is a channel that consists of trend lines of resistance and support of the analyzed instrument, represented as moving averages with the selected type and smoothing period on a certain timeframe, where:
- Middle Line - the middle of the channel (the moving average of the pivot point using the Floor Pivot method)
- R1 - first resistance (moving average of support + Factor*ATR)
- R2 - second resistance (R1 + Factor*ATR)
- S1 - first support (moving average of resistance-Factor*ATR)
- S2 - second support (S1-Factor*ATR)
- Factor-ATR multiplier
Despite the fact that the indicator consists of moving averages, it can work equally well both during a trend and in its absence.
Characteristics of the trend movement:
• During an uptrend, the moving averages of the indicator are directed upwards, the price is above the Middle Line level most of the time
• During a downtrend, the moving averages of the indicator are directed down, the price is below the Middle Line level most of the time
• During the flat period, the boundaries of the moving average channel narrow, the channel tends to align in a horizontal position, the price consolidates most of the time around the Middle Line level, fighting off the support and resistance levels of the indicator.
The position of asset prices outside the indicator may mean an early correction or trend reversal.
How to trade:
One of the trading methods may be that during a breakout or a pullback after a breakout of the Middle Line level, the target of further movement, depending on the direction of this movement, may be the levels R1, R2 or S1, S2. Use this situation to make a profit.
I wish you good luck in building your trading plans and remember: such indicators do not predict the future price movement on the chart, they only determine the characteristics of the price movement at the current time, taking into account historical data.
On-Balance Volume Oscillator with Divergence and PivotsThis is On-Balance Volume recalculated to be an Oscillator, a Divergence hunter was added, also Pivot Points and Alerts.
On-Balance Volume, or OBV is considered a "leading indicator" - in contrast to a "lagging indicator" just as Moving Averages it does not show a confirmation what already happened, but it shows what can happen in the future. For example: The chart is climbing while the OBV oscillator is slowly declining, gets weaker and weaker, maybe even prints bearish divergences? That means that a reversal might be occurring soon. Leading indicators are best paired with Stop and Resistance Lines, general Trendlines, Fib Retracements etc...Your chart is approaching a very important Resistance Trendline but the OBV shows a very positive signal? That means there is a high probability that the Resistance is going to be pushed though and becomes Support in the future.
What are those circles?
-These are Divergences. Red for Regular-Bearish. Orange for Hidden-Bearish. Green for Regular-Bullish. Aqua for Hidden-Bullish.
What are those triangles?
- These are Pivots. They show when the OBV oscillator might reverse, this is important to know because many times the price action follows this move.
Please keep in mind that this indicator is a tool and not a strategy, do not blindly trade signals, do your own research first! Use this indicator in conjunction with other indicators to get multiple confirmations.
Times and Gold Zonethis indicator is to see all the time sessions but you have another session that you can change the hour to only see the best volatility of the pair you want
OBV + Simple Moving AverageThird time is a charm. On Balance Volume with simple moving average. Hopefully we don't get this kicked back to us.
[UTILS] Unit Testing FrameworkTL;DR
This script doesn't provide any buy/sell signals.
This script won't make you profitable implicitly.
This script is intended for utility function testing, library testing, custom assertions.
It is free and open-source.
Introduction
About the idea: is not exclusive, programmers tend to use this method a lot and for a long time.
The point is to ensure that parts of a software, "units" (i.e modules, functions, procedures, class methods etc), work as they should, meet they design and behave as intended. That's why we use the term "Unit testing".
In PineScript we don't have a lot of entities mentioned above yet. What we have are functions. For example, a function that sums numbers should return a number, a particular sum. Or a professor wrote a function that calculates something or whatever. He and you want to be sure that the function works as expected and further code changes (refactoring) won't break its behaviour. What the professor needs to do is to write unit tests for his function/library of functions. And what you need to do is to check if the professor wrote tests or not.
No tests = No code
- Total test-driven development
Ok, it is not so serious, but very important in software development. And I created a tool for that.
I tried to follow the APIs of testing tools/libs/frameworks I worked or work with: Jasmine (Javascript), Mocha/Chai (Javascript), Jest (Javascript), RSpec (Ruby), unittest (Python), pytest (Python) and others. Got something workable but it would be much easier to implement (and it would look much better) if PineScript had a higher-order functions feature.
API
_describe(suiteName: string)
A function to declare a test suite. Each suite with tests may have 2 statuses:
✔️ Passed
❌ Failed
A suite is considered to be failed if at least one of the specs in it has failed.
_it(specName: string, actual: any, expected: any)
A function to run a test. Each test may have 3 statuses:
✔️ Passed
❌ Failed
⛔ Skipped
Some examples:
_it("is a falsey value", 1 != 2, true)
_it("is not a number", na(something), true)
_it("should sum two integers", _sum(1, 2), 1)
_it("arrays are equal", _isEqual(array.from(1, 2), array.from(1, 2)), true)
Remember that both the 'actual' and 'expected' arguments must be of the same type.
And a group of _it() functions must be preceded by a _describe() declaration (see in the code).
_test(specName: string, actual: any, expected: any)
An alias for _it . Does the same thing.
_xit(specName: string, actual: any, expected: any)
A function to skip a particular test for a while. Doesn't make any comparisons, but the test will appear in the results as skipped.
This feature is unstable and may be removed in the future releases.
_xtest(specName: string, actual: any, expected: any)
An alias for _xit . Does the same thing.
_isEqual(id_1: array, id_2: array)
A function to compare two arrays for equality. Both arrays must be of the same type.
This function doesn't take into account the order of elements in each array. So arrays like (1, 2, 3) and (3, 2, 1) will be equal.
_isStrictEqual(id_1: array, id_2: array)
A function to compare two arrays for equality. Both arrays must be of the same type.
This function is a stricter version of _isEqual because it takes into account the order of elements in each array. So arrays like (1, 2, 3) and (3, 2, 1) won't be equal.
Usage
To use this script to test your library you need to do the following steps:
1) Copy all the code you see between line #5 and #282 (Unit Testing Framework Core)
2) Place the copied code at the very beginning of your script (but below study())
3) Start to write suites and tests where your code ends. That's it.
NOTE
The current version is 0.0.1 which means that a lot of things may be changed on the way to 1.0.0 - the first stable version.
REAL MARKET RATESBased on near and long term eurodollar yield curve. Attempts to indicate, through a spread median, how major players may position themselves in the near future.
On Balance Volume - Color Packed Patch'emOBV is provided as a built-in by TradingView.
This contribution grew out of reading about trend discovery, and since the library kept on this end was lacking in a volume-centric indicator, it looked like a good time to play around.
This approach isn't all that much different than many others with the possible exception of its color scheme.
Should you decide to use the script, it might be worth your while to work with the logic of color and line, to produce alerts.
Enjoy.
+ Rate of Change (and OBV)The Rate of Change, or RoC, is a momentum indicator that measures the percentage change in price between the current period and the price n periods ago. It oscillates above and below a zeroline, basically showing positive or negative momentum. I applied the OBV's calculation to it, but without the inclusion of volume (also added a lookback period) to see what would happen.
Actually what happened was I was looking at hot-rodding the OBV indicator, but then wondered if I could apply the cumulative calculation to another indicator to see what would happen. Not sure why I chose the Rate of Change, but it seemed a neat idea. And it worked! And so I called it the "Cumulative Rate of Change." I only recently realized that this is actually just the OBV without volume, HOWEVER the OBV does not have a lookback period, and its source is the close of each period. Basically, when you look at the calculation for the OBV you'll notice that it's a cumulative measure of the "change" of the closing price against the previous close times the volume. The Rate of Change is basically that measurement over more than one period, excluding the volume, and is not cumulative. Thus the "Cumulative Rate of Change" is basically an OBV without the volume but with the capability to adjust the lookback period.
Anyway, after days and weeks of playing with the indicator pretty infrequently I did decide that I actually really liked it, especially with the addition of moving averages and bollinger bands. So I decided to play with it a bit more.
I added a drop-down menu to include the standard Rate of Change indicator, and then thought I may as well add the OBV too, in case someone might like to compare that to the C-RoC, or just wants an OBV with myriad moving averages and bollinger bands.
By default I have the indicator set to the "C-RoC" and the lookback is set to 1, but play with longer settings (this is pretty much necessary if using the traditional RoC, which is by default set to 10 in TradingView, and is nigh on useless at 1).
I also recommend playing with the source. 'Close' is nice, but 'ohlc4' provides some very nice signals as well, as it follows the price flow for each period completely, filtering the noisiness of 'close' as source.
Hope you guys like this. With the bollinger bands and your preferred moving average settings this can be a powerful tool for re-entering trades in trend, taking profits, determining momentum swings.
Smart On Balance Volume MTFSmart On Balance Volume
And constructed this indicator to have a variation of the conventional volume, the on balance volume is an indicator that is not given much value when I think that it is a formidable underlying basis of what is happening more when some etf cannot be measured with the PVI or NVI.
The Stochastico is built with the OBV signal of 3 different time frames, as it is for daily work
Has multiple settings and signals =
Color in overbought and oversold zones
visual alerts of crossovers in overbought and oversold zones
Alerts in for TDW on overbought and oversold
Signal length for% K
Signal length for% D
Smoothing length for% K and% D
A switch is added to toggle between the 3 time frames and the main one
Switch is added so you can see the original OBV
A switch is added to change the color in the bars
If you like it and find it useful please leave the comments below
Lumber to Gold ratioDISCRIPTION:-
Lumber to gold ratio helps to predict up upcomming market correction as investors are flocking towards safe heaven.
USE CASE SCENARIO:-
If the ratio is above the zero horizontal line it is a risk of scenario
If the ratio plunge below zero it might show imminent market correction.
BUFFET INDICATORDISCRIPTION
The stock market cap to GDP ratio has become known as the Buffett Indicator in recent years, as Warren Buffett commented that he believes it is “probably the best single measure of where valuations stand at any given moment.”
CALCULATION
100*VALUE OF ALL STOCKS IN COUNTRY/GDP OF COUNTRY
100*wilshire5000/gdp
Trend Background by Alejandro PThis indicator is a comprehensive trend indicator designed to help traders filter market conditions for their trading.
The indicator has the option to use a classic Simple Moving Average as a trend filer or a more advanced Simple Moving Average Slope.
The indicator can also use the Aroon indicator as the trend filter and both the SMA and Aroon can be used together to only trade in strong trends.
The Simple Moving Average Slope and the Aroon filters can allow you to filter our 3 market conditions. 1- Upwards Trend, 2- Downwards Trend, 3- Ranging
By tuning these filters to your strategy you can make sure you are only taking trades when the trend is on your side and you can even filter out ranging market conditions to trade the best strategies depending on the market conditions.
Technical details:
If the Simple Moving Average filter is on and the Slope filter if off the indicator will determine the trend by where the price is relative to the moving average. If the price is higher than the SMA then the trend will be bullish, if the price is below the SMA the trend will be bearish.
If SMA filter and Slope FIlter are both on then the trend es defined by the slope of the SMA, this means that if the SMA slope is increasing then the trend will be bullish, if the slow is negative then it will be bearish, but if the slope is within a certain percentile that is classified as neutral then there will be no trend or a neutral market.
If the Aroon filter is enabled this will calculate the trend by the percent of candles with new highs or lows in a similar way as the SMA slope filter works
If both filters are enabled then both filters will have to coincide for a bull or bear trend to be determined.
Forex bot full strategy with risk managementThis is a full strategy designed for forex major pairs, specially EUR/USD using 1h time frame chart.
Its components are
200 EMA
MACD
OBV
PSAR
RIsk management with tp and sl movements
Rules for entry
For long = Previous histogram from MACD was below 0 and current one is above 0. CLose of a candle is above EMA 200 , OBV oscillator is negative and we have an uptrend from PSAR
For short = Previous histogram from MACD was above 0 and current one is below 0. CLose of a candle is below EMA 200 , OBV oscillator is positive and we have an downtrend from PSAR
Rules for exit
For tp and sl values we calculate the distance from the close of candle until the psar values.
If you have any questions, let me know !
Advanced VolumeThis simple indicator improves upon the built in volume indicator by adding the following:
-Option to use an EMA instead of SMA
-Advanced Coloring: Lighter bars show growing volume, darker bars show falling volume. Gray bars show very low relative volume (less than or equal to 50% of the moving average), while bars which have a highlighted background have a high relative volume( you can choose the threshold level, default is 2 times the RVOL).
Enjoy!
PercentChannelSimilar to my "DollarChannel" script, this keeps track of lows and highs, but snaps a line whenever A) the high exceeds low+(low*ratio), or B) low falls under high-(high*ratio).
This results in a channel that tracks percent-changes rather than absolute dollar-value changes.
12 Weeks of Weekly LevelsA very simple indicator, which basically looks back on the past 12 weeks at 8PM EST and finds the highs and the lows. Once it finds those levels, it draws them as horizontal rays on the chart. The lows are drawn in green (to indicate previous buy zones) and the highs in red (to indicate previous sell zones). No user inputs are required
Nothing fancy, just weekly levels for the past quarter. You can easily draw these on a chart yourself, but it becomes very time consuming if you are watching a bunch of instruments and then Sundays come around.
Special shoutout to rumpypumpydumpy on StackOverflow for helping me work out the kinks, this is the first indicator I ever created. Hope it helps you find confluence in your decision making
Relative Fundamental ComparisonWhen dealing with stocks, I like to review basic fundamentals of the company. This script displays the fundamental ratios of base chart stock with three other stocks (I can’t increase the number due to security function limitations). I found it particularly important when dealing with an unknown company. I quickly compare the company with other industry leaders to get a comparative fundamental review.
I am very new to Pinescript, so waiting for your comments and review.