Risk Reward Calculator [lovealgotrading]
OVERVIEW:
This Risk Reward Calculator strategy can help you maximize your RR value with help of algorithmic trading.
INDICATOR:
I wanted to setup my trades more easier with this indicator, I didn't want to calculate everytime before orders, with help this indicator we can calculate R:R value, avarage price, stoploss price, take-profit price, order prices, all position cost and more ...
Our strategy is a risk revard calculation indicator that is made easy to use by using visualized lines and panels, and also has algorithmic trading support.
With the help of this indicator, we can quickly and easily calculate our risk reward values and enter the positions.
If we want to ensure that our balance grows regularly while trading in the stock market, we need to manage the risks and rewards otherwise we may fall below our initial balance at the end of the day, even if we seem to be winning.
What is the Risk-Reward value ?
This value is a value that shows how many times the amount of risk we take when entering the position is successful, we will earn.
- For example, you risked $100 while entering the trade, so if your trade stops, you will lose 100 $.
Your Risk-Reward(RR) value is 2 means that if your position is successful, you will have 200 $ in your pocket.
A trader's success is determined by the amount of R he earns monthly or yearly, not how much money he makes.
What is different in this indicator ?
I want to say thank you to © EvoCrypto. His Calculator (weighted) – evo indicator helped me when I was developed my indicator.
I want to explain what I have improved:
1-In this strategy, we can determine the time period in which we want to open our positions.
2-We can open a maximum of 4 positions in the same direction and close our positions at a single level. StopLoss or TakeProfit
3-This indicator, which works in the form of a strategy, shows where our positions have been opened or closed. With the help of this, it helps us to determine our strategy in our future positions more accurately.
4-The most important improvement is that we do not miss our positions with the help of alarms (WEB HOOK). if we want, we receive by quickly connecting all these positions to our robot, the software can enter and exit the position while we are busy.
IMPLEMENTATION DETAILS – SETTINGS:
1 - We can set the start and end dates of the positions we will take.
2- We can set our take profit, stoploss levels.
3- If your trade is stopped, we can determine the amount of the trade that we will lose.
4- We can adjust our entry levels to positions and our position sizes at entry levels.
(Sum of positions weight must be 100%)
5- We can receive our positions even if we are busy with the help of algorithmic trading. For this, we must paste our Jshon codes into the fields specified in the settings panel.
6- Finally, we can change the settings we want and don't want to have in our visual elements.
Let's make a LONG side example together
We have determined our positions to enter stoploss, take profit and long positions. We did not forget to set the start time of our strategy
Our strategy appear on the graph as follows.
Our strategy has calculated the total position size, our R-R value, the distance of the current price to the stop and take profit levels, in short, a lot of things we could look visually.
Notes:
If you're going to connect this bot to an automatic Long or Short direction,
Don’t forget! you need to Webhook URL,
Don’t miss paste this code to your message window {{strategy.order.alert_message}}
ALSO:
If you have any ideas what to add to my work to add more sources or make calculations cooler, feel free to write me.
Educational
Dynamic Stop Loss DemoWhat does this script do ?
This script is for pine script programmers and explains how to implement a dynamic stop-loss strategy. It is different from trailing stop-loss. Trailing stop-loss can only set the retracement value, but this script can take profit on part of the position at a fixed price and allows users to decide whether to take profit on all positions based on whether a certain track is breached or other conditions author want. In this demo, it use rsi crossover and crossunder to decide the strategy condition, and use close price as open price, and use lowest low / highest high as stop price, and use 1.5 risk ratio to calculate the fixed first profit price. It will take 50% position size when the first profit price was reached. Then it will close all rest positions when the inverse condition come out or the dynamic stop(calculated by ATR) breached or when the price back to the open price or the stop price.
How is this script implemented
When start strategy by strategy.entry , it gives a custom id which contains direction, openPrice, stopPrice, profitPrice, qty, etc. It can be get from the global variable strategy.posiition_entry_name .
Simple ICT Market Structure by toodegreesThis Simple ICT Market Structure is based on the teachings of ICT, specifically in his episode 12 of the Public 2022 Mentorship.
The only omission here is the peculiar calculation of Intermediate Term points, for which I am not using the concept of repricing imbalances – this can be added later!
Feel free to use this tool, however it is quite simple and market structure is something we all know very well how to spot. In my opinion it is helpful to display the long term swing points to identify more mature pools of liquidity.
The reason for coding this tool is to help new coders understand PineScript (I have a video tutorial where I code this from start to finish), as well as fostering some algorithmic thinking in your trading of ICT Concepts and Algorithmic Delivery.
If you have any questions about the code, shoot me a message!
Hope you learn something and GLGT!
3D BowlingIntroducing the "3D Bowling Game" – a fun and interactive demo scene project in Pine Script, powered by a custom 3D engine! This bowling game showcases the potential of Pine Script for developing engaging and immersive experiences, even within the confines of a trading platform.
To play the game, you'll first be prompted to choose where you want to throw the ball. Next, you'll be asked to draw a line indicating the direction you want the ball to go. Sit back and enjoy as the game takes care of the rest!
The source code features various sections, including:
Types and helper functions to manipulate vectors, matrices, and angles
Routines for calculating cross products, dot products, and vector normalization
Transformation matrices for rotation and scaling
Functions for perspective transformation, mesh transformations, and face normal calculations
Culling and shading algorithms to provide a more realistic visual experience
The project's source code is an excellent starting point for anyone interested in exploring the capabilities of Pine Script beyond the typical trading indicators and strategies. The 3D Bowling Game demonstrates the flexibility of Pine Script and its potential for creating interactive experiences in a seemingly unconventional environment.
So, what are you waiting for? Dive into the source code, tweak it to your liking, or build upon it to create your own interactive 3D experiences. Enjoy the game, and happy coding!
With light. I will say there is an issue with the fact that you cant draw as may linefills as you can lines.
TradeBee Percent Gap AlertA simple script to enable adding a trigger when a stock reaches 'X' percent, the 'X' can be configured.
The script also displays current tickers gap %, this is particularly helpful when you have 2 or more panels on a chart
Strategy DesignerHello traders.
Thanks to the tool I have published, everyone who knows or does not know coding will be able to create strategies and see the results instantly on the screen. Yes it looks very nice :)
What does this script do?
Thanks to this tool, even if you don't know any coding, you will be able to create your own strategies. You can add and remove indicators.
Entrance
The first thing you need to do is to set a strategy in your mind.
Then you need to adjust the settings of the indicators installed in the system. Please set the indicators first, because later they are forgotten.
The screen for entering the parameters of the indicators will be as follows.
After entering the parameters there is an important part . In this section, we can adjust the strategy settings.
First we choose between which dates we want the strategy to run. We then choose whether we want the strategy results to be displayed in a table or not.
We choose how the Terms should be linked together. For example, if you have a condition that is expected to produce more than one receive signal, select whether these conditions are connected to each other with and or with the connector.
In this way, you can determine whether all or any of the rules in your strategy should apply.
Next, we choose whether our strategy will work in the spot market or in a bidirectional market. Yes, you can design a strategy for both spot and bidirectional trades :)
At the bottom of the above image, we see a screen where we can adjust the stop level and tp level. As a standard, adjustments are made according to the percentage level you enter. However, if you remove the tick next to the percent sign, the previous stop level and the next profit level are determined as much as the value you entered.
At the bottom is the trailing stop. When you open the trailing stop, the trailing stop becomes active in your strategy.
Very important, when the trailing stop and the stop are active at the same time, the trailing stop value is valid.
It's time to design our strategy. Each chapter that begins with an exclamation point is a separate fiction.
If you do not mark the Active button, that condition will not be included in the calculation.
Direction = It is the direction for which the fiction in this region is valid.
We came to the indicator setting screen. Here, there is a screen where we can select two different indicators on the right and left.
We choose the first indicator starting with 1.
Then we choose from the middle region how we want these two indicators to interact.
We choose our second indicator from the place starting with 2.
If you want an indicator to interact with any value, tick the box where it says Value and fill in the value in the blank. When Value is ticked, the second indicator does not work.
Educational Strategy : TRIPLE DRAG-ON SYSTEM V.1The Triple Dragon System is a technical trading strategy that uses a combination of three different indicators to identify potential buy and sell signals in the market. The three indicators used in this strategy are the Extended Price Volume Trend (EPVT), the Donchian Channels, and the Parabolic SAR. Each of these indicators provides different types of information about the market, and by combining them, we can create a more comprehensive trading system.
The EPVT is used to identify potential trend changes and measure the strength of a trend. The Donchian Channels are used to identify the direction of the trend, while the Parabolic SAR is used to provide additional confirmation of trend changes and help determine potential entry and exit points.
In this strategy, we first use the EPVT and Donchian Channels to identify the direction of the trend. When the EPVT is above its baseline and the price is above the upper Donchian Channel, it suggests an uptrend. Conversely, when the EPVT is below its baseline and the price is below the lower Donchian Channel, it suggests a downtrend.
Once we have identified the trend direction, we use the Parabolic SAR to help determine potential entry and exit points. When the Parabolic SAR is below the price and flips to above the price, it suggests a potential buy signal. Conversely, when the Parabolic SAR is above the price and flips to below the price, it suggests a potential sell signal.
To further refine our trading signals, we use multiple timeframes to confirm the trend direction and ensure that we are not entering the market during a period of high volatility. We also use multiple take-profit levels to lock in profits and manage risk.
Overall, the Triple Dragon System is a comprehensive technical trading strategy that combines multiple indicators to provide clear entry and exit signals. By using a combination of trend-following and momentum indicators, we can identify potential trading opportunities while minimizing risk. Please note that this strategy is for educational purposes only and should not be taken as financial advice.
Custom Trading Session HighlighterThe Custom Trading Session Highlighter is a simple yet powerful indicator that allows you to visualize specific trading sessions on your chart by highlighting the background within the specified time range. This indicator can be helpful for traders who want to focus on specific market hours or analyze the market behavior during certain time periods.
Features:
>Customizable start and end times: Input your desired trading session start and end times using the format "HHMM" (e.g., "0930" for 9:30 AM). The indicator allows you to select the time range in 30-minute intervals.
>Trading session background color: The specified trading session will be highlighted with a semi-transparent green color, making it easy to differentiate the session from the rest of the chart.
>Overlay: The indicator overlays on the price chart, so it doesn't take up any additional space on your screen.
How to use:
>Add the Custom Trading Session Highlighter to your chart.
>Configure the start and end times of the session you want to highlight using the input fields in the indicator settings.
>Observe the highlighted trading session on your chart to analyze market behavior within that specific time range.
Multi-Time Period Chart[1] 3 overlays w/ Halfbacks These are 3 High-Low ranges that uses the code of TradingView's built-in Multi-Time Period Chart indicator as well as adds on optional midpoint (or "halfback") to the overlays. Finally, there are labels offset on the right margin that indicate the open price for each of those timeframes. One thing I adjusted is that range of each timeframe is omitted. This is because the original TV indicator's boxes have their right edge completely covering the wicks (Thus, the title for this indicator). This script has plenty of utility, but it designed specifically with the STRAT (Rob Smith) methodology in mind.
Sessions Indicator [CodeDNL]A sessions indicator that doesn't cover the whole trading screen, and continues into the future.
Made to be easier on the eyes than existing solutions.
Murder Algo Stats: last portion of Indices closing hour (S&P)Stats regarding the 'murder algo' (last 10mins of the closing hour). Works on all sub-1hr timeframes. Best used on 5min, 10min 15min timeframe. Ideal use on 10min timeframe.
Can be applied to other user input sessions also
What i'm calling the 'Murder Algo' is the tendency of dynamic lower time frame price action in the final 10minutes of the S&P closing hour (or any of the three major US indices: S&P, Nasdaq, Dow).
If there are un-met liquidity targets (i.e. clean highs or lows) as we come into the last portion of the closing hour, price has a tendency to stretch up or down to reach these targets, swiftly.
These statisitics are somewhat experimental/research; trying to quantify this tendency. Please comment below if you think of some additions / modifications that may prove useful.
//Purpose:
-To get statistics of the tendency to 'reach' of the final bar (10minute bar in the above) of the closing hour in Indices (3pm - 4pm NY time).
-Specifically to see how often price reaches for HH or LL in the final bar of the closing hour (most of the time); and to see how far it reaches one way when it does (Mean, median, mode).
//Notes:
-Two sets of historical stats; one is based on the 'solo reach' of the last bar; the other is based on the reach of the last bar from the average price of the preceding bars of the session (purple line in the above)
-Works on any timeframe below hourly. Ideally used on 10min timeframe, but may be interesting to plot on 15min or 5min timeframe also.
-Should also work on custom user-defined session; though this indicator was explicly designed to investigate the 'murder algo': that final rush and/or whipsaw tendency of price in the last few minutes of Regular trading on Indices.
-For S&P, best used on SPX, which gives the longest history of all the S&P variants due to only showing Regular trading hours bars (500 days of history on 10min timeframe, for premium users)
-For most stats, i've rounded to ES1! mintick (i.e. rounded to nearest quarter dollar) =>> This allows more meaningful values for 'mode' statistical measure.
-I trade S&P; but this 'muder algo' phenomenon also obviously presents in Nasdaq and Dow.
//User Inputs:
-Session time input (defaults to closing hour 3pm - 4pm NY time)
-Average method (for the average of all the input session EXCEPT the final bar)
-Toggle on/off Average line.
-other formatting options: text color, table position, line color/style/size.
Example usage with annotations on SPX 500 chart 15m timeframe; using closing hour (3pm-4pm NY time) as our session:
Papercuts Price Distance TravelledPapercuts Price Distance Travelled
aka
Maximum Per-Share Profit Potential
For: Intraday swing and scalp Traders.
This is a simple idea i wanted to explore where you could visualize the data of how much a price actually moves during the day.
Measuring through Daily ATR is helpful, but it only measures OHLC of the day, and way more tradeable movement happens than that.
So this measures movement a different way to increase perspective and awareness of price action.
Its like taking a pleated filter and unpleating it, which reveals a way longer structure.
It does this by aggregating the path of travel of an RSVAEMA (Relative Strength Volume Adjusted EMA) and returns the absolute value of its results.
Then it resets this daily, and returns the peak into an array that gets averaged.
This is helpful for seeing how normal or abnormal a days move might actually be. Many days feel extreme, but they are not, and vice versa.
This can be utilized to see how much movement actually happens at different levels. TSLA on 5m is an average daily movement of around 20$, but TSLA 15sec chart shows an average movement of around 100$. Pretty insane.
Arbitrage SpreadThis indicator helps to find spreads between cryptocurrencies, assess their correlation, spread, z score and atr z score.
The graphs are plotted as a percentage. Because of the limitation in pine tradingview for 5000 bars a period was introduced (after which a new starting point of the graph construction will be started), if you want it can be disabled
The multiplier parameter affects only the construction of the joint diagram on which z score and atr z score are calculated (construction of the diagram is done by dividing one pair by another and multiplying by the multiplier parameter) is shown with a red line
To create a notification you have to specify the data for parameters other than zero which you want to monitor. For parameters z score and atr z score data are counted in both directions
The data can be tracked via the data window
Link to image of the data window prnt.sc
Rounded Forex Levels: Big-Figure, Mid-Figure, 80-20 levels, BFRNSimple indicator to show Rounded levels in typical Forex pairs: Big figure, Mid-figure, 80-20 Insitutional Levels, 10pip levels, 5pip levels
Wrote this indicator because other ones out there seem to clutter the chart. This is simple, low-clutter and can be set by user to have arbitrary start and end points for the lines.
I wanted the ability for lines to plot discreetly to the right hand side of price as in the chart above, since in my opinion, these are only of secondary consideration to a trader, an extra confirmation/confluence to an existing idea.
//Purpose & Usage:
-Big-figure levels (100pips) & Mid-figure levels (50pips) will have a senstitivity to price, that can be an additional tool when looking for confluence for a target or an entry.
-As well as BF levels and MF levels; Institutional levels (20pips below and 20 pips above a Big Figure level) and standard 10pip or 5pip levels, can be useful in the right context (i.e added confirmation that of a minor sweep target; added conviction in an idea if the level aligns with another seperately derived level).
//User inputs:
-Toggle on/off each of the types of level.
-Line spacing: choose pip spacing of lines .
-Number of lines above/below (i.e. setting of 5 will be 11 lines. One central, 5 above, 5 below).
-Formatting: for each class of lines, code by color, style and width (as per the example chart below).
-Line start offset and line end offset: bars forward/back for each of start point and end point. So lines could be spread right across chart; or neatly pushed to the far right or left of the chart.
//Notes:
-Designed for typical Forex pairs with units close to 1.0 (like Eur/Usd, Usd/Cad, Aud/Usd, Gbp/Usd, Eur/Gbp, Nzd/Usd).
-Lines are based from the rounded close of the previous bar, Updating (if applicable) on each new bar.
Demo Plotting levels in the past; Dialog box example display:
Inversion GapsAn inverted fair value gap (FVG) occurs when candles start closing below a bullish FVG or above a bearish FVG and in this case, support FVGs become resistances and vice versa. This is a smart money concept introduced by ICT. While we a number of have indicators for FVGs, we don't have any for inversion FVGs. This indicator is just for that - it shows FVGs only after they're inverted.
The meat of it comes from being able to plot HTF inverted FVGs in LTF. In the above BTC chart, you can see M15 inverted FVGs plotted on M1 chart and you can see price respecting them. Mitigations can also be shown as lines (as you can see in the chart).
You can also setup alerts for formation and mitigation of such inversion FVGs.
ICT Concepts [LuxAlgo]The ICT Concepts indicator regroups core concepts highlighted by trader and educator "The Inner Circle Trader" (ICT) into an all-in-one toolkit. Features include Market Structure (MSS & BOS), Order Blocks, Imbalances, Buyside/Sellside Liquidity, Displacements, ICT Killzones, and New Week/Day Opening Gaps.
🔶 SETTINGS
🔹 Mode
When Present is selected, only data of the latest 500 bars are used/visualized, except for NWOG/NDOG
🔹 Market Structure
Enable/disable Market Structure.
Length: will set the lookback period/sensitivity.
In Present Mode only the latest Market Structure trend will be shown, while in Historical Mode, previous trends will be shown as well:
You can toggle MSS/BOS separately and change the colors:
🔹 Displacement
Enable/disable Displacement.
🔹 Volume Imbalance
Enable/disable Volume Imbalance.
# Visible VI's: sets the amount of visible Volume Imbalances (max 100), color setting is placed at the side.
🔹 Order Blocks
Enable/disable Order Blocks.
Swing Lookback: Lookback period used for the detection of the swing points used to create order blocks.
Show Last Bullish OB: Number of the most recent bullish order/breaker blocks to display on the chart.
Show Last Bearish OB: Number of the most recent bearish order/breaker blocks to display on the chart.
Color settings.
Show Historical Polarity Changes: Allows users to see labels indicating where a swing high/low previously occurred within a breaker block.
Use Candle Body: Allows users to use candle bodies as order block areas instead of the full candle range.
Change in Order Blocks style:
🔹 Liquidity
Enable/disable Liquidity.
Margin: sets the sensitivity, 2 points are fairly equal when:
'point 1' < 'point 2' + (10 bar Average True Range / (10 / margin)) and
'point 1' > 'point 2' - (10 bar Average True Range / (10 / margin))
# Visible Liq. boxes: sets the amount of visible Liquidity boxes (max 50), this amount is for Sellside and Buyside boxes separately.
Colour settings.
Change in Liquidity style:
🔹 Fair Value Gaps
Enable/disable FVG's.
Balance Price Range: this is the overlap of latest bullish and bearish Fair Value Gaps.
By disabling Balance Price Range only FVGs will be shown.
Options: Choose whether you wish to see FVG or Implied Fair Value Gaps (this will impact Balance Price Range as well)
# Visible FVG's: sets the amount of visible FVG's (max 20, in the same direction).
Color settings.
Change in FVG style:
🔹 NWOG/NDOG
Enable/disable NWOG; color settings; amount of NWOG shown (max 50).
Enable/disable NDOG ; color settings; amount of NDOG shown (max 50).
🔹 Fibonacci
This tool connects the 2 most recent bullish/bearish (if applicable) features of your choice, provided they are enabled.
3 examples (FVG, BPR, OB):
Extend lines -> Enabled (example OB):
🔹 Killzones
Enable/disable all or the ones you need.
Time settings are coded in the corresponding time zones.
🔶 USAGE
By default, the indicator displays each feature relevant to the most recent price variations in order to avoid clutter on the chart & to provide a very similar experience to how a user would contruct ICT Concepts by hand.
Users can use the historical mode in the settings to see historical market structure/imbalances. The ICT Concepts indicator has various use cases, below we outline many examples of how a trader could find usage of the features together.
In the above image we can see price took out Sellside liquidity, filled two bearish FVGs, a market structure shift, which then led to a clean retest of a bullish FVG as a clean setup to target the order block above.
Price then fills the OB which creates a breaker level as seen in yellow.
Broken OBs can be useful for a trader using the ICT Concepts indicator as it marks a level where orders have now been filled, indicating a solidified level that has proved itself as an area of liquidity. In the image above we can see a trade setup using a broken bearish OB as a potential entry level.
We can see the New Week Opening Gap (NWOG) above was an optimal level to target considering price may tend to fill / react off of these levels according to ICT.
In the next image above, we have another example of various use cases where the ICT Concepts indicator hypothetically allow traders to find key levels & find optimal entry points using market structure.
In the image above we can see a bearish Market Structure Shift (MSS) is confirmed, indicating a potential trade setup for targeting the Balanced Price Range imbalance (BPR) below with a stop loss above the buyside liquidity.
Although what we are demonstrating here is a hindsight example, it shows the potential usage this toolkit gives you for creating trading plans based on ICT Concepts.
Same chart but playing out the history further we can see directly after price came down to the Sellside liquidity & swept below it...
Then by enabling IFVGs in the settings, we can see the IFVG retests alongside the Sellside & Buyside liquidity acting in confluence.
Which allows us to see a great bullish structure in the market with various key levels for potential entries.
Here we can see a potential bullish setup as price has taken out a previous Sellside liquidity zone and is now retesting a NWOG + Volume Imbalance.
Users also have the option to display Fibonacci retracements based on market structure, order blocks, and imbalance areas, which can help place limit/stop orders more effectively as well as finding optimal points of interest beyond what the primary ICT Concepts features can generate for a trader.
In the above image we can see the Fibonacci extension was selected to be based on the NWOG giving us some upside levels above the buyside liquidity.
🔶 DETAILS
Each feature within the ICT Concepts indicator is described in the sub sections below.
🔹 Market Structure
Market structure labels are constructed from price breaking a prior swing point. This allows a user to determine the current market trend based on the price action.
There are two types of Market Structure labels included:
Market Structure Shift (MSS)
Break Of Structure (BOS)
A MSS occurs when price breaks a swing low in an uptrend or a swing high in a downtrend, highlighting a potential reversal. This is often labeled as "CHoCH", but ICT specifies it as MSS.
On the other hand, BOS labels occur when price breaks a swing high in an uptrend or a swing low in a downtrend. The occurrence of these particular swing points is caused by retracements (inducements) that highlights liquidity hunting in lower timeframes.
🔹 Order Blocks
More significant market participants (institutions) with the ability of placing large orders in the market will generally place a sequence of individual trades spread out in time. This is referred as executing what is called a "meta-order".
Order blocks highlight the area where potential meta-orders are executed. Bullish order blocks are located near local bottoms in an uptrend while bearish order blocks are located near local tops in a downtrend.
When price mitigates (breaks out) an order block, a breaker block is confirmed. We can eventually expect price to trade back to this breaker block offering a new trade opportunity.
🔹 Buyside & Sellside Liquidity
Buyside / Sellside liquidity levels highlight price levels where market participants might place limit/stop orders.
Buyside liquidity levels will regroup the stoploss orders of short traders as well as limit orders of long traders, while Sellside liquidity levels will regroup the stoploss orders of long traders as well as limit orders of short traders.
These levels can play different roles. More informed market participants might view these levels as source of liquidity, and once liquidity over a specific level is reduced it will be found in another area.
🔹 Imbalances
Imbalances highlight disparities between the bid/ask, these can also be defined as inefficiencies, which would suggest that not all available information is reflected by the price and would as such provide potential trading opportunities.
It is common for price to "rebalance" and seek to come back to a previous imbalance area.
ICT highlights multiple imbalance formations:
Fair Value Gaps: A three candle formation where the candle shadows adjacent to the central candle do not overlap, this highlights a gap area.
Implied Fair Value Gaps: Unlike the fair value gap the implied fair value gap has candle shadows adjacent to the central candle overlapping. The gap area is constructed from the average between the respective shadow and the nearest extremity of their candle body.
Balanced Price Range: Balanced price ranges occur when a fair value gap overlaps a previous fair value gap, with the overlapping area resulting in the imbalance area.
Volume Imbalance: Volume imbalances highlight gaps between the opening price and closing price with existing trading activity (the low/high overlap the previous high/low).
Opening Gap: Unlike volume imbalances opening gaps highlight areas with no trading activity. The low/high does not reach previous high/low, highlighting a "void" area.
🔹 Displacement
Displacements are scenarios where price forms successive candles of the same sentiment (bullish/bearish) with large bodies and short shadows.
These can more technically be identified by positive auto correlation (a close to open change is more likely to be followed by a change of the same sign) as well as volatility clustering (large changes are followed by large changes).
Displacements can be the cause for the formation of imbalances as well as market structure, these can be caused by the full execution of a meta order.
🔹 Kill Zones
Killzones represent different time intervals that aims at offering optimal trade entries. Killzones include:
- New York Killzone (7:9 ET)
- London Open Killzone (2:5 ET)
- London Close Killzone (10:12 ET)
- Asian Killzone (20:00 ET)
🔶 Conclusion & Supplementary Material
This script aims to emulate how a trader would draw each of the covered features on their chart in the most precise representation to how it's actually taught by ICT directly.
There are many parallels between ICT Concepts and Smart Money Concepts that we released in 2022 which has a more general & simpler usage:
ICT Concepts, however, is more specifically aligned toward the community's interpretation of how to analyze price 'based on ICT', rather than displaying features to have a more classic interpretation for a technical analyst.
Regression Channel Alternative MTF V2█ OVERVIEW
This indicator is a predecessor to Regression Channel Alternative MTF , which is coded based on latest update of type, object and method.
█ IMPORTANT NOTES
This indicator is NOT true Multi Timeframe (MTF) but considered as Alternative MTF which calculate 100 bars for Primary MTF, can be refer from provided line helper.
The timeframe scenarios are defined based on Position, Swing and Intraday Trader.
Suppported Timeframe : W, D, 60, 15, 5 and 1.
Channel drawn based on regression calculation.
Angle channel is NOT supported.
█ INSPIRATIONS
These timeframe scenarios are defined based on Harmonic Trading : Volume Three written by Scott M Carney.
By applying channel on each timeframe, MW or ABCD patterns can be easily identified manually.
This can also be applied on other chart patterns.
█ CREDITS
Scott M Carney, Harmonic Trading : Volume Three (Reaction vs. Reversal)
█ TIMEFRAME EXPLAINED
Higher / Distal : The (next) longer or larger comparative timeframe after primary pattern has been identified.
Primary / Clear : Timeframe that possess the clearest pattern structure.
Lower / Proximate : The (next) shorter timeframe after primary pattern has been identified.
Lowest : Check primary timeframe as main reference.
█ FEATURES
Color is determined by trend or timeframe.
Some color is depends on chart contrast color.
Color is determined by trend or timeframe.
█ EXAMPLE OF USAGE / EXPLAINATION
Zigzag Array ExperimentalThis is experimental script for zigzag which uses type, method and array. Not recommend for actual usage, for pine script study maybe useful.
In this experiment, I use type as coded below. It seems have limitation as specially when push as array. As Trading View recommendation, pushing float and int into array especially for type not guarantee to work. I agree with that. Preferred to push array as line or label especially for types.
// @type Used for point especially for array
// @field x int value for bar_index
// @field y float value for price
// @field sty label style
// @field col color for text label
// @field str high or low string
type point
int x = na
float y = na
string sty = na
color col = na
string str = na
I simulate the arrays as below.
var dirLine = array.new()
var dirLabel = array.new()
var dirPoint = array.new()
....
dirPoint.unshift(zigzag.createPoint(0))
dirLabel.unshift(zigzag.createLabel(fontSize, 0, true))
dirLine.unshift(zigzag.createLine(width, switchLine, 0, true))
Here are some results.
Watermark° (Quote, Name, Timeframe, Date)I have been asked for this a lot, so here it is!
It's an easy script to read, and for all you aspiring Pinescript coders out there it might serve as a little introduction on Tables , switch operator, and a bit of UI/UX!
Description:
This is just a watermark, which follows my personal style an aesthetic when it comes to Pinescript tools. I like to keep my charts clean to focus on Time and price, and I love to have a reminder to remain disciplined.
Homo Faber Fortunae Suae is a Latin maxim which loosely translates to: Humans Are The Makers Of Their Own Destiny.
So make your own destiny, master yourself and the charts!
Indicator Features:
– Display symbol ticker, timeframe and date all in one place.
– Make it look nice 🤗
– Protect your TV username ID, by having your chart show a custom username (if you are sharing charts outside of Tradingview, and are known under a different alias there)
Note: no matter what, by exporting images from TV (copy image/copy link to chart) your TV username will appear in the top left corner of the image
👇👁
Strategy Template + Performance & Returns table + ExtrasA script I've been working on since summer 2022. A template for any strategy so you just have to write or paste the code and go straight into risk management settings
Features:
>Signal only Longs/only Shorts/Both
>Leverage system
>Proper fees calculation (even with leverage on)
>Different Stop Loss systems: Simple percentage, 4 different "move to Break Even" systems and Scaling SL after each TP order (read the disclaimer at the bottom regarding this and the TV % profitable metric)
>2 Take Profit systems: Simple percentages, or Risk/reward ratios based on SL level
>Additional option on TP so last one "rides free" until closure of position or Stoploss is hit (for more than 1 orders)
>Up to 5 TP orders
>Show or hide SL/TP levels on demand
>2 date filters. Manual filter is nothing new, enter two dates/hours and filter will turn on. BUT automatic filter is another thing (thanks to user @bfr_ for his help in codingthis feature)
>AUTOMATIC DATE FILTER. Allows you to split all historical data on the chart in X periods, then choose the range of periods used. Up to 10 but that can be changed, instructions included. Useful for WalkForward simulations, haven't seen a script in TradingView that allows you to do this and test your strategy on "unseen data" automatically
EXTRA SETTINGS
Besides, some additions I like to add to my codes:
>Returns table for monthly and weekly performance. Requires recalculation on every tick. This is a modified version of @QuantNomad's work. May add lower TF options later on
>Volume Based S/R system. Original work from @shtcoinr
>One feature that was made by me, the "portfolio table". Yields info and metrics of your strategy, current position and balance. You're able to turn it off and change its size
Should anyone find an error, or have any idea on how to improve this code, please contact me. Future updates could come, stay tuned
DISCLAIMER:
In order to have accurate StopLoss hit, I had to change the previous system, which was a "close position on candle close" instead at actual stoploss level. It was fixed, but resulted on inflation of the number of trading orders, thus reducing the percent profitable and making it strongly biased and unreal. Keep that in mind, that "real" profitability could be 2x or 3x the metric TradingView says. If your strategy has a really high trading frequency, resulting in 3000+ orders, might be a problem. Try to make use of the automatic/manual date filter as workaround, I have no means of changing this, seems it is not a bug but an intended design of the PineScript Code
ICT NWOG/NDOG & EHPDA [LuxAlgo]This indicator displays New Week/Day Opening Gaps alongside Event Horizon PD Arrays which were conceptualized by a trader, ICT.
🔶 SETTINGS
Show: Determines if new week opening gaps (NWOG) or new day opening gaps (NDOG) are shown.
Amount: Controls the amount of most recent NWOGs/NDOGs to display on the chart.
Show EHPDA: Displays Event Horizons PD arrays.
🔶 USAGE
New Week/Day Opening Gaps are generally used as potential support or resistance areas.
Trader ICT describes that under consolidating market conditions, price tends to revert towards the opening gap area. This is consistent with other analysis suggesting that price has a tendency to come back toward gaps, ultimately looking to fill them.
ICT also introduces a novel concept, the "Event Horizon PD Array" (EHPDA) which are intermediary levels constructed from the average between the neighboring NWOGs or NDOGs.
EHPDA's are described by ICT as levels that "will not allow price to escape to the NWOG that will create a surge towards the NWOG it got too "close" to but has not yet reached."
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.
Variety MA Cluster Filter Crosses [Loxx]What is a Cluster Filter?
One of the approaches to determining a useful signal (trend) in stream data. Small filtering (smoothing) tests applied to market quotes demonstrate the potential for creating non-lagging digital filters (indicators) that are not redrawn on the last bars.
Standard Approach
This approach is based on classical time series smoothing methods. There are lots of articles devoted to this subject both on this and other websites. The results are also classical:
1. The changes in trends are displayed with latency;
2. Better indicator (digital filter) response achieved at the expense of smoothing quality decrease;
3. Attempts to implement non-lagging indicators lead to redrawing on the last samples (bars).
And whereas traders have learned to cope with these things using persistence of economic processes and other tricks, this would be unacceptable in evaluating real-time experimental data, e.g. when testing aerostructures.
The Main Problem
It is a known fact that the majority of trading systems stop performing with the course of time, and that the indicators are only indicative over certain intervals. This can easily be explained: market quotes are not stationary. The definition of a stationary process is available in Wikipedia:
A stationary process is a stochastic process whose joint probability distribution does not change when shifted in time.
Judging by this definition, methods of analysis of stationary time series are not applicable in technical analysis. And this is understandable. A skillful market-maker entering the market will mess up all the calculations we may have made prior to that with regard to parameters of a known series of market quotes.
Even though this seems obvious, a lot of indicators are based on the theory of stationary time series analysis. Examples of such indicators are moving averages and their modifications. However, there are some attempts to create adaptive indicators. They are supposed to take into account non-stationarity of market quotes to some extent, yet they do not seem to work wonders. The attempts to "punish" the market-maker using the currently known methods of analysis of non-stationary series (wavelets, empirical modes and others) are not successful either. It looks like a certain key factor is constantly being ignored or unidentified.
The main reason for this is that the methods used are not designed for working with stream data. All (or almost all) of them were developed for analysis of the already known or, speaking in terms of technical analysis, historical data. These methods are convenient, e.g., in geophysics: you feel the earthquake, get a seismogram and then analyze it for few months. In other words, these methods are appropriate where uncertainties arising at the ends of a time series in the course of filtering affect the end result.
When analyzing experimental stream data or market quotes, we are focused on the most recent data received, rather than history. These are data that cannot be dealt with using classical algorithms.
Cluster Filter
Cluster filter is a set of digital filters approximating the initial sequence. Cluster filters should not be confused with cluster indicators.
Cluster filters are convenient when analyzing non-stationary time series in real time, in other words, stream data. It means that these filters are of principal interest not for smoothing the already known time series values, but for getting the most probable smoothed values of the new data received in real time.
Unlike various decomposition methods or simply filters of desired frequency, cluster filters create a composition or a fan of probable values of initial series which are further analyzed for approximation of the initial sequence. The input sequence acts more as a reference than the target of the analysis. The main analysis concerns values calculated by a set of filters after processing the data received.
In the general case, every filter included in the cluster has its own individual characteristics and is not related to others in any way. These filters are sometimes customized for the analysis of a stationary time series of their own which describes individual properties of the initial non-stationary time series. In the simplest case, if the initial non-stationary series changes its parameters, the filters "switch" over. Thus, a cluster filter tracks real time changes in characteristics.
Cluster Filter Design Procedure
Any cluster filter can be designed in three steps:
1. The first step is usually the most difficult one but this is where probabilistic models of stream data received are formed. The number of these models can be arbitrary large. They are not always related to physical processes that affect the approximable data. The more precisely models describe the approximable sequence, the higher the probability to get a non-lagging cluster filter.
2. At the second step, one or more digital filters are created for each model. The most general condition for joining filters together in a cluster is that they belong to the models describing the approximable sequence.
3. So, we can have one or more filters in a cluster. Consequently, with each new sample we have the sample value and one or more filter values. Thus, with each sample we have a vector or artificial noise made up of several (minimum two) values. All we need to do now is to select the most appropriate value.
An Example of a Simple Cluster Filter
For illustration, we will implement a simple cluster filter corresponding to the above diagram, using market quotes as input sequence. You can simply use closing prices of any time frame.
1. Model description. We will proceed on the assumption that:
The aproximate sequence is non-stationary, i.e. its characteristics tend to change with the course of time.
The closing price of a bar is not the actual bar price. In other words, the registered closing price of a bar is one of the noise movements, like other price movements on that bar.
The actual price or the actual value of the approximable sequence is between the closing price of the current bar and the closing price of the previous bar.
The approximable sequence tends to maintain its direction. That is, if it was growing on the previous bar, it will tend to keep on growing on the current bar.
2. Selecting digital filters. For the sake of simplicity, we take two filters:
The first filter will be a variety filter calculated based on the last closing prices using the slow period. I believe this fits well in the third assumption we specified for our model.
Since we have a non-stationary filter, we will try to also use an additional filter that will hopefully facilitate to identify changes in characteristics of the time series. I've chosen a variety filter using the fast period.
3. Selecting the appropriate value for the cluster filter.
So, with each new sample we will have the sample value (closing price), as well as the value of MA and fast filter. The closing price will be ignored according to the second assumption specified for our model. Further, we select the МА or ЕМА value based on the last assumption, i.e. maintaining trend direction:
For an uptrend, i.e. CF(i-1)>CF(i-2), we select one of the following four variants:
if CF(i-1)fastfilter(i), then CF(i)=slowfilter(i);
if CF(i-1)>slowfilter(i) and CF(i-1)slowfilter(i) and CF(i-1)>fastfilter(i), then CF(i)=MAX(slowfilter(i),fastfilter(i)).
For a downtrend, i.e. CF(i-1)slowfilter(i) and CF(i-1)>fastfilter(i), then CF(i)=MAX(slowfilter(i),fastfilter(i));
if CF(i-1)>slowfilter(i) and CF(i-1)fastfilter(i), then CF(i)=fastfilter(i);
if CF(i-1)<slowfilter(i) and CF(i-1)<fastfilter(i), then CF(i)=MIN(slowfilter(i),fastfilter(i)).
Where:
CF(i) – value of the cluster filter on the current bar;
CF(i-1) and CF(i-2) – values of the cluster filter on the previous bars;
slowfilter(i) – value of the slow filter
fastfilter(i) – value of the fast filter
MIN – the minimum value;
MAX – the maximum value;
What is Variety MA Cluster Filter Crosses?
For this indicator we calculate a fast and slow filter of the same filter and then we run a cluster filter between the fast and slow filter outputs to detect areas of chop/noise. The output is the uptrend is denoted by green color, downtrend by red color, and chop/noise/no-trade zone by white color. As a trader, you'll likely want to avoid trading during areas of chop/noise so you'll want to avoid trading when the color turns white.
Extras
Bar coloring
Alerts
Loxx's Expanded Source Types, see here:
Loxx's Moving Averages, see here:
An example of filtered chop, see the yellow circles. The cluster filter identifies chop zones so you don't get stuck in a sideways market.