lib_kernelLibrary "lib_kernel"
Library "lib_kernel"
This is a tool / library for developers, that contains several common and adapted kernel functions as well as a kernel regression function and enum to easily select and embed a list into the settings dialog.
How to Choose and Modify Kernels in Practice
Compact Support Kernels (e.g., Epanechnikov, Triangular): Use for localized smoothing and emphasizing nearby data.
Oscillatory Kernels (e.g., Wave, Cosine): Ideal for detecting periodic patterns or mean-reverting behavior.
Smooth Tapering Kernels (e.g., Gaussian, Logistic): Use for smoothing long-term trends or identifying global price behavior.
kernel_Epanechnikov(u)
Parameters:
u (float)
kernel_Epanechnikov_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel_Triangular(u)
Parameters:
u (float)
kernel_Triangular_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel_Rectangular(u)
Parameters:
u (float)
kernel_Uniform(u)
Parameters:
u (float)
kernel_Uniform_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel_Logistic(u)
Parameters:
u (float)
kernel_Logistic_alt(u)
Parameters:
u (float)
kernel_Logistic_alt2(u, sigmoid_steepness)
Parameters:
u (float)
sigmoid_steepness (float)
kernel_Gaussian(u)
Parameters:
u (float)
kernel_Gaussian_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel_Silverman(u)
Parameters:
u (float)
kernel_Quartic(u)
Parameters:
u (float)
kernel_Quartic_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel_Biweight(u)
Parameters:
u (float)
kernel_Triweight(u)
Parameters:
u (float)
kernel_Sinc(u)
Parameters:
u (float)
kernel_Wave(u)
Parameters:
u (float)
kernel_Wave_alt(u)
Parameters:
u (float)
kernel_Cosine(u)
Parameters:
u (float)
kernel_Cosine_alt(u, sensitivity)
Parameters:
u (float)
sensitivity (float)
kernel(u, select, alt_modificator)
wrapper for all standard kernel functions, see enum Kernel comments and function descriptions for usage szenarios and parameters
Parameters:
u (float)
select (series Kernel)
alt_modificator (float)
kernel_regression(src, bandwidth, kernel, exponential_distance, alt_modificator)
wrapper for kernel regression with all standard kernel functions, see enum Kernel comments for usage szenarios. performance optimized version using fixed bandwidth and target
Parameters:
src (float) : input data series
bandwidth (simple int) : sample window of nearest neighbours for the kernel to process
kernel (simple Kernel) : type of Kernel to use for processing, see Kernel enum or respective functions for more details
exponential_distance (simple bool) : if true this puts more emphasis on local / more recent values
alt_modificator (float) : see kernel functions for parameter descriptions. Mostly used to pronounce emphasis on local values or introduce a decay/dampening to the kernel output
Indicators and strategies
Total Volume for Custom PeriodIndicator Description: Total Volume for Custom Period
This indicator calculates the total trading volume for a specified time period and displays the result in the top-right corner of the chart. It is designed for traders and analysts who want to see the cumulative volume over a defined range of time without needing to calculate it manually.
Features:
Customizable Time Period:
Define the start and end times of the calculation using the easy-to-use settings panel.
The indicator dynamically updates as you adjust the dates.
Accurate Volume Calculation:
Calculates the total trading volume for all candlesticks between the selected start and end dates.
Works on all assets and timeframes supported by TradingView (stocks, crypto, forex, etc.).
Fixed Display:
The result is displayed in the top-right corner of the chart inside a clear and simple table.
The value remains visible regardless of chart movement or zoom level.
Real-time Updates:
Automatically recalculates the volume when new data is added or the selected time period changes.
Customizable Design:
Black text with a transparent background ensures the display is clear and non-intrusive.
Large text size for easy readability.
Use Cases:
Volume Analysis: Quickly assess the total trading activity over a specific time period.
Historical Data Analysis: Compare volume data across different time intervals.
Custom Strategies: Use the total volume metric as part of a broader trading strategy or analysis.
How It Works:
Open the settings panel of the indicator and input the desired Start Date and End Date.
The indicator calculates the total trading volume for all candles within the selected range.
The result is displayed in the top-right corner of the chart.
This indicator is a simple yet powerful tool for traders who rely on volume analysis to make informed decisions. It enhances your ability to study market behavior during specific periods and provides insights into trading activity with ease.
Bullish and Bearish Harami DetectorHere’s a description of the script I built for you, designed for a **TradingView public indicator**:
### **Custom Bullish and Bearish Harami Detector with Timeframe Selection**
This custom Pine Script detects **Bullish Harami** and **Bearish Harami** candlestick patterns on the selected timeframe, with configurable settings for how many prior candles to consider for pattern detection.
---
### **Features:**
1. **Timeframe Selection:**
- **Input Field for Timeframe**: The script allows users to choose the timeframe for detecting patterns. For instance, you can set it to 1 hour, 4 hours, or even daily candles, ensuring the detection works as per your chosen market view.
- This is controlled by the `input.timeframe` function, and the user is prompted to select the desired timeframe (e.g., "1h", "4h", "1d").
2. **Enable/Disable Pattern Detection:**
- The user has the flexibility to enable or disable the detection of **Bullish Harami** and **Bearish Harami** patterns.
- The two toggles `detectBullishHarami` and `detectBearishHarami` allow users to turn on/off the detection for each pattern type.
3. **Customizable Bearish Candle Count for Bullish Harami:**
- The user can define how many prior **bearish candles** should be present before a **Bullish Harami** can be detected.
- The input variable `bearishCandleCountBullish` lets you choose how many previous bearish candles to consider for detecting a **Bullish Harami** (for example, the last 3, 5, or 6 bearish candles).
4. **Customizable Bullish Candle Count for Bearish Harami:**
- Similar to the Bullish Harami, the script allows the user to define how many prior **bullish candles** should be present before a **Bearish Harami** pattern is detected.
- The input variable `bearishCandleCountBearish` lets you select how many previous bullish candles to check for **Bearish Harami**.
5. **Pattern Detection Logic:**
- **Bullish Harami**: Detected when a bearish candle (open > close) is followed by a smaller bullish candle (open < close) where the entire body of the second candle is contained within the body of the first candle.
- **Bearish Harami**: Detected when a bullish candle (open < close) is followed by a smaller bearish candle (open > close) where the entire body of the second candle is contained within the body of the first candle.
- Both patterns are subject to the user-defined conditions (number of previous bearish or bullish candles).
6. **Visual Indicators:**
- **Bullish Harami**: A green label is plotted **below the bar** to indicate a **Bullish Harami** pattern.
- **Bearish Harami**: A red label is plotted **above the bar** to indicate a **Bearish Harami** pattern.
- The labels are displayed using the `plotshape` function with custom colors and text.
7. **Additional Settings**:
- The script includes tooltips and descriptions for each input to make the settings clear for users, allowing even those unfamiliar with candlestick patterns to understand and use the indicator effectively.
---
### **How It Works:**
- The script first checks the specified timeframe and identifies the current and previous candlesticks.
- It then applies the user-defined conditions for detecting the **Bullish Harami** and **Bearish Harami** patterns by checking the relative positions and sizes of the candlesticks over the selected number of previous candles.
- Once a pattern is detected, it plots a label on the chart (green for **Bullish Harami** and red for **Bearish Harami**) at the appropriate location (below or above the candle).
- The script updates dynamically as the price action unfolds.
---
### **Use Cases:**
- **Traders**: This script is useful for traders who want to identify reversal patterns like **Bullish Harami** and **Bearish Harami** on their chosen timeframes and adjust the sensitivity by changing the number of prior candles for pattern detection.
- **Customization**: Users can fine-tune the script’s settings based on their specific trading strategy, adjusting both the timeframe and the number of candles for pattern detection.
---
### **Conclusion:**
This indicator is an effective tool for detecting candlestick patterns, specifically **Bullish Harami** and **Bearish Harami**, on **TradingView**. By allowing customization in terms of timeframe and the number of prior candles to consider, users can tailor the script to fit their trading strategy and market conditions.
Breakaway Fair Value Gaps [LuxAlgo]The Breakaway Fair Value Gap (FVG) is a typical FVG located at a point where the price is breaking new Highs or Lows.
🔶 USAGE
In the screenshot above, the price range is visualized by Donchian Channels.
In theory, the Breakaway FVGs should generally be a good indication of market participation, showing favor in the FVG's breaking direction. This is a combination of buyers or sellers pushing markets quickly while already at the highest high or lowest low in recent history.
While this described reasoning seems conventional, looking into it inversely seems to reveal a more effective use of these formations.
When the price is pushed to the extremities of the current range, the price is already potentially off balance and over-extended. Then an FVG is created, extending the price further out of balance.
With this in consideration, After identifying a Breakaway FVG, we could logically look for a reversion to re-balance the gap.
However, it would be illogical to believe that the FVG will immediately mitigate after formation. Because of this, the dashboard display for this indicator shows the analysis for the mitigation likelihood and timeliness.
In the example above, the information in the dashboard would read as follows (Bearish example):
Out of 949 Bearish Breakaway FVGs, 80.19% are shown to be mitigated within 60 bars, with the average mitigation time being 13 bars.
The other 19.81% are not mitigated within 60 bars. This could mean the FVG was mitigated after 60 bars, or it was never mitigated.
The unmitigated FVGs within the analysis window will extend their mitigation level to the current bar. We can see the number of bars since the formation is represented to the right of the live mitigation level.
Utilizing the current distance readout helps to better judge the likelihood of a level being mitigated.
Additionally, when considering these mitigation levels as targets, an additional indicator or analysis can be used to identify specific entries, which would further aid in a system's reliability.
🔶 SETTINGS
Trend Length: Sets the (DC) Trend length to use for Identifying Breakaway FVGs.
Show Mitigation Levels: Optionally hide mitigation levels if you would prefer only to see the Breakaway FVGs.
Maximum Duration: Sets the analysis duration for FVGs, Past this length in bars, the FVG is counted as "Un-Mitigated".
Show Dashboard: Optionally hide the dashboard.
Use Median Duration: Display the Median of the Bar Length data set rather than the Average.
Triangular Moving AverageTriangular Moving Average (TMA)
The Triangular Moving Average (TMA) indicator is a versatile tool designed for traders seeking a smoother trend-following experience. By applying a double-smoothing technique, the TMA reduces market noise and highlights significant price trends, making it an ideal choice for identifying direction and potential reversals.
Key Features:
Customizable Period: Adjust the period length to suit your trading strategy.
Selectable Price Type: Choose from Close, Open, High, Low, Median, Typical, or Weighted prices.
Multi-Timeframe Capability: Analyze trends across different timeframes for confluence.
This indicator also dynamically changes color to reflect trend direction, helping traders visualize momentum shifts more effectively:
Green: Bullish trend (upward movement).
Red: Bearish trend (downward movement).
Gray: Neutral or flat movement.
Disclaimer
This indicator is a technical analysis tool and should not be considered financial advice. Trading involves substantial risk, and past performance is not indicative of future results. Always do your own research and consult with a licensed financial advisor before making trading decisions. The author is not responsible for any losses incurred through the use of this indicator.
10% Drop from Current High - Akshay10% Drop from Current High TradingView Indicator
Description:
The "10% Drop from Current High" indicator dynamically tracks the highest price within a user-defined period and highlights when the current price drops by a specified percentage. This tool is invaluable for traders looking to monitor significant pullbacks or corrections from recent highs.
Key Features:
Customizable Drop Percentage:
Allows users to set the percentage drop to track, with a default value of 10%.
Configurable via an input field to suit different trading strategies and market conditions.
Lookback Period:
Tracks the highest price over a user-defined lookback period (default is 20 bars).
This ensures the indicator adapts to short-term or long-term market conditions based on user preferences.
Dynamic Levels:
Current High Level: Plots the highest price within the lookback period in blue.
Drop Level: Plots the calculated drop level (e.g., 10% below the current high) in red.
Visual Alerts:
Background Highlighting:
A translucent red background appears when the current price is at or below the drop level, signaling a significant pullback.
Shape Marker:
A downward label is plotted below the bar when the price touches or falls below the drop level, providing cSet Alerts:lear visual feedback.
Overlay on Price Chart:
The indicator is plotted directly on the price chart (overlay=true), ensuring seamless integration with other technical analysis tools.
Use Case:
This indicator is designed for traders who want to:
Monitor Pullbacks:
Identify when the price of an asset experiences a defined percentage drop from its recent high, signaling potential reversal zones or buying opportunities.
Use visual cues to react quickly to price movements.
Analyze Trends:
Combine with other indicators to assess the strength of trends and corrections.
Customization Options:
Drop Percentage: Adjust the percentage drop to track based on asset volatility and trading strategy.
Lookback Period: Modify the lookback period to focus on short-term (e.g., 5 bars) or long-term (e.g., 50 bars) price highs.
This indicator provides a flexible and intuitive way to track price pullbacks, helping traders make informed decisions and stay ahead in dynamic market conditions.
Fancy Oscillator Screener [Daveatt]⬛ OVERVIEW
Building upon LeviathanCapital original RSI Screener (), this enhanced version brings comprehensive technical analysis capabilities to your trading workflow. Through an intuitive grid display, you can monitor multiple trading instruments simultaneously while leveraging powerful indicators to identify market opportunities in real-time.
⬛ FEATURES
This script provides a sophisticated visualization system that supports both cross rates and heat map displays, allowing you to track exchange rates and percentage changes with ease. You can organize up to 40 trading pairs into seven customizable groups, making it simple to focus on specific market segments or trading strategies.
If you overlay on any circle/asset on the chart, you'll see the accurate oscillator value displayed for that asset
⬛ TECHNICAL INDICATORS
The screener supports the following oscillators:
• RSI - the oscillator from the original script version
• Awesome Oscillator
• Chaikin Oscillator
• Stochastic RSI
• Stochastic
• Volume Oscillator
• CCI
• Williams %R
• MFI
• ROC
• ATR Multiple
• ADX
• Fisher Transform
• Historical Volatility
• External : connect your own custom oscillator
⬛ DYNAMIC SCALING
One of the key improvements in this version is the implementation of dynamic chart scaling. Unlike the original script which was optimized for RSI's 0-100 range, this version automatically adjusts its scale based on the selected oscillator.
This adaptation was necessary because different indicators operate on vastly different numerical ranges - for instance, CCI typically ranges from -200 to +200, while Williams %R operates from -100 to 0.
The dynamic scaling ensures that each oscillator's data is properly displayed within its natural range, making the visualization both accurate and meaningful regardless of which indicator you choose to use.
⬛ ALERTS
I've integrated a comprehensive alert system that monitors both overbought and oversold conditions.
Users can now set custom threshold levels for their alerts.
When any asset in your monitored group crosses these thresholds, the system generates an alert, helping you catch potential trading opportunities without constant manual monitoring.
em will help you stay informed of market movements and potential trading opportunities.
I hope you'll find this tool valuable in your trading journey
All the BEST,
Daveatt
FU Candle Indicator V3.2What the FU Candle Indicator does:
First we need to understand what FU candles are. There's bullish and bearish FU candles.
Bullish FU candles are candles that have a long wick that takes out the previous candles low, then turns around and closes above the high of the previous candle.
Bearish FU candles are candles that have a long wick that takes out the previous candles high, then turns around and closes below the low of the previous candle.
Then there's so called attempted FU candles (ATT FU)
The difference between normal FU candles and ATT FU candles is, that the ATT FU candle doesn't close above/below the high/low of the previous candle but only above the previous candle's body close.
Bullish ATT FU Candle:
Bearish ATT FU Candle:
Detection of Bullish FU Candles:
Bullish FU Candles are detected by measuring the distance between the low of the previous candle and the low of the current candle.
Then the distance between the previous candles high and the current candles close price are measured.
If current candle low < previous candle low and current candle close > previous candle high = Bullish FU Candle.
Detection of Bullish ATT FU Candles:
Bullish ATT FU Candles are detected by measuring the distance between the low of the previous candle and the low of the current candle.
Then the distance between the previous candles close or open price and the current candles close price are measured. If the previous candle closed bearish, the open price is used for comparison, if the previous candle closed bullish, the close price is used for comparison.
If current candle low < previous candle low and current candle close > previous candle open or close = Bullish ATT FU Candle.
Detection of Bearish FU Candles:
Bearish FU Candles are detected by measuring the distance between the high of the previous candle and the high of the current candle.
Then the distance between the previous candles low, AND the current candles close price are measured.
If current candle high > previous candle high, AND current candle close < previous candle low = Bearish FU Candle.
Detection of Bearish ATT FU Candles:
Bearish ATT FU Candles are detected by measuring the distance between the high of the previous candle and the high of the current candle.
Then the distance between the previous candles close or open price and the current candles close price are measured. If the previous candle closed bearish, the open price is used for comparison, if the previous candle closed bullish, the close price is used for comparison.
If current candle high > previous candle high and current candle close < previous candle open or close = Bearish ATT FU Candle.
What makes this script unique?
It shows and liquidity grab and a break of structure on a lower timeframe in one candle.
It allows to adjust the settings for the asset and timeframe you're using
The built in filters (Fractal Filter and EMA Filter) are both optional but allow to filter out certain candles and most importantly it leaves room for experimentation and optimisation to your trading style.
Input Settings and how to use them:
Bullish FU Candle Color --> This setting is to set the color for bullish FU candles.
Bearish FU Candle Color --> This setting is to set the color for bearish FU candles.
Chart --> This setting enables you to display FU's on different timeframes instead of only the current time. It's set to current timeframe by default.
Liq. Grab in Points --> This is the strength of the liquidity grab. By how many points has the current candle taken out the low/ high of the previous candle. It's set to 20 by default but it has to be adjusted to the timeframe and asset you're using.
Engulfing in Points --> This the strength of the engulfing of the previous candle. It measures the distance of the current close price to the open, close, high or low of the previous candle. It depends if the current candle is bullish or bearish and if the previous candle was bullish or bearish and if ATT FUs are enabled but this setting applies to all methods. It's set to 20 by default but you have to adjust it to the asset and timeframe you're using.
Min. Size in Points --> This setting is to filter out tiny candles. It measures the overall size of the FU candle from low to high. It's set to 20 by default but you have to adjust it to the asset and timeframe you are using.
Min. Body Size in Points --> This setting is to filter out FU candles that have a tiny body. It measures the size of the body from open to close. It's set to 20 by default but you have to adjust it to the asset and timeframe you are using.
Max. Body Size in Points --> This setting is to filter out FU candles that have a huge body. It measures the size of the body from open to close. It's set to 10000 by default but you have to adjust it to the asset and timeframe you are using.
Show ATT FU Candles --> ATT FU Candles are FU's where the body only engulfs the previous candles body but not the wick. This type of FU candles is just as valid as the strong FU's where the Body and the wick of the previous Candle is engulfed. The setting is enabled by default.
Rejection Filter --> This setting is used filter out FU candles where the opposite side rejection is stronger than the body direction of the FU. This filters out a lot of traps. It's disabled by default.
Fractal Filter --> FU's are only valid if they broke a fractal of the past x candles. This filters out some of the FU candles that are inside a range and therefore invalid. This is an optional filter and disabled by default.
EMA Filter --> FU's are only if they are above/ below the EMA. This is to filter out most of the FU candles that are inside ranges. The EMA period can be set too. This is an optional filter and enabled and EMA length set to 7 by default. You can enable it and/ or change the length of the EMA to fit your trading style.
Show Entry Lines --> The entry line setting has been changed in terms of styling. The upper and lower line has been removed. Now only the 50% retracement line of the candle body is displayed and the line type, color, strength and length can be set to keep charts as clean as possible.
Alert Timeframes --> You can select the timeframes for which you want to receive an alert if you set and alert for the FU Candle indicator. If you set an alert for the FU Candle Indicator it will send an alert for every FU candle on every selected timeframe.
TF1-TF8 --> This setting is to enable or disable alerts for timeframe 1 - timeframe 8. By default all alerts are disabled, I recommend only enabling the ones that you actually use.
Recommended use:
A bullish FU candle doesn't necessarily mean it's a long and vice versa a bearish FU candle doesn't necessarily mean it's a short. In fact, most FU candles are traps. Often times you'll see a bullish FU candle starting a bearish reversal.
Whenever you see an FU Candle check the following:
Did the FU candle take relevant liquidity?
Is the FU Candle in line with the overall bias or does it go against the bias?
Where did the FU react? Example: A bearish FU candle that reacts in a bullish FVG is a perfect long entry and vice versa.
A bullish FU candle that takes out a relevant swing high can often be a fake-out and price can immediately reverse as the next candle opens.
Timing is also very important. Usually the valid FU candles happen after a strong move to one direction during high volume times and right before or right after a new candle opens on a higher timeframe.
Examples of valid setups:
Nr. 1) Mitigation Setup
Overall bullish on the higher time frame, liquidity grab to the downside, shift in momentum, strong move to the upside left a FVG. later price comes back into the FVG and forms a FU candle --> perfect long trade targeting the opposite side of the range.
Entry either at close of the FU or at the 50% retracement.
Nr. 2) Trap Setup
Clear bullish trend respecting the trend line, bearish FU candle forms but it didn't take any relevant liquidity to the upside. Only internal range liquidity. Perfect long entry using a buy limit below the lower wick of the FU candle with the SL below the nearest low.
Nr. 3) Liquidity Grab Setup
Bearish trend, price comes up aggressively and takes out a high and forms an FU Candle. Market entry short at close of the FU candle or at the 50% retracement of the FU candle or by putting a limit order right above the wick of the candle that follows the FU candle, targeting the opposite side of the range.
Nr. 4) Fake Breakout Setup
Price takes out a significant HTF low, then makes at least 2 BOS on the LTF and forms an Order Block or leaves an FVG. Price forms a bearish U that fails to close below the FVG or Orderblock.
Market entry long at the close of the bearish FU targeting the opposite side of the range. Vice versa for shorts. In simple terms: Bullish FUs at the top of the range and bearish FUs at the bottom of the range are usually always traps.
Sometimes price takes out the high/low of a trap FU before reversing aggressively so you can also have a limit order below the low of the bearish FU or above the high of a bullish FU in this case. But you risk missing the trade.
Entry Methods:
Entry Type 1) Market Entry at the close of the FU candle. --> Never miss a trade, not the best RRR.
Entry Type 2 Limit Entry at the 50% retracement of the body of the FU candle. --> Miss some of the trades but better RRR.
Entry Type 3 Limit order below the wick of the candle that follows the FU candle. --> Miss quite a lot of trades but by far best RRR.
Why this is a closed source script:
The source code of this script is not open because I have spent several years of my life developing it and I use it in all my trading bots.
Also I'm open for feedback and will modify/ update the script for free if I get input that can make it better.
For questions, please reach out via DM or check out my youtube channel. I have several videos explaining in detail how I use these candles, which are valid and which aren't.
Fourier Extrapolation of PriceThis advanced algorithm leverages Fourier analysis to predict price trends by decomposing historical price data into its frequency components. Unlike traditional algorithms that often operate in lower-dimensional spaces, this method harnesses a multidimensional approach to capture intricate market behaviors. By utilizing additional dimensions, the algorithm identifies and extrapolates subtle patterns and oscillations that are typically overlooked, providing a more robust and nuanced forecast.
Ideal for traders seeking a deeper understanding of market dynamics, this tool offers an enhanced predictive capability by aligning its calculations with the complexity of real-world financial systems.
DNSE VN301!, SMA & EMA Cross StrategyDiscover the tailored Pinescript to trade VN30F1M Future Contracts intraday, the strategy focuses on SMA & EMA crosses to identify potential entry/exit points. The script closes all positions by 14:25 to avoid holding any contracts overnight.
HNX:VN301!
www.tradingview.com
Setting & Backtest result:
1-minute chart, initial capital of VND 100 million, entering 4 contracts per time, backtest result from Jan-2024 to Nov-2024 yielded a return over 40%, executed over 1,000 trades (average of 4 trades/day), winning trades rate ~ 30% with a profit factor of 1.10.
The default setting of the script:
A decent optimization is reached when SMA and EMA periods are set to 60 and 15 respectively while the Long/Short stop-loss level is set to 20 ticks (2 points) from the entry price.
Entry & Exit conditions:
Long signals are generated when ema(15) crosses over sma(60) while Short signals happen when ema(15) crosses under sma(60). Long orders are closed when ema(15) crosses under sma(60) while Short orders are closed when ema(15) crosses over sma(60).
Exit conditions happen when (whichever came first):
Another Long/Short signal is generated
The Stop-loss level is reached
The Cut-off time is reached (14:25 every day)
*Disclaimers:
Futures Contracts Trading are subjected to a high degree of risk and price movements can fluctuate significantly. This script functions as a reference source and should be used after users have clearly understood how futures trading works, accessed their risk tolerance level, and are knowledgeable of the functioning logic behind the script.
Users are solely responsible for their investment decisions, and DNSE is not responsible for any potential losses from applying such a strategy to real-life trading activities. Past performance is not indicative/guarantee of future results, kindly reach out to us should you have specific questions about this script.
---------------------------------------------------------------------------------------
Khám phá Pinescript được thiết kế riêng để giao dịch Hợp đồng tương lai VN30F1M trong ngày, chiến lược tập trung vào các đường SMA & EMA cắt nhau để xác định các điểm vào/ra tiềm năng. Chiến lược sẽ đóng tất cả các vị thế trước 14:25 để tránh giữ bất kỳ hợp đồng nào qua đêm.
Thiết lập & Kết quả backtest:
Chart 1 phút, vốn ban đầu là 100 triệu đồng, vào 4 hợp đồng mỗi lần, kết quả backtest từ tháng 1/2024 tới tháng 11/2024 mang lại lợi nhuận trên 40%, thực hiện hơn 1.000 giao dịch (trung bình 4 giao dịch/ngày), tỷ lệ giao dịch thắng ~ 30% với hệ số lợi nhuận là 1,10.
Thiết lập mặc định của chiến lược:
Đạt được một mức tối ưu ổn khi SMA và EMA periods được đặt lần lượt là 60 và 15 trong khi mức cắt lỗ được đặt thành 20 tick (2 điểm) từ giá vào.
Điều kiện Mở và Đóng vị thế:
Tín hiệu Long được tạo ra khi ema(15) cắt trên sma(60) trong khi tín hiệu Short xảy ra khi ema(15) cắt dưới sma(60). Lệnh Long được đóng khi ema(15) cắt dưới sma(60) trong khi lệnh Short được đóng khi ema(15) cắt lên sma(60).
Điều kiện đóng vị thể xảy ra khi (tùy điều kiện nào đến trước):
Một tín hiệu Long/Short khác được tạo ra
Giá chạm mức cắt lỗ
Lệnh chưa đóng nhưng tới giờ cut-off (14:25 hàng ngày)
*Tuyên bố miễn trừ trách nhiệm:
Giao dịch hợp đồng tương lai có mức rủi ro cao và giá có thể dao động đáng kể. Chiến lược này hoạt động như một nguồn tham khảo và nên được sử dụng sau khi người dùng đã hiểu rõ cách thức giao dịch hợp đồng tương lai, đã đánh giá mức độ chấp nhận rủi ro của bản thân và hiểu rõ về logic vận hành của chiến lược này.
Người dùng hoàn toàn chịu trách nhiệm về các quyết định đầu tư của mình và DNSE không chịu trách nhiệm về bất kỳ khoản lỗ tiềm ẩn nào khi áp dụng chiến lược này vào các hoạt động giao dịch thực tế. Hiệu suất trong quá khứ không chỉ ra/cam kết kết quả trong tương lai, vui lòng liên hệ với chúng tôi nếu bạn có thắc mắc cụ thể về chiến lược giao dịch này.
Session High/Low Average & Range [1CG]The Session High/Low Average & Range indicator independently measures the average price movement from the opening price in each direction. It also displays the maximum high and low distance, called Range. Separating the averages and range into highs and lows helps analyze the volatility of the market as well as the direction.
USE EXAMPLES
Session Open
Session Close
Customization
Minimal - 1x and 2x Averages are replaced with custom lines, in order to show distance to3x.
Calculations
Average High: (high price of session - session opening price) / (session period)
Average Low: (session opening price - low price of session) / (session period)
Range High: The highest price of the last (session period)
Range Low: The lowest price of the last (session period)
INPUTS
Session
Here you can choose the hours for your session and time zone. The default is London session in New York time. Next, the session period determines how many sessions to sample from for the average and range lines, the default is 20. Lastly, you can choose the number of sessions to appear on the chart not including the current session if you are in one, 5 by default.
Lines
All of the lines allow you to change the color, width, and style. They also have a label option to choose to display the price. The bottom of the section allows you to change the location and size of the label text.
**Open Line** -Displays the opening price for the length of the session.
**Average Lines** - Displays the 1x, 2x, and 3x the average distance from open in each direction. Additionally, you can toggle a background color to highlight the area.
**Custom Lines** - Displays a customizable multiple of either the average or range. By default the first custom line displays the Range at a 1x multiplier and the second line displays an Average at a 1.5x multiplier
Display Distance
Here you can choose to display the distance from the lines to the open. This data is marked with a “Δ”. For the three Average lines this will display in the area between the line and the open in the position and size of your choice. The custom lines will have the distance information displayed on the line itself. This helps keep the data organized.
Customizable Days Range HighlighterThis Pine Script highlights ranges where consecutive green candles (bullish candles) form a price move within a specified percentage range.
It draws a visual box to represent this move, with the ability to customize both the percentage range and the number of consecutive green candles required to trigger the highlight.
The script calculates the range based on the low to close of the candles, allowing you to focus on the body of the candle (excluding wicks).
Key Features:
Customizable Percentage Range: Set a range (from and to) for the percentage price move between the lowest low and the close of the candle. This enables you to target specific price moves based on your trading strategy.
Consecutive Green Candle Range: Highlight moves only after a specific number of consecutive green candles. You can define the minimum and maximum number of green candles (days) that must be present for the range to be considered valid.
Wick Option: Choose whether to include wicks in the price move calculation or focus purely on the low to close of each green candle (body of the candle).
Visual Highlights: When a valid range is identified, the script draws a green box around the price move and labels it with the calculated percentage move. This helps you visually spot significant bullish price moves.
Parameters:
Percentage Move From: Minimum percentage move between the low and close of the candle for the range to be highlighted.
Percentage Move To: Maximum percentage move for the range to be considered valid.
Minimum and Maximum Green Candles: Set the minimum and maximum number of consecutive green candles (bullish candles) to trigger the range highlight.
Include Wicks: Choose whether to include the candle wicks in the percentage calculation or focus on the body (low to close).
How It Works:
The script tracks consecutive green candles and calculates the range from the low to close of each green candle.
When a valid range is found, where the price move falls within the defined percentage range and the consecutive green candles are within the specified days range, a box is drawn around the price move.
A label is also placed on the chart, showing the percentage move, to help you quickly identify potentially significant price movements.
This tool is ideal for traders who are looking for specific bullish moves over a series of green candles and want to visually identify those opportunities based on price movement and percentage change.
ManipulationLegHelperLibraryLibrary "ManipulationLegHelperLibrary"
TODO: add library description here
devToArray(dev)
Parameters:
dev (string)
getDev(d, bull, h, l)
Parameters:
d (float)
bull (bool)
h (float)
l (float)
getBearLeg(sweeps, minLegSize, drawLegBox, boxColor)
Parameters:
sweeps (int)
minLegSize (float)
drawLegBox (bool)
boxColor (color)
getBullLeg(sweeps, minSize, drawBox, boxColor)
Parameters:
sweeps (int)
minSize (float)
drawBox (bool)
boxColor (color)
leg
Fields:
time (series int)
low (series float)
high (series float)
edge (series bool)
edge_price (series float)
validated (series int)
sweeps (series int)
barC (series int)
bx (series box)
EMAs MTF (Miu)This indicator plots multiple EMA (Exponential Moving Average) on chart.
You can set up to 3 different EMA for the current timeframe and you can add up to 3 more different EMA with a different timeframe. So you can have up to 6 EMAs on your chart.
This way you can easily see multiple EMA lines with a single indicator to setup.
Indicator will automaticaly plot labels with symbol's price, timeframe and which EMA is set for easy identification.
You can also set an alert that will trigger anytime current price crosses any active EMA.
Alerts will provide detailed information such as:
1) Symbol
2) Which EMA and timeframe that has been crossed
3) Current symbol price
Feel free to give feedbacks on comments section below. Suggestions are welcome.
Enjoy!
Trend Stability Index (TSI)Overview
The Trend Stability Index (TSI) is a technical analysis tool designed to evaluate the stability of a market trend by analyzing both price movements and trading volume. By combining these two crucial elements, the TSI provides traders with insights into the strength and reliability of ongoing trends, assisting in making informed trading decisions.
Key Features
• Dual Analysis: Integrates price changes and volume fluctuations to assess trend stability.
• Customizable Periods: Allows users to set evaluation periods for both trend and volume based on their trading preferences.
• Visual Indicators: Displays the Trend Stability Index as a line chart, highlights neutral zones, and uses background colors to indicate trend stability or instability.
Configuration Settings
1. Trend Length (trendLength)
• Description: Determines the number of periods over which the price stability is evaluated.
• Default Value: 15
• Usage: A longer trend length smooths out short-term volatility, providing a clearer picture of the overarching trend.
2. Volume Length (volumeLength)
• Description: Sets the number of periods over which trading volume changes are assessed.
• Default Value: 15
• Usage: Adjusting the volume length helps in capturing significant volume movements that may influence trend strength.
Calculation Methodology
The Trend Stability Index is calculated through a series of steps that analyze both price and volume changes:
1. Price Change Rate (priceChange)
• Calculation: Utilizes the Rate of Change (ROC) function on the closing prices over the specified trendLength.
• Purpose: Measures the percentage change in price over the trend evaluation period, indicating the direction and momentum of the price movement.
2. Volume Change Rate (volumeChange)
• Calculation: Applies the Rate of Change (ROC) function to the trading volume over the specified volumeLength.
• Purpose: Assesses the percentage change in trading volume, providing insight into the conviction behind price movements.
3. Trend Stability (trendStability)
• Calculation: Multiplies priceChange by volumeChange.
• Purpose: Combines price and volume changes to gauge the overall stability of the trend. A higher positive value suggests a strong and stable trend, while negative values may indicate trend weakness or reversal.
4. Trend Stability Index (TSI)
• Calculation: Applies a Simple Moving Average (SMA) to the trendStability over the trendLength period.
• Purpose: Smooths the trend stability data to create a more consistent and interpretable index.
Trend/Ranging Determination
• Stable Trend (isStable)
• Condition: When the TSI value is greater than 0.
• Interpretation: Indicates that the current trend is stable and likely to continue in its direction.
• Unstable Trend / Range-bound Market
• Condition: When the TSI value is less than or equal to 0.
• Interpretation: Suggests that the trend may be weakening, reversing, or that the market is moving sideways without a clear direction.
Visualization
The TSI indicator employs several visual elements to convey information effectively:
1. TSI Line
• Representation: Plotted as a blue line.
• Purpose: Displays the Trend Stability Index values over time, allowing traders to observe trend stability dynamics.
2. Neutral Horizontal Line
• Representation: A gray horizontal line at the 0 level.
• Purpose: Serves as a reference point to distinguish between stable and unstable trends.
3. Background Color
• Stable Trend: Green background with 80% transparency when isStable is true.
• Unstable Trend: Red background with 80% transparency when isStable is false.
• Purpose: Provides an immediate visual cue about the current trend’s stability, enhancing the interpretability of the indicator.
Usage Guidelines
• Identifying Trend Strength: Utilize the TSI to confirm the strength of existing trends. A consistently positive TSI suggests strong trend momentum, while a negative TSI may signal caution or a potential reversal.
• Volume Confirmation: The integration of volume changes helps in validating price movements. Significant price changes accompanied by corresponding volume shifts can reinforce the reliability of the trend.
• Entry and Exit Signals: Traders can use crossovers of the TSI with the neutral line (0 level) as potential entry or exit points. For instance, a crossover from below to above 0 may indicate a bullish trend initiation, while a crossover from above to below 0 could suggest bearish momentum.
• Combining with Other Indicators: To enhance trading strategies, consider using the TSI in conjunction with other technical indicators such as Moving Averages, RSI, or MACD for comprehensive market analysis.
Example Scenario
Imagine analyzing a stock with the following observations using the TSI:
• The TSI has been consistently above 0 for the past 30 periods, accompanied by increasing trading volume. This scenario indicates a strong and stable uptrend, suggesting that buying opportunities may be favorable.
• Conversely, if the TSI drops below 0 while the price remains relatively flat and volume decreases, it may imply that the current trend is losing momentum, and the market could be entering a consolidation phase or preparing for a trend reversal.
Conclusion
The Trend Stability Index is a valuable tool for traders seeking to assess the reliability and strength of market trends by integrating price and volume dynamics. Its customizable settings and clear visual indicators make it adaptable to various trading styles and market conditions. By incorporating the TSI into your trading analysis, you can enhance your ability to identify and act upon stable and profitable trends.
Momentum BBPCT Z-Score [QuantAlgo]Momentum BBPCT Z-Score 💫📈
The Momentum BBPCT Z-Score by QuantAlgo is an advanced indicator designed to identify statistical extremes and momentum shifts in price action across various timeframes and market conditions. This system combines Bollinger Bands percentage analysis with Z-score calculations and Statistical Momentum evaluation to help traders and investors identify overbought/oversold conditions and trend strength. By evaluating both statistical extremes and momentum together, this tool empowers users to make data-driven decisions, whether they aim to follow trends or capture mean reversion opportunities.
💫 Conceptual Foundation and Innovation
The Momentum BBPCT Z-Score by QuantAlgo provides a unique framework for assessing price action and momentum through a blend of statistical analysis and momentum evaluation. Unlike traditional Bollinger Band indicators that only reflect price position, this system incorporates Z-score normalization to reveal statistically significant deviations, helping users determine whether price movements are extreme relative to historical norms. By combining high-quality momentum analysis with Z-scores of Bollinger Band positioning, it evaluates both statistical probabilities and momentum quality, while Z-scores standardize deviations from historical trends, enabling traders and investors to spot extreme conditions. This dual approach allows users to better identify mean reversion opportunities while respecting strong momentum conditions, enhancing both counter-trend and trend-following strategies.
📊 Technical Composition and Calculation
The Momentum BBPCT Z-Score is composed of several statistical and momentum components that create a dynamic dual scoring model:
Bollinger Bands Percentage (BBPCT) : Measures the relative position of price between bands on a 0-100 scale, providing a normalized view of price extremes relative to the bands.
Z-Score Normalization : Applies statistical normalization to BBPCT values to identify significant deviations from historical means, helping traders and investors quantify the extremity of current market conditions.
Statistical Momentum Analysis : Evaluates price action across multiple periods to determine momentum strength and persistence, adding depth to the analysis beyond simple price positioning.
📈 Key Indicators and Features
The Momentum BBPCT Z-Score combines various statistical and technical tools to deliver a well-rounded analysis of market conditions.
The indicator utilizes dynamic Bollinger Bands with customizable length and standard deviation multipliers to adapt to market volatility. Z-score calculations are applied to normalize the percentage position within these bands, providing clear statistical context for price movements. The Statistical Momentum component evaluates price action across user-defined periods, helping validate trends and identify potential reversals.
The indicator also incorporates multi-layered visualization with gradient color coding to signal both statistical extremes and momentum conditions. These adaptive visual cues, combined with threshold-based alerts for overbought and oversold zones, help traders and investors track both statistical extremes and momentum shifts, adding reliability to both mean-reversion and trend-following strategies.
⚡️ Practical Applications and Examples
✅ Add the Indicator: Add the indicator to your TradingView chart by clicking on the star icon to add it to your favorites ⭐️
👀 Monitor Z-Scores and Momentum: Watch the Z-score values and momentum state to identify statistically significant price movements. During extreme readings, consider mean reversion opportunities, while strong momentum readings may signal trend-following opportunities.
🔔 Set Alerts: Configure alerts for Z-score extremes and momentum shifts, ensuring you can act on significant statistical and trend changes promptly.
🌟 Summary
The Momentum BBPCT Z-Score by QuantAlgo is a highly adaptable tool, designed to support both statistical and momentum analysis across different market environments. By combining Z-score normalized Bollinger Band positioning with Statistical Momentum Analysis, it helps traders and investors identify statistically significant price movements while measuring momentum quality, providing more reliable trading signals. The tool's flexibility across timeframes makes it ideal for both mean reversion and trend-following strategies, allowing users to capture opportunities while maintaining statistical rigor in their analysis.