Double Zig Zag with HHLLHello Traders,
Here Double Zig Zag with HHLL script is with you. it calculates 2 Zig Zag simultaneously and draws them, and also it calculates and puts Higher High, Lower Low, Higher Low, Lower High labels. All these are done dynamically, it means last HH/HL/LL/LH can change. if price continues to go up then HL can turn to LL or if price continues to go down then LH can turn to HH. This script can be used for different purposes such trend analysis, support/resistance levels, breakouts etc.
I tried to make many things optional:
You can set Periods for Zig Zags as you wish
You can set different colors for both Zig Zag Up/Down lines
You have option to show both Zig Zag, one of them or none them
You have option to show both HHLL, one of them or none them
You can set Zig Zag 1 line style as Dashed or Dotted
You can set Line Widths for Zig Zags
Some examples:
Enjoy!
Lonesometheblue
Start the Script on Last Nth Bar [Experimental]Hello Pine Scripters,
Sometimes we need to run some processes in the scripts on last N bar but currently we don't know bar_index value of realtime bar or number of remaining bars before we reached it. So most of us use "start date" as input and run some processes after "start date".
This experimental script finds last Nth bar approximately. As you can see in the script we (should) use GMT, otherwise as I see the result might not be accurate (we don't know timezone used on the chart)
The idea is to find/use similar bar in the past (using timenow as reference) and then calculate aproximate the time of last Nth bar. the results may not be accurate all the time, also we can not know local holidays etc.
At the moment the script works on 1minute or higher time frames (it won't work on less 1min timeframes)
In the future if the Pine Team add something like "bar_index_realtime" then we will not need such things. by the way many thanks to Pine Team, they are doing great job.
You can use this script in your scripts as you want, no need to ask permission. If you can improve it let me know ;)
Enjoy!
RSI Tops and BottomsHello Traders
This script finds Tops when RSI is in overbought area or Bottoms when RSI is in oversold area and checks the divergence between them. it checks divergence at tops/bottoms after RSI exited from OB/OS areas.
You can change overbought / oversold levels.
You can limit the time that RSI is in OB/OS area with the option "Max Number of Bars in OB/OS"
you can set the minimum/maximum distances between Tops/Bottoms with the options "Min Number of Bars between Tops/Bottoms" and "Max Number of Bars between Topss/Bottoms"
and you can set the color and line widths as you wish.
These tops or bottom must be sequential, means there mustn't be another top while checking tops or bottom while checking bottoms between them.
in next example you can see valid and invalid bottoms:
After you got signal then you better use Stop Order, a few pips higher than the high of colored candle for long positions, ( vise versa in short positions ). so you may escape from traps. ("Stop order" is filled when the price reached a pre-specified price. for example the price is now 10.0 and you set Buy Stop Order at 11.0 then if price reaches 11.0 then your buy order get filled. you can put stoploss a few pips lower than the low of colored candle or you can use ATR to decice stoploss level. how you wish)
For example in following screenshot you can see that buy stop order was not filled and you didn't take long position.
Enjoy!
Bitcoin Bullish Percent IndexHello Traders,
This is Bitcoin Bullish Percent Index script. First lets talk about what the Bullish Percent Index and how it is calculated:
"The Bullish Percent Index (BPI) is a breadth indicator based on the number of securities on Point & Figure Buy Signals, Developed by Abe Cohen in the mid-1950s. Because a security is either on a P&F Buy or Sell Signal, there is no ambiguity when it comes to P&F charts. This makes BPI a straightforward indicator with clearly defined signals."
The calculation is straightforward and simple: (Number of securities on P&F Buy signals) / (Total number of securities)
Here you can see what the P&F buy signal is:
In this script I choose 40 cryptos that is correlated ( as I see ) with BTC (including BtcUsdt). in the first part the script creates P&F chart for each security and check if there is Buy or Sell signal and sum the buy signals if there is. in the second part it creates P&F chart by using the P&F buy/sell signals coming from the securities P&F chart. because of complicated calculation the script may need a few seconds to load.
in the first part reversal value is 3 by default but you can set different values as reversal. sometimes I got better results with reversal = 5.
in BPI part reversal = 3 is used. so each box represents 2% (each X or O is a box). And this means it takes at least a 6% move in BPI for a reversal. the Bullish Percent Index favors the bulls when above 50% and the bears when below 50%. The bulls have the edge when over 50% of stocks are on a P&F Buy Signal. BPI is also considered overbought when above 70% and oversold when below 30%. BPI can move between 0 and 100.
Because of 40 securities are used in the script and all different prices, it uses Percentage scaling only. it can calculate the Percentage automatically by using the time frame of the chart or you can set it as you wish.
The Signals coming from BPI:
Bull Alert: BPI is below 30% and then forms a new column of X's (rises)
Bear Alert: BPI is above 70% and then forms a new column of O's that decline below 70%.
Bull Confirmed: BPI is on a P&F buy signal and in a column of X's (rising).
Bear Confirmed: BPI is on a P&F sell signal and in a column of O's (falling).
Bull Correction: BPI is on a P&F buy signal, but currently falling (column of O's).
Bear Correction: BPI is on a P&F sell signal, but currently rising (column of X's).
If you are not familiar with Bullish Percent Index you better search it on the net to get more info, you can find a lot of articles and web sites about BPI.
as I remember I developed the script 6-7 months ago and today I had chance to publish it as it was
Enjoy!
Clock [Example]Hello All,
I published this script as an example. it calculates/show current Hour, Minute and Second by using timenow function, it also show remaining time to close of the candle. You can freely use the source code in your scripts if you need.
"A man who dares to waste one hour of time has not discovered the value of life" - Charles Darwin
Enjoy!
Multi Time Frame CandlesHello Traders,
This script can show (upto) 3 candles of another time frames without changing chart time frame realtime . You can choose the time frame and number of candles in the options. You have option to change body and wick colors as well.
in this example number of candles is 2:
You can set body and wick colors:
In this example, weekly candles are shown on 1h chart:
Enjoy!
Support Resistance - Aging [Example]Hello All,
First all of Thanks to Pine Team for adding Arrays to Pine!
In this script I tried to make example for
1. Finding S/R lines using highest/lowest function
2. Using 1D array as 2D (we keep S/R levels and age)
3. "Age" usage for S/R levels, getting older on each candle and changing colors by their age (maximum age is 127 then it disappears)
You can use "Close"/Open " or " High/Low " as source.
There is an option for the background color, by default it's Black, do not forget to set it accordingly :)
Enjoy!
Cumulative Delta VolumeHello Traders,
This is Cumulative Delta Volume script. Delta refers to the difference between buying and selling volume at each price level. Cumulative Delta builds upon this concept by recording a cumulative tally of these differences in buying vs selling volume. The Cumulative Delta indicator plots as candlesticks or line. One of the main uses of Cumulative Delta is to confirm or deny market trends. you may need to search it for yourself ;)
You have option to see it as Candles or a Line. also there are options to show 2 SMAs and 2 EMAs with different Lengths, you can set the lengths as you wish.
By default it shows CDV as Heikin Ashi Candles, it can also show it as normal candles:
It can show CDV as a line:
Also you may need to check divergence:
Enjoy!
Support Resistance - Dynamic v2Hello Traders!
After the addition of "Arrays" to the Pine, I developed new and improved version of Support Resistance - Dynamic script as version 2. In this script Arrays were used. This can be used as Support Resistance tool, also it will be an example for the people who want to learn Array usage in Pine. Many thanks to Pine Team for adding Arrays!
The script finds the Pivot Points and check them in channels if there can be S/R or not, and draws mid line of the channel as S/R line. you can set number of PPs and channel width in the options. Each channel width is optimized dynamically according to Pivot Points. Also you can choose " High/Low " or " Close/Open " as source for Pivot Points.
There is an option for maximum number of S/R levels. S/R levels are found and sorted dynamically and number of S/R lines with enough strength changes dynamically.
Some other options for coloring and line width. (Solid, Dashed or Dotted)
S/R levels are shown in the Labels and Label colors are changed automatically, if S/R line is below the closing price then it's color is Green (as Support), otherwise its color is Red (as Resistance).
Examples:
Enjoy!
Smoothed CandlesHello Traders,
This is " Smoothed Candles " script to get rid of noises and to get a smoothed chart to figure out breakouts and price movements easily.
There are three scaling methods: User Defined, Dynamic (ATR) and Percentage
Optionally you can add 2 Simple Moving Averages and 2 Exponential Moving Averages
Optionally you can hide the Wicks, example:
You can add moving averages:
Easily find breakouts:
Enjoy!
Position SizingHello All,
This script can be used for Position Sizing.
After you entered Capital you have, how much you can Risk per Trade, Profit and Stoploss Levels, it calculates Number of Buys/Sells, Position Size and Reward/Risk ratio. you need to choose one of "Long" or "Short" position you will take.
Number of Buys formula = Capital * RiskPerTrade / Loss
Position Size = NumberOfBuys * EntryPrice
Reward / Risk rate = (TargetPrice - EntryPrice) / (EntryPrice - StoplossPrice)
Enjoy!
Trend Following with Moving AveragesHello Traders,
With the info "Trend is Your Friend ", you should not take position against the trend. This script checks multipte moving averages if they are above/below the closing price and try to find trend. The moving averages with the length 8, 13, 21, 34, 55, 89, 144, 233, 377 used. these are fibonacci numbers, but optionally you can change the lengths of each moving averages. while it's green you better take long positions, while it's red you better take short positions according to other indcators or tools.
Optionally you have "smoothing" option to get rid of whipsaws. it's enabled by default.
You have option to use following moving average types: EMA, SMA, RMA, WMA, VWMA. by default it's EMA
Also the script has "Resolution" option. with this option you can get the trend for other time frames, in following example 1h was set as for higher time frame on 15m chart:
This should not be used as buy/sell signal indicators as it's tries to find trend but not entry points, you should use other indicators (such RSI, Momentum) or other tools to find buy/sell signals.
Enjoy!
MACD-ASHello All,
This the script for Moving Average Convergence Divergence – MACD of Thomas Aspray, and called as MACD-AS and you may get earlier signals than MACD.
As MACD and MACD-AS are trend following indicators, they do not function well in sideway markets.
An example how it gets earlier signals than MACD
Good luck!
Support Resistance MTFHello Traders,
This is Support Resistance script that uses Multi Time Frame. While getting Close/Open/High/Low values of Higher Time Frames the script does NOT use Security function , instead it calculates them.
while choosing Higher Time Frame, you can use "Auto" option so it uses predefined Higher Time Frames, or you can choose the Higher Time Frame Manually from the list. options for HTF => 15mins, 30mins, 60mins, 120mins, 180mins, 240mins, 720mins, Day, Week, 2 Weeks, Months, 3 Months, 6 Months, 12 Months.
You have option to use High/Low or Close/Open values while calculating support resistance levels.
"Period for Highest/Lowest Bars" option is used as loopback period to check if it's Highest/lowest bars. smaller numbers = more sensitive result.
You have option for transparency and coloring of support/resistance levels/zone => Red, Lime, Blue, White, Black, Olive, Gray
An example for 15 min chart, 4hours selected as HTF
You can set transparency and colors as you wish:
You can choose Close/Open prices while calculating S/R levels instead of High/Low
Enjoy!
Volume Multi Time FrameHi All,
This script shows total volume info of Higher Time Frame. it checks open/close prices of higher time frame and sets the color. it also show a dynamic line on last volume , so you can see when HTF candle started and ended. by looking at the color of volume columns you can see HTF candle is green or red. it's something like weis wave volume that is using HTF candles.
Higher time frame is set automatically, you can set it manually by choosing "User-defined" in the indicator options and choose higher time frame as you want
Here some examples:
Current time freame is 1min and htf is 1hour
Current time freame is 1min and htf is 1day
Enjoy!
Consolidation Zones - LiveHello Traders!
This is the script that finds Consolidation Zones in Realtime.
How it works?
- The script finds highest/lowest bars by using "Loopback Period"
- Then it calculates direction
- By using the direction and highest/lowest bar info it calculates consolidation zones in realtime
- If the length of consolidation area is equal/greater than user-defined min length then this area is shown as consolidation zone
- Then Consolidation Zone extends automatically if there is no breakout
if you increase the Loopback Length then you get bigger consolidation zones:
You have option to "Paint Consolidation Area" or not:
Enjoy!
Candlestick Reversal SystemHello Traders,
In the book "Secrets of a Pivot Boss: Revealing Proven Methods for Profiting in the Market" by Franklin Ochoa, Four different types of reversal systems were introduced and candlestick patterns are used to find reversals. I will not write a lot about the book, you should get/read it for yourself. There are many great ideas in the book, Candlesetick Reversal System, Following Trend, Time Price Opportunity, Advanced Camarilla Concepts and much more.
Reversal systems mentioned in the book are :
- Wick Reversal System
- Exteme Reversal System
- Outside Reversal System
- Doji Reversal System
I tried to add these four reversal systems to the script. If you need detailed info you better read the book ;)
Enjoy!
Donchian Trend RibbonHello Traders,
I think you all know Donchian Channels. so I am not going to write about it.
With this indicator I tried to create Donchian Trend Ribbon by using Donchian Channels.
How it works ?
- it calculates main trend direction by using the length that is user-defined. so you can change it as you wish
- then it calculates trend direction for each 9 lower lengths. if you set the length = 20 then the lengths are 19, 18,...11
- and it checks if the trend directions that came from lower lengths is same or not with main trend direction.
- it changes the trend color of the ribbon.
-
Warning: Entry points may also represents trend reversal. So you should use stoploss line if you decide to take buy/sell positions.
P.S. I didn't backtest it, it's non-repainting, it should be used educational purposes only.
Published by user request. You may want to see following one:
Enjoy!
Donchian TrendHello All,
I think all of you knows Donchian Channels . so I am not going to write about it.
With this indicator I tried to create Trend Lines by using Donchian Channel upper/lower bands. I tried add possible entry levels as well.
How it works ?
- it calculates main trend direction by using the length that is user-defined. so you can change it as you wish
- then it calculates trend direction for 9 lower lengths. if you set the length = 20 then the lengths are 19, 18,...11
- and it checks if the trend directions that came from lower lengths is same or not with main trend direction.
- it changes the trendline color. lighter trend line means stonger trend, darker trend lines means entry points or possible trend reversal.
- it puts entry points by using trend directions that were created by using lower lengths. it gets entry points if high/low touches main trend line as well.
Warning: Arrows are entry points but it may also represents trend reversal. So you should use stoploss line if you decide to take buy/sell positions.
P.S. I didn't backtest it, it's non-repainting, it should be used educational purposes only . I believe it can be improved, so I am open for new ideas to improve it ;)
Enjoy!
Divergence Histogram for Many IndicatorHello Traders,
This script analyses divergences for 11 predefined indicators and then draws column on the graph. Red columns for negatif divergence (means prices may go down or trend reversal), Lime columns for positive divergences (means prices may go up or trend reversal)
The script uses Pivot Points and on each bar it checks divergence between last Pivot Point and current High/Low and if it finds any divergence then immediately draws column. There is no Latency/Lag.
There are predefined 11 indicators in the script, which are RSI , MACD , MACD Histogram, Stochastic , CCI , Momentum, OBV, Diosc, VWMACD, CMF and MFI.
Smaller Pivot Point Period check smaller areas and if you use smaller numbers it would be more sensitive and may give alerts very often. So you should set it accordingly.
There is "Check Cut-Through in indicators" option, I recomment you to enable it. it checks that there is cut-through in indicators or not, if no cut-through then it's shown as valid divergence.
You should see following one as well if you haven't yet:
Enjoy!
Pivot Point SupertrendHello All,
There are many types of SuperTrend around. Recently I thought about a Supertrend based on Pivot Points then I wrote "Pivot Point SuperTrend" script. It looks it has better performance on keeping you in the trend more.
The idea is behind this script is finding pivot point, calculating average of them and like in supertrend creating higher/lower bands by ATR. As you can see in the algorithm the script gives weigth to past pivot points, this is done for smoothing it a bit.
As I wrote above it may keep you in the trend more, lets see an example:
As an option the script can show main center line and I realized that when you are in a position, this line can be used as early exit points. (maybe half of the position size)
While using Pivot Points, I added support resistance lines by using Pivot Point, as an option the script can show S/R lines:
And also it can show Pivot Points:
When you changed Pivot Point Period you can see its reaction, in following example PP period is 4 (default value is 2). Smaller PP periods more sensitive trendlines.
Alerts added for Buy/Sell entries and Trend Reversals. (when you set alerts use the option " Once Per Bar Close ")
ENJOY!
Expanded Camarilla LevelsHello Everyone,
The Expanded Camarilla Level s is introduced in the book " Secrets of a Pivot Boss: Revealing Proven Methods for Profiting in the Market " by Franklin Ocho a. I will not write a lot about the book, you should read it for yourself. There are many great ideas in the book, such using these levels, following trend, time price opportunity, Advanced Camarilla Concepts and much more.
The definition/formula of the levels defined in the book. ( actualy L1, L2, H1 and H2 levels are not used in the strategy, so not shown on the chart )
RANGE = highhtf - lowhtf
H5 = (HIGH/ LOW) * CLOSE
H4 = CLOSE + RANGE * 1.1/2
H3 = CLOSE+ RANGE * 1.1/4
H2 = CLOSE+ RANGE * 1.1/6
H1 = CLOSE+ RANGE * 1.1/12
L1 = CLOSE- RANGE * 1.1/12
L2 = CLOSE- RANGE * 1.1/6
L3 = CLOSE- RANGE * 1.1/4
L4 = CLOSE- RANGE * 1.1/2
L5 = CLOSE- (H5 - CLOSE)
Levels:
Strategy: you need to take care of the candles, as you can see there is bearish candle on first part, and Bullish Candle on second part!
Another Strategy:
An Example:
ENJOY!
Parabolic SAR [with Algorithm and Alerts]Hello All,
In one of my projects I needed Parabolic SAR algorithm. I decided to write it in Pine and publish it. Then I added Alerts and Labels. here it is ;)
ENJOY!