Mid to High daily % - MA & ThresholdPurpose of this script is to provide a metric for comparing crypto volatility in terms of the % gain that can be garnished if you buy the midpoint price of the day and sell the high***. I'm specifically using bots that buy non-stop. This metric makes it easy to compare crypto coins while also providing insight on what a take profit % should be if I want to be sure it closes often instead of getting stuck in a position.
Added a few moving averages of (Mid-range to High Daily %). When these lines starts to trend down, it's time to lower the take profit % or move on to the next coin.
Decided to add a threshold so I could easily mark where I think the (Mid-range to High Daily %) is for most days.
Ex. I can mark 10% threshold and can eyeball roughly ~75% of the days in the past month or so were at or above that level. Then I know I have plenty volatility for a bot taking 5% profit. Also if you have plenty of periodic poke-through that month (let's say once a week) you might argue that you can set it to 7% if you're willing to wait about that long. Either way this metric is conservative because it is only the middle of the range to the high, a less conservative version might provide the % gain if you bought the day low and sold the day high.
***Since this calculation only takes the middle of the range and the high of the day into account, red days are volatile against a buyer but to your advantage if you are a seller. BUT if you have plenty of safety buy orders this volatility in price only means your total purchase volume increases and when/if you reach a take profit level you sell more there.
Would like to upgrade and add a separate MA line for green days and a separate MA line for red days to discern if that particular coin has a bias. Also would like to include some statistics on how many candles are above or below threshold for a certain period instead of eyeballing.
Indicadores de Banda
SAR-adjusted extremesThis indicator shows how far (i.e. the absolute distance) of the extremes (i.e. high & low) are from the current parabolic SAR
Davood Kumothis andicator is build in base of ichimoku cloud.
Select the interval at which the kumo clouds change phase and depending on what time frame we are in, we give the time inputs to the indicator.
then, the indicator calculates the area of the cloud and set the ascending and descending targets when price break the highest or lowest candle in that time range.
So entry point is the highest and lowest candle and first and second targets are determined by the indicator.
note : i used this andicator only in crypto market not forex and it works well
world stage indexThis is an indicator that expresses the ratio of "stage1" and "stage4" of world index.
40 symbols are as follows
(JAPAN, US, EUROPE, and CANADA)
OSE:NK2251!, DJ:DJI, NASDAQ:IXIC, SP:SPX, XETR:DAX, TVC:CAC40, TVC:UKX, TSX:TSX
(ASIA)
TVC:SHCOMP, SZSE:399001, TVC:HSI, TWSE:TAIEX, BSE:SENSEX, OANDA:SG30SGD, INDEX:KSI, SET:SET
(EUROPE)
INDEX:SX5E, INDEX:FTSEMIB, SIX:SMI, BME:IBC, EURONEXT:BEL20, TVC:AEX, OMXCOP:OMXC25, XETR:0Q5X
(Pacific Ocean)
ASX:XJO, TVC:NZ50G, IDX:COMPOSITE, FTSEMYX:FBMKLCI, BMFBOVESPA:IBOV, BMV:ME, BVL:SPBLPGPT, BYMA:IMV
(Eastern Europe & Middle East)
MOEX:IMOEX, GPW:WIG20, OMXHEX:OMXH25, OMXSTO:OMXS30, DFM:DFMGI, TADAWUL:TASI, OSE:GNRI, EGX:EGX30
The criteria are as follows:
EMA5≧EMA20≧EMA40 : Stage1
EMA5≦EMA20≦EMA40 : Stage4
A.The sum of Stage1 was multiplied by 2.5 and drawn on a scale of 0 to 100, with yellow area
B.The Sum of Stage4 was multiplied by 2.5 and drawn on a scale of 0 to 100, with blue area.
C. The ratio of A/B was multiplied by 2.5 and drawn on a scale of 0 to 100, with red lines.
This idea is from Kojirou Kousi.
40 symbols of this script are partially different from Kojiro kousi's idea.
But he said the difference isn't matter.
「小次郎講師指数」に着想を得た、世界40カ国の株価指数stage状態です。
参考文献は、小次郎講師著書「世界一わかりやすい投資の勝ち方」です。
小次郎講師とは一部異なるシンボルを採用していますが、
多少の違いは余り大した問題では無いと御本人から教わった事があります。
先進国に関してはおそらくほとんど同じだと思います。
stage1の合計の%を黄色、stage4の合計の%を青色、stage1の合計/stage4の合計の%を赤で表示しています。
雰囲気で分かればいいので、正確な数字までは表示しませんでした。
個人的には現状分析以外にも、プラクティス時に世界情勢を把握するのに重宝しています。
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 !