EMA/DEMA_group_stdThis indicator is like its sister indicator in that it measures dispersion but instead of being cumulative it measures distance between moving averages in each group.
Group 1:11, 13, 18, 21
Group 2:18, 21, 29, 34
Group 3: 29, 34, 47, 55
Group 4: 47, 55, 76, 89
Group 5: 76, 89 123, 144
Group 6: 123, 144, 199, 233
Group 7: 199, 233, 322, 377
How to use
1. Divergences
2. Moving average crosses
3. Momentum
Plotshape colors show when moving averages are nearing a crossover and level can be manually set in menu.
Indicatori e strategie
Unified ATR LevelsThis is a unified ATR-based band plotting indicator.
It allows you to display:
Default ATR (on current timeframe)
Preset ATR (mapped to higher timeframe logic)
User-defined ATR (on any custom timeframe)
✳️ Features:
Configurable multipliers, colors, and line widths
Smart label positioning (left, middle, right)
Clean visuals with adjustable label size
Ideal for multi-timeframe analysis and volatility zones
📌 All feedback welcome!
Tags:
volatility, ATR, multi-timeframe, support-and-resistance, custom-indicator
BB + RSI & Volume FilterThis script overlays three sets of technical filters on your price chart and generates signals when conditions align:
Bollinger Bands
Calculates upper, middle, and lower bands using either SMA or EMA.
Buy signal when price crosses up through the lower band.
Sell signal when price crosses down through the upper band.
Volume Filter
Computes a simple moving average of volume.
Ensures breakout moves have sufficient volume by requiring current volume > SMA(volume) × multiplier.
RSI Filter
Computes RSI on the chosen source.
Buy when RSI crosses above the oversold threshold.
Sell when RSI crosses below the overbought threshold.
Only plots RSI signals that pass the volume filter.
You get:
Bollinger entry/exit shapes (labeled “BB ↑/↓”).
RSI entry/exit shapes (labeled “RSI”) only when volume confirms the move.
Alerts for each signal type.
This combination reduces false breakouts by requiring both volatility (Bollinger) or momentum (RSI) and volume confirmation
👽 TIME PERIODS👽 TIME PERIODS v1.15
Visualize key time divisions and session levels on any chart:
• Timezone‐aware session shading
– Highlight active NY session (configurable HHMM–HHMM and days)
– Adjustable background opacity
• Weekly & Monthly Separators
– Toggle on/off
– Custom color, style (solid/dashed/dotted) & width
• Day-of-Week Labels
– Diamonds at session start for M–S
– Toggle on/off
• Session Open Line
– Horizontal line at each session’s open
– Configurable color, width & “distanceRight” in bars
– Always shows current session
• Midpoint Vertical Line
– Plots halfway between session open & close
– Custom color, style & width
– Toggle on/off
▶ All elements grouped for easy parameter tweaking
▶ Fully timezone-configurable (default America/New_York)
▶ Version 1.15 — added distanceRight feature & current session support
Use this to see exactly where your chosen session, weekly/monthly boundaries, and intraday pivot points fall—across any timeframe.
AlphaTrend//@version=5
indicator('AlphaTrend', shorttitle='AT', overlay=true, format=format.price, precision=2, timeframe='')
coeff = input.float(1, 'Multiplier', step=0.1)
AP = input(14, 'Common Period')
ATR = ta.sma(ta.tr, AP)
src = input(close)
showsignalsk = input(title='Show Signals?', defval=true)
novolumedata = input(title='Change calculation (no volume data)?', defval=false)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend ) ? nz(AlphaTrend ) : upT : downT > nz(AlphaTrend ) ? nz(AlphaTrend ) : downT
color1 = AlphaTrend > AlphaTrend ? #00E60F : AlphaTrend < AlphaTrend ? #80000B : AlphaTrend > AlphaTrend ? #00E60F : #80000B
k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3)
k2 = plot(AlphaTrend , color=color.new(#FC0400, 0), linewidth=3)
fill(k1, k2, color=color1)
buySignalk = ta.crossover(AlphaTrend, AlphaTrend )
sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend )
K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk )
O2 = ta.barssince(sellSignalk )
plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))
plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))
alertcondition(buySignalk and O1 > K2, title='Potential BUY Alarm', message='BUY SIGNAL!')
alertcondition(sellSignalk and O2 > K1, title='Potential SELL Alarm', message='SELL SIGNAL!')
alertcondition(buySignalk and O1 > K2, title='Confirmed BUY Alarm', message='BUY SIGNAL APPROVED!')
alertcondition(sellSignalk and O2 > K1, title='Confirmed SELL Alarm', message='SELL SIGNAL APPROVED!')
alertcondition(ta.cross(close, AlphaTrend), title='Price Cross Alert', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low, AlphaTrend), title='Candle CrossOver Alarm', message='LAST BAR is ABOVE ALPHATREND')
alertcondition(ta.crossunder(high, AlphaTrend), title='Candle CrossUnder Alarm', message='LAST BAR is BELOW ALPHATREND!')
alertcondition(ta.cross(close , AlphaTrend ), title='Price Cross Alert After Bar Close', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low , AlphaTrend ), title='Candle CrossOver Alarm After Bar Close', message='LAST BAR is ABOVE ALPHATREND!')
alertcondition(ta.crossunder(high , AlphaTrend ), title='Candle CrossUnder Alarm After Bar Close', message='LAST BAR is BELOW ALPHATREND!')
yuchenseo 15min intervalsHourly Candle Behaviour Indicator
- 0-15min look for continuation
- 15-30min look for reversal
- 30-45min look for reversal
Dynamic ATR Label//@version=5
indicator("Dynamic ATR Label", overlay=true)
// User definable ATR parameters
atrLength = input.int(14, "ATR Length", minval=1)
priceSource = input.source(close, "Price Source")
// Calculate ATR
atrValue = ta.atr(atrLength)
// Calculate ATR in percentage
atrPercent = (atrValue / priceSource) * 100
// Format the ATR percentage for display
atrText = "ATR: " + str.tostring(atrPercent, "#.##") + "%"
// Create or update the label
var label atrLabel = na
if na(atrLabel)
// Create the label on the first bar
atrLabel := label.new(x=bar_index, y=high, text=atrText,
xloc=xloc.bar_index, yloc=yloc.price, // Define how x and y are interpreted
style=label.style_label_down, color=color.blue,
textcolor=color.white, size=size.normal)
else
// Update the label's position and text on subsequent bars
label.set_xy(atrLabel, x=bar_index, y=high) // Only update x and y coordinates
label.set_text(atrLabel, atrText)
MA Deviationインジケーター名: MA乖離率インジケーター / MA Deviation Indicator
📖 説明(日本語)
このインジケーターは、3本の移動平均線(MA)の乖離率を視覚化し、相場の過熱感やトレンドの強さを判定するためのツールです。
✅ 主な機能
複数の移動平均タイプに対応:SMA, EMA, WMA, RMA, VWMA, HMAから選択可能。
最大3本の移動平均を自由に設定可能。
それぞれのMA間の乖離率(%)をチャートにプロット。
指定した閾値を超えた時に背景色を表示(緑=乖離が正方向に大きい、赤=負方向に大きい)。
データウィンドウ上で「背景表示フラグ」も確認可能(サインが出ているかどうかが数値で確認できます)。
⚠️ 注意事項
乖離率は過去の価格と比較したものであり、将来の価格を保証するものではありません。
短期トレードよりも、トレンドの強弱や過熱感の把握に適しています。
複数のMAを使用しない場合でも、背景色は他の設定されたMAペアで判定されることにご注意ください。
📖 Description (English)
This indicator visualizes the percentage deviation between up to 3 configurable moving averages (MA), helping traders assess trend momentum and potential overextension.
✅ Key Features
Supports multiple MA types: Choose from SMA, EMA, WMA, RMA, VWMA, and HMA.
Set up to 3 custom MAs with different periods.
Plots the deviation (%) between each pair of selected MAs.
Background color highlights extreme deviations (green = strong positive deviation, red = strong negative deviation).
Data Window flag (1 or 0) shows whether background highlight is active.
⚠️ Notes
Deviation percentages are not predictive, but useful for identifying trend strength or market overheating.
Especially useful for trend analysis, not for exact entry signals.
Even if not all lines are shown, the background color may still appear based on the enabled MA comparisons.
Post-Market Session AnalyzerThis script visually analyzes U.S. post-market trading hours (4:00 PM to 8:00 PM EST) by:
a) Highlighting post-market session background
b) Coloring candles based on price direction
c) Marking the final post-market candle with a trend label
Great for:
1) Traders who monitor after-hours price movement
2) Spotting late-day reversals or sentiment shifts
3) Understanding extended trading activity
Your trading time period background fillThis script allows you to add background highlights to charts during any regional trading session, customize your own trading time, and is precise and customizable yet simple and easy to use, making it more convenient to review transactions.
Support global mainstream time zones: The drop-down list includes 30 commonly used IANA time zones (default is Asia/Shanghai) (such as Asia/Shanghai, America/New_York, Europe/London, etc.), one-click switching, no need to manually calculate the time difference.
Fully localized time input: "Start hour/minute" and "End hour/minute" are filled in with the local time of the selected time zone. The end hour defaults to 23:00 and can be adjusted to 0-23 at will.
Accurate time difference splitting: The script internally splits the time zone offset into whole hours and remainder minutes (supports half-hour zones, such as UTC+5:30), and ensures that all parameters are integers when calling timestamp to avoid errors.
Dynamic background rendering: Each K-line is judged according to the UTC timestamp whether it falls within the set range. If it meets the time period, it will be marked with a semi-transparent green background, and it will return to its original state after crossing the time period, helping you to identify the opening, closing or active period of any market at a glance.
Wide range of scenarios: It can be used for time-sharing highlighting of all-weather varieties of foreign exchange and cryptocurrency, and can also be used in conjunction with backtesting and timing strategies to only send signals during the active period of the target market, greatly improving trading efficiency and strategy accuracy.
Just select the region and set the time, and the script will automatically complete all complex time zone conversions and drawing, allowing you to focus on the transaction itself.
Alligator Crossover AlertThe Alligator Indicator consists of:
Jaw (Blue line): 13-period Smoothed Moving Average, shifted by 8 bars
Teeth (Red line): 8-period Smoothed Moving Average, shifted by 5 bars
Lips (Green line): 5-period Smoothed Moving Average, shifted by 3 bars
A crossing of these lines can signal:
Start of a new trend (when lines fan out in order)
Consolidation or end of trend (when lines cross over each other) - The indicator is for visual representation of the crossovers
Previous Day High/Low with Labelsprevious day range, moving averages editable and with notes to add to the screen
Fibonacci Extension Distance Table## 🧾 **Script Name**: Fibonacci Extension Distance Table
### 🎯 Purpose:
This script helps traders visually track **key Fibonacci extension levels** on any chart and immediately see:
* The **price target** at each extension
* The **distance in percentage** from the current market price
It is especially helpful for:
* **Profit targets in trending trades**
* Monitoring **potential resistance zones** in uptrends
* Planning **entry/exit timing**
---
## 🧮 **How It Works**
1. **Swing Logic (A → B → C)**
* It automatically finds:
* `A`: the **lowest low** in the last `swingLen` bars
* `B`: the **highest high** in that same lookback
* `C`: current bar’s low is used as the **retracement point** (simplified)
2. **Extension Formula**
Using the Fibonacci formula:
```text
Extension Price = C + (B - A) × Fibonacci Ratio
```
The script calculates projected target prices at:
* **100%**
* **127.2%**
* **161.8%** (Golden Ratio)
* **200%**
* **261.8%**
3. **Distance Calculation**
For each level, it calculates:
* The **absolute difference** between current price and the extension level
* The **percentage difference**, which helps quickly assess how close or far the market is from that target
---
## 📋 **Table Output in Top Right**
| Level | Target ₹ | Dist % from current price |
| ------ | ---------- | ------------------------- |
| 100% | Calculated | % Above/Below |
| 127.2% | Calculated | % Above/Below |
| 161.8% | Calculated | % Above/Below |
| 200% | Calculated | % Above/Below |
| 261.8% | Calculated | % Above/Below |
* The table updates **live on each bar**
* It **highlights levels** where price is nearing
* Useful in **any time frame** and **any market** (stocks, crypto, forex)
---
## 🔔 Example Use Case
You bought a stock at ₹100, and recent swing shows:
* A = ₹80
* B = ₹110
* C = ₹100
The 161.8% extension = 100 + (110 − 80) × 1.618 = ₹148.54
If the current price is ₹144, the table will show:
* Golden Ratio Target: ₹148.54
* Distance: −4.54
* Distance %: −3.05%
You now know your **target is near** and can plan your **exit or trailing stop**.
---
## 🧠 Benefits
* No need to draw extensions manually
* Automatically adapts to new swing structures
* Supports **scalping**, **swing**, and **positional** strategies
Price Extension from 8 EMAOverview
This indicator can be used to see how far away the price is from the 8 EMA. It compares this to the Average Daily Range % to see if the stock may be overextended. The "Extension Multiplier" represents how far the stock is extended away from the 8 EMA.
Core Concept
This indicator is best used for breakout trades that are trying to make sure they are not chasing the stock.
How to Use This Indicator
This tool is primarily intended for analyzing daily charts of individual stocks and is often used by breakout traders to evaluate potential entry areas.
If the stock is far away from the 8 EMA, it is likely not ready to break out. If it is close to the 8ema, it could be ready to move higher.
This indicator can also be used in the opposite way. For example, shorting or puts.
Understanding the colors
Green (Not Extended): Indicates the price is close to the 8 EMA. This often corresponds to periods of consolidation.
Yellow (Slightly Extended): The price is beginning to move away from the 8 EMA.
Orange (Extended): The price has moved a considerable distance from the 8 EMA.
Red (Very Extended): The price is at an extreme distance from the 8 EMA, historically increasing the likelihood of a pullback or consolidation.
Settings
Info Row Position: Adjusts the vertical position of the display table on the chart. Useful when using other indicators.
ADR Length: Sets the lookback period for calculating the Average Daily Range. Or the average range % for different timeframes.
Timeframe: Determines the timeframe for the EMA and ADR calculation (the default is Daily).
log.info() - 5 Exampleslog.info() is one of the most powerful tools in Pine Script that no one knows about. Whenever you code, you want to be able to debug, or find out why something isn’t working. The log.info() command will help you do that. Without it, creating more complex Pine Scripts becomes exponentially more difficult.
The first thing to note is that log.info() only displays strings. So, if you have a variable that is not a string, you must turn it into a string in order for log.info() to work. The way you do that is with the str.tostring() command. And remember, it's all lower case! You can throw in any numeric value (float, int, timestamp) into str.string() and it should work.
Next, in order to make your output intelligible, you may want to identify whatever value you are logging. For example, if an RSI value is 50, you don’t want a bunch of lines that just say “50”. You may want it to say “RSI = 50”.
To do that, you’ll have to use the concatenation operator. For example, if you have a variable called “rsi”, and its value is 50, then you would use the “+” concatenation symbol.
EXAMPLE 1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//@version=6
indicator("log.info()")
rsi = ta.rsi(close,14)
log.info(“RSI= ” + str.tostring(rsi))
Example Output =>
RSI= 50
Here, we use double quotes to create a string that contains the name of the variable, in this case “RSI = “, then we concatenate it with a stringified version of the variable, rsi.
Now that you know how to write a log, where do you view them? There isn’t a lot of documentation on it, and the link is not conveniently located.
Open up the “Pine Editor” tab at the bottom of any chart view, and you’ll see a “3 dot” button at the top right of the pane. Click that, and right above the “Help” menu item you’ll see “Pine logs”. Clicking that will open that to open a pane on the right of your browser - replacing whatever was in the right pane area before. This is where your log output will show up.
But, because you’re dealing with time series data, using the log.info() command without some type of condition will give you a fast moving stream of numbers that will be difficult to interpret. So, you may only want the output to show up once per bar, or only under specific conditions.
To have the output show up only after all computations have completed, you’ll need to use the barState.islast command. Remember, barState is camelCase, but islast is not!
EXAMPLE 2
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//@version=6
indicator("log.info()")
rsi = ta.rsi(close,14)
if barState.islast
log.info("RSI=" + str.tostring(rsi))
plot(rsi)
However, this can be less than ideal, because you may want the value of the rsi variable on a particular bar, at a particular time, or under a specific chart condition. Let’s hit these one at a time.
In each of these cases, the built-in bar_index variable will come in handy. When debugging, I typically like to assign a variable “bix” to represent bar_index, and include it in the output.
So, if I want to see the rsi value when RSI crosses above 0.5, then I would have something like
EXAMPLE 3
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//@version=6
indicator("log.info()")
rsi = ta.rsi(close,14)
bix = bar_index
rsiCrossedOver = ta.crossover(rsi,0.5)
if rsiCrossedOver
log.info("bix=" + str.tostring(bix) + " - RSI=" + str.tostring(rsi))
plot(rsi)
Example Output =>
bix=19964 - RSI=51.8449459867
bix=19972 - RSI=50.0975830828
bix=19983 - RSI=53.3529808079
bix=19985 - RSI=53.1595745146
bix=19999 - RSI=66.6466337654
bix=20001 - RSI=52.2191767466
Here, we see that the output only appears when the condition is met.
A useful thing to know is that if you want to limit the number of decimal places, then you would use the command str.tostring(rsi,”#.##”), which tells the interpreter that the format of the number should only be 2 decimal places. Or you could round the rsi variable with a command like rsi2 = math.round(rsi*100)/100 . In either case you’re output would look like:
bix=19964 - RSI=51.84
bix=19972 - RSI=50.1
bix=19983 - RSI=53.35
bix=19985 - RSI=53.16
bix=19999 - RSI=66.65
bix=20001 - RSI=52.22
This would decrease the amount of memory that’s being used to display your variable’s values, which can become a limitation for the log.info() command. It only allows 4096 characters per line, so when you get to trying to output arrays (which is another cool feature), you’ll have to keep that in mind.
Another thing to note is that log output is always preceded by a timestamp, but for the sake of brevity, I’m not including those in the output examples.
If you wanted to only output a value after the chart was fully loaded, that’s when barState.islast command comes in. Under this condition, only one line of output is created per tick update — AFTER the chart has finished loading. For example, if you only want to see what the the current bar_index and rsi values are, without filling up your log window with everything that happens before, then you could use the following code:
EXAMPLE 4
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//@version=6
indicator("log.info()")
rsi = ta.rsi(close,14)
bix = bar_index
if barstate.islast
log.info("bix=" + str.tostring(bix) + " - RSI=" + str.tostring(rsi))
Example Output =>
bix=20203 - RSI=53.1103309071
This value would keep updating after every new bar tick.
The log.info() command is a huge help in creating new scripts, however, it does have its limitations. As mentioned earlier, only 4096 characters are allowed per line. So, although you can use log.info() to output arrays, you have to be aware of how many characters that array will use.
The following code DOES NOT WORK! And, the only way you can find out why will be the red exclamation point next to the name of the indicator. That, and nothing will show up on the chart, or in the logs.
// CODE DOESN’T WORK
//@version=6
indicator("MW - log.info()")
var array rsi_arr = array.new()
rsi = ta.rsi(close,14)
bix = bar_index
rsiCrossedOver = ta.crossover(rsi,50)
if rsiCrossedOver
array.push(rsi_arr, rsi)
if barstate.islast
log.info("rsi_arr:" + str.tostring(rsi_arr))
log.info("bix=" + str.tostring(bix) + " - RSI=" + str.tostring(rsi))
plot(rsi)
// No code errors, but will not compile because too much is being written to the logs.
However, after putting some time restrictions in with the i_startTime and i_endTime user input variables, and creating a dateFilter variable to use in the conditions, I can limit the size of the final array. So, the following code does work.
EXAMPLE 5
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CODE DOES WORK
//@version=6
indicator("MW - log.info()")
i_startTime = input.time(title="Start", defval=timestamp("01 Jan 2025 13:30 +0000"))
i_endTime = input.time(title="End", defval=timestamp("1 Jan 2099 19:30 +0000"))
var array rsi_arr = array.new()
dateFilter = time >= i_startTime and time <= i_endTime
rsi = ta.rsi(close,14)
bix = bar_index
rsiCrossedOver = ta.crossover(rsi,50) and dateFilter // <== The dateFilter condition keeps the array from getting too big
if rsiCrossedOver
array.push(rsi_arr, rsi)
if barstate.islast
log.info("rsi_arr:" + str.tostring(rsi_arr))
log.info("bix=" + str.tostring(bix) + " - RSI=" + str.tostring(rsi))
plot(rsi)
Example Output =>
rsi_arr:
bix=20210 - RSI=56.9030578034
Of course, if you restrict the decimal places by using the rounding the rsi value with something like rsiRounded = math.round(rsi * 100) / 100 , then you can further reduce the size of your array. In this case the output may look something like:
Example Output =>
rsi_arr:
bix=20210 - RSI=55.6947486019
This will give your code a little breathing room.
In a nutshell, I was coding for over a year trying to debug by pushing output to labels, tables, and using libraries that cluttered up my code. Once I was able to debug with log.info() it was a game changer. I was able to start building much more advanced scripts. Hopefully, this will help you on your journey as well.
RSI Cảnh Báo Vùng 20/80 by TTVRSI 8 tín hiệu B khi đạt 20 và Sell khi đạt 80, có thể cài đặt khi đạt đến ngưỡng này
BTCs RSI Dip & EMA Crossover AlertThis indicator helps you catch potential reversal opportunities after a stock or crypto asset becomes oversold.
🛠 How it works:
Watches RSI (Relative Strength Index)
First, it waits for RSI to dip below a level you choose (default is 30), which often signals the asset is oversold and due for a bounce.
Waits for Price Confirmation
After the RSI dip, the indicator watches for the first time price closes above both the 55 EMA and 200 EMA — a strong sign that momentum may be shifting upward.
Sends a “Buy” Signal
When that happens, the script:
Plots a green “Buy” label on the chart
Triggers an alert (labeled "Buy Indicator") so you’re notified immediately
⚙️ Customizable Inputs:
RSI threshold (e.g. 30 or 25)
RSI period (e.g. 14)
EMA lengths (default: 55 and 200)
✅ Designed to:
Avoid false signals by requiring both RSI weakness and price strength
Only trigger once per RSI dip, so you’re not spammed with repeat alerts
Use it to stay patient during downtrends and get alerted when the technicals show a possible turnaround. Great for swing traders and longer-term entries.
Custom Sell Signal - MACD + EMA + Volume//@version=5
indicator("Custom Sell Signal - MACD + EMA + Volume", overlay=true)
// MACD Settings
fast_length = 12
slow_length = 26
signal_smoothing = 9
= ta.macd(close, fast_length, slow_length, signal_smoothing)
// 50 EMA
ema50 = ta.ema(close, 50)
// Volume Moving Average (20 SMA)
volSMA = ta.sma(volume, 20)
// Conditions
macdCrossBelow = ta.crossunder(macdLine, signalLine)
macdAboveZero = macdLine > 0
closeNearOrBelowEMA50 = close <= ema50 * 1.005 // Adjust buffer (0.5%) if needed for "near"
volumeAboveSMA = volume > volSMA
// Final Sell Condition
sellCondition = macdCrossBelow and macdAboveZero and closeNearOrBelowEMA50 and volumeAboveSMA
// Plotting
plot(ema50, color=color.blue, title="50 EMA")
// Sell Signal Plot
plotshape(sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// Alert Condition
alertcondition(sellCondition, title="Sell Signal Alert", message="Sell Signal Generated")
SMMA Cross Strategy stopsuzThey were formed by the intersections of 2 SMMA moving averages. You can adjust the parameter and make profit.
Fast Fourier Transform [ScorsoneEnterprises]The SCE Fast Fourier Transform (FFT) is a tool designed to analyze periodicities and cyclical structures embedded in price. This is a Fourier analysis to transform price data from the time domain into the frequency domain, showing the rhythmic behaviors that are otherwise invisible on standard charts.
Instead of merely observing raw prices, this implementation applies the FFT on the logarithmic returns of the asset:
Log Return(𝑚) = log(close / close )
This ensures stationarity and stabilizes variance, making the analysis statistically robust and less influenced by trends or large price swings.
For a user-defined lookback window 𝑁:
Each frequency component 𝑘 is computed by summing real and imaginary projections of log-returns multiplied by complex exponential functions:
𝑒^−𝑖𝜃 = cos(𝜃)−𝑖sin(𝜃)
where:
θ = 2πkm / N
he result is the magnitude spectrum, calculated as:
Magnitude(𝑘) = sqrt(Real_Sum(𝑘)^2 + Imag_Sum(𝑘)^2)
This spectrum represents the strength of oscillations at each frequency over the lookback period, helping traders identify dominant cycles.
Visual Analysis & Interpretation
To give traders context for the FFT spectrum’s values, this script calculates:
25th Percentile (Purple Line)
Represents relatively low cyclical intensity.
Values below this threshold may signal quiet, noisy, or trendless periods.
75th Percentile (Red Line)
Represents heightened cyclical dominance.
Values above this threshold may indicate significant periodic activity and potential trend formation or rhythm in price action.
The FFT magnitude of the lowest frequency component (index 0) is plotted directly on the chart in teal. Observing how this signal fluctuates relative to its percentile bands provides a dynamic measure of cyclical market activity.
Chart examples
In this NYSE:CL chart, we see the regime of the price accurately described in the spectral analysis. We see the price above the 75th percentile continue to trend higher until it breaks back below.
In long trending markets like NYSE:PL has been, it can give a very good explanation of the strength. There was confidence to not switch regimes as we never crossed below the 75th percentile early in the move.
The script is also usable on the lower timeframes. There is no difference in the usability from the different timeframes.
Script Parameters
Lookback Value (N)
Default: 30
Defines how many bars of data to analyze. Larger N captures longer-term cycles but may smooth out shorter-term oscillations.