Support, Resistance & OHLCUPDATE:
This Pine Script code is an indicator for TradingView that displays support, resistance, and OHLC (Open, High, Low, Close) data across various timeframes. The code is divided into two main sections: Support/Resistance and OHLC Data.
Support and Resistance:
Logic for Support and Resistance: The indicator draws support and resistance lines after 4 consecutive candles without forming new lows (for support) or new highs (for resistance). This means that a support or resistance level is created after 4 candles that don't set new extremes.
Support: When the last 3 candles have lower lows, and the current candle forms a higher low, the support level is set.
Resistance: When the last 3 candles have higher highs, and the current candle forms a lower high, the resistance level is set.
Drawing the Lines and Labels:
Once the support or resistance level is determined, a horizontal line is drawn that extends left and right from the candle.
Additionally, labels for support and resistance are shown if the corresponding settings are enabled. These labels appear at a distance from the line and display the current support or resistance value.
Deleting the Lines:
If the price falls below the support level or rises above the resistance level, the respective line is deleted. This means that the market has breached the support or resistance level, making the line invalid.
When the support or resistance line is breached, alerts can be triggered to notify the trader.
Alerts:
The script provides options to set alerts when a support or resistance line is created or broken. These alerts notify the trader when the price reaches an important level.
OHLC Data:
The code allows the display of the high, low, close, and open values of the last candles across different timeframes (hourly, daily, weekly, monthly).
Settings:
Options are available to show these values for the respective timeframes.
The user can also adjust the size of the labels.
Visualization: The indicator plots lines for the high, low, and close values for each timeframe and places labels showing the respective values.
In summary, the indicator provides a detailed view of support and resistance levels, which are based on a 4-candle logic, and displays important OHLC values across different timeframes. The indicator also allows setting alerts for specific price levels, so traders can quickly react to market movements.
Candlestick analysis
BUY/SELL Timeframe ContinuityTime frame continuity refers to the alignment of price trends across multiple time frames. This means that the price movement is showing a consistent trend (either up or down) on various timeframes, like the 5-minute, 30-minute, hourly, and daily charts.
Why is it important?
Confirms Trend Strength: When multiple timeframes align, it indicates a strong and sustained trend.
Risk Management: Trading in the direction of the aligned trend can reduce risk.
This indicator checks if the current price of a selected timeframe is above or below its opening price. A buy/sell signal appears the second all bullish timeframes align (buy) or all bearish timeframes align. You can choose to paint the candles when the buy/sell conditions happen. You can select up to 10 different timeframes.
NOTE: With this indicator I prefer timeframes 15m, 30m, 1H, 4H, D, 5D, W - Together these timeframes are great for short-term trends on any stock.
Custom Zig Zag with Absolute Price DifferenceThis Zig-Zag indicator visualizes the price movements of a financial instrument and highlights the relevant turning points (pivots) where the price has undergone a significant change. It uses a deviation threshold to mark only substantial movements and ignore minor fluctuations.
The input parameters allow the user to customize the indicator:
Deviation (%): Defines the minimum percentage deviation required to mark a turning point.
Depth: Specifies how many periods before and after a pivot are considered to determine whether it is a real high or low.
Line Color: Allows the user to change the color of the lines that connect the pivots.
Extend to Last Bar: If enabled, extends the last lines to the current bar.
Display Absolute Price Difference: If enabled, the indicator shows the absolute price difference between the current pivot and the previous one.
Label Size: Allows adjusting the font size of the displayed labels.
The logic of the indicator is based on calculating pivots (highs and lows) using price movements. The indicator then tracks the changes between successive pivots and represents them as lines. When the price shows a significant difference from the last pivot (measured in percentage), a line is drawn, and a label displaying the price difference is shown.
Additionally, the indicator uses the calc_dev function to compute the price deviation between the last pivot and the current price. This provides users with a clear visualization of price changes, helping to identify larger price movements.
Fibonacci Rainbow Day Trade-AYNETSummary of the "Fibonacci Rainbow Day Trade"
This script dynamically calculates Fibonacci retracement levels based on the daily high and low and plots them as colorful lines on the chart. It is designed for day traders to visually identify potential support and resistance zones using Fibonacci levels.
Key Features:
Dynamic Fibonacci Levels:
Levels are calculated using the daily high (day_high) and low (day_low).
Default levels: 0, 0.236, 0.382, 0.5, 0.618, 0.786, 1.
These levels represent key areas where price is likely to react.
Colorful Rainbow Visualization:
Each Fibonacci level is represented by a unique color.
Colors are defined in a rainbow_colors array: red, orange, yellow, green, blue, purple, teal.
Customizable Inputs:
Users can modify the Fibonacci levels, line thickness (fibo_line_width), and whether to show labels.
Labels display the level percentage (e.g., 0.236) at their respective lines.
Optional Labels:
The script includes labels that annotate each Fibonacci level on the chart.
Labels are placed beside the corresponding lines for clarity.
Works on Any Timeframe:
Although the levels are based on the daily high/low, the script can be applied to any intraday timeframe.
Use Case:
Identify Support and Resistance Zones:
Watch for price reactions near Fibonacci levels to determine potential entry/exit points.
Dynamic Updates:
Fibonacci levels are updated daily, ensuring they remain relevant for intraday trading.
Custom Visualization:
Adjust levels, colors, and display options to suit your trading style.
Example Calculation:
Daily High: $120
Daily Low: $100
Fibonacci 0.618 Level: $100 + ($120 - $100) * 0.618 = $111.36
This script provides a visually appealing and effective way to incorporate Fibonacci levels into day trading strategies. 🌈
TraderRob 15M Rob Reversal StrategyTraderRob 15M Rob Reversal
The indicator is for a strategy I saw on YouTube. Check the link below to know the conditions and setup. I also added a threshold to exclude doji candles from signals, but you can adjust it to your liking.
www.youtube.com
Roman's Ranges(GOLD FUTURES)This indicator provides the user with Gold Future's previous day’s range and how long it took for the price to reach its first extreme for the day. This information is used to predict the most probable daily direction trend and estimate how long you should expect to hold your winning trade. The distance and time are based on the market open candle (6:30 am). It measures from the retracement wick of the candle to the last 5m close of the day’s first extreme low or high point. It also includes that distance in pts.
Previous market data does not guarantee future results, however, you can leverage the knowledge of the previous day’s ranges to set reasonable take profit levels and when your target is not met automatically, you know how long it took on the previous day to reach the day’s first low/high. If you are nearing that amount of time and your trade is not as profitable as expected, it is easier to get out with less profits using this estimated time rather than hoping the market closes in your favor.
Markets go through cycles and it can be difficult to trade them all if you have a fault expectation how how far the price is expected to move. Price tends to deviate slowly from the average ranges slightly day after day, but you can expect an average range to prevail throughout the week +/- 3 points. It can be very easy to be stuck on 5-point take-profit levels that you don’t pay attention to the average range being twice or three times that distance. The same can be said for the opposite scenario with having higher profit expectations than reasonably possible.
This indicator and my statements are not financial advice. This is meant for educational purposes only.
Previous High and Low Count with Probabilities + Risk On/Off1. Purpose of the Script:
This trading script combines two important concepts:
Previous High and Low Count: It tracks whether the current price exceeds the previous day’s high or low and calculates probabilities for the next price movement (up or down).
Risk On / Risk Off Indicator: It evaluates market sentiment through various indicators (such as the Fear & Greed Index, VIX, and others) and shows whether the market is in a risk-on or risk-off state. This information impacts the probabilities of price movement.
2. How it Works:
Previous High and Low:
The script tracks how often the price exceeds the previous day’s high or low and calculates the probability of an upward or downward movement based on that. This gives you an idea of how often the market reacts at the previous day's high or low.
Risk On / Risk Off:
Based on various market factors (Fear & Greed Index, VIX, Put-Call Ratio, etc.), the script calculates the Risk On or Risk Off state.
In Risk On, the probability of an upward movement increases, and the probability of a downward movement decreases. In Risk Off, it’s the opposite.
Adjusted Probabilities:
The probabilities for an Up or Down movement are adjusted based on the current Risk On / Risk Off state. In a Risk On environment, the probability for an upward move increases, while in a Risk Off environment, the probability for a downward move increases.
3. How to Use the Script:
Add the Script in TradingView:
TradingView:
Click on "Add to Chart" to apply the script to your chart.
Manual Input of Indicators:
For the Fear & Greed Index, VIX, and other indicators, you need to manually enter the current values. You can get these values from various publicly available sources:
Fear & Greed Index: CNN Fear & Greed Index
VIX (Volatility Index): VIX Index
Other indicators like Put-Call Ratio, Bitcoin Volatility, Oil Prices, and US Dollar Index can also be manually inputted, and they can be found on finance websites like Yahoo Finance, MarketWatch, and Bloomberg.
Observe the Colors and Symbols:
If the market is in a Risk On state, the background will turn green, and a green triangle will appear below the candle.
If the market is in a Risk Off state, the background will turn red, and a red triangle will appear above the candle.
Track the Probabilities:
A label will appear on the chart showing the calculated probabilities for Up and Down movements. These probabilities are adjusted based on the current market state (Risk On/Off).
4. Meaning of the Probabilities:
Up Probability: Indicates the probability that the price will rise.
Down Probability: Indicates the probability that the price will fall.
The probabilities are dynamic and adjust based on the Risk On / Risk Off state, helping you make better decisions based on the current market conditions.
orb[whd]Clash.Verge_2.0.0-rc.7_arm64-setup.nsis.zip25.9MB
Clash.Verge_2.0.0-rc.7_x64_mac_dmg.z0120.0MB
Clash.Verge_2.0.0-rc.7_x64_mac_dmg.zip19.7MB
Clash.Verge_2.0.0-rc.7_x64-setup.nsis.zip28.8MB
ClashVerge32位-win
ClashVerge64位-win
ClashVerge-intel-mac
ClashVerge-m-macClash.Verge_2.0.0-rc.7_arm64-setup.nsis.zip25.9MB
Clash.Verge_2.0.0-rc.7_x64_mac_dmg.z0120.0MB
Clash.Verge_2.0.0-rc.7_x64_mac_dmg.zip19.7MB
Clash.Verge_2.0.0-rc.7_x64-setup.nsis.zip28.8MB
ClashVerge32位-win
ClashVerge64位-win
ClashVerge-intel-mac
ClashVerge-m-mac
Market Open Range Breakaway v1.2Script Name: Market Open Range Breakaway 1.2
This TradingView script, "Market Open Range Breakaway," highlights the market's opening range for a user-selected day of the week. It calculates the high and low prices during a specified period after the market opens, plots these levels, and tracks the opening price. The script dynamically adjusts for time zones and only displays data during market hours on the chosen day, with optional background shading for the defined range period.
Purpose: Identifies and highlights the market's opening range for a selected day of the week.
Features: Calculates and plots the high, low, and open price during the market's opening range.
Configurable range duration (e.g., 15, 30, or 60 minutes).
Automatically adjusts for different time zones.
Displays levels only during market hours on the target day.
Optional background shading for the opening range.
Inputs: Target day of the week.
Opening range duration.
Use Case: Ideal for traders looking to analyze breakout levels or price movements around the opening range.
DAVID AKONJANG FROM TIKO CAMEROON 2This Pine Script (version 5) is a technical analysis indicator for TradingView, created by "David Akonjang from Tiko, Cameroon." Here's a brief description:
1. **Indicator Settings**:
- The indicator is applied directly on the price chart (`overlay=true`).
- It uses the **Relative Strength Index (RSI)** to generate buy and sell signals.
2. **Inputs**:
- `rsi_length`: The RSI calculation period, which defaults to 14 but can be adjusted by the user.
- `source`: The data source for the RSI calculation, defaulting to the closing price.
3. **RSI Calculation**:
- The RSI is calculated using the `ta.rsi` function with the specified period (`rsi_length`) and data source.
4. **Signal Conditions**:
- **Buy Condition**: A "Buy" signal is triggered when the RSI crosses above 70 (indicating a potential overbought condition being breached).
- **Sell Condition**: A "Sell" signal is triggered when the RSI crosses below 30 (indicating a potential oversold condition being breached).
5. **Plotting Signals**:
- **Buy Signals**: Displayed as green upward labels below the price bars where the buy condition is met.
- **Sell Signals**: Displayed as red downward labels above the price bars where the sell condition is met.
### Key Usage:
- This script helps traders identify potential reversal points based on RSI thresholds (overbought and oversold regions).
[TheMandalor] Invert or Mirror Chart SUPPORT RESSISTANTThis is a new idea to find supports and resistant’s for any charts.
What is the concept of this indicator:
1. It is used close and inverted it on chart
2. When the real chart and the inverted chart is crossing together several times, this point will be important on this concept that means the price will care about this point again and again.
3. When you draw a horizontal line as support and resistance check it with this indicator too, if your support and resistance is touched with inverted chart, it will be more important than normal support/ resistance.
4. This indicator has plot candle too, it means you can compare regular chart with the inverted one at same time if you need.
Here is the steps:
1. When you add the indicator to your chart it will add your ticker as inverted.
2. Change your chart type to line chart.
3. Fix your scale in both sides left and right (the indicator's side is on the left).
4. Now you must have two type of line charts, one is yours (The blue one) and one is plotted with this indicator (The purple one).
5. Draw a horizontal line where these two lines have more crossing at the middle of chart, this line will be a powerful line later.
6. Find other more crossed points and draw horizontal line for them too.
7. Now you can see these indicator's support and resistant’s, now you can remove the indicator and watch how the price will touch, reverse, or stay on your new type of support and resistant’s lines.
PS: I have added candle plotting too if you need it.
Volume-Based Bar ColorThis indicator changes the bar color if the bar has more than a specified amount of volume. Best use case would be to apply it to a tick chart (ex: 500 Tick) and set the volume threshold to say 590-600 volume. This would show you visually where and when 18-20% more volume than required was in a candle. That candle can then be used to identify volume based zones where buys and sellers may be in control. Works well with volume profile.
Pinbar Buy/Sell ArrowsPin Bar Detection: The script defines functions for detecting bullish and bearish pin bars based on the proportions of the candlestick body and wicks.
Bullish Pin Bar: Has a long upper wick relative to the body and a body-to-wick ratio below a certain threshold.
Bearish Pin Bar: Has a long lower wick relative to the body and a body-to-wick ratio below a certain threshold.
Arrows: Green "BUY" arrows are plotted below bullish pin bars, and red "SELL" arrows are plotted above bearish pin bars.
ABHITHEMAHI Previous Day High/Low & Round Numbers//@version=5
indicator(title="Previous Day High/Low & Round Numbers", overlay=true)
// Previous Day High and Low
prevHigh = request.security(syminfo.ticker, "D", high )
prevLow = request.security(syminfo.ticker, "D", low )
prevclose = request.security(syminfo.ticker, "D", close )
// Determine if the chart is intraday
isIntraday = ta.change(time("D")) == 0
// Plot Previous Day High and Low
plot(isIntraday ? prevHigh : na, title="Previous Day High", style=plot.style_cross, color=color.red, linewidth=2)
plot(isIntraday ? prevLow : na, title="Previous Day Low", style=plot.style_cross, color=color.green, linewidth=2)
plot(isIntraday ? prevclose : na, title="prevclose", style=plot.style_cross, color=color.green, linewidth=2)
// Round Number Levels
incrementVal = input.float(defval=500, title="Unit Place Rounding Value", tooltip="The Unit Place that a number will be rounded and distance between rounded levels. Example Value setting of 100 and a price of 225.00 would result in a line level value of 200.00; Where a price of 265.00 would result in a line level value of 300 with the same value setting of 100")
lQty = input.int(defval=2, minval=1, maxval=50, title="Line Amount", tooltip="Each Line Amount increase will add a line level above and below baseline level; Baseline = line nearest to price)")
offset = input.int(defval=50, minval=0, maxval=490, step=10, title="Line Price Horizontal Offset", inline="a")
textCol = input.color(defval=color.white, title="Price Label Text Color", tooltip="Use Horizontal Offset to adjust the X position of the price labels. To hide price labels disable Labels on the style tab", inline="a")
belowColor = input.color(defval=color.blue, title="Line Color Below price", inline="b")
aboveColor = input.color(defval=color.orange, title="Line Color Above price", inline="b")
ext = input.string(defval="To Right", options= , title="Extend Line: ")
float iv = incrementVal
lQty := lQty + 1
// Calculate Round Number Levels
RoundValue(value) =>
math.round(value / iv) * iv
baseVal = RoundValue(close)
// Plot Round Number Levels
if isIntraday
for j = 0 to lQty - 1
line.new(bar_index, baseVal + (j * iv), bar_index+1, baseVal + (j * iv), extend=ext == "Both" ? extend.both : extend.right, color=close > baseVal + (j * iv) ? belowColor : aboveColor)
for k = 1 to lQty - 1
line.new(bar_index, baseVal - (k * iv), bar_index+1, baseVal - (k * iv), extend=ext == "Both" ? extend.both : extend.right, color=belowColor)
Fibonacci Candlestick - AYNETHow It Works
Inputs:
ltf_timeframe: Specify the timeframe for candlestick data (e.g., 1H, 4H).
Fibonacci Levels:
Toggle Fibonacci level visibility (show_fib_levels).
Customize Fibonacci line color (fib_color) and width (fib_width).
Candlestick Data:
Fetches open, high, low, and close prices for the specified timeframe using request.security.
Fibonacci Levels:
Calculates standard Fibonacci retracement levels (0.0, 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%) for each candle's high-low range.
Draws horizontal lines for each level using line.new.
Candlestick Visualization:
Plots lower timeframe candles with customizable bullish and bearish colors.
Key Features
Dynamic Fibonacci Levels:
Fibonacci levels are recalculated for each candlestick's high-low range.
Levels update dynamically with new candles.
Candlestick Overlay:
Visualizes candlestick data from the specified timeframe directly on the current chart.
Customizable Appearance:
Configure colors for Fibonacci levels, candlestick bodies, and wicks.
Use Cases
Microstructure Analysis:
Analyze individual candlesticks with their Fibonacci retracements for potential support/resistance zones.
Multi-Timeframe Trading:
Overlay candlestick and Fibonacci data from a lower timeframe onto a higher timeframe chart.
Let me know if you'd like further enhancements or explanations! 😊
Wick Detection (1 and 0) - AYNETDetailed Scientific Explanation
1. Wick Detection Logic
Definition of a Wick:
A wick, also known as a shadow, represents the price action outside the range of a candlestick's body (the region between open and close).
Upper Wick: Occurs when the high value exceeds the greater of open and close.
Lower Wick: Occurs when the low value is lower than the smaller of open and close.
Upper Wick Detection:
pinescript
Kodu kopyala
bool has_upper_wick = high > math.max(open, close)
This checks if the high price of the candle is greater than the maximum of the open and close prices. If true, an upper wick exists.
Lower Wick Detection:
pinescript
Kodu kopyala
bool has_lower_wick = low < math.min(open, close)
This checks if the low price of the candle is less than the minimum of the open and close prices. If true, a lower wick exists.
2. Binary Representation
The presence of a wick is encoded as a binary value for simplicity and computational analysis:
Upper Wick: Represented as 1 if present, otherwise 0.
pinescript
Kodu kopyala
float upper_wick_binary = has_upper_wick ? 1 : 0
Lower Wick: Represented as 1 if present, otherwise 0. This value is inverted (-1) for visualization purposes.
pinescript
Kodu kopyala
float lower_wick_binary = has_lower_wick ? 1 : 0
3. Visualization with Histograms
The plot function is used to create histograms for visualizing the binary wick data:
Upper Wicks: Plotted as positive values with green columns:
pinescript
Kodu kopyala
plot(upper_wick_binary, title="Upper Wick", color=color.new(color.green, 0), style=plot.style_columns, linewidth=2)
Lower Wicks: Plotted as negative values with red columns:
pinescript
Kodu kopyala
plot(lower_wick_binary * -1, title="Lower Wick", color=color.new(color.red, 0), style=plot.style_columns, linewidth=2)
Features and Applications
1. Wick Visualization:
Upper wicks are displayed as positive green columns.
Lower wicks are displayed as negative red columns.
This provides a clear visual representation of wick presence in historical data.
2. Technical Analysis:
Wick formations often indicate market sentiment:
Upper Wicks: Sellers pushed the price lower after buyers drove it higher, signaling rejection at the top.
Lower Wicks: Buyers pushed the price higher after sellers drove it lower, signaling rejection at the bottom.
3. Signal Generation:
Traders can use wick detection to build strategies, such as identifying key price levels or market reversals.
Enhancements and Future Improvements
1. Wick Length Measurement
Instead of binary detection, measure the actual length of the wick:
pinescript
Kodu kopyala
float upper_wick_length = high - math.max(open, close)
float lower_wick_length = math.min(open, close) - low
This approach allows for thresholds to identify significant wicks:
pinescript
Kodu kopyala
bool significant_upper_wick = upper_wick_length > 10 // For wicks longer than 10 units.
bool significant_lower_wick = lower_wick_length > 10
2. Alerts for Long Wicks
Trigger alerts when significant wicks are detected:
pinescript
Kodu kopyala
alertcondition(significant_upper_wick, title="Long Upper Wick", message="A significant upper wick has been detected.")
alertcondition(significant_lower_wick, title="Long Lower Wick", message="A significant lower wick has been detected.")
3. Combined Wick Analysis
Analyze both upper and lower wicks to assess volatility:
pinescript
Kodu kopyala
float total_wick_length = upper_wick_length + lower_wick_length
bool high_volatility = total_wick_length > 20 // Combined wick length exceeds 20 units.
Conclusion
This script provides a compact and computationally efficient way to detect candlestick wicks and represent them as binary data. By visualizing the data with histograms, traders can easily identify wick formations and use them for technical analysis, signal generation, and volatility assessment. The approach can be extended further to measure wick length, detect significant wicks, and integrate these insights into automated trading systems.
Daily Divider 1.0.1Daily Divider with Custom Day Labels is a visual indicator that places vertical dividers on TradingView charts at the start of each day. This indicator helps improve clarity in technical analysis by visually separating each trading session. Additionally, it allows for customization of the day labels with abbreviations (such as “Mon” for Monday, “Tue” for Tuesday, etc.), which are displayed alongside the divider lines.
Features:
• Day Dividers: Draws vertical lines at the start of each trading day to clearly separate daily sessions.
• Custom Day Labels: You can change the day abbreviations (e.g., “Sun” for Sunday, “Mon” for Monday) directly in the indicator settings.
• Style Options: The divider line style (solid, dashed, dotted) and its color can be adjusted to fit your preferences.
• Text Settings: Customize the color and size of the day labels, with the option to show or hide the labels.
• Timeframe Optimization: The divider lines are only drawn on daily or lower timeframes, ensuring they don’t appear on higher timeframes (weekly, monthly, etc.).
This indicator is ideal for traders who perform daily analysis and want a clearer view of the different days of the week on their charts, without the need to manually mark the day divisions.
SPX Open vs SMA AlertThis indicator is specifically designed to identify the first market-relevant candle of the S&P 500 (SPX) after the market opens. The opening price of the trading day is compared to a customizable simple moving average (SMA) period. A visual marker and an alert are triggered when the opening price is above the SMA. Perfect for traders seeking early market trends or integrating automated trading strategies.
Features:
Market Open: The indicator uses the New York market open time (09:30 ET), accounting for time zones and daylight saving time changes.
Flexible Time Offset: Users can set a time offset to trigger alerts after the market opens.
Customizable SMA: The SMA period is adjustable, with a default value of 10.
Visual Representation: A step-line SMA is plotted directly on the chart with subtle transparency and clean markers.
Alert Functionality: Alerts are triggered when conditions are met (opening price > SMA).
Usage:
This indicator is ideal for identifying relevant trading signals early in the session.
Alerts can also serve as triggers for automated trading, e.g., in conjunction with the Trading Automation Toolbox.
Supports both intraday and daily charts.
Alarm Settings:
Select the appropriate symbol (e.g., SPX) and the alert condition "SPX Open > SMA10".
Trigger Settings:
Choose "Once Per Bar Close" to ensure the condition is evaluated at the end of each candle.
If you prefer to evaluate the condition immediately when it becomes true, choose "Once Per Minute".
Duration:
Set the alarm to "Open-ended" if you want it to remain active indefinitely.
Alternatively, set a specific expiration date for the alarm.
BoS yellow candleThe "BoS Yellow Candle" indicator identifies and highlights the first candle that breaks a Break of Structure (BoS) in a given look-back period. A BoS occurs when the price either breaks above the highest high or below the lowest low within a user-defined look-back range (default set between 7 and 12 candles).
Bullish Break of Structure: The first candle to break above the previous high is marked with a yellow body.
Bearish Break of Structure: The first candle to break below the previous low is also marked with a yellow body.
This visual aid helps traders quickly identify potential structural breakouts for further analysis or strategy development.
High & Low Markers between EMA CrossesThis Pine Script code creates a TradingView indicator that marks the highest and lowest points based on EMA (Exponential Moving Average) crosses. Below is a detailed explanation of its features and functionality:
Key Features of the Indicator
Calculation of EMA (Exponential Moving Average):
Calculates the EMA for a user-specified period (default is 20).
The period can be adjusted using the input parameter "EMA Length."
Detection of Crosses Relative to EMA:
Detects when the candle's close crosses above the EMA (ta.crossover) or crosses below it (ta.crossunder).
Tracking and Marking the Highest High:
Begins tracking the highest high after the close crosses above the EMA.
Marks the highest high when the close crosses below the EMA again (default marker color is green).
Tracking and Marking the Lowest Low:
Begins tracking the lowest low after the close crosses below the EMA.
Marks the lowest low when the close crosses above the EMA again (default marker color is red).
User-Customizable Settings:
Allows users to customize the marker colors for highs and lows.
Marker positions can be adjusted using the "Marker Offset" setting (default is 30 ticks).
Optional Display of EMA Line:
The EMA line is calculated but hidden by default (display=display.none).
このPine Scriptコードは、EMA (指数移動平均) のクロスを基準にした高値と安値のマーキングを行うトレーディングビューのインジケーターを作成します。以下に、このインジケーターの特徴と動作を詳細に説明します。
インジケーターの主な特徴
EMA (指数移動平均) の計算:
任意の期間のEMAを計算します(デフォルト値は20)。
ユーザーが「EMA Length」入力パラメータを使用して期間を変更可能。
EMAを基準としたクロスの判定:
ローソク足の終値がEMAを上抜けた場合 (ta.crossover) と、下抜けた場合 (ta.crossunder) を検知します。
高値の追跡とマーキング:
終値がEMAを上抜けたタイミングから始まり、その後の最高値を追跡。
EMAを再度下抜けると、最高値の位置にマーカー(色は緑、デフォルト設定)を表示。
安値の追跡とマーキング:
終値がEMAを下抜けたタイミングから始まり、その後の最安値を追跡。
EMAを再度上抜けると、最安値の位置にマーカー(色は赤、デフォルト設定)を表示。
ユーザー設定のカスタマイズ:
高値・安値マーカーの色を自由に変更可能。
マーカーの表示位置を「Marker Offset」で調整可能(デフォルトは30ティック)。
EMAラインの非表示オプション:
EMA自体は計算されますが、デフォルトでは非表示(display=display.none)。
EMA ZigZagこの「EMA ZigZag」インジケータは、EMA(指数平滑移動平均)とジグザグパターンのコンセプトを組み合わせた独自のテクニカル指標です。価格の動きに対してEMAを基準とし、価格がEMAを越えた際の高値および安値を追跡しながらジグザグ線を描画することで、トレンドの転換点や重要なサポート・レジスタンスレベルを視覚的に確認することができます。
機能と特徴
EMAの計算: 指定された期間のEMA(初期設定では20期間)を計算し、価格の動きに対して柔軟なトレンドラインを提供します。
価格のクロスオーバー検出: ローソク足の終値がEMAを上抜けた(クロスオーバー)もしくは下抜けた(クロスアンダー)タイミングを自動的に検出します。
高値・安値の追跡とジグザグ描画: EMAのクロスに応じて、高値と安値のポイントを追跡し、それらを結ぶジグザグ線を描画します。これにより、トレンドの方向とその転換点を簡単に確認できます。
柔軟なカスタマイズ: ジグザグ線の色やEMAの期間を自由に設定することができ、トレーダーの好みに応じてインジケータを調整できます。
AI Buy/Sell SIgnals by price prediction//@version=5
indicator("AI Buy/Sell SIgnals by price prediction", overlay=true)
learning_times = input.int(200, "Learning times")
ema_length = input.int(1, "EMA length")
learn_filter_length = input.int(5, "SMA Filter length")
learning_block = input.bool(title="Filter Learning data", defval=true)
reaction = input.int(1, "Reaction (1-3)")
a = close
var input_list = array.new_float(100)
var weights = array.new_float(100)
var outt = array.new_float(2)
//def info table
var tab = label.new(bar_index, high, ".", style=label.style_label_left, color=color.white)
infotable = table.new(position=position.top_right, columns=3, rows=3, bgcolor=color.new(color.white, 0))
label.delete(tab)
get_errg(input_array, weights_array, len_of_both) =>
out = 0
for x = 0 to len_of_both
out += int(array.get(weights_array, x) * array.get(input_array, x))
out
//getting inputs
array.set(input_list, 0, ta.valuewhen(bar_index, close, 10))
array.set(input_list, 1, ta.valuewhen(bar_index, close, 20))
array.set(input_list, 2, ta.valuewhen(bar_index, close, 30))
array.set(input_list, 3, ta.valuewhen(bar_index, close, 40))
array.set(input_list, 4, ta.valuewhen(bar_index, close, 50))
array.set(input_list, 5, ta.valuewhen(bar_index, close, 60))
array.set(input_list, 6, ta.valuewhen(bar_index, close, 70))
array.set(input_list, 7, ta.valuewhen(bar_index, close, 80))
array.set(input_list, 8, ta.valuewhen(bar_index, close, 90))
array.set(input_list, 9, ta.valuewhen(bar_index, close, 100))
array.set(input_list, 10, ta.valuewhen(bar_index, open, 10))
array.set(input_list, 11, ta.valuewhen(bar_index, open, 20))
array.set(input_list, 12, ta.valuewhen(bar_index, open, 30))
array.set(input_list, 13, ta.valuewhen(bar_index, open, 40))
array.set(input_list, 14, ta.valuewhen(bar_index, open, 50))
array.set(input_list, 15, ta.valuewhen(bar_index, open, 60))
array.set(input_list, 16, ta.valuewhen(bar_index, open, 70))
array.set(input_list, 17, ta.valuewhen(bar_index, open, 80))
array.set(input_list, 18, ta.valuewhen(bar_index, open, 90))
array.set(input_list, 19, ta.valuewhen(bar_index, open, 100))
// teaching neural network
sma = ta.sma(ta.ema(close, 10), learn_filter_length)
if math.abs(ta.valuewhen(bar_index, sma, 1) - sma) > close / 10000 or not learning_block
for rn = 0 to learning_times
for list_number = 0 to 19
if rn == 0
array.set(weights, list_number, 1) // Initialisiere die Gewichte mit 1
else
target_output = close
current_output = get_errg(input_list, weights, 19)
current_input = array.get(input_list, list_number)
target_input = target_output / current_output * current_input // Berechne die entsprechende Eingabe für das Gewicht
array.set(weights, list_number, target_input)
// getting new output
array.set(outt, 0, get_errg(input_list, weights, 19))
var col = #ff1100
var table_i_col = ''
var pcol = #ff1100
// getting signals
if ta.ema(ta.valuewhen(bar_index, array.get(outt, 0), 1), ema_length) < ta.sma(ta.ema(array.get(outt, 0), ema_length), 10)
col := #39ff14
table_i_col := 'AI Up'
if ta.ema(ta.valuewhen(bar_index, array.get(outt, 0), 1), ema_length) > ta.sma(ta.ema(array.get(outt, 0), ema_length), 10)
col := #ff1100
table_i_col := 'AI down'
if ta.valuewhen(bar_index, col, 50) == col and ta.valuewhen(bar_index, col, 10) == ta.valuewhen(bar_index, col, 20) and ta.valuewhen(bar_index, col, 30) == ta.valuewhen(bar_index, col, 40) and reaction == 1
pcol := col
if ta.valuewhen(bar_index, col, 50) == col and ta.valuewhen(bar_index, col, 10) == ta.valuewhen(bar_index, col, 20) and reaction == 2
pcol := col
if ta.valuewhen(bar_index, col, 50) == col and reaction == 3
pcol := col
// plotting all info
plot(0, "plot2", col, offset=50)
plot(ta.sma(ta.ema(close, 10), 10), color=ta.valuewhen(bar_index, pcol, 50), linewidth=2)
table.cell(infotable, 0, 0, str.tostring(float(array.get(outt, 0))))
table.cell(infotable, 0, 1, str.tostring(float(ta.valuewhen(bar_index, array.get(outt, 0), 50))))
table.cell(infotable, 0, 2, str.tostring(table_i_col))