Support and Resistance: Triangles [YinYangAlgorithms]Overview:
Triangles have always been known to be the strongest shape. Well, why wouldn’t that likewise apply to trading? This Indicator will create Upwards and Downwards Triangles which in turn create Support and Resistance locations. For example, we find 2 highs that meet the criteria (within deviation %, Minimum Distance and Lookback Distance). We calculate the distance between these two and create an Equilateral Triangle Downwards (You can adjust the % if you want more of an Isosceles Triangle). The midpoint (tip) of this triangle is the Support and the bottom (base) of it is the Resistance. The exact opposite applies for an Upwards Triangle.
The reason why Triangles may make for good Support and Resistance locations is the % 's used, much like the fibonacci, use ratios relevant in nature and everywhere in the world around us, so why not for trading too?
Tutorial:
If you look at the locations we’ve circled above, all of them exhibit strong rejections are predictive Support and Resistance locations plotted by the triangles created. There can only ever be 1 Upward and 1 Downward Triangle at a time, so when a new one is created, the Support and Resistance locations are moved.
If you scroll back far enough you’ll notice the Triangles disappear but their Support and Resistance locations are still plotted. This has to do with the fact you are allowed only so many Lines plotted and when a new Triangle is created, an old one will be removed. The Support and Resistance locations however will stay.
If we look at the example above, you can see the Support and Resistance locations the Triangles made here may have helped predict where the price would struggle to surpass.
By default the Look Back Distance is set to 50 and the Min Distance is 10 (settings used in all previous examples). However, you can modify these to make Triangles more ‘Rare’ and therefore the Support and Resistance locations change less. In the example above for Instance we left Look Back Distance to 50 but changed Min Distance from 10 to 25. This results in Support and Resistance locations that may hold better in the long term.
If we scroll back a bit, we can see the settings ‘Look Back Distance’ 50 and ‘Minimum Distance’ 25 had done a decent job at predicting the ATH resistance and many Support and Resistance locations around it. Keep in mind, previous results don’t mean future results, but Triangles may create ratios which apply well to trading.
We will conclude our Tutorial here. Hopefully you can see the benefit to the ratio Triangles make when predicting Support and Resistance locations.
Settings:
Show Triangles: If all you want to know is the Support and Resistance locations, there’s no need to draw the Triangles.
Triangle Zones: What types of triangles should we create our zones for? Options are Upward, Downward, Both, None.
Max Deviation Allowed: Maximum Deviation up or down from the last bars High/Low for potential to create a Triangle.
Lookback Distance: How far back we look to see for potential of a High/Low within Deviation range.
Min Distance: This is so triangles are spaced properly and not from 2 bars beside each other. Min distance allocated between 2 points to create a Triangle.
Bar Percent Increase: How much % multiplier do we apply for each bar spacing of the triangle. 0.005 creates a close to Equilateral Triangle, but other values like 0.004 and 0.006 seem to work well too.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Yinyang
Machine Learning: Support and Resistance [YinYangAlgorithms]Overview:
Support and Resistance is normally based upon Pivot Points and Highest Highs and Lowest Lows. Many times coders even incorporate Volume, RSI and other factors into the equation. However there may be a downside to doing a pure technical approach based on historical levels. We live in a time where Machine Learning is becoming more and more used; thus we have decided to create a Machine Learning Support and Resistance Projection based Indicator. Rather than using traditional Support and Resistance calculations using historical data, we have taken a rather different approach. This Indicator instead attempts to Predict and Project where Support and Resistance locations will be based on a Machine Learning Model using a form of KNN (k-Nearest Neighbors).
Since this indicator creates a Projection of where it deems Support and Resistance will be, it has the ability to move its Support and Resistance before the price even gets to it if it believes it will surpass its projections. This may create a more accurate placement of Support and Resistance as they’re not based on historical levels.
This Indicator does not Repaint.
How it works:
This Indicator makes its projections based on the source you provide (by default close) of the previous bar and submits the source, RSI and EMA to our Projection Function to get its projection of the current bar.
The Projection function essentially calculates potential movement after finding the differences between the source the MA from the current bar, previous bar and average over the span of Machine Learning Length.
Potential movement is defined as:
Average Difference + Average(Machine Learning Average, Average Last Distance)
Average Difference: (Absolute value of Current Source - Current MA) - (Absolute value of Machine Learning Average - Machine Learning MA)
Average Last Distance: Average(Current Source - Current MA, Previous Source - Previous MA)
It then predicts the next bars directional movement (bullish or bearish bar) using several factors:
Previous Source > Previous MA
Current Source - Current MA > Average Source - Average MA
Current RSI > Previous RSI
Current RSI > 30 and Previous RSI <= 30
Current RSI < 70 and Previous RSI >= 70
This helps us to predict the direction the next bar may move.
We then calculate a multiplier that we apply to our Potential Movement value to get our final result which is our Current Bars Close Projection.
Our multiplier is calculated using:
(Current RSI > 30 and Previous RSI <= 30) OR (Current RSI < 70 and Previous RSI >= 70)
Current Source - Current MA > Previous Source - Previous MA
We then create an array and fill it with the previous X projections (Machine Learning Length) and send it to another function. This function, if told to, will sort the data accordingly and then output the KNN average of the length given.
We calculate and plot various KNN lengths to create different Zones:
Strong Support: Length of 2 but sort the data Ascending (low to high)
Strong Resistance: Length of 2 but sort the data Descending (high to low)
Support: Length of Machine Length Length / 10 or Min of 2 sorted by Ascending
Resistance: Length of Machine Length Length / 10 or Min of 2 sorted by Descending
There are also 4 other plots you may be wondering what they are, there is your AVG, VWMA, Long Term Memory and Current Projection.
By default your Current Projection is disabled in settings but you can enable it if you are curious to see how the projections for each close are calculated. It is, however, not a crucial point of interest (white line).
The average is simply the average value of the Machine Learning Data (purple line).
The VWMA is a VWMA calculation applied to our Data over a length specified in settings (by default 1)(blue line). The VWMA is crucial when combined with the Avg as they can cross over and under each other. These crosses represent potential Bullish and Bearish zones.
Lastly, but certainly not least, we have the Long Term Memory (maroon line). The Long Term Memory can be displayed either as an ‘Average’, ‘Hard Line’ or ‘None’. The Long Term Average is only updated every Machine Learning Length Bar Index’s and is populated with the average of the Machine Learning Data. For Instance, if Machine Learning Length is set to 100, the Long Term Memory is only updated every 100 bars, and since its length is the same as the Machine Learning Length, that means its data is composed of 10,000 bars worth of data. The Long Term Memory may be very beneficial for determining where Support and Resistance lie over the Long Term within a Machine Learning Algorithm. When set to ‘Average’ it plots the connection lines diagonally, and although they may be more visually appealing, they’re less useful when it comes to actually seeing support and resistance as generally speaking, support and resistance lie on the horizontal. When set to ‘Hard Line’ the Long Term Memory is connected with hard lines and holds the price value until the next time it is updated. This makes it much more useful for potentially identifying Support and Resistance.
Tutorial:
Here is an overview of what the Indicator looks like, now let's start to dissect it.
In the example above we can see how all of the lines between the Major Support and Resistance zones may act as BOTH Support and Resistance depending on which side the price is currently on. In the circle on the left, we can see how it can fluctuate between the two. If you look at the circle on the right, we can see how the Average line acts as a strong support before it fails to maintain it. Generally speaking, most Support and Resistance locations may potentially fail to hold after 3 tests, as the Average did in this example.
As you can see, the Support and Resistance doesn’t wait to be tested before adjusting, which is why there are 2 lines which create their zones. The inner line is the Support/Resistance and the outer line is the Strong Support/Resistance. The Yellow Circle shows the inner line was able to calculate the moving resistance correctly and then adjusted accordingly as it was projecting the price to keep increasing. However, if you look at the White Circle, you can see that since there was first a crash, and then parabolic movement, that the inner zone could not move and predict the resistance as well as the outer zone could.
We consider the price to be ‘Overvalued’ when it is above the VWMA (blue line) and ‘Undervalued’ when it is below the VWMA. It is considered ‘fair’ price when it is within the VWMA to Average zone (between the blue and purple lines). If you look at the example above, you’ll notice where the two yellow circles are, it is not only considered ‘Overvalued’, but it then proceeds to ride the inner resistance line upwards. This is common when the market is overly bullish and vice versa when it is bearish. Please keep in mind, although it is common, it doesn’t mean a correction can’t happen.
In this example above we look at the last bull run that may have started due to the halving. This bull run was very bullish as you can see in the example above. The price was constantly sitting within the Resistance Zone and the VWMA that was very close to it was constantly acting as a Support. Naturally, due to the Algorithm used in this Indicator, as the momentum starts to slow down, the VWMA (blue line) will start to space out more and more from the Resistance Zone. This doesn’t mean the momentum is gone, it just means it may be slowing down.
Unfortunately we have to study the Bear Market with a different perspective than the Bull Market. However, there are still some similarities within the two. If you refer to the example above and the previous example, you can clearly see that the Bull Market loves to stay with the Resistance Zone and use the VWMA as a Support. However, the Bear Market does not. This is a normal occurrence, however we can see from the example above you may see a correction / horizontal movement when the Outer Support Line is touched. If you look at all 3 yellow circles, the Outer Support Line was touched, then either a small correction or horizontal consolidation occurred.
We will conclude our Tutorial here, hopefully you’ll be able to benefit from a moving Support and Resistance calculated with Machine Learning that projects its locations, rather than using traditional calculations.
Settings:
Source: This source is the base for all our calculations
Machine Learning Length: How much projection data are we storing and using to make calculations.
Smoothing Length: We need to smooth calculations such as RSI, EMA and VWMA. What length are we smoothing it with?
VWMA ML Projection Length: How far into our Machine Learning data should we average for our VWMA. Please note the 'Smoothing Length' is still applied here after getting the Projection Average.
Long Term Memory: Long term memory has the same storage length but is only updated once per Machine Learning Length. For instance, if Machine Learning Length is 100, it will save the Average of our data once every 100 bars. This means its memory is an average of 10,000 bars of Machine Learning. 'Average' connects its values diagonally whereas 'Hard Line' holds its value until it changes.
Use Average Last Distance In Potential Movement: This can help accuracy but generally also displaces the Support and Resistance by projecting it further.
Show Current Projection: Projections occur for each bar, and our Machine Learning utilizes these projections by storing and evaluating them. This toggle will display the Current Projection Line which is used to create all our Projections.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
YinYang Bar ForecastOverview:
YinYang Bar Forecast is a prediction indicator. It predicts the movement for High, Low, Open and Close for up to 13 bars into the future. We created this Indicator as we felt the TradingView community could benefit from a bar forecast as there wasn’t any currently available.
Our YinYang Bar Forecast is something we plan on continuously working on to better improve it, but at its current state it is still very useful and decently accurate. It features many calculations to derive what it thinks the future bars will hold. Let’s discuss some of the logic behind it:
Each bar has its High, Low, Open and Close calculated individually for highest accuracy. Within these calculations we first check which bar it is we are calculating and base our span back length that we are getting our data from based on the bar index we are generating. This helps us get a Moving Average for this bar index.
We take this MA and we apply our Custom Volume Filter calculation on it, which is essentially us dividing the current bars volume over the average volume in the last ‘Filtered Length’ (Setting) length. We take this decimal and multiply it on our MA and smooth it out with a VWMA.
We take the new Volume Filtered MA and apply a RSI Filter calculation on it. RSI Filter is where we take the difference between the high and low of this bar and we multiply it with an RSI calculation using our Volume Filtered MA. We take the result of that multiplication and either add or subtract it from the Volume Filtered MA based on if close > open. This makes our RSI Filtered MA.
Next, we do an EMA Strength Calculation which is where we check if close > ema(close, ‘EMA Averaged Length’) (Setting). Based on this condition we assign a multiplier that is applied to our RSI Filtered MA. We divide by how many bars we are predicting and add a bit to each predictive bar so that the further we go into the future the stronger the strength is.
Next we check RSI and RSI MA levels and apply multiplications based on its RSI levels and if it is greater than or less than the MA. Also it is affected by if the RSI is <= 30 and >= 70.
Finally we check the MFI and MFI MA levels and like RSI we apply multiplications based on its MFI levels and if it is greater than or less than the MA. It is also affected by if the MFI is <= 30 and >= 70.
Please note the way we calculate this may change in the future, this is just currently what we deemed works best for forecasting the future bars. Also note this script uses MA calculations out of scope for efficiency but there is potential for inconsistencies.
Innately it’s main use is the projection it provides. It only draws the bars for realtime bars and not historical ones, so the best way to backtest it is with TradingView’s Replay Tool.
Well, enough of the logic behind it, let's get to understanding how to use it:
Tutorial:
So unfortunately we aren’t able to plot legit bars/candles into the future so we’ve had to do a bit of a work around using lines and fills. As you can see here we have 4 Lines and 3 Zones:
Lines:
Green: Represents the High
Orange: Represents the Open
Teal: Represents the Close
Red: Represents the Low
Zones:
High Zone: This zone is from either Open or Close to the High and is ALWAYS filled with Green.
Open/Close Zone: This zone is from the Open to the Close and is filled with either Green or Red based on if it's greater than the previous bar (real or forecasted).
Low Zone: This zone is from either Open or Close to the Low and is ALWAYS filled with Red.
As you can see generally the Forecasted bars are generally within strong pivot locations and are a good estimation of what will likely go on. Please note, the WHOLE structure of the prediction can change based on the current bars movements and the way it affects the calculations.
Let's look 1 bar back from the current bar just so we can see what it used to Forecast:
As you can see it has changed quite a bit from the previous bar, but if you look close, we drew horizontal lines around where its projecting the next bar to be (our current realtime bar), if we go back to the live chart:
Its projections were pretty close for the high and low. Generally, right now at least, it does a much better job at predicting the high and low than it does the open and close, however we will do our best to fine tune that in future updates.
Remember, this indicator is not meant to base your trades on, but rather give you a Forecast towards the general direction of the next few bars. Somewhat like weather, the farther the bar (or day for weather), the harder it is to predict. For this reason we recommend you focusing on the first few bars as they are more accurate, but review the further ones as they may help show the trend and the way that pair will move.
We will conclude this tutorial here, hopefully this Predictive Indicator can be of some help and use to you. If you have any questions, comments, ideas or concerns please let us know.
Settings:
Forecast Length: How many bars should we predict into the Future? Max 13
Each Bar Length Multiplier: For each new Forecast bar, how many more bars are averaged? Min 2
VWMA Averaged Length: All Forecast bars are put into a VWMA, what length should we use?
EMA Averaged Length: All Forecast bars are put into a EMA, what length should we use?
Filtered Length: What length should we use for Filtered Volume and RSI?
EMA Strength Length: What length should we use for the EMA Strength
HAPPY TRADING!
YinYang RSI Volume Trend StrategyThere are many strategies that use RSI or Volume but very few that take advantage of how useful and important the two of them combined are. This strategy uses the Highs and Lows with Volume and RSI weighted calculations on top of them. You may be wondering how much of an impact Volume and RSI can have on the prices; the answer is a lot and we will discuss those with plenty of examples below, but first…
How does this strategy work?
It’s simple really, when the purchase source crosses above the inner low band (red) it creates a Buy or Long. This long has a Trailing Stop Loss band (the outer low band that's also red) that can be adjusted in the Settings. The Stop Loss is based on a % of the inner low band’s price and by default it is 0.1% lower than the inner band’s price. This Stop Loss is not only a stop loss but it can also act as a Purchase Available location.
You can get back into a trade after a stop loss / take profit has been hit when your Reset Purchase Availability After condition has been met. This can either be at Stop Loss, Entry or None.
It is advised to allow it to reset in case the stop loss was a fake out but the call was right. Sometimes it may trigger stop loss multiple times in a row, but you don’t lose much on stop loss and you gain lots when the call is right.
The Take Profit location is the basis line (white). Take Profit occurs when the Exit Source (close, open, high, low or other) crosses the basis line and then on a different bar the Exit Source crosses back over the basis line. For example, if it was a Long and the bar’s Exit Source closed above the basis line, and then 2 bars later its Exit Source closed below the basis line, Take Profit would occur. You can disable Take Profit in Settings, but it is very useful as many times the price will cross the Basis and then correct back rather than making it all the way to the opposing zone.
Longs:
If for instance your Long doesn’t need to Take Profit and instead reaches the top zone, it will close the position when it crosses above the inner top line (green).
Please note you can change the Exit Source too which is what source (close, open, high, low) it uses to end the trades.
The Shorts work the same way as the Long but just opposite, they start when the purchase source crosses under the inner upper band (green).
Shorts:
Shorts take profit when it crosses under the basis line and then crosses back.
Shorts will Stop loss when their outer upper band (green) is crossed with the Exit Source.
Short trades are completed and closed when its Exit Source crosses under the inner low red band.
So, now that you understand how the strategy works, let’s discuss why this strategy works and how it is profitable.
First we will discuss Volume as we deem it plays a much bigger role overall and in our strategy:
As I’m sure many of you know, Volume plays a huge factor in how much something moves, but it also plays a role in the strength of the movement. For instance, let’s look at two scenarios:
Bitcoin’s price goes up $1000 in 1 Day but the Volume was only 10 million
Bitcoin’s price goes up $200 in 1 Day but the Volume was 40 million
If you were to only look at the price, you’d say #1 was more important because the price moved x5 the amount as #2, but once you factor in the volume, you know this is not true. The reason why Volume plays such a huge role in Price movement is because it shows there is a large Limit Order battle going on. It means that both Bears and Bulls believe that price is a good time to Buy and Sell. This creates a strong Support and Resistance price point in this location. If we look at scenario #2, when there is high volume, especially if it is drastically larger than the average volume Bitcoin was displaying recently, what can we decipher from this? Well, the biggest take away is that the Bull’s won the battle, and that likely when that happens we will see bullish movement continuing to happen as most of the Bears Limit Orders have been fulfilled. Whereas with #2, when large price movement happens and Bitcoin goes up $1000 with low volume what can we deduce? The main takeaway is that Bull’s pressured the price up with Market Orders where they purchased the best available price, also what this means is there were very few people who were wanting to sell. This generally dictates that Whale Limit orders for Sells/Shorts are much higher up and theres room for movement, but it also means there is likely a whale that is ready to dump and crash it back down.
You may be wondering, what did this example have to do with YinYang RSI Volume Trend Strategy? Well the reason we’ve discussed this is because we use Volume multiple times to apply multiplications in our calculations to add large weight to the price when there is lots of volume (this is applied both positively and negatively). For instance, if the price drops a little and there is high volume, our strategy will move its bounds MUCH lower than the price actually dropped, and if there was low volume but the price dropped A LOT, our strategy will only move its bounds a little. We believe this reflects higher levels of price accuracy than just price alone based on the examples described above.
Don’t believe us?
Here is with Volume NOT factored in (VWMA = SMA and we remove our Volume Filter calculation):
Which produced -$2880 Profit
Here is with our Volume factored in:
Which produced $553,000 (55.3%)
As you can see, we wen’t from $-2800 profit with volume not factored to $553,000 with volume factored. That's quite a big difference! (Please note previous success does not predict future success we are simply displaying the $ amounts as example).
Now how about RSI and why does it matter in this strategy?
As I’m sure most of you are aware, RSI is one of the leading indicators used in trading. For this reason we figured it would only make sense to incorporate it into our calculations. We fiddled with RSI for quite awhile and sometimes what logically seems to be the right way to use it isn’t. Now, because of this, our RSI calculation is a little odd, but basically what we’re doing is we calculate the RSI, then turn it into a percentage (between 0-1) that can easily be multiplied to the price point we need. The price point we use is the difference between our high purchase zone and our low purchase zone. This allows us to see how much price movement there is between zones. We multiply our zone size with our RSI multiplication and we get the amount we will add +/- to our basis line (white line). This officially creates the NEW high and low purchase zones that we are actually using and displaying in our trades.
If you found that confusing, here are some examples to why it is an important calculation for this strategy:
Before RSI factored in:
Which produced 27.8% Profit
After RSI factored in:
Which produced 553% Profit
As you can see, the RSI makes not only the purchase zones more accurate, but it also greatly increases the profit the strategy is able to make. It also helps ensure an relatively linear profit slope so you know it is reliable with its trades.
This strategy can work on pretty much anything, but you should tweak the values a bit for each pair you are trading it with for best results.
We hope you can find some use out of this simple but effective strategy, if you have any questions, comments or concerns please let us know.
HAPPY TRADING!
Sacred Geometry by DGTSacred geometry ascribes symbolic and sacred meanings to certain geometric shapes and certain geometric proportions. The study of sacred geometry has its roots in the study of nature, and the mathematical principles at work therein
In trading, using geometry for technical analysis is highly used concept, such as Gann Tools, Fibonacci Tools, Elliott Wave Theory are some examples that are based on the idea that the market is geometric and cyclical in nature
Thanks to @AtomOfScent's "almost like sacred geometry" comment to FibFans on Previous HTF HL
study give me the idea to go further and to demonstrate just how far we can go with this style of analysis. And here comes an experimental attempt to present some of sacred geometric shapes such as Seed of Life, Fruit of Life and Spiral, where the resulting image may help technical analysts to predict price changes.
Fruit of Life, example and how it is derived (maximum line limitation does not allow to draw all circles, so red circles are drawn manually to present the idea). Fruit of Life is base for the Metatron’s Cube and we can create all five Platonic Solids from it (Hexahedron, Tetrahedron, Octahedron, Icosahedron and Dodecahedron)
Spiral Examples :
Again special thanks to @AtomOfScent for commenting on the draft version of the study as well as providing valuable suggestions.
Disclaimer :
Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely
The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script