Double Trend Counter [theEccentricTrader]█ OVERVIEW
This indicator counts the number of confirmed double trend scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
█ FEATURES
Inputs
• Start Date
• End Date
• Position
• Text Size
Table
The table is colour coded, consists of seven columns and, as many as, fifteen rows. Blue cells denote the multi-part trend scenarios, green cells denote the corresponding double uptrend scenarios and red cells denote the corresponding double downtrend scenarios.
The double trend scenarios are listed in the first column with their corresponding total counts to the right, in the second and fifth columns. The last row in column one, displays the sample period which can be adjusted or hidden via indicator settings.
The third and sixth columns display the double trend scenarios as percentages of total 1-part double trends. And columns four and seven display the total double trend scenarios as percentages of the last, or preceding double trend part. For example, 4-part double trends as percentages of 3-part double trends and so on.
Plots
For a visual aid to this indicator please use in conjunction with my Double Trends indicator which can be found on my profile page under scripts, or in community scripts under the same name.
Green up-arrows, with the number of the double trend part, denote double uptrends. Red down-arrows, with the number of the double trend part, denote double downtrends.
█ HOW TO USE
This indicator is intended for research purposes, strategy development and strategy optimisation. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe.
It can, for example, give you an idea of whether the current double trend will continue or fail, based on the current double trend scenario and what has happened in the past under similar circumstances. Such information can be very useful when conducting top down analysis across multiple timeframes and making strategic decisions.
What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
Statistics
Rangemeter [theEccentricTrader]█ OVERVIEW
This indicator simply displays candle and peak to trough ranges in points or pips, depending on the symbol type, in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Open Green and Red Candles
• An open green candle is one that has a close price equal to or above the price it opened, but has not yet closed to confirm the condition.
• An open red candle is one that has a close price lower than the price it opened, but has not yet closed to confirm the condition.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Open Range
An open range is here defined as one that is forming but has not yet completed. For example, a swing low that has an open green candle proceeding a red candle or series of red candles. Or a swing high that has an open red candle proceeding a green candle or series of green candles.
The table will only display the open range under the aforementioned circumstances, otherwise it will display the current, or previous, range.
█ FEATURES
Inputs
• Show Candle Ranges
• Show Largest and Smallest Candle Ranges
• Average Candle Range Lookback
• Show Ranges
• Show Largest and Smallest Ranges
• Average Range Lookback
• Position
• Text Size
█ HOW TO USE
The indicator can be used for strategy filtering and development, gauging current market conditions versus historic and helping to make more informed discretionary trading decisions. It can also be used like my Wavemeter indicator to objectively set the angle and projection ratio for my Fan Projections and Parallel Projections indicators.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by ensuring the lookback for the average range does not reach as far back as the start of the chart. If you are unsure about the candle count you can use my Candle Counter indicator to find out how many candles are displayed on the chart.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the lookback will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000.
Opening Hour/Closing Hour Indices Statistics: high/low times; 5mVery specific indicator designed for 5min timeframe, to show the statistical timings of the highs and lows of Opening hour (9:30-10am) and Closing hour (3pm-4pm) NY time
~~Shown here on SPX 5min chart. Works all variants of the US indices. SPX and SPY typically show more days of history (non-extended session =>> more bars).
//Purpose:
-To get statistics on the timings of the high and low of the opening hour and the high & low of the closing hour.
//Design & Limitations:
- Designed for the 5minute chart ONLY . Need a sweet spot of 'bucket' size for the statistics: to allow meaningful comparison between times.
-Will also display on 1min chart but NOT the statistics panel, only the realtime data (today's opening hour/ closing hour timings).
-Can be slow to load depending on server load at the time. This is becasue of the multiple usage of looping array functions. Please be patient when loading or changing settings.
//User inputs:
-Standard formatting options: highlight color, table text color. Toggle on/off independently
-Decimal % percision (default = 0, i.e. 23%. If set to 1 => 22.8%)
-Show statistics: Show Opening hour statistics, Show Closing hour statistics
//Notes:
-Days of history shown at top of table; this is the size of the dataset. i.e. 254 here (254 trading days) =>> 254 opening hour highs, 254 closing hour lows etc.
--to illustrate with the above: 18% of those 254 closing hour highs occured on the 15:00 5min candle (i.e. between 15:00 and 15:05).
-SPY or SPX offer the largest history/dataset (circa 254 trading days).
-Note that the final timing in each hour is 10:25am and 15:55pm respectively: this is because the 10:25am 5min candle essentially ends at 10:30am =>> we properly captures the opening hour this way
-Pro+ users will get less data history than Premium users (half as much, due to 10k vs 20k bars history limit).
OHLC📕 LIBRARY OHLC
🔷 Introduction
This library is a custom library designed to work with real-time bars. It allows to easily calculate OHLC values for any source.
Personally, I use this library to accurately display the highest and lowest values on visual indicators such as my progress bars.
🔷 How to Use
◼ 1. Import the OHLC library into your TradingView script:
import cryptolinx/OHLC/1
- or -
Instead of the library namespace, you can define a custom namespace as alias.
import cryptolinx/OHLC/1 as src
◼ 2. Create a new OHLC source using the `new()` function.
varip mySrc = OHLC.new() // It is required to use the `varip` keyword to init your ``
- or -
If you has set up an alias before.
varip mySrc = src.new()
===
In that case, your `` needs to be `na`, define your object like that
varip mySrc = na
◼ 3. Call the `hydrateOHLC()` method on your OHLC source to update its values:
Basic
float rsi = ta.rsi(close, 14)
mySrc.hydrateOHLC(rsi)
- or -
Inline
rsi = ta.rsi(close, 14).hydrateOHLC(mySrc)
◼ 4. The data is accessible under their corresponding names.
mySrc.open
mySrc.high
mySrc.low
mySrc.close
🔷 Note: This library only works with real-time bars and will not work with historical bars.
Smart Money Concepts Probability (Expo)█ Overview
The Smart Money Concept Probability (Expo) is an indicator developed to track the actions of institutional investors, commonly known as "smart money." This tool calculates the likelihood of smart money being actively engaged in buying or selling within the market, referred to as the "smart money order flow."
The indicator measures the probability of three key events: Change of Character ( CHoCH ), Shift in Market Structure ( SMS ), and Break of Structure ( BMS ). These probabilities are displayed as percentages alongside their respective levels, providing a straightforward and immediate understanding of the likelihood of smart money order flow.
Finally, the backtested results are shown in a table, which gives traders an understanding of the historical performance of the current order flow direction.
█ Calculations
The algorithm individually computes the likelihood of the events ( CHoCH , SMS , and BMS ). A positive score is assigned for events where the price successfully breaks through the level with the highest probability, and a negative score when the price fails to do so. By doing so, the algorithm determines the probability of each event occurring and calculates the total profitability derived from all the events.
█ Example
In this case, we have an 85% probability that the price will break above the upper range and make a new Break Of Structure and only a 16.36% probability that the price will break below the lower range and make a Change Of Character.
█ Settings
The Structure Period sets the pivot period to use when calculating the market structure.
The Structure Response sets how responsive the market structure should be. A low value returns a more responsive structure. A high value returns a less responsive structure.
█ How to use
This indicator is a perfect tool for anyone that wants to understand the probability of a Change of Character ( CHoCH ), Shift in Market Structure ( SMS ), and Break of Structure ( BMS )
The insights provided by this tool help traders gain an understanding of the smart money order flow direction, which can be used to determine the market trend.
█ Any Alert function call
An alert is sent when the price breaks the upper or lower range, and you can select what should be included in the alert. You can enable the following options:
Ticker ID
Timeframe
Probability percentage
-----------------
Disclaimer
The information contained in my Scripts/Indicators/Ideas/Algos/Systems does not constitute financial advice or a solicitation to buy or sell any securities of any type. I will not accept liability for any loss or damage, including without limitation any loss of profit, which may arise directly or indirectly from the use of or reliance on such information.
All investments involve risk, and the past performance of a security, industry, sector, market, financial product, trading strategy, backtest, or individual's trading does not guarantee future results or returns. Investors are fully responsible for any investment decisions they make. Such decisions should be based solely on an evaluation of their financial circumstances, investment objectives, risk tolerance, and liquidity needs.
My Scripts/Indicators/Ideas/Algos/Systems are only for educational purposes!
NIFTY USDNifty in terms of USD value over time.
Nifty 50 index of Indian Stock Market, in terms of US Dollar terms at that specific time.
MarkovChainLibrary "MarkovChain"
Generic Markov Chain type functions.
---
A Markov chain or Markov process is a stochastic model describing a sequence of possible events in which the
probability of each event depends only on the state attained in the previous event.
---
reference:
Understanding Markov Chains, Examples and Applications. Second Edition. Book by Nicolas Privault.
en.wikipedia.org
www.geeksforgeeks.org
towardsdatascience.com
github.com
stats.stackexchange.com
timeseriesreasoning.com
www.ris-ai.com
github.com
gist.github.com
github.com
gist.github.com
writings.stephenwolfram.com
kevingal.com
towardsdatascience.com
spedygiorgio.github.io
github.com
www.projectrhea.org
method to_string(this)
Translate a Markov Chain object to a string format.
Namespace types: MC
Parameters:
this (MC) : `MC` . Markov Chain object.
Returns: string
method to_table(this, position, text_color, text_size)
Namespace types: MC
Parameters:
this (MC)
position (string)
text_color (color)
text_size (string)
method create_transition_matrix(this)
Namespace types: MC
Parameters:
this (MC)
method generate_transition_matrix(this)
Namespace types: MC
Parameters:
this (MC)
new_chain(states, name)
Parameters:
states (state )
name (string)
from_data(data, name)
Parameters:
data (string )
name (string)
method probability_at_step(this, target_step)
Namespace types: MC
Parameters:
this (MC)
target_step (int)
method state_at_step(this, start_state, target_state, target_step)
Namespace types: MC
Parameters:
this (MC)
start_state (int)
target_state (int)
target_step (int)
method forward(this, obs)
Namespace types: HMC
Parameters:
this (HMC)
obs (int )
method backward(this, obs)
Namespace types: HMC
Parameters:
this (HMC)
obs (int )
method viterbi(this, observations)
Namespace types: HMC
Parameters:
this (HMC)
observations (int )
method baumwelch(this, observations)
Namespace types: HMC
Parameters:
this (HMC)
observations (int )
Node
Target node.
Fields:
index (series int) : . Key index of the node.
probability (series float) : . Probability rate of activation.
state
State reference.
Fields:
name (series string) : . Name of the state.
index (series int) : . Key index of the state.
target_nodes (Node ) : . List of index references and probabilities to target states.
MC
Markov Chain reference object.
Fields:
name (series string) : . Name of the chain.
states (state ) : . List of state nodes and its name, index, targets and transition probabilities.
size (series int) : . Number of unique states
transitions (matrix) : . Transition matrix
HMC
Hidden Markov Chain reference object.
Fields:
name (series string) : . Name of thehidden chain.
states_hidden (state ) : . List of state nodes and its name, index, targets and transition probabilities.
states_obs (state ) : . List of state nodes and its name, index, targets and transition probabilities.
transitions (matrix) : . Transition matrix
emissions (matrix) : . Emission matrix
initial_distribution (float )
FunctionProbabilityViterbiLibrary "FunctionProbabilityViterbi"
The Viterbi Algorithm calculates the most likely sequence of hidden states *(called Viterbi path)*
that results in a sequence of observed events.
viterbi(observations, transitions, emissions, initial_distribution)
Calculate most probable path in a Markov model.
Parameters:
observations (int ) : array . Observation states data.
transitions (matrix) : matrix . Transition probability table, (HxH, H:Hidden states).
emissions (matrix) : matrix . Emission probability table, (OxH, O:Observed states).
initial_distribution (float ) : array . Initial probability distribution for the hidden states.
Returns: array. Most probable path.
FunctionBaumWelchLibrary "FunctionBaumWelch"
Baum-Welch Algorithm, also known as Forward-Backward Algorithm, uses the well known EM algorithm
to find the maximum likelihood estimate of the parameters of a hidden Markov model given a set of observed
feature vectors.
---
### Function List:
> `forward (array pi, matrix a, matrix b, array obs)`
> `forward (array pi, matrix a, matrix b, array obs, bool scaling)`
> `backward (matrix a, matrix b, array obs)`
> `backward (matrix a, matrix b, array obs, array c)`
> `baumwelch (array observations, int nstates)`
> `baumwelch (array observations, array pi, matrix a, matrix b)`
---
### Reference:
> en.wikipedia.org
> github.com
> en.wikipedia.org
> www.rdocumentation.org
> www.rdocumentation.org
forward(pi, a, b, obs)
Computes forward probabilities for state `X` up to observation at time `k`, is defined as the
probability of observing sequence of observations `e_1 ... e_k` and that the state at time `k` is `X`.
Parameters:
pi (float ) : Initial probabilities.
a (matrix) : Transmissions, hidden transition matrix a or alpha = transition probability matrix of changing
states given a state matrix is size (M x M) where M is number of states.
b (matrix) : Emissions, matrix of observation probabilities b or beta = observation probabilities. Given
state matrix is size (M x O) where M is number of states and O is number of different
possible observations.
obs (int ) : List with actual state observation data.
Returns: - `matrix _alpha`: Forward probabilities. The probabilities are given on a logarithmic scale (natural logarithm). The first
dimension refers to the state and the second dimension to time.
forward(pi, a, b, obs, scaling)
Computes forward probabilities for state `X` up to observation at time `k`, is defined as the
probability of observing sequence of observations `e_1 ... e_k` and that the state at time `k` is `X`.
Parameters:
pi (float ) : Initial probabilities.
a (matrix) : Transmissions, hidden transition matrix a or alpha = transition probability matrix of changing
states given a state matrix is size (M x M) where M is number of states.
b (matrix) : Emissions, matrix of observation probabilities b or beta = observation probabilities. Given
state matrix is size (M x O) where M is number of states and O is number of different
possible observations.
obs (int ) : List with actual state observation data.
scaling (bool) : Normalize `alpha` scale.
Returns: - #### Tuple with:
> - `matrix _alpha`: Forward probabilities. The probabilities are given on a logarithmic scale (natural logarithm). The first
dimension refers to the state and the second dimension to time.
> - `array _c`: Array with normalization scale.
backward(a, b, obs)
Computes backward probabilities for state `X` and observation at time `k`, is defined as the probability of observing the sequence of observations `e_k+1, ... , e_n` under the condition that the state at time `k` is `X`.
Parameters:
a (matrix) : Transmissions, hidden transition matrix a or alpha = transition probability matrix of changing states
given a state matrix is size (M x M) where M is number of states
b (matrix) : Emissions, matrix of observation probabilities b or beta = observation probabilities. given state
matrix is size (M x O) where M is number of states and O is number of different possible observations
obs (int ) : Array with actual state observation data.
Returns: - `matrix _beta`: Backward probabilities. The probabilities are given on a logarithmic scale (natural logarithm). The first dimension refers to the state and the second dimension to time.
backward(a, b, obs, c)
Computes backward probabilities for state `X` and observation at time `k`, is defined as the probability of observing the sequence of observations `e_k+1, ... , e_n` under the condition that the state at time `k` is `X`.
Parameters:
a (matrix) : Transmissions, hidden transition matrix a or alpha = transition probability matrix of changing states
given a state matrix is size (M x M) where M is number of states
b (matrix) : Emissions, matrix of observation probabilities b or beta = observation probabilities. given state
matrix is size (M x O) where M is number of states and O is number of different possible observations
obs (int ) : Array with actual state observation data.
c (float ) : Array with Normalization scaling coefficients.
Returns: - `matrix _beta`: Backward probabilities. The probabilities are given on a logarithmic scale (natural logarithm). The first dimension refers to the state and the second dimension to time.
baumwelch(observations, nstates)
**(Random Initialization)** Baum–Welch algorithm is a special case of the expectation–maximization algorithm used to find the
unknown parameters of a hidden Markov model (HMM). It makes use of the forward-backward algorithm
to compute the statistics for the expectation step.
Parameters:
observations (int ) : List of observed states.
nstates (int)
Returns: - #### Tuple with:
> - `array _pi`: Initial probability distribution.
> - `matrix _a`: Transition probability matrix.
> - `matrix _b`: Emission probability matrix.
---
requires: `import RicardoSantos/WIPTensor/2 as Tensor`
baumwelch(observations, pi, a, b)
Baum–Welch algorithm is a special case of the expectation–maximization algorithm used to find the
unknown parameters of a hidden Markov model (HMM). It makes use of the forward-backward algorithm
to compute the statistics for the expectation step.
Parameters:
observations (int ) : List of observed states.
pi (float ) : Initial probaility distribution.
a (matrix) : Transmissions, hidden transition matrix a or alpha = transition probability matrix of changing states
given a state matrix is size (M x M) where M is number of states
b (matrix) : Emissions, matrix of observation probabilities b or beta = observation probabilities. given state
matrix is size (M x O) where M is number of states and O is number of different possible observations
Returns: - #### Tuple with:
> - `array _pi`: Initial probability distribution.
> - `matrix _a`: Transition probability matrix.
> - `matrix _b`: Emission probability matrix.
---
requires: `import RicardoSantos/WIPTensor/2 as Tensor`
MyLibraryLibrary "MyLibrary"
TODO: add library description here
fun(x)
TODO: add function description here
Parameters:
x (float) : TODO: add parameter x description here
Returns: TODO: add what function returns
Leveraged Share Conversion IndicatorHello everyone,
Releasing my leveraged share conversion indicator.
I noticed that the option traders have all the fun and resources but the share traders don't really have many resources in terms of adjusting or profits on leveraged and inverse shares. So, I decided to change that this this indicator!
What it does:
In a nut shell, the calculator converts one share to the price of another through the use of a regression based analysis.
There are multiple pre-stored libraries available in the indicator, including IWM, SPY, BTC and QQQ.
However, if the ticker you want to convert is not in one of the pre-defined libraries, you can select "Use Alternative Ticker" and indicate the stock you wish to convert.
Using Libraries:
If the conversion you want is available in one of the libraries, simply select the conversion you would like. For example, if you want to convert SPY to SPXU, select that conversion. The indicator will then launch up the conversion results which it will display in a dashboard to the right and will also display the plotted conversion on a chart (see imagine below:
In the dashboard, the indicator will show you:
a) The conversion result: This is the most likely price based on the analysis
b) The standard error: This is the degree of error within the conversion. This is the basis of the upper and lower bands. In statistics, we can add and subtract the standard error from the likely result to get the "Upper" and "Lower" Confidence levels of assessment. This is just a fancy way of saying the range in which our predicted result will fall. So, for example, in the image above it shows you the price of SPXU is assessed to be around 16$ based on SPY's price. The standard error range is 15-17. This means that, the majority of the time, based on this SPY close price, SPXU should fall between 15-17$ with the most likely result being the 16$ range.
Why is there error?
Because leveraged shares have an inherent decay in them. The degree of decay can be captured utilizing the standard error. So at any given time, the small changes in price fluctuations caused by the fact that the share is leveraged can be assessed and displayed using standard error measurements.
c) The current correlation: This is important! Because if the stocks are not strongly correlated, it tells you there is a problem. In general, a perfect correlation is 1 or -1 (perfectly negative correlation or inverse correlation) and a bad correlation is anything under 0.5 or -0.5. So, for an INVERSE leveraged share, you would expect the correlation to read a negative value. Ideally -1. Because the inverse share is doing the opposite of the underlying (if the underlying goes up, the inverse goes down and vice versa). For a non-inverse leveraged share, the correlation should read a positive value. As the underlying goes up, so too does the leveraged.
Manual Conversion using Library:
If you are using a pre-defined library but want to convert a manual close price, simply select "Enable manual conversion" at the bottom of the settings and then type in the manual close price. If you are converting SPY to SPXU, type in the manual close price of SPY to get the result in SPXU and vice versa.
Using an Alternative Ticker:
If the ticker you want is not available in a pre-defined library (i.e. UDOW, BOIL, APPU, TSLL, etc.), simply select "Use Alternative Ticker" in the settings menu. When you select this, make sure your chart is set to the dominant chart. The "Dominant chart" is the chart of the underlying. So, if you want TSLA to TSLL, be sure you have the TSLA chart open and then set your Alternative Ticker to TSLL or TSLQ.
The process of using an Alternative Ticker remains the same. If you wish to enter a manual close price, simply select "Enable Manual Conversion".
Special Considerations:
The indicator uses 1 hour candles. Thus, please leave your dominant chart set on the 1 hour time frame to avoid confusing the indicator.
The lookback period of the manual conversion is 10, 1 hour candles. As such, the results should not be used to make longer term predictions (i.e. anything over 6 months is pushing the capabilities of a manual conversion but fair game for the pre-defined library conversions which use more longer-term data).
You can technically use the indicator to make assessments between 2 separate equities. For example, the relationship between QQQ and ARKK, SPY and DIA, IWM and SPY, etc. If there is a good enough correlation, you can use it to make predictions of the opposing ticker. For example, if DIA goes to 340, what would SPY likely do? And vice versa.
As always, I have prepared a tutorial and getting started video for your reference:
As always, let me know your questions and requests/recommendations for the indicator below. This indicator is my final reference indicator in my 3 part reference indicator release. I will be going back over the feedback to make improvements based on the suggestions I have received. So please feel free to leave any suggestions here and I will take them into consideration for improvement!
Thank you for checking this out and as always, safe trades!
Trend Counter [theEccentricTrader]█ OVERVIEW
This indicator counts the number of confirmed trend scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend.
█ FEATURES
Inputs
Start Date
End Date
Position
Text Size
Show Sample Period
Table
The table is colour coded, consists of seven columns and, as many as, forty-one rows. Blue cells denote the multi-part trend scenarios, green cells denote the corresponding return line uptrend and uptrend scenarios and red cells denote the corresponding downtrend and return line downtrend scenarios.
The trend scenarios are listed in the first column with their corresponding total counts to the right, in the second and fifth columns. The last row in column one, displays the sample period which can be adjusted or hidden via indicator settings.
The third and sixth columns display the trend scenarios as percentage of total 1-part trends. And columns four and seven display the total trend scenarios as percentages of the, last, or preceding trend part. For example 4-part trends as a percentages of 3-part trends. This offers more insight into what might happen next at any given point in time.
Plots
For a visual aid to this indicator please use in conjunction with my Return Line Uptrends, Downtrends, Uptrends and Return Line Downtrends indicators which can all be found on my profile page under scripts, or in community scripts under the same names. Unfortunately, I could not fit all the plots with the correct offsets into one script so I had to make a separate indicator for each trend type. I decided against labels as this would limit the visual data points to 500.
Green up-arrows, with the number of the trend part, denote return line uptrends and uptrends. Red down-arrows, with the number of the trend part, denote downtrends and return line downtrends.
█ HOW TO USE
This is intended for research purposes, strategy development and strategy optimisation. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe.
It can, for example, give you an idea of whether the current trend will continue or fail, based on the current trend scenario and what has happened in the past under similar circumstances. Such information can be very useful when conducting top down analysis across multiple timeframes and making strategic decisions.
What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
Candle Trend Counter [theEccentricTrader]█ OVERVIEW
This indicator counts the number of confirmed candle trend scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Muti-Part Green and Red Candle Trends
• A multi-part green candle trend begins upon the completion of a swing low and continues until a red candle completes the swing high, with each green candle counted as a part of the trend.
• A multi-part red candle trend begins upon the completion of a swing high and continues until a green candle completes the swing low, with each red candle counted as a part of the trend.
█ FEATURES
Inputs
Start Date
End Date
Position
Text Size
Show Sample Period
Show Plots
Table
The table is colour coded, consists of seven columns and, as many as, thirty-one rows. Blue cells denote the multi-part candle trend scenarios, green cells denote the corresponding green candle trend scenarios and red cells denote the corresponding red candle trend scenarios.
The candle trend scenarios are listed in the first column with their corresponding total counts to the right, in the second column. The last row in column one, displays the sample period which can be adjusted or hidden via indicator settings.
The third column displays the total candle trend scenarios as percentages of total 1-candle trends, or complete swing highs and swing lows. And column four displays the total candle trend scenarios as percentages of the, last, or preceding candle trend part. For example 4-candle trends as a percentage of 3-candle trends. This offers more insight into what might happen next at any given point in time.
Plots
I have added plots as a visual aid to the various candle trend scenarios listed in the table. Green up-arrows, with the number of the trend part, denote green candle trends. Red down-arrows, with the number of the trend part, denote red candle trends.
█ HOW TO USE
This indicator is intended for research purposes, strategy development and strategy optimisation. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe.
It can, for example, give you an idea of whether the next candle will close higher or lower than it opened, based on the current scenario and what has happened in the past under similar circumstances. Such information can be very useful when conducting top down analysis across multiple timeframes and making strategic decisions.
What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
Swing Counter [theEccentricTrader]█ OVERVIEW
This indicator counts the number of confirmed swing high and swing low scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Peak and Trough Prices (Advanced)
• The advanced peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the highest preceding green candle high price, depending on which is higher.
• The advanced trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the lowest preceding red candle low price, depending on which is lower.
Green and Red Peaks and Troughs
• A green peak is one that derives its price from the green candle/s that constitute the swing high.
• A red peak is one that derives its price from the red candle that completes the swing high.
• A green trough is one that derives its price from the green candle that completes the swing low.
• A red trough is one that derives its price from the red candle/s that constitute the swing low.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
█ FEATURES
Inputs
• Start Date
• End Date
• Position
• Text Size
• Show Sample Period
• Show Plots
• Show Lines
Table
The table is colour coded, consists of three columns and nine rows. Blue cells denote neutral scenarios, green cells denote return line uptrend and uptrend scenarios, and red cells denote downtrend and return line downtrend scenarios.
The swing scenarios are listed in the first column with their corresponding total counts to the right, in the second column. The last row in column one, row nine, displays the sample period which can be adjusted or hidden via indicator settings.
Rows three and four in the third column of the table display the total higher peaks and higher troughs as percentages of total peaks and troughs, respectively. Rows five and six in the third column display the total lower peaks and lower troughs as percentages of total peaks and troughs, respectively. And rows seven and eight display the total double-top peaks and double-bottom troughs as percentages of total peaks and troughs, respectively.
Plots
I have added plots as a visual aid to the swing scenarios listed in the table. Green up-arrows with ‘HP’ denote higher peaks, while green up-arrows with ‘HT’ denote higher troughs. Red down-arrows with ‘LP’ denote higher peaks, while red down-arrows with ‘LT’ denote lower troughs. Similarly, blue diamonds with ‘DT’ denote double-top peaks and blue diamonds with ‘DB’ denote double-bottom troughs. These plots can be hidden via indicator settings.
Lines
I have also added green and red trendlines as a further visual aid to the swing scenarios listed in the table. Green lines denote return line uptrends (higher peaks) and uptrends (higher troughs), while red lines denote downtrends (lower peaks) and return line downtrends (lower troughs). These lines can be hidden via indicator settings.
█ HOW TO USE
This indicator is intended for research purposes and strategy development. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe. It can, for example, give you an idea of any inherent biases such as a greater proportion of higher peaks to lower peaks. Or a greater proportion of higher troughs to lower troughs. Such information can be very useful when conducting top down analysis across multiple timeframes, or considering entry and exit methods.
What I find most fascinating about this logic, is that the number of swing highs and swing lows will always find equilibrium on each new complete wave cycle. If for example the chart begins with a swing high and ends with a swing low there will be an equal number of swing highs to swing lows. If the chart starts with a swing high and ends with a swing high there will be a difference of one between the two total values until another swing low is formed to complete the wave cycle sequence that began at start of the chart. Almost as if it was a fundamental truth of price action, although quite common sensical in many respects. As they say, what goes up must come down.
The objective logic for swing highs and swing lows I hope will form somewhat of a foundational building block for traders, researchers and developers alike. Not only does it facilitate the objective study of swing highs and swing lows it also facilitates that of ranges, trends, double trends, multi-part trends and patterns. The logic can also be used for objective anchor points. Concepts I will introduce and develop further in future publications.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
The sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
█ NOTES
I feel it important to address the mention of advanced peak and trough price logic. While I have introduced the concept, I have not included the logic in my script for a number of reasons. The most pertinent of which being the amount of extra work I would have to do to include it in a public release versus the actual difference it would make to the statistics. Based on my experience, there are actually only a small number of cases where the advanced peak and trough prices are different from the basic peak and trough prices. And with adequate multi-timeframe analysis any high or low prices that are not captured using basic peak and trough price logic on any given time frame, will no doubt be captured on a higher timeframe. See the example below on the 1H FOREXCOM:USDJPY chart (Figure 1), where the basic peak price logic denoted by the indicator plot does not capture what would be the advanced peak price, but on the 2H FOREXCOM:USDJPY chart (Figure 2), the basic peak logic does capture the advanced peak price from the 1H timeframe.
Figure 1.
Figure 2.
█ RAMBLINGS
“Never was there an age that placed economic interests higher than does our own. Never was the need of a scientific foundation for economic affairs felt more generally or more acutely. And never was the ability of practical men to utilize the achievements of science, in all fields of human activity, greater than in our day. If practical men, therefore, rely wholly on their own experience, and disregard our science in its present state of development, it cannot be due to a lack of serious interest or ability on their part. Nor can their disregard be the result of a haughty rejection of the deeper insight a true science would give into the circumstances and relationships determining the outcome of their activity. The cause of such remarkable indifference must not be sought elsewhere than in the present state of our science itself, in the sterility of all past endeavours to find its empirical foundations.” (Menger, 1871, p.45).
█ BIBLIOGRAPHY
Menger, C. (1871) Principles of Economics. Reprint, Auburn, Alabama: Ludwig Von Mises Institute: 2007.
Global GDPThis is the GlobalGDP of the richest and most populous countries
It is measured in USD
The countries included are the same than are included in my Global M2 indicator, as of to be able to compare them side to side.
Candle Counter [theEccentricTrader]█ OVERVIEW
This indicator counts the number of confirmed candle scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.
█ CONCEPTS
Green and Red Candles
A green candle is one that closes with a high price equal to or above the price it opened.
A red candle is one that closes with a low price that is lower than the price it opened.
Upper Candle Trends
A higher high candle is one that closes with a higher high price than the high price of the preceding candle.
A lower high candle is one that closes with a lower high price than the high price of the preceding candle.
A double-top candle is one that closes with a high price that is equal to the high price of the preceding candle.
Lower Candle Trends
A higher low candle is one that closes with a higher low price than the low price of the preceding candle.
A lower low candle is one that closes with a lower low price than the low price of the preceding candle.
A double-bottom candle is one that closes with a low price that is equal to the low price of the preceding candle.
█ FEATURES
Inputs
Start Date
End Date
Position
Text Size
Show Sample Period
Show Plots
Table
The table is colour coded, consists of three columns and twenty-two rows. Blue cells denote all candle scenarios, green cells denote green candle scenarios and red cells denote red candle scenarios.
The candle scenarios are listed in the first column with their corresponding total counts to the right, in the second column. The last row in column one, row twenty-two, displays the sample period which can be adjusted or hidden via indicator settings.
Rows two and three in the third column of the table display the total green and red candles as percentages of total candles. Rows four to nine in column three, coloured blue, display the corresponding candle scenarios as percentages of total candles. Rows ten to fifteen in column three, coloured green, display the corresponding candle scenarios as percentages of total green candles. And lastly, rows sixteen to twenty-one in column three, coloured red, display the corresponding candle scenarios as percentages of total red candles.
Plots
I have added plots as a visual aid to the various candle scenarios listed in the table. Green up-arrows denote higher high candles when above bar and higher low candles when below bar. Red down-arrows denote lower high candles when above bar and lower low candles when below bar. Similarly, blue diamonds when above bar denote double-top candles and when below bar denote double-bottom candles. These plots can also be hidden via indicator settings.
█ HOW TO USE
This indicator is intended for research purposes and strategy development. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe. It can, for example, give you an idea of any inherent biases such as a greater proportion of green candles to red. Or a greater proportion of higher low green candles to lower low green candles. Such information can be very useful when conducting top down analysis across multiple timeframes, or considering trailing stop loss methods.
What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.
This is just the first and most basic in a series of indicators that can be used to study objective price action scenarios and develop a systematic approach to trading.
█ LIMITATIONS
Some higher timeframe candles on tickers with larger lookbacks such as the DXY, do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.
The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.
It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
Commission-aware Trade LabelsCommission-aware Trade Labels
Description:
This library provides an easy way to visualize take-profit and stop-loss levels on your chart, taking into account trading commissions. The library calculates and displays the net profit or loss, along with other useful information such as risk/reward ratio, shares, and position size.
Features:
Configurable take-profit and stop-loss prices or percentages.
Set entry amount or shares.
Calculates and displays the risk/reward ratio.
Shows net profit or loss, considering trading commissions.
Customizable label appearance.
Usage:
Add the script to your chart.
Create an Order object for take-profit and stop-loss with desired configurations.
Call target_label() and stop_label() methods for each order object.
Example:
target_order = Order.new(take_profit_price=27483, stop_loss_price=28000, shares=0.2)
stop_order = Order.new(stop_loss_price=29000, shares=1)
target_order.target_label()
stop_order.stop_label()
This script is a powerful tool for visualizing your trading strategy's performance and helps you make better-informed decisions by considering trading commissions in your profit and loss calculations.
Library "tradelabels"
entry_price(this)
Parameters:
this : Order object
@return entry_price
take_profit_price(this)
Parameters:
this : Order object
@return take_profit_price
stop_loss_price(this)
Parameters:
this : Order object
@return stop_loss_price
is_long(this)
Parameters:
this : Order object
@return entry_price
is_short(this)
Parameters:
this : Order object
@return entry_price
percent_to_target(this, target)
Parameters:
this : Order object
target : Target price
@return percent
risk_reward(this)
Parameters:
this : Order object
@return risk_reward_ratio
shares(this)
Parameters:
this : Order object
@return shares
position_size(this)
Parameters:
this : Order object
@return position_size
commission_cost(this, target_price)
Parameters:
this : Order object
@return commission_cost
target_price
net_result(this, target_price)
Parameters:
this : Order object
target_price : The target price to calculate net result for (either take_profit_price or stop_loss_price)
@return net_result
create_take_profit_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_stop_loss_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_entry_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_line(this, target_price, line_color, offset_x, line_style, line_width, draw_entry_line)
Parameters:
this
target_price
line_color
offset_x
line_style
line_width
draw_entry_line
Order
Order
Fields:
entry_price : Entry price
stop_loss_price : Stop loss price
stop_loss_percent : Stop loss percent, default 2%
take_profit_price : Take profit price
take_profit_percent : Take profit percent, default 6%
entry_amount : Entry amount, default 5000$
shares : Shares
commission : Commission, default 0.04%
Mason’s Line IndicatorThe Macon Strategy is an idea conceived by Didier Darcet , co-founder of Gavekal Intelligence Software. Inspired by the Water Level, an instrument used by masons to check the horizontality or verticality of a wall. This method aims to measure the psychology of financial markets and determine if the market is balanced or tilting towards an unfavorable side, focusing on the behavioral risk of markets rather than economic or political factors.
The strategy examines the satisfaction and frustration of investors based on the distance between the low and high points of the market over a period of one year. Investor satisfaction is influenced by the current price of the index and the path taken to reach that price. The distance to the low point provides satisfaction, while the distance to the high point generates frustration. The balance between the two dictates investors’ desire to hold or sell their positions.
To refine the strategy, it is important to consider the opinion of a group of investors rather than just one individual. The members of a hypothetical investor club invest successively throughout the past year. The overall satisfaction of the market on a given day is a democratic expression of all participants.
If the overall satisfaction is below 50%, investors are frustrated and sell their positions. If it is above, they are satisfied and hold their positions. The position of the group of investors relative to the high and low points represents the position of the air bubble in the water level. Market performance is measured day by day based on participant satisfaction or dissatisfaction.
In conclusion, memory, emotions, and decision-making ability are closely linked, and their interaction influences investment decisions. The Macon Strategy highlights the importance of the behavioral dimension in understanding financial market dynamics. By studying investor behavior through this strategy, it is possible to better anticipate market trends and make more informed investment decisions.
Presentation of the Mason’s Line Indicator:
The main strategy of this indicator is to measure the average satisfaction of investors based on the position of an imaginary air bubble in a tube delimited by the market’s highs and lows over a given period. After calculating the satisfaction level, it is then normalized between 0 and 1, and a moving average can be used to visualize trends.
Key features:
Calculation of highs and lows over a user-defined period.
Determination of the position of the air bubble in the tube based on the closing price.
Calculation of the average satisfaction of investors over a selected period.
Normalization of the average satisfaction between 0 and 1.
Visualization of normalized or non-normalized average satisfaction levels, as well as their corresponding moving averages.
User parameters:
Period for min and max (days) : Sets the period over which highs and lows will be calculated (1 to 365 days).
Period for average satisfaction (days) : Determines the period over which the average satisfaction of investors will be calculated (1 to 365 days).
Period for SMA : Sets the period of the simple moving average used to smooth the data (1 to 1000 days).
Bubble_value : Adjustment of the air bubble value, ranging from 0 to 1, in increments of 0.025.
Normalized average satisfaction : Option to choose whether to display the normalized or non-normalized average satisfaction.
Please note that the Mason’s Line Indicator is not a guarantee of future market performance and should be used in conjunction with proper risk management. Always ensure that you have a thorough understanding of the indicator’s methodology and its limitations before making any investment decisions. Additionally, past performance is not indicative of future results.
Kimchi Premium watchThis indicator provides easy-to-see Kimchi premium information.
It provides three pieces of information.
1. Current premium
2. The highest value of the premium over the last 240 candlesticks in the current timeframe.
3. The highest value of the premium over the last 240 candlesticks in the current timeframe.
I think this script is a very simple indicator.
It is usually recommended to get value in a large time frame.
The basic operation formula is as follows.
premium(percent) = ( BTC KRW - ( BTC USDT x USD KRW ) / ( BTC USDT x USDT USD x USD KRW )) x 100
Thank you.
Сoncentrated Market Maker Strategy by oxowlConcentrated Market Maker Strategy by oxowl. This script plots an upper and lower bound for liquidity provision, and checks for rebalancing conditions. It also includes alert conditions for when the price crosses the upper or lower bounds.
Here's an overview of the script:
It defines the input parameters: liquidity range percentage, rebalance frequency in minutes, and minimum trade size in assets.
It calculates the upper and lower bounds for liquidity provision based on the liquidity range percentage.
It initializes variables for the last rebalance time and price.
It defines a rebalance condition based on the frequency and current price within the specified range.
If the rebalance condition is met, it updates the last rebalance time and price.
It plots the upper and lower bounds on the chart as lines and adds price labels for both bounds.
It defines alert conditions for when the price crosses the upper or lower bounds.
Finally, it creates alert conditions with appropriate messages for when the price crosses the upper or lower bounds.
Concentrated liquidity is a concept often used in decentralized finance (DeFi) market-making strategies. It allows liquidity providers (LPs) to focus their liquidity within a specific price range, rather than across the entire price curve. Using an indicator with concentrated liquidity can offer several advantages:
Increased capital efficiency: Concentrated liquidity allows LPs to allocate their capital within a narrower price range. This means that the same amount of capital can generate more significant price impact and potentially higher returns compared to providing liquidity across a broader range.
Customized risk exposure: LPs can choose the price range they feel most comfortable with, allowing them to better manage their risk exposure. By selecting a range based on their market outlook, they can optimize their positions to maximize potential returns.
Adaptive strategies: Indicators that support concentrated liquidity can help traders adapt their strategies based on market conditions. For example, they can choose to provide liquidity around a stable price range during low-volatility periods or adjust their range when market conditions change.
To continue integrating this script into your trading strategy, follow these steps:
Import the script into your TradingView account. Navigate to the Pine editor, paste the code, and save it as a new script.
Apply the indicator to a trading pair chart. You can customize the input parameters (liquidity range percentage, rebalance frequency, and minimum trade size) based on your preferences and risk tolerance.
Set alerts for when the price crosses the upper or lower bounds. This will notify you when it's time to take action, such as adding or removing liquidity, or rebalancing your position.
Monitor the performance of your strategy over time. Adjust the input parameters as needed to optimize your returns and manage risk effectively.
(Optional) Integrate the script with a trading bot or automation platform. If you're using an API-based trading solution, you can incorporate the logic and conditions from the script into your bot's algorithm to automate the process of providing concentrated liquidity and rebalancing your positions.
Remember that no strategy is foolproof, and past performance is not indicative of future results. Always exercise caution when trading and carefully consider your risk tolerance.
Linear Regress on Price And VolumeLinear regression is a statistical method used to model the relationship between a dependent variable and one or more independent variables. It assumes a linear relationship between the dependent variable and the independent variable(s) and attempts to fit a straight line that best describes the relationship.
In the context of predicting the price of a stock based on the volume, we can use linear regression to build a model that relates the price of the stock (dependent variable) to the volume (independent variable). The idea is to use lookback period to predict future prices based on the volume.
To build this indicator, we start by collecting data on the price of the stock and the volume over a selected of time or by default 21 days. We then plot the data on a scatter plot with the volume on the x-axis and the price on the y-axis. If there is a clear pattern in the data, we can fit a straight line to the data using a method called least squares regression. The line represents the best linear approximation of the relationship between the price and the volume.
Once we have the line, we can use it to make predictions. For example, if we observe a certain volume, we can use the line to estimate the corresponding price.
It's worth noting that linear regression assumes a linear relationship between the variables. In reality, the relationship between the price and the volume may be more complex, and other factors may also influence the price of the stock. Therefore, while linear regression can be a useful tool, it should be used in conjunction with other methods and should be interpreted with caution.
Bitwise, Encode, DecodeLibrary "Bitwise, Encode, Decode"
Bitwise, Encode, Decode, and more Library
docs()
Hover-Over Documentation for inside Text Editor
bAnd(a, b)
Returns the bitwise AND of two integers
Parameters:
a : `int` - The first integer
b : `int` - The second integer
Returns: `int` - The bitwise AND of the two integers
bOr(a, b)
Performs a bitwise OR operation on two integers.
Parameters:
a : `int` - The first integer.
b : `int` - The second integer.
Returns: `int` - The result of the bitwise OR operation.
bXor(a, b)
Performs a bitwise Xor operation on two integers.
Parameters:
a : `int` - The first integer.
b : `int` - The second integer.
Returns: `int` - The result of the bitwise Xor operation.
bNot(n)
Performs a bitwise NOT operation on an integer.
Parameters:
n : `int` - The integer to perform the bitwise NOT operation on.
Returns: `int` - The result of the bitwise NOT operation.
bShiftLeft(n, step)
Performs a bitwise left shift operation on an integer.
Parameters:
n : `int` - The integer to perform the bitwise left shift operation on.
step : `int` - The number of positions to shift the bits to the left.
Returns: `int` - The result of the bitwise left shift operation.
bShiftRight(n, step)
Performs a bitwise right shift operation on an integer.
Parameters:
n : `int` - The integer to perform the bitwise right shift operation on.
step : `int` - The number of bits to shift by.
Returns: `int` - The result of the bitwise right shift operation.
bRotateLeft(n, step)
Performs a bitwise right shift operation on an integer.
Parameters:
n : `int` - The int to perform the bitwise Left rotation on the bits.
step : `int` - The number of bits to shift by.
Returns: `int`- The result of the bitwise right shift operation.
bRotateRight(n, step)
Performs a bitwise right shift operation on an integer.
Parameters:
n : `int` - The int to perform the bitwise Right rotation on the bits.
step : `int` - The number of bits to shift by.
Returns: `int` - The result of the bitwise right shift operation.
bSetCheck(n, pos)
Checks if the bit at the given position is set to 1.
Parameters:
n : `int` - The integer to check.
pos : `int` - The position of the bit to check.
Returns: `bool` - True if the bit is set to 1, False otherwise.
bClear(n, pos)
Clears a particular bit of an integer (changes from 1 to 0) passes if bit at pos is 0.
Parameters:
n : `int` - The integer to clear a bit from.
pos : `int` - The zero-based index of the bit to clear.
Returns: `int` - The result of clearing the specified bit.
bFlip0s(n)
Flips all 0 bits in the number to 1.
Parameters:
n : `int` - The integer to flip the bits of.
Returns: `int` - The result of flipping all 0 bits in the number.
bFlip1s(n)
Flips all 1 bits in the number to 0.
Parameters:
n : `int` - The integer to flip the bits of.
Returns: `int` - The result of flipping all 1 bits in the number.
bFlipAll(n)
Flips all bits in the number.
Parameters:
n : `int` - The integer to flip the bits of.
Returns: `int` - The result of flipping all bits in the number.
bSet(n, pos, newBit)
Changes the value of the bit at the given position.
Parameters:
n : `int` - The integer to modify.
pos : `int` - The position of the bit to change.
newBit : `int` - na = flips bit at pos reguardless 1 or 0 | The new value of the bit (0 or 1).
Returns: `int` - The modified integer.
changeDigit(n, pos, newDigit)
Changes the value of the digit at the given position.
Parameters:
n : `int` - The integer to modify.
pos : `int` - The position of the digit to change.
newDigit : `int` - The new value of the digit (0-9).
Returns: `int` - The modified integer.
bSwap(n, i, j)
Switch the position of 2 bits of an int
Parameters:
n : `int` - int to manipulate
i : `int` - bit pos to switch with j
j : `int` - bit pos to switch with i
Returns: `int` - new int with bits switched
bPalindrome(n)
Checks to see if the binary form is a Palindrome (reads the same left to right and vice versa)
Parameters:
n : `int` - int to check
Returns: `bool` - result of check
bEven(n)
Checks if n is Even
Parameters:
n : `int` - The integer to check.
Returns: `bool` - result.
bOdd(n)
checks if n is Even if not even Odd
Parameters:
n : `int` - The integer to check.
Returns: `bool` - result.
bPowerOfTwo(n)
Checks if n is a Power of 2.
Parameters:
n : `int` - number to check.
Returns: `bool` - result.
bCount(n, to_count)
Counts the number of bits that are equal to 1 in an integer.
Parameters:
n : `int` - The integer to count the bits in.
to_count `string` - the bits to count
Returns: `int` - The number of bits that are equal to 1 in n.
GCD(a, b)
Finds the greatest common divisor (GCD) of two numbers.
Parameters:
a : `int` - The first number.
b : `int` - The second number.
Returns: `int` - The GCD of a and b.
LCM(a, b)
Finds the least common multiple (LCM) of two integers.
Parameters:
a : `int` - The first integer.
b : `int` - The second integer.
Returns: `int` - The LCM of a and b.
aLCM(nums)
Finds the LCM of an array of integers.
Parameters:
nums : `int ` - The list of integers.
Returns: `int` - The LCM of the integers in nums.
adjustedLCM(nums, LCM)
adjust an array of integers to Least Common Multiple (LCM)
Parameters:
nums : `int ` - The first integer
LCM : `int` - The second integer
Returns: `int ` - array of ints with LCM
charAt(str, pos)
gets a Char at a given position.
Parameters:
str : `string` - string to pull char from.
pos : `int` - pos to get char from string (left to right index).
Returns: `string` - char from pos of string or "" if pos is not within index range
decimalToBinary(num)
Converts a decimal number to binary
Parameters:
num : `int` - The decimal number to convert to binary
Returns: `string` - The binary representation of the decimal number
decimalToBinary(num, to_binary_int)
Converts a decimal number to binary
Parameters:
num : `int` - The decimal number to convert to binary
to_binary_int : `bool` - bool to convert to int or to string (true for int, false for string)
Returns: `string` - The binary representation of the decimal number
binaryToDecimal(binary)
Converts a binary number to decimal
Parameters:
binary : `string` - The binary number to convert to decimal
Returns: `int` - The decimal representation of the binary number
decimal_len(n)
way of finding decimal length using arithmetic
Parameters:
n `float` - floating decimal point to get length of.
Returns: `int` - number of decimal places
int_len(n)
way of finding number length using arithmetic
Parameters:
n : `int`- value to find length of number
Returns: `int` - lenth of nunber i.e. 23 == 2
float_decimal_to_whole(n)
Converts a float decimal number to an integer `0.365 to 365`.
Parameters:
n : `string` - The decimal number represented as a string.
Returns: `int` - The integer obtained by removing the decimal point and leading zeroes from s.
fractional_part(x)
Returns the fractional part of a float.
Parameters:
x : `float` - The float to get the fractional part of.
Returns: `float` - The fractional part of the float.
form_decimal(a, b, zero_fix)
helper to form 2 ints into 1 float seperated by the decimal
Parameters:
a : `int` - a int
b : `int` - b int
zero_fix : `bool` - fix for trailing zeros being truncated when converting to float
Returns: ` ` - float = float decimal of ints | string = string version of b for future use to ref length
bEncode(n1, n2)
Encodes two numbers into one using bit OR. (fastest)
Parameters:
n1 : `int` - The first number to Encodes.
n2 : `int` - The second number to Encodes.
Returns: `int` - The result of combining the two numbers using bit OR.
bDecode(n)
Decodes an integer created by the bCombine function.(fastest)
Parameters:
n : `int` - The integer to decode.
Returns: ` ` - A tuple containing the two decoded components of the integer.
Encode(a, b)
Encodes by seperating ints into left and right of decimal float
Parameters:
a : `int` - a int
b : `int` - b int
Returns: `float` - new float of encoded ints one on left of decimal point one on right
Decode(encoded)
Decodes float of 2 ints seperated by decimal point
Parameters:
encoded : `float` - the encoded float value
Returns: ` ` - tuple of the 2 ints from encoded float
encode_heavy(a, b)
Encodes by combining numbers and tracking size in the
decimal of a floating number (slowest)
Parameters:
a : `int` - a int
b : `int` - b int
Returns: `float` - new decimal of encoded ints
decode_heavy(encoded)
Decodes encoded float that tracks size of ints in float decimal
Parameters:
encoded : `float` - encoded float
Returns: ` ` - tuple of decoded ints
decimal of float (slowest)
Parameters:
encoded : `float` - the encoded float value
Returns: ` ` - tuple of the 2 ints from encoded float
Bitwise, Encode, Decode Docs
In the documentation you may notice the word decimal
not used as normal this is because when referring to
binary a decimal number is a number that
can be represented with base 10 numbers 0-9
(the wiki below explains better)
A rule of thumb for the two integers being
encoded it to keep both numbers
less than 65535 this is because anything lower uses 16 bits or less
this will maintain 100% accuracy when decoding
although it is possible to do numbers up to 2147483645 with
this library doesnt seem useful enough
to explain or demonstrate.
The functions provided work within this 32-bit range,
where the highest number is all 1s and
the lowest number is all 0s. These functions were created
to overcome the lack of built-in bitwise functions in Pinescript.
By combining two integers into a single number,
the code can access both values i.e when
indexing only one array index
for a matrices row/column, thus improving execution time.
This technique can be applied to various coding
scenarios to enhance performance.
Bitwise functions are a way to use integers in binary form
that can be used to speed up several different processes
most languages have operators to perform these function such as
`<<, >>, &, ^, |, ~`
en.wikipedia.org