Double Top/Bottom - UltimateHellow traders, this is my final script regarding double top/bottom pattern recognition. This script is built based on zig zag indicator whereas the previous ones are built based on pivot points.
Double Top:
Recognition - Checks on Zigzag if LH is followed by HH
Confirmation - When low crosses under last lower pivot point on zigzag
Invalidation - When high crosses over HH
Double Bottom:
Recognition - Checks on Zigzag if HL is followed by LL
Confirmation - When high crosses over last higher pivot point on zigzag
Invalidation - When low crosses under LL
Few major changes in this version compared to previous ones:
Zigzag offers more simplicity in deriving the pattern and also enahnces accuracy. Things such as pivot distance, absolute peaks are removed as they are redundant.
Option to display risk per reward which defines how steep is the W-M triangle. This is simply the ratio of price difference between mid point to top most and bottom most points. In case of double top, downside is considered as reward and upside is considered as risk and with double bottom, downside is considered as risk and upside is considered as reward. Lower risk per reward signifies better trade.
Option to display stats which shows number of occurances of double top and bottom and how many times price crossed confirmation point and invalidation point (which are also marked with dashed lines) Stats are color coded. Higher success rates are colored in shades of green, lower success rates are colored in shades of orange whereas the neutral success rates are coloed in light yellow.
Example of stat shown in Neutral shade. I could not find any instrument which had confirmation rate less than 0.4 - which suggests confirmation rate for the patter is pretty strong:
Links for the other two scripts are here:
Punti Pivot
NSDT Trend CandlesThis script changes the color of the candles based on uptrend (green), downtrend (red), neutral/chop (yellow). It uses an ATR and Pivots to determine the direction, or lack of. Since all markets move differently and market volatility changes, you will need to adjust the settings to find a potential match for the day. It's pretty simple to use. Just enter in the direction of the trend and exit (or reverse) when the candle color changes.
Musashi_BattleTimer-Musashi_Battle Timer-
Four financial sessions presented in a compact way that suits my trading style.
The indicator will do the following:
- Plot Background color separating sessions:
- Highlight Gray since Tokyo open to London open, then a gap.
- Highlight Red from London open to NY open, then a gap.
- Highlight Red from NY open to London Close, then a gap
- Highlight Gray from London close to Sidney open
- Sidney open to Tokio open NO highlight.
- Plot dotted limits for the highest and lowest price of the day.
- Plot a range for the Asian session (Sydney + Tokyo).
- Plot a few day's ADR (Average Daily Range) and extend the current one.
Have a good day.
Double Top/Bottom V2This is an enhanced version of Double Top/Bottom detector.
Initial basic version can be found here:
Concept of deriving pattern is similar but there are few major changes.
Double Top:
Get the highest pivot high from last X pivot highs ( DTHigh1 )
Look for next top most pivot high which happened after DTHigh1 ( DTHigh2 )
Look for lowest pivot low between DTHigh1 and DTHigh2 ( DTLow )
Double Bottom:
Get the lowest pivot low from last X pivot lows ( DBLow1 )
Look for next lowest pivot low which happened after DBLow1 ( DBLow2 )
Look for highest pivot high between DBLow1 and DBLow2 ( DbHigh )
Other Key parameters:
checkForAbsolutePeaks and absolutePeakLoopback work together. When selected, double top and double bottom is formed only if DTHigh1 / DBLow1 are highest/lowest points from last absolutePeakLoopback bars back.
considerPivotDistance will make sure distance between Highs(in double top) and lows(in double bottom) are below 2 ( MaxAtrDistanceBase ) times ATR. And distance between average Highs/Lows to Low/High forming triangle is less than 6 ( MaxAtrDistanceHighLow ) times ATR. This will avoid showing steep triangles as double top/bottoms.
showLastLevels option allows users to display dashed lines on double top/bottom confirmation and invalidation levels for last formed double bottom and tops. These can be treated as strong support and resistence. Dashed lines are permanently formed on double top/bottom setups when an invalidation or confirmation occurs by price crossing either lowest or highest points of double top/bottom triangles.
Alerts:
Probable double top/bottom - when double top or bottom triangles formed.
Double top/bottom confirmation - when double top or bottom is confirmed.
Double top/bottom invalidation - when double top or bottom is invalidated.
Few important points about adjusting parameters:
Lower pivot lengths will generate more signals. But, too frequent signals may not be desirable as well.
higher absolutePeakLoopback will reduce number of signals while strengthening them.
Unchecking consider pivot distance or reducing MaxAtrDistanceBase/MaxAtrDistanceHighLow may considerably increase the number of pivots specially when pivot lengths are lower side. This may result in reduced quality of signals as well.
Moving average condition which is part of basic script is not included in this. We can add Hull Suite or moving average crossover on the chart as confirmation of strong signal.
VWAP AverageThe VWAP Average does NOT reset on a singular timeframe ie. daily, weekly etc. "Newsession" is based on input length on current session timeframe, just like any other moving average.
VWAP High/Low ChannelIn short, the VWAP High/Low Channel is based on VWAP "newsession" on swing high/low, with a basis of the two.
The VWAP High/Low channel seems to act like Bollinger bands or Donchain Channels when squeezing for a breakout, while also acting as a pivot after a breakout.
Trend Key PointsEach trend has its high and low key points that are important in the next prices. Sometimes it's hard to find out the keys with a naked eye, so I tried to code a simple indicator to marking these points also, as a bonus, to draw support and resistance lines from previous critical pivot points.
Let me explain the details with a downtrend. If we consider the previous trend, each downtrend starts with a HH and end with a LL. There are always many tries between that HH and LL to turn the trend up. This indicator counts that inner attempts. The higher the number of attempts, the more important move has been started from the beginning (HH). These numbers take their final form when the trend ends and are included in the label at the beginning of each trend.
Key points with 3 and more inner tries are consider as critical point by default but It's alterable and you can change it as you want. The indicator draws lines from critical points too, so you can use that lines as support and resistance in next candles.
Likewise, there are marks below inner LLs and above inner HHs.
This indicator idea is entirely my own and is a product I've really thought about, AND you have allowed to use and share it anywhere to anyone. I did my best to make it useful, even so I am open to any improvement. If you have an idea or a suggestion, don't forget to leave a comment.
FullPac4Trader (I.Denis)The script combines the three most important indicators on the chart.
1. A set of six moving averages ( EMA and SMA ), which can be turned on and adjusted at your discretion.
2. Indication of support and resistance levels, calculated according to the Bollinger scheme.
3. Pivot Point and the nearest goals using the Floor method with the possibility of selecting a time period.
The script version is v.1 (beta)
The development of this script will continue. Feedback and suggestions are welcome.
Martyv Auto Fib Retracement with Logarithmic SupportSimple & easy auto-fib levels. Took the out-of-the-box version provided by TradingView and added Logarithmic support and a nicer palette, and made the controls a bit nicer to use (in my opinion lol). Enjoy.
Stronger Classical Support/Resistance + Round LevelsI wrote some Support/Resistance scripts before this. In this new script, I implemented the logic of the code from the scratch, so it's very different from my previous S/R indicators and I think it's more advanced, accurate and efficient.
As the result it could do the followings for now:
- Draw more strong classical resistance/support levels by checking previous direction changes of the chart as far as Pine technically allows
- Colorize the levels based on the counted points of retracement/pullback (The darker the color is, the stronger the level is.)
- Show the number of reactions to each level
- Change the color of each level based on its main role as support, resistance or both
- Draw close round levels to current price for Forex pairs
I suggest all users of my previous S/R indicators to try this one.
Feel free to send me any issue or opinion!
Wide BarsSimple scripts show the wide range bars within in the look back period, visualizing the bigger momentum.
Added four exponential moving averages which define the trend of the instrument.
Wide range candles in the direction of overall trend on higher timeframes; give confluence of higher participation in the same direction.
Note : Decent volume above the average volume with wide range candle adds more value.
CPR SutradingA simple CPR indicator which plots pivot line, bottom cpr, top cpr, supports , resistances along with previous day high, low and close.
[USDCHF-USDCAD] H1 Predict signal DinhChienFX's [2 orders]Identify trend:
4 EMAS 50-100-150-200:
- Uptrend: ema: 50 > 100 > 150 > 200
- Downtrend: ema: 50 < 100 < 150 < 200
Pivot:
- Left: 15 candles
- Right: 15 candles.
- Uptrend: Higher low - Higher High
- Downtrend: Lower Low - Lower High.
Keltner Channel:
- Uptrend: Candle crosses Upper 2.
- Downtrend: Candlestick crosses the Lower 2 line.
Strong trend according to ADX indicator:
- DI: 9
- Smooth: 9
- ADX: 38
Order entry point:
- Buy: Upper Keltner
- Sell Lower Keltner
Take Profit/Stop Loss: atr (20) x2 = Height of Keltner channel from Lower to Upper line.
EmperorBTC's VWAP StrategyEmperorBTC's VWAP Indicator & Strategy
v2.1
coded by Bogdan Vaida
This indicator was created after EmperorBTC's conditions.
Good timeframes for it: 30', 15', 5'
To convert from strategy to study switch the commented lines in the beginning
and at the end of the script and vice versa.
What this indicator does is to check if:
o Pivot Point was crossed
o Stoch-RSI and VWAP were crossed in current or previous candle
o Candle (or previous candle) close is in the trend direction
If all these are true then it will go long or short based on direction.
2 Dimensional Array using one floating point entry This is an attempt to create a two dimensional floating point array from the pine single dimension array.
It enables some useful array functions like sorting, when you are trying to keep track of price and location in time or bars and you would like to sort the array.
Other array functions on this array will not work, like average and other statistical functions - they will provide bad results. I would suggest continuing to use a single dimensional array for each element where that kind of array function is required.
I wrote this simply as a mean of using the sort functions when I had to sort price and try to keep the bar location or time in synch.
Other array functions could be written to manipulate this kind of array, leave that to others. The goal here was to avoid using for loops which would be a performance impact on large arrays.
The basic concept is to create one floating point number from two, put that into an array, and then be able to pull the compound value out and parse out the individual components.
I imagine it could also accommodate a 3 or 4 dimensional array with some work, as long as you had some idea of how many digits are consumed by each element. For example you may be interested in storing price, RSI, x_loc values and then be able to sort and parse them out.
Zig Lines with Percent & ValueOverview, Features, and Usage:
The Zig Lines with Percent & Value is an indicator that highlights the highest and lowest points of the market from pivot points and zigzag lines based on the ZigZag Period setting. By a default value of 13 for the ZigZag Period this works well on Bitcoin or other alt coins on the 1 hour or higher timeframe charts.
What makes this indicator unique is that it draws a green line to signify an uptrend or a red line to signify a down trend. It will also show the percent difference between the previous point/line, for example: If you see a -negative percentage point with a red line drawn to it, then you are looking at a low pivot point and then as the green line is drawn to a +positive percentage value the percentage you see is the difference between the two points. This is great to see a trend reversal as you can look at previous pivot points and notice about how far the price moves before it changes direction (trend reversal).
There is an invisible EMA line that is used to assist with coloring the negative vs positive values. The value above or below the percentage is the lowest or highest price at that pivot point . The display of the price at the pivot point depends on your ZigZag Period setting and the timeframe of your chart.
Added Bollinger Bands as it fits perfectly with the visuals of the Zig Lines & Pivots.
Usage of Bollinger Bands:
~As the price or candle gets close to the top or bottom of the Bollinger band it can give you a better confirmation that the pivot location is at it's final place, and the trend is more likely to switch directions.
It’s important to know this indicator should not be used for alerts of any type it does repaint as the green or red line is drawing based on live chart data and it can change depending on the direction of the market. This is a great visual tool for trend analysis or to be used with other indicators as a confirmation for a possible good entry or exit position.
Credits ( and consent to use ):
Credits go to user LonesomeTheBlue for creation of this 'Double Zig Zag with HHLL' script.
The addition of the Value above/below the Percentages is from user Noldo and that script is found here:
The Bollinger Bands setup was suggested by user countseven12 and his script that uses the same BB setup is found here:
References:
1. Chen, James. (2021 March 15). Zig Zag Indicator . Received from http: www.investopedia.com
2. Mitchell, Cory. (2021 April 30). Pivot Points . Received from http: www.investopedia.com
Gridimus MaximusGridimus Maximus draws N grid lines stepping by price or percent in chosen direction from set price, or draws N grid lines stepping by pivots.
The queue function method used is adapted from an example provided on the PineCoders website, much gratitude to LucF for this gem!
To prevent grid lines out of range from causing chart to rescale right click on chart's price column and enable Scale Price Chart Only.
Pictured example above is using Type Of Increment: Steps By Pivot, Number Of Steps: 5.
Pictured example below is using Type Of Increment: Steps By Price, Number Of Steps: 6, Starts From Price: $10k, Steps By Percent Or Price: $10k.
Pictured example below is using Type Of Increment: Steps By Percent, Number Of Steps: 7, Starts From Price: $10k, Steps By Percent Or Price: 33%.
NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
Logging in Pine ScriptI'm building quite a lot of pretty complicated indicators/strategies in Pine Script. Quite often they don't work from the 1 try so I have to debug them heavily.
In Pine Script there are no fancy debuggers so you have to be creative. You can plot values on your screens, check them in the data window, etc.
If you want to display some textual information, you can plot some info as labels on the screen.
It's not the most convenient way, so with the appearance of tables in Pine Script, I decided to implement a custom logger that will allow me to track some useful information about my indicator over time.
Tables work much better for this kind of thing than labels. They're attached to your screen, you can nicely scale them and you can style them much better.
The idea behind it is very simple. I used few arrays to store the message, bar number, timestamp, and type of the message (you can color messages depend on the type for example).
There is a function log_msg that just append new messages to these arrays.
In the end, for the last bar, I create the table and display the last X messages in it.
In parameters, you can show/hide the entire journal, change the number of messages displayed and choose an offset. With offset, you can basically scroll through the history of messages.
Currently, I implemented 3 types of messages, and I color messages according to these types:
Message - gray
Warning - yellow
Error - red
Of course, it's a pretty simple example, you can create a much fancier way of styling your logs.
What do you think about it? Is it useful for you? What do you use to debug code in Pine Script?
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as good as in historical backtesting.
This post and the script don’t provide any financial advice.
NYSE extended session backgroundThis script adds background to the chart to highlight different time areas in any chart.
The time areas are in relation to the open/close time of NYSE , both regular and extended session.
The background colors are the following by default:
NO COLOR : NYSE is open
DARK BLUE : NYSE is closed
LIGHT BLUE : NYSE post market session
ORANGE : NYSE pre market session
In addition, previous day close price line is shown during extended and closed sessions (orange line).
This script is useful to visualize any chart in relation to the NYSE timetable.
MTF Trend WidgetThis indicator identifies trends in multiple higher timeframes (D, W, M) and shows them in a widget off to the right of the chart.
It's meant to be used as an alternative filter for "trading with the trend." Typically people use moving averages of varying lengths for this (i.e. if over 200 MA it's an uptrend, etc.), but I wanted to see if it might be more effective to see if the higher timeframes were actually trending or not in a certain direction.
For the purposes of this indicator, an uptrend is defined as higher highs and higher lows. So if currently in a downtrend and the highs are broken, the indicator will flip to an uptrend because now we have a higher high. Vice versa for downtrends.
The user can choose the lookback period for defining these highs/lows (the pivot points). A smaller lookback number will give you more frequent pivot points.
The user can toggle on visibility of all historical pivot points to make sure the frequency and placement of the swing highs/lows is to their liking.
The user can show the support/resistance lines of those most recent swing high/low points on the multiple timeframes as well.
When these lines are breached, that is when the trends change, so you can see if you are close to changing any longer term trends.
My hope is that this gives people a quick glance at the overall trend without having to cycle through different timeframes.
CheckmateTrades - Pivots End GameThis indicator is based on the Pivot study. Traders will be able to plot CPR, Standard floor pivots as well as Camarilla Pivots on multiple timeframes.
Why pivots from multiple timeframes are relevant and included in this one indicator?
We can analyse pivots on multiple timeframes for different trading setups. As in, Daily floor pivots are best suited for analysing the market trend for Day trading. Similarly, Weekly and Monthly floor pivots can be analysed for Swing and positional trading entries. Whereas yearly pivot is best suited for trend analysis for investment purpose.
What is the relevance of plotting tomorrow's pivot level in advance?
Pivot are calculated based on the price happened on a previous day. And hence trader can plot tomorrow pivots in advance to shortlist stocks for tomorrow's trading session.
TimeFrames Available to traders are –
1. Daily
2. Weekly
3. Monthly
A) Daily Pivots
Present Day –
1. Trader can plot Daily CPR
2. Trader can plot Daily R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Daily S1, S2, S3 and S4 pivot support levels
4. Trader can plot Daily Camarilla levels
Future Day –
1. Trader can plot Tomorrow CPR
2. Trader can plot Tomorrow R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Tomorrow S1, S2, S3 and S4 pivot support levels
4. Trader can plot Tomorrow Camarilla levels
5. Previous Day High and Low
B) Weekly Pivots
Present Week –
1. Trader can plot Present week CPR
2. Trader can plot Present week R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Present week S1, S2, S3 and S4 pivot support levels
4. Trader can plot Present week Camarilla levels
Next Week –
1. Trader can plot Next week CPR
2. Trader can plot Next week R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Next week S1, S2, S3 and S4 pivot support levels
4. Trader can plot Next week Camarilla levels
5. Previous Week High and Low
C) Monthly Pivots
Present Month –
1. Trader can plot Present Month CPR
2. Trader can plot Present Month R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Present Month S1, S2, S3 and S4 pivot support levels
4. Trader can plot Present Month Camarilla levels
Next Month –
1. Trader can plot Next Month CPR
2. Trader can plot Next Month R1, R2, R3 and R4 pivot resistance levels
3. Trader can plot Next Month S1, S2, S3 and S4 pivot support levels
4. Trader can plot Next Month Camarilla levels
5. Previous Month High and Low
Moreover, I have also included SMA (Simple moving averages) study in this indicator. Trader can add 20,50 & 200 SMA on there charts.
Why is it relevant? Trader can get a visual confirmation of an up-trending or an down-trending move by looking at rising or falling 20 & 50 SMA respectively
Usually in an uptrending stocks. 20 & 50 SMA will move in parallel to each other and will rise upwards. Price will tend to trade above the 20 SMA and 20 SMA will continue to act as a support.
Pivot Detective Indicator v1.0Overview of Features
The Pivot Detective is an indicator that simply highlights the waves of the market by identifying the pivot highs and pivot lows by using shapes and zigzag lines.
What makes this indicator unique is that you do not have to specify the number of bars to the left or right side of the pivots (aka pivot strength), nor do you need to specify percent deviation for filtering the zigzag (1)lines. Thus, the indicator will monitor price action and keep track of pivot high and low prices and implements a common trend analysis algorithm to determine when the trend has reversed to confirm the pivot price and begin tracking the next pivot price. The tolerance of the trend reversal can be configured to be strict or loose depending on your preference.
Be aware that this indicator does not determine key levels of price like support (S1, S2, etc.) and resistance (R1, R2, etc.) levels that are found in the traditional Pivot Points indicators (2).
Usage Information
The indicator can be applied to any chart at any time frame. It is very customizable where you can add or change various chart elements to help you enhance your interpretation of the price action trend reversals at the pivots. You can specify the pivot shapes, colors, and visibility as well as zigzag line thickness, color, and visibility. You can adorn the pivot shapes with any combination of price, rate of change percentage, and pivot trend using HH/LH/LL/HL text as well as control the coloring schemes for the in-progress pivot. The size of the text can also be customized.
Be aware that this indicator makes use of lines and labels which are limited to 500 lines and 500 labels, so if traverse far into the history, they will not appear because they have reached these limits and were removed by the chart's rendering engine.
Lastly, you can define "any alert() function call" messages on the "New Pivot High Point" and "New Point Low Point" events. These alerts provide custom placeholders that can be used in the messages, which are: {{exchange}}, {{ticker}}, {{currency}}, {{new_pivot_point_price}}, and {{new_pivot_point_roc}}
References
1. Chen, James. (2021 March 15). Zig Zag Indicator. Received from http: www.investopedia.com
2. Mitchell, Cory. (2021 April 30). Pivot Points. Received from http: www.investopedia.com
Pivot boxes [LM]Hello traders,
let me intoduce you pivot boxes. New features of pinescript that allows to render boxes enabled to highlight pivot zone. Range high or low is defined by pivot high or low and rangeLow and RangeHigh are defined by close of following candle.
It has two settings that you can change at your will, it also enables hide/show particular pivot setting
Hope you will enjoy as I enjoyed to write it.
Lukas