Regular vs Electronic Trading hours Gap (RTH vs ETH); 4pm-9:30am-Shows the gap between 4pm close and 9:30am open; the Regular trading hours Vs Electronic trading hours Gap (RTH vs ETH).
-Displays this as a box starting at 9:30am, whose bottom is the 9:30am open; top is previous day's 4pm close.
-Displays when chart is toggled to either of ETH or RTH.
-Useful reminder of area above/below opening bell price that price often has a tendency to want to fill in, partially or fully
--(all times here refer to America/New_York timezone)
//Options:
~Number of past boxes to show
~Extend boxes fully to the right
~Box background color, border color, and opacities
//Limitations:
-works only on timeframes 30mins or lower (works on 1,2,5,10,15,30minutes)
-will not work on non-typical low timeframes (like 4min or 7min) since they are not divisible into 30
Các mẫu biểu đồ
Negative Correlation SignalsThank you to Hendrik Fuchs who coded this for me - I highly recommend you...
The AUDUSD/EURUSD has a negative correlation with the DXY as does the GBPJPY/USDJPY have with the JPYX. This indicator is very simple and uses opposite candle pinbars (pinbar/doji structure can be set by you) of the two instruments on the chart whilst the stochastic RSI should be above 80 for overbought on the one but below 20 on the other for oversold (or vice versa) to generate a signal.
This indicator works as follow:
1. Choose an instrument that has an opposing negatively correlated instrument (EURUSD & DXY, GBPJPY & JPYX, US100 & VIX, etc.)
2. Add indicator to the chart and open settings.
3. Open the settings and add the correct instruments (default is set to GBPJPY & JPYX).
4. Enter your desired Stochastic RSI & candle formation settings.
You will see buy and sell signals appear on the charts. Alerts are possible (Any alert() function call). Does not repaint after close of candle. Better on higher timeframes but can also be used for scalping. Best used as confluence or as part of a trend trading system.
There are obviously many many variations that I have not even thought off - please let us know in the comment section if you find settings/timeframes/instruments that work particularly well.
Engulfing Pinbar [serkany88]This is an experimental candlestick pattern that combines pinbars and engulfing patterns as my own implementation. These signals can be used as a possible reversal points based on timeframe used or set wick size. Of course these signals should never be used on their own but rather can be used as another confluence of possible entry signal.
Functional and Manual alerts provided with simple and clean code.
TLDR: Use as a possible reversal point for your entries in combination with your trend and volatility filters. Green means possible bullish move, Red means possible bearish move.
Recursive Zigzag [Trendoscope]Here is an another outcome of Object Oriented Zigzag and Pattern Ecosystem of Libraries.
We already have another implementation of recursive zigzag which makes use of earlier library rzigzag . Here in this example, we make use of similar logic but leverage the new type and method based Zigzag system libraries to derive the indicator.
🎲 Design Overview
Similar to Recursive Auto Pitchfork, here too the indicator code is around 50 lines. Whereas most of the heavy lifting is done by the libraries.
🎲 Base Libraries
Base libraries are those which does not have any dependency. They form basic structures which are later used in other libraries. These libraries need to be crafted carefully so that minimal updates are done later on. Any updates on these libraries will impact all the dependent libraries and scripts.
🎯 Drawing
DrawingTypes - Defines basic drawing types Point, Line, Label, Box, Linefill and related property types.
DrawingMethods - All the methods or functionality surrounding Basic types are defined here.
🎲 Layer 1 Libraries
These are the libraries which has direct dependency on base libraries.
🎯 Zigzag
ZigzagTypes - Types required for defining Zigzag and Divergence
ZigzagMethods - Methods associated with Zigzag Type definitions.
🎲Indicator
Indicator draws zigzags based on given length. And then recursively derives next level zigzags based on previous levels. As per the utility, indicator is useful in several ways
Visualising price structure based on zigzag pivots - which in turn can help visualise patterns.
Ability to add any oscillator makes it easy to spot divergences with choice of indicators.
Programmers can use the derived values to build complex algorithms such as automatic pattern recognition.
🎯 Settings
Settings are explained via tooltips. These are very much straight forward and directly related to zigzag, oscillators and divergence.
Price Legs & Fib Projections: Fibonacci Confluence-Plots price legs based on two user input lookback numbers. Smaller number for small legs, larger number for large legs.
-Plots Fib projections of these price legs, above and below; User can input four independent fib levels or standard deviation levels
## User Inputs ##
~Show visible chart only; Show price leg labels (time and price); show small legs (fibs and/or boxes); show large legs (fibs and/or boxes)
~Input 4 Fibonacci levels or measured move levels. Toggle each level on/off
~toggle on/off Fib levels ABOVE or fib levels BELOW
~extend Fib levels 'X' bars to the right, or toggle on/off 'Full Extend' to the right
## Tips & Notes ##
-use 'Full Extend' together with 'visible chart only' if searching for multiple confluence of Fib levels.
-can quickly get very cluttered, but the aim in writing this was to try to find area of confluence at a glance amongst a mess of levels, then hide the indicator and study/note that area.
-if lines don't print toward the left hand side of the chart you've likely reached the max line limit set by Tradingview.
-Fib level input of 1.0 represents zero % extension above the high or below the low of the leg; 2.0 represents 100% extension.
1hr S&P: Visible chart only; large legs only; 50%, 100%, 150%, 200% Fib extensions; Above only; lines extended fully to the right:
Usage notes; 15m S&P: Small & Large price legs; partial extend; all fib levels above/below:
Investments/swing trading strategy for different assetsStop worrying about catching the lowest price, it's almost impossible!: with this trend-following strategy and protection from bearish phases, you will know how to enter the market properly to obtain benefits in the long term.
Backtesting context: 1899-11-01 to 2023-02-16 of SPX by Tvc. Commissions: 0.05% for each entry, 0.05% for each exit. Risk per trade: 2.5% of the total account
For this strategy, 5 indicators are used:
One Ema of 200 periods
Atr Stop loss indicator from Gatherio
Squeeze momentum indicator from LazyBear
Moving average convergence/divergence or Macd
Relative strength index or Rsi
Trade conditions:
There are three type of entries, one of them depends if we want to trade against a bearish trend or not.
---If we keep Against trend option deactivated, the rules for two type of entries are:---
First type of entry:
With the next rules, we will be able to entry in a pull back situation:
Squeeze momentum is under 0 line (red)
Close is above 200 Ema and close is higher than the past close
Histogram from macd is under 0 line and is higher than the past one
Once these rules are met, we enter into a buy position. Stop loss will be determined by atr stop loss (white point) and break even(blue point) by a risk/reward ratio of 1:1.
For closing this position: Squeeze momentum crosses over 0 and, until squeeze momentum crosses under 0, we close the position. Otherwise, we would have closed the position due to break even or stop loss.
Second type of entry:
With the next rules, we will not lose a possible bullish movement:
Close is above 200 Ema
Squeeze momentum crosses under 0 line
Once these rules are met, we enter into a buy position. Stop loss will be determined by atr stop loss (white point) and break even(blue point) by a risk/reward ratio of 1:1.
Like in the past type of entry, for closing this position: Squeeze momentum crosses over 0 and, until squeeze momentum crosses under 0, we close the position. Otherwise, we would have closed the position due to break even or stop loss.
---If we keep Against trend option activated, the rules are the same as the ones above, but with one more type of entry. This is more useful in weekly timeframes, but could also be used in daily time frame:---
Third type of entry:
Close is under 200 Ema
Squeeze momentum crosses under 0 line
Once these rules are met, we enter into a buy position. Stop loss will be determined by atr stop loss (white point) and break even(blue point) by a risk/reward ratio of 1:1.
Like in the past type of entries, for closing this position: Squeeze momentum crosses over 0 and, until squeeze momentum crosses under 0, we close the position. Otherwise, we would have closed the position due to break even or stop loss.
Risk management
For calculating the amount of the position you will use just a small percent of your initial capital for the strategy and you will use the atr stop loss for this.
Example: You have 1000 usd and you just want to risk 2,5% of your account, there is a buy signal at price of 4,000 usd. The stop loss price from atr stop loss is 3,900. You calculate the distance in percent between 4,000 and 3,900. In this case, that distance would be of 2.50%. Then, you calculate your position by this way: (initial or current capital * risk per trade of your account) / (stop loss distance).
Using these values on the formula: (1000*2,5%)/(2,5%) = 1000usd. It means, you have to use 1000 usd for risking 2.5% of your account.
We will use this risk management for applying compound interest.
In settings, with position amount calculator, you can enter the amount in usd of your account and the amount in percentage for risking per trade of the account. You will see this value in green color in the upper left corner that shows the amount in usd to use for risking the specific percentage of your account.
Script functions
Inside of settings, you will find some utilities for display atr stop loss, break evens, positions, signals, indicators, etc.
You will find the settings for risk management at the end of the script if you want to change something. But rebember, do not change values from indicators, the idea is to not over optimize the strategy.
If you want to change the initial capital for backtest the strategy, go to properties, and also enter the commisions of your exchange and slippage for more realistic results.
If you activate break even using rsi, when rsi crosses under overbought zone break even will be activated. This can work in some assets.
---Important: In risk managment you can find an option called "Use leverage ?", activate this if you want to backtest using leverage, which means that in case of not having enough money for risking the % determined by you of your account using your initial capital, you will use leverage for using the enough amount for risking that % of your acount in a buy position. Otherwise, the amount will be limited by your initial/current capital---
Some things to consider
USE UNDER YOUR OWN RISK. PAST RESULTS DO NOT REPRESENT THE FUTURE.
DEPENDING OF % ACCOUNT RISK PER TRADE, YOU COULD REQUIRE LEVERAGE FOR OPEN SOME POSITIONS, SO PLEASE, BE CAREFULL AND USE CORRECTLY THE RISK MANAGEMENT
Do not forget to change commissions and other parameters related with back testing results!
Some assets and timeframes where the strategy has also worked:
BTCUSD : 4H, 1D, W
SPX (US500) : 4H, 1D, W
GOLD : 1D, W
SILVER : 1D, W
ETHUSD : 4H, 1D
DXY : 1D
AAPL : 4H, 1D, W
AMZN : 4H, 1D, W
META : 4H, 1D, W
(and others stocks)
BANKNIFTY : 4H, 1D, W
DAX : 1D, W
RUT : 1D, W
HSI : 1D, W
NI225 : 1D, W
USDCOP : 1D, W
Recursive Auto-Pitchfork [Trendoscope]"Say Hi" to object oriented programming with Pinescript using types and methods. This is the beginning of new era of Pinescript where we are moving from isolated scripts containing indicator and strategies to whole ecosystem of Object Oriented Programming with libraries of highly reusable components. Those who are familiar with programming would have already realised how big these improvements are and what it brings to the table.
With this script, I am not just providing an indicator for traders but also an introduction for programmers on how to design and build object oriented components in Pinescript using types and methods. Big thanks to Tradingview and Pine development team for making this happen. We look forward for many such gifts in the future :)
🎲 Architecture
As mentioned before, we are not just building an indicator here. But, an ecosystem of components. Using Types and Methods we can visualise libraries as Classes. Thus, we can build an ecosystem of libraries in layered approach to enhance effective code reusability.
Generic architecture can be visualised as below
Coming to the specific case of Auto Pitchfork indicator, the indicator code is less than 50 lines for logic and around 100 lines of inputs. But, most of the heavy-lifting is done by the libraries underneath. Here is a snapshot of related libraries and how they are connected.
All libraries are divided into two portions.
Types - Contains only type definitions
Methods - Contains only method definitions related to the types defined in the Types library
Together, these libraries can be visualised as Class. Methods are defined in such a way all exported methods are related to Types and no other functions or features are defined. If we need further functionality which does not depend on the types, we need to do this via some other library and use them here. Similarly, we should not define any methods related to these types in other libraries.
Reason for splitting the libraries to types and methods is to enable updating methods without disturbing types. Since libraries create interdependencies due to versioning, it is best if we do less updates on the type definitions. Splitting the two enables adding more features while keeping the type definition version intact.
🎲 Base Libraries
Base libraries are those which does not have any dependency. They form basic structures which are later used in other libraries. These libraries need to be crafted carefully so that minimal updates are done later on. Any updates on these libraries will impact all the dependent libraries and scripts.
🎯 Drawing
DrawingTypes - Defines basic drawing types Point, Line, Label, Box, Linefill and related property types.
DrawingMethods - All the methods or functionality surrounding Basic types are defined here.
🎲 Layer 1 Libraries
These are the libraries which has direct dependency on base libraries.
🎯 Zigzag
ZigzagTypes - Types required for defining Zigzag and Divergence
ZigzagMethods - Methods associated with Zigzag Type definitions.
🎯Pitchfork
PitchforkTypes - Basic and Drawing Types for Pitchfork objects
PitchforkMethods - Methods associated with Pitchfork type definitions
🎲 Indicator and Settings
Indicator draws pitchfork based on recursive zigzag configurations. Recursive zigzag is derived with following logic:
Base level zigzag is calculated with regular zigzag algorithm with given length and depth
Next level zigzag is calculated based on base zigzag. And we recursively calculate higher level zigzags until we are left with 4 or less pivots or when no further reduction is possible
On every level of zigzag, we then check the last 3 pivots and draw pitchfork based on the retracement ratio.
Indicator settings are summarised in the tooltips and are as below.
Finally, big thanks to my partner @CryptoArch_ for bringing up the topic of pitchfork for our next development.
Strat Dashboard [TFO]The Strat Dashboard tracks up to 10 signals while highlighting common strat reversal patterns, the SSS 50% rule, timeframe continuity, and some additional criteria with VWAP and moving averages.
With the strat, all price action bars/candles are simplified into 3 total possibilities: 1 (inside bar), 2 (a bar that takes the previous bar's high OR low), and 3 (outside bar). The first table column for Last X Candles shows the most recent candles according to this notation, for example, 1 - 2D - 2U. This would mean we had an inside bar, followed by a bar that took the previous bar's low, followed then by a bar that took the previous bar's high. Note that the colors in this column are set according to whether the current bar's close exceeds the previous bar's high/low. By default, these colors are green if above the previous bar's highs, or red if below the previous bar's lows. If the current close is in between the previous candle's high and low (even after already taking the prior high or low), no color will be applied.
The SSS 50% column shows a yes or no value for whether the current bar aligns with the SSS 50% rule, where a bar has taken either the previous high or low, and has since reversed to at least the midway point of the previous bar's height - essentially anticipating a 2 that may become a 3 (outside bar).
Timeframe continuity (TFC) shows a yes or no value for when the current candle on multiple timeframes are all green or red (above the open price or below the open price, respectively). For example, if you were looking at the current 15m, 1h, and 1D bars, and they were all above the open price, you could say there's TFC between all three timeframes. As of the initial release, you can select up to 3 different timeframes. The table values will only be true when all selected timeframes are in alignment. When setting alerts, first deselect the timeframes if you don't want TFC logic to impact alerts.
The "Last" column shows the last strat reversal pattern that was confirmed (after the last bar closes). Waiting for a candle close is the safer option since a 2 can turn into a 3; however for higher timeframes, it may be beneficial to make an update to this indicator in which you can have live alerts as well (not waiting for a candle close). You can select which strat reversals you want to be shown from the settings. Various strat reversals may be selected for alerts of type "Any"; for example, if setting up an alert for "Any" strat reversal on Symbol 1, then this alert will go off when any of the *selected* strat reversals occur for that specific symbol. Deselect any strat reversals that you don't want to be included in these alerts.
Lastly, the EMA and VWAP columns simply show whether price is above or below said value. This tracks the current candle close, and may repaint/change several times if the current bar is oscillating above and below these values.
Failed Breakdown Detection'Failed Breakdowns' are a popular set up for long entries.
In short, the set up requires:
1) A significant low is made ('initial low')
2) Initial low is undercut with a new low
3) Price action then 'reclaims' the initial low by moving +8-10 points from the initial low
This script aims at detecting such set ups. It was coded with the ES Futures 15 minute chart in mind but may be useful on other instruments and time frames.
Business Logic:
1) Uses pivot lows to detect 'significant' initial lows
2) Uses amplitude threshold to detect a new low beneath the initial low; used /u/ben_zen script for this
3) Looks for a valid reclaim - a green candle that occurs within 10 bars of the new low
4) Price must reclaim at least 8 points for the set up to be valid
5) If a signal is detected, the initial low value (pivot low) is stored in array that prevents duplicate signals from being generated.
6) FBD Signal is plotted on the chart with "X"
7) Pivot low detection is plotted on the chart with "P" and a label
8) New lows are plotted on the chart with a blue triangle
Notes:
User input
- My preference is to use the defaults as is, but as always feel free to experiment
- Can modify pivot length but in my experience 10/10 work best for pivot lows
- New low detection - 55 bars and 0.05 amplitude work well based on visual checks of signals
- Can modify the number of points needed to reclaim a low, and the # of bars limit under which this must occur.
Alerts:
- Alerts are available for detection of new lows and detection of failed breakdowns
- Alerts are also available for these signals but only during 7:30PM-4PM EST - 'prime time' US trading hours
Limitations:
- Current version of the script only compares new lows to the most recent pivot low, does not look at anything prior to that
- Best used as a discretionary signal
Visit /u/ben_zen's Profile:
www.tradingview.com
Profile Link www.tradingview.com
Range ( Adjustable ) HLLSfor range of the price ( Adjustable )
This indicator shows you in what price range it may move.
This indicator is adjustable. You must set your installation to the past of its chart. (depends on timeframe)
Pay attention to adapt it in different time frames and with your strategy.
The function of this indicator is simple.
Based on the first factor (the number of previous candles), you can adjust average range channel with the second factor for height of the channel.
Indecision Indicator [CHE]"In times of great uncertainty, indecision is often the wisest course of action."
Introduction:
The Indecision Indicator is a custom script for use in Trading View. The script is designed to help traders determine potential reversal points in financial markets, by displaying different levels of indecision or rejection.
Glossary:
Indecision: Indicates a situation where the market is uncertain and can move in either direction.
Rejection: Indicates a situation where the market has rejected a certain price level and is likely to move in the opposite direction.
Totalwick: The total length of the upper and lower shadows on a candlestick chart.
MACD: Moving Average Convergence Divergence, a popular momentum indicator.
Inputs:
Rejection: Allows the user to choose between the different types of indecision to display, including Indecision, Rejection, Totalwick, All, and MACD.
Indecision Length: The number of candles used to calculate the indecision level.
Length: The length of the Moving Average used to smooth the indecision or rejection levels.
Trigger Length: The number of candles used to calculate the trigger line, which is used to indicate potential reversal points.
Output:
The script calculates the lower and upper rejection levels, as well as the indecision level, and displays them as lines on the chart. The lines are color-coded to indicate whether the market is in a state of indecision or rejection, and whether it is likely to move up or down.
Best regards
Chervolino
Central Bank Dark Energy TracerCentral Bank Dark Energy Tracer (CBDE Tracer)
What makes The Universe grow at an accelerating pace?
Dark Energy.
What makes The Economy grow at an accelerating pace?
Debt.
Debt is the Dark Energy of The Economy.
The CBDE Tracer is a tool that tracks currency assets in US dollars that can be scaled to fit other assets on TradingView.
The example provided is QQQ with scale factors and offsets applied that best curve fit to the most recent price action.
The white line is non-US assets from the following central banks:
-JPY (Japan)
-CNY (China)
-UK (British Pound)
-SNB (Swiss National Bank)
-ECB (European Central Bank )
The lime green line is for US Federal Reserve data including a midpoint of WRESBAL and the fed liquidity calculation (WALCL - WTREGEN) and then subtracting RRPONTSYD
The purple line is the average of the two, US assets, and non-US.
The settings can be configured so that only the average is showing, which should the closest aggregate of all liquidity data.
mentfx Triple MThis indicator colors the wick of a candle on any timeframe based on whether the following rules are met:
A colored wick below a candle indicates that the candles low was lower than the previous candles low, and the body of the candle closed above the previous candles low.
A colored wick above a candle indicates that the candles high was higher than the previous candles high, and the body of the candle closed below the previous candles high.
The idea behind this indicator is to fractally see a distribution (colored wick above a candle) or an accumulation (colored wick below a candle) as a confirmation once you have established a directional trend or turning point. This indicator will color any wick that meets these conditions. This indicator is meant more so as an entry confirmation, coupling it with your understanding of turning points, or likely points that price will continue in a direction - this can provide a nice confirmation.
Expected Move Plotter [CHE]Expected Move Plotter
"There is magic in everything new."
Introduction:
This script is an indicator for financial trading that plots the expected movement of a security based on the average range over the last five periods. The script is written in Pine Script, a high-level programming language used for creating technical indicators, strategies, and other trading tools for the TradingView platform.
Inputs:
Percentage of Open and Close: This input specifies the percentage of the open and close price to use for the expected movement.
Time Periods: The script takes the different time periods into account and translates them to either 60 seconds, 240 seconds, 1 day, 3 days, 7 days, 1 month, 3 months or 12 months.
Calculation:
The script uses the "Open" and "High"/"Low" values of the last 5 periods to calculate the average range and plots the expected movement above and below the current open price. The plot is either green or red depending on whether the expected move is above or below the current close.
Code Breakdown:
The script starts by defining three integer constants: MS_IN_MIN, MS_IN_HOUR, and MS_IN_DAY, which represent the number of milliseconds in a minute, hour, and day, respectively.
The function timeStep_translate() returns a string that represents the timeframe for a chart based on the current timeframe. The function first converts the chart's timeframe to milliseconds and then uses a switch statement to determine the string value to be returned based on the number of milliseconds in the timeframe.
The script then retrieves the data for the open, high, and low values for the last five periods. The high and low values are used to calculate the average range, which is then used to plot the expected movement above and below the current open price.
Conclusion:
This script provides traders with a visual representation of the expected movement of a security based on the average range over the last five periods. It takes different time periods into account and provides a clear indication of whether the expected move is above or below the current close. The script is easy to use and provides a useful tool for traders looking to make informed trading decisions.
Best regards Chervolino
Range DetectionThis is a simple indicator to find the sideways market or ranging market.
It is mainly focused on BTCUSD as BTCUSD doesn’t make big moves each and every candle. It makes big breakouts with one candle and then goes sideways for a longer period of time.
So, this indicator identifies those big candles and plots high and lows of those big candles using lines. New range is created only when new candles close above or below previous major candles high or low.
Price Legs: Time & Distance. Measuring moves in time & price-Tool to measure price legs in terms of both time and price; gives an idea of frequency of market movements and their typical extent and duration.
-Written for backtesting: seeing times of day where setups are most likely to unfold dynamically; getting an idea of typical and minimum sizes of small/large legs.
-Two sets of editable lookback numbers to measure both small and large legs independently.
-Works across timeframes and assets (units = mins/hours/days dependent on timeframe; units = '$' for indices & futures, 'pips' for FX).
~toggle on/off each set of bull/bear boxes.
~choose lookback/forward length for each set. Increase number for larger legs, decrease for smaller legs.
(for assets outside of the big Indices and FX, you may want to edit the multiplier, pMult, on lines 23-24)
small legs
large legs
RSI Multi Symbol/Time Frame DetectorThis code is an implementation of the Relative Strength Index (RSI) indicator, which is a popular momentum indicator used in technical analysis. The RSI measures the strength of an asset's price action and provides information on whether the asset is overbought or oversold. The code also calculates a moving average of the RSI and allows the user to choose the type of moving average to be calculated (SMA, EMA, SMMA, WMA, or VWMA).
The user can select from different time frames (5, 15, 60, or 240), symbols (SP:SPX, OANDA:EURUSD, or OANDA:NZDUSD), RSI lengths, and moving average types and lengths.
The code starts by defining a function called "ma" for calculating different types of moving averages. This function takes as input the source data for the moving average calculation (the RSI), the length of the moving average, and the type of moving average. The function uses a switch statement to return the appropriate calculation based on the inputted moving average type.
Next, the code calculates the RSI and its moving average. The RSI is calculated using the well-known formula for the RSI, which involves calculating the average gains and losses over a specified period of time and then dividing the average gains by the average losses. The moving average is calculated using the "ma" function defined earlier.
Finally, the code allows the user to choose the symbol and time frame to be used in the RSI calculation, as well as the length of the RSI and the moving average, and the type of moving average. The user can choose from three symbols (SP:SPX, OANDA:EURUSD, OANDA:NZDUSD) and four time frames (5, 15, 60, and 240 minutes). The code then uses the "request.security" function to retrieve the RSI calculation for the selected symbol and time frame.
Note: This code is example for you to use multi timeframe/symbol in your indicator or Strategy , also prevent Repainting Calculation
Three Bar Gap (Simple Price Action - with 1 line plot)This script is tailored towards experienced traders who prefer to view raw price charts during live execution. It searches for a three-bar pattern of what is colloquially called "fair value gap", or "imbalance" and uses a single line to plot the results. The goal is to display price in a way that is as simple as possible so that chart readers who don't prefer to add indicators on their screen will still find this indicator as an acceptable option to consider for.
From a code perspective, this script explores a new PineScript feature called UDT (user-defined types). This is an incredible update because it brings developers one step close to having the ability to create abstract data types.
█ What is price action?
Experienced traders will tell you that the chart that they use for live execution is raw, clean, and uses no indicators. They say they execute on price action, so what exactly is price action?
There is no formal definition to it, but one can agree that it implies the process of analyzing price without considering the fundamentals, without needing to know what the news was about, and without needing to know any of the Greeks (except for the desire to “seek alpha” Ha.haa...). This is not to say that price action traders are executing in their own vacuums without the need to know what is happening around the world. Surely fundamentals and financial models can be used beforehand for developing a bias for what is being traded, but it’s price-first at the moment of execution. That said, Factor (A) is Price.
Factor (B) is time-perception, it’s how the trader reads the tape. How the trader perceives price to change with respect to time is valuable information. Interpretation of "time" will be elaborated in the next section that talks about candlestick patterns detected by this script.
Putting this together, price action means the analysis of price movement by only considering (A) price, and (B) time, to predict which direction the market will move. A speculative trader is timing the market with the expectation to make a quick in-and-out profit; she/she is using price action. On the other hand, a long term investor holding a diversified portfolio with a strategy based on modern portfolio theory combined with fundamental analysis (at this point candlesticks are irrelevant) but has one additional criteria of, say, can only go Long on a stock when it has closed Green on Daily; he/she is also considered to be executing on price action.
█ Candlestick patterns
This script calculates the displacement of highs and lows over three consecutive bars.
A) Down move = When High of the recent confirmed bar is lower than the Low of the previous-previous candle
B) Up move = When Low of the recent confirmed bar is higher than the High of the previous-previous candle
(Note that its the confirmed bar that is being talked about, so it does not repaint)
An ATR filter will be applied to reduce the number of lines generated as many times they might just be associated with minor price changes.
Interpretations:
When price moves quickly across three bars, it can be thought that it has gapped. Although the candle in the middle appears to be solid, it’s not from a conceptual perspective. This is because time itself is arbitrary; timeframes don’t necessarily have to be fixed intervals. Take stocks with regular trading hours for example, if price makes a breakaway gap and you bundle the after-hours and pre-market sessions together as one candle, never minding that intervals should be fixed, then you will see the exact three-bar-gap patterns. Similar happens during intraday sessions on lower timeframes, if you zoom-in closer, you’ll see that ticks within the middle candle are sparsely dispersed. This is why it's called a gap.
█ Parameters with fixed inputs & assumptions used:
ATR is used for filtering out minor movements that will likely be deemed as irrelevant by trader for the purpose of live execution. The following inputs are required:
A) ATR lookback period
B) Multiplier
The product of ATR(len=A) and B produces a threshold for minimum distance that price must gap by. Initially, it was proposed to be only based on one ATR, but often an ATR is too wide and using it will filter out too many lines. Because of this observation, a multiplier (Parameter B) has been introduced to allow users to apply fractional ATR as a threshold.
█ Applications:
For trend followers: Follow the direction of the gap. Entering above recent high/low points above/below the first impulse with a stop-limit order is a viable tactic.
For contrarians fading a trend: The mid-point is a good point of reference for predicting potential areas of support/resistance.
WON WeekliesWilliam O'Neil was a big proponent of using weekly charts, often highlighting the significance of 3 or more tight weekly closes, or a sequence of five or more consecutive up weeks. This indicator recognizes both of these conditions providing clear visual cues to signify this institutional buying activity. When three tight weekly closes or more occur a circle will be drawn around the middle close or the background will change color, depending on user preference. If five or more consecutive up weeks are detected a box is drawn around all the price action of those weeks.
User Options:
- Choose to display both or only one condition
- Customizable colors
- Define what a tight close is (default is less than 1.5%)
- Change background color or display smaller circles for 3 weeks tight
- Alerts for both
Note: 5 weekly closes wont print until the 5th weeks candle is closed.
Price Swing Detection - Smart Money ConceptSince my own style is Smart Money Concept and these days I have seen a lot of my friends who are having trouble identifying structures for their indicators and strategies. I wrote this code so they could use it in their strategy . In fact, this type of structure, as one of the strongest technical structures, can increase the success of your strategy according to your personalization.
The script detects swings (i.e. significant highs and lows) in a financial instrument's price action over a specified period. The user can set the lookback period (number of candles to consider) and the colors of the lines representing bullish and bearish trends.
The script has two functions: detectSwing and pivot high. The detectSwing function calculates the swing highs and lows for the specified number of candles. The function uses the ta.highest and ta.lowest functions to find the highest and lowest prices, respectively, over the lookback period. The function also determines the swing state (high or low) of the current candle and returns the calculated swing values.
The pivot high function calculates the pivot high, which is an important step in detecting bullish structures in the market. If a new top (i.e. swing high) is found, the script updates the pivot high values and creates a line from the recent top to the last bar. The script also updates the trailing maximum values, which are used to extend the top extension line.
For Strategy :
The variable "trendDirection" in the code is used to keep track of the trend state, either bullish (up trend) or bearish (down trend), in the market. The variable is initialized to 0 which represents a downtrend. The value of this variable is updated later in the code based on the calculations of swing highs and lows, pivot crosses, and the trailing maximum. If a bullish structure is detected, the value of "trendDirection" is set to 1, indicating an uptrend.
Broadening Formations [TFO]This indicator highlights deviations from broadening formations (or megaphone patterns). Deviations from broadening ranges can often foreshadow reversals, especially in consolidation phases. These deviations are highlighted via trendlines that change color when tested, and also have the option to be alerted.
These broadening formations are heavily used with "The Strat" and can add confluence when looking for reversals within higher timeframe points of interest.
Golden PocketGolden Pocket
This marks up the fibonacci retracement levels of 0.65 and 0.618 by default, these levels are often referred to as the golden pocket.
They are known by this because when price has an impulse either to the up or downside, price will end up retracing at some point. This Golden pocket often lines up with other means of confluence where it's considered a good entry price from the retrace.
Unlike standard fib retracement indicators, these boxes will extend with current price until they are hit. As well as this, there is a moving average filter which you can set to higher timeframes meaning that you can choose to only look for golden pockets which are following the higher time frame trend. You can easily monitor all of your settings by setting up just 1 alert.
Settings
You have the option to enable/disable the line which marks out the pivot points the fib is being calculated from, you can also change the colour and style of the line.
Below this you have the option to choose what colour the fib boxes are and what colour they change to once price hits it. If you want them to disappear change the colours opacity to 0%.
If you want to change the golden pocket levels you can do that by changing the 0.618 or 0.65 levels in the settings.
The pivot distance controls what part defines a pivot high or low, it must be the highest/lowest to the left/right of the pivot candle count.
MA filter will only accept golden pockets which are trending with the Moving average.
You can change all the settings of the Moving average which acts as a filter including which timeframe it is calculated on.
Alerts
Simply toggle this on int the settings and then click on the 3 dots next to the indicators name, 'add alert', leave the top boxes as they are, you can name the alert anything you like but once you confirm this, it will monitor all golden pockets on the particular asset and timeframe you are looking at. The alerts are set up to trigger as soon as price touches one of the boxes.
Use Cases
We like setting are moving average up on the daily timeframe and using the Moving average filter so we know we are only trading with the higher timeframe trend. From there we can set up alerts on any lower timeframe.
Feel free to use any part of this script in your own code, please just give us a mention so we can check out your contributions to the community as well!
Happy to take in any suggestions or ways of improving
RahulLines CloudJ-Lines Cloud is a technical analysis tool that is used to identify potential support and resistance levels on a chart. It is based on the concept of the "J-Lines," which are lines that are drawn on a chart in order to identify potential turning points in price. The J-Lines Cloud is a variation of the J-Lines that is used to identify levels of support and resistance using cloud, it typically uses multiple lines to create a cloud-like shape, which represents a zone of support or resistance.
To use the J-Lines Cloud, you will typically need a charting platform that has the ability to plot the J-Lines Cloud indicator. The indicator will typically take the form of a cloud-like shape on the chart, with different colors used to represent different levels of support and resistance.
Once the J-Lines Cloud is plotted on the chart, traders can use it to identify potential levels at which the price of an asset may change direction. For example, if the price of an asset is approaching a level of resistance identified by the J-Lines Cloud, a trader may choose to sell or exit a long position. Conversely, if the price of an asset is approaching a level of support identified by the J-Lines Cloud, a trader may choose to buy or enter a long position.
It's important to note that the J-Lines Cloud is a tool for technical analysis and not a standalone strategy, it should be used in combination with other indicators or strategies and also it should be used with the proper risk management and stop loss analysis.