指標和策略
Volume-Based Candle Colorindicates the increase in volume on the individual candles relative to the 20ma on the volume indicator.
Relative StrengthDescription:
This indicator provides a simplified yet powerful method for measuring a stock's momentum based on its proximity to its recent high. It is a direct implementation of a trading concept discussed in a lecture from the New York Institute of Finance.
Core Concept
The underlying theory, supported by academic research, is that a stock making a new high is one of the most bullish signals possible. Such stocks have a statistical tendency to continue making new highs in the near term.
Instead of requiring complex relative strength calculations against a universe of stocks, this indicator uses a simple and elegant ratio to act as a proxy for momentum:
Indicator Value = Current Close / Highest High of Lookback Period
A value approaching 1.0 indicates the stock is strong and nearing a new high. A value at 1.0 means a new high has just been made.
How to Use This Indicator
The indicator consists of two primary components:
RS Line (Teal): The core momentum calculation (Close / High).
Signal MA (Orange): A moving average of the NHRS Line, which acts as the trigger for signals.
The signals are generated based on the crossover between these two lines:
BUY Signal: When the RS Line crosses ABOVE its moving average. This suggests that short-term momentum is accelerating and a new uptrend may be starting. The background will turn green.
SELL Signal: When the RS Line crosses BELOW its moving average. This indicates that momentum is fading and it may be prudent to exit the position to avoid a decline. The background will turn red.
Indicator Settings
You can customize the indicator to fit your trading style and the timeframe you are analyzing:
High Lookback Period: Choose the period for the "Highest High" calculation. Options range from 1 Month to 12 Months (52 weeks), allowing you to measure short-term or long-term strength.
Moving Average Length: Adjust the length of the signal line's moving average. The lecturer defaults to 26 weeks for a six-month view.
Moving Average Type: Select the type of moving average for the signal line (SMA, EMA, WMA, HMA).
Credits and Inspiration
Proper credit is essential. This script is a practical application of a concept that builds upon foundational academic work.
The core idea that a stock's proximity to its 52-week high is an investable anomaly was detailed in the 2004 Journal of Finance paper:
"The 52 Week High and Momentum Investing" by Thomas J. George and Chuan-Yang Hwang.
The lecturer's contribution, which this script implements, was to simplify this concept into an actionable trading tool by applying a moving average crossover to generate clear and objective buy and sell signals.
Disclaimer: This tool is for educational and informational purposes only. It is not financial advice. All trading involves risk, and you should always perform your own research and backtesting before making any trading decisions.
Adaptive Causal Wavelet Trend FilterThe Adaptive Causal Wavelet Trend Filter is a technical indicator implementing causal approximations of wavelet transform properties for better trend detection with adaptive volatility response.
The Adaptive Causal Wavelet Trend Filter (ACWTF) applies mathematical principles derived from wavelet analysis to financial time series, providing robust trend identification with minimal lag. Unlike conventional moving averages, it preserves significant price movements while filtering market noise through signal processing that i describe below.
I was inspired to build this indicator after reading " Wavelet-Based Trend Identification in Financial Time Series " by In, F., & Kim, S. 2013 and reading about Mexican Hat wavelet filters.
The ACWTF maintains optimal performance across varying market regimes without requiring parameter adjustments by adapting filter characteristics to current volatility conditions.
Mathematical Foundation
Inspired by the Mexican Hat wavelet (Ricker wavelet), this indicator implements causal approximations of wavelet filters optimized for real-time financial analysis. The multi-resolution approach identifies features at different scales and the adaptive component dynamically adjusts filtering characteristics based on local volatility measurements.
Key mathematical properties include:
Non-linear frequency response adaptation
Edge-preserving signal extraction
Scale-space analysis through dual filter implementation
Volatility-dependent coefficient adjustment, which I love
Filter Methods
Adaptive: Implements a volatility-weighted combination of multiple filter types to optimize the time-frequency resolution trade-off
Hull: Provides a causal approximation of wavelet edge detection properties with forward-projection characteristics
VWMA: Incorporates volume information into the filtering process for enhanced signal detection
EMA Cascade: Creates a multi-pole filter structure that approximates certain wavelet scaling properties
Suggestion: try all as they will provide slightly different signals. Try also different time-frames.
Practical Applications
Trend Direction Identification: Clear visual trend direction with reduced noise and lag
Regime Change Detection: Early identification of significant trend reversals
Market Condition Analysis: Integrated volatility metrics provide context for current market behavior
Multi-timeframe Confirmation: Alignment between primary and secondary filters offers additional confirmation
Entry/Exit Timing: Filter crossovers and trend changes provide potential trading signals
The comprehensive information panel provides:
Current filter method and trend state
Trend alignment between timeframes
Real-time volatility assessment
Price position relative to filter
Overall trading bias based on multiple factors
Implementation Notes
Log returns option provides improved statistical properties for financial time series
Primary and secondary filter lengths can be adjusted to optimize for specific instruments and timeframes
The indicator performs particularly well during trend transitions and regime changes
The indicator reduces the need for using additional indicators to check trend reversion
Range Breakout [sgbpulse]Range Breakout
1. Overview
The "Range Breakout " indicator is a powerful tool designed to identify and visually display price ranges on your chart using pivot points. It dynamically draws two distinct boxes – an External Range and an Internal Range – helping traders pinpoint potential support and resistance zones. Beyond its visual representation, the indicator offers a comprehensive set of 12 unique breakout alerts, providing real-time notifications for significant price movements outside these defined ranges. Additionally, it integrates RSI and MFI metrics for momentum confirmation.
2. How It Works
The indicator operates by identifying pivot points based on user-defined "left" and "right" bar lengths. A high pivot is a bar with a specified number of lower highs both to its left and right, and similarly for a low pivot.
External Range: Calculated using longer pivot lengths (default: 15 bars left, 6 bars right). This range represents broader, more significant price consolidation areas.
Internal Range: Calculated using shorter pivot lengths (default: 4 bars left, 3 bars right). This range captures tighter, more immediate price consolidations within the broader trend.
The External Range will always be greater than or equal to the Internal Range, as it's based on a wider historical context. Both ranges are displayed as transparent boxes on your chart, dynamically adjusting as new pivots are formed.
3. Key Features and Settings
Customizable Pivot Lengths:
External Range (Left/Right Bars): Adjust sensitivity for identifying the broader price range. Longer lengths lead to more stable, but less frequent, range updates.
Internal Range (Left/Right Bars): Adjust sensitivity for the tighter, more immediate price range.
Tool Tips: Minimum 6 bars for the External Range, and minimum 2 bars for the Internal Range.
Customizable Range Colors: Easily change the background colors of the External and Internal Range boxes to match your chart's aesthetic.
Dynamic Range Display: The indicator automatically updates the range boxes as new pivot highs and lows are formed, always presenting the most current valid ranges.
RSI / MFI Settings:
Timeframe Source: Select the timeframe for RSI and MFI calculation.
- Chart: Calculation based on the current chart timeframe.
- Daily: Always calculated based on the daily ("D") timeframe, even if the chart is on a lower timeframe.
RSI Length: Period length for RSI calculation (default: 14).
RSI Overbought Level: Overbought level for RSI (default: 70.0).
RSI Oversold Level: Oversold level for RSI (default: 30.0).
MFI Length: Period length for MFI calculation (default: 14).
MFI Overbought Level: Overbought level for MFI (default: 80.0).
MFI Oversold Level: Oversold level for MFI (default: 20.0).
4. Synergy of Ranges & Breakout Strength
The interaction between the External and Internal Ranges provides deep insights into price movement and breakout strength:
Immediate Direction: The movement of the Internal Range (up or down) indicates the short-term directional bias within the broader framework of the External Range.
Strength Confirmation: A breakout of the External Range, followed by a breakout of the Internal Range, confirms the strength of the move and increases confidence in the breakout.
Strong Momentum ("Leaving" Ranges Behind): When price breaks out with exceptionally strong momentum, it continues to move aggressively and does not immediately form new pivots. In such situations, the existing ranges (External and Internal) remain in place while the candles "leave them behind." A "Full Candle" breakout, where the entire candle moves past both ranges, indicates a particularly powerful and decisive move.
Momentum (RSI / MFI) as Confirmation:
- RSI (Relative Strength Index): Measures the speed and change of price movements. Extreme values (above 70 or below 30) indicate overbought/oversold conditions respectively, confirming strong momentum in a breakout.
- MFI (Money Flow Index): Similar to RSI but incorporates volume. Extreme values (above 80 or below 20) indicate strong money flow in/out, reinforcing breakout confirmation.
- Importance of Confirmation: If a breakout occurs but momentum indicators do not confirm it (for example, an upside breakout while RSI is declining), this could signal weakness in the move and the risk of a false breakout (Fakeout).
5. Visuals
The indicator provides clear visual representations on the chart:
Range Boxes:
Two dynamic boxes are drawn on the chart: one for the External Range and one for the Internal Range.
These boxes update continuously, displaying the current range boundaries based on the latest pivots. They provide an immediate visual indication of support and resistance levels.
RSI/MFI Status Labels:
Small text labels appear to the right of the current bar, vertically centered.
They display the status of RSI and MFI: RSI OB (Overbought), RSI OS (Oversold), MFI OB, MFI OS, along with the exact value.
Important: The labels remain on the chart as long as the condition holds (indicator is above/below the level), unlike alerts which mark a singular crossover event.
Plotting of Key Values:
The indicator plots six invisible series on the chart, primarily to allow the user to view the exact numerical values of:
- The upper and lower bounds of the External Range (External High, External Low).
- The upper and lower bounds of the Internal Range (Internal High, Internal Low).
- The calculated RSI and MFI values (RSI, MFI).
These values are accessible for viewing through TradingView's Data Window and also via the Status Line when hovering over the relevant candle. This enables more precise quantitative analysis of range levels and momentum.
6. Comprehensive Breakout Alerts
The "Range Breakout " indicator provides 12 distinct alert conditions for breakouts, allowing you to select the required level of confirmation for each alert. All alerts are triggered only upon a fully confirmed bar close (barstate.isconfirmed) to minimize false signals and ensure reliability.
All breakout alerts are configured to detect a Crossover/Crossunder of the levels, meaning a specific event where the price moves from one side of the range to the other.
External Range Breakout UP
- Close: Price closes above the External Range.
- Real Body: The entire "real body" of the candle (min of open/close prices) closes above the External Range.
- Full Candle: The entire candle (the lowest point of the candle) closes above the External Range.
External Range Breakout DOWN
- Close: Price closes below the External Range.
- Real Body: The entire "real body" of the candle (max of open/close prices) closes below the External Range.
- Full Candle: The entire candle (the highest point of the candle) closes below the External Range.
Internal Range Breakout UP
- Close: Price closes above the Internal Range.
- Real Body: The "real body" of the candle closes above the Internal Range.
- Full Candle: The entire candle closes above the Internal Range.
Internal Range Breakout DOWN
- Close: Price closes below the Internal Range.
- Real Body: The "real body" of the candle closes below the Internal Range.
- Full Candle: The entire candle closes below the Internal Range.
7. Ideal Use Cases
This indicator is ideal for traders who:
Want to clearly identify and monitor price consolidation zones.
Seek confirmation for breakout strategies across various timeframes.
Require reliable and automated alerts for potential entry or exit points based on range expansion.
8. Complementary Indicator
For even more comprehensive market analysis, we highly recommend using this indicator in conjunction with Market Structure Support & Resistance External/Internal & BoS .
This powerful complementary indicator automatically and accurately identifies significant support and resistance levels by locating high and low pivot points, as well as key Pre-Market High/Low levels. Its strength lies in its dynamic adaptability to any timeframe and asset, providing precise and relevant real-time levels while maintaining a clean chart. It also identifies Break of Structure (BoS) to signal potential trend changes or continuations.
Using both indicators together provides a robust framework for identifying defined ranges and potential trend shifts, enabling more informed trading decisions.
View Market Structure Support & Resistance External/Internal & BoS Indicator
9. Important Note: Trading Risk
This indicator is intended for educational and informational purposes only and does not constitute investment advice or a recommendation for trading in any form whatsoever.
Trading in financial markets involves significant risk of capital loss. It is important to remember that past performance is not indicative of future results. All trading decisions are your sole responsibility. Never trade with money you cannot afford to lose.
EMA Stack (13–200) Toggle📈 EMA Stack (13–200) Toggle – Color-Coded Trend Filter
Customizable EMA stack with slope-based coloring:
• 🟩 Green = Bullish slope
• 🟥 Red = Bearish slope
• Lengths: 13, 20, 34, 50, 89, 100, 200
• Toggle each EMA on/off in settings
✅ Great for:
• Trend confirmation
• Pullback entries
• Momentum confluence across timeframes
• Heikin Ashi candle setups (as shown in screenshot)
Clean, clear, and built for scalping or trend-riding.
ATR as % of Close (Daily)Sometimes, ATR is more comparable and meaningful when we express it in % rather than dollar. This is a quickly developed version (using ChatGPT), so review it and use it with caution, although the calculation is quite straightforward.
EMA-Pack MTFEMA-Pack MTF
This TradingView Pine Script defines a custom indicator called "EMA-Pack MTF" that overlays various types of moving averages and Bollinger Bands across multiple timeframes on a chart. It begins by importing the built-in technical analysis library and defining a custom ma function that calculates several types of moving averages (SMA, EMA, TEMA, DEMA, HMA, and ALMA) based on user input. The ema function is the core logic, retrieving market data for the specified timeframe and calculating fast, mid, slow, 50, 100, and 200-period moving averages along with Bollinger Band components (basis, upper, and lower bands). The function adjusts values to the nearest valid price tick and returns them.
User input fields allow customization of timeframes, source data, moving average types, and Bollinger Band parameters. The script calls the ema function for each selected timeframe (1 minute, 5 minutes, 15 minutes, 1 hour, 4 hours, and 1 day), storing their respective computed values. It then plots the calculated moving averages and Bollinger Band basis lines on the chart, using different colors and line widths to distinguish between them. Some plots are hidden by default (display.none) to reduce chart clutter. This script is useful for multi-timeframe trend analysis using customizable moving averages and Bollinger Bands.
20 EMA Envelope with Editable %Its Ema envelope with editable feature of EMA and % of EMA how much one want deviation from EMA.
Volume Shelf Breakout WatcherThis indicator detects potential breakout opportunities from high-volume price shelves (HVNs) using a custom volume profile engine. It scans the past 100 bars (adjustable) to identify price ranges with heavy volume accumulation, then monitors for a breakout when price is near the top of that range.
To increase accuracy, it optionally confirms momentum using:
✅ MACD bullish crossover
✅ RSI > 55
✅ Volume spike above 20-bar average
When all enabled conditions are met, the indicator highlights the bar with a green label and background shading, and can trigger alerts for trade setups.
Use this indicator to:
Identify volume-based consolidation zones
Anticipate price surges through low-volume areas ("volume gaps")
Catch breakouts with momentum confirmation
Inputs:
Volume Profile Range (bars)
HVN Sensitivity (top % of volume)
MACD confirmation toggle
RSI level toggle
Volume spike toggle
Ideal for:
Traders looking to enter early on momentum moves as price escapes compression zones into areas of less resistance.
ICT Killzones & Pivots [TFO]Italian time: Traccia dei box per le tre time zone principali: Asia, Europa e America
200 EMA, 50 EMA, 21 EMAEMA Indicator 3 in 1 (21,50,200) Why download three individual indicator in you can have all in one.
SPY-ES & QQQ-NQ Live Ratiothis shows the live ratios of SPY and QQQs o you can easily convert them into ES and NQ levels
MA Respect IndicatorThis indicator tells you how much a moving average is being respected.
Green = highly respected
Blue = watch out, transitioning
Red = not respected at all.
If you trade moving averages, you may find this very helpful with determining when and when not to trust a MA. This can be changed to look at a VWAP, and many other different MA calculation types.
Session Overlay - FXMontys dual session overlayDeveloped by FX Monty
This indicator was created for traders who want a cleaner, more structured way to mark their session highs and lows, as well as lower time frame supply and demand zones using volume-based analysis.
🔹 What This Indicator Is For
Designed to complement both the Core Sessions and CM Sessions indicators.
Helps identify key trading sessions: Asia, London, and New York.
Supports traders who blend session structure, liquidity, and LTF price action for more precise setups.
📌 How to Use
Marking Highs & Lows:
Use the Core Sessions Indicator to mark session highs and lows. You can use either a box or a horizontal ray — whichever gives the cleanest visual.
Supply & Demand Zones (LTF):
Use the CM Sessions Indicator for marking LTF supply and demand zones within a session.
➤ Don’t forget to adjust your session times manually, especially for daylight savings.
High/Low of Day (HOD/LOD):
Use the 5-minute timeframe on the CM Sessions chart to mark the day’s highs and lows.
✘ Exclude the Asia session from this when evaluating HOD/LOD.
🧠 Strategy Background
This indicator is rooted in two powerful trading methodologies from my mentors:
TJR's Liquidity Concepts – Which influence how we frame session-based liquidity using the Core Sessions logic.
JordanFX's Session-Based Approach – The inspiration for using session structuring for lower time frame entries.
💙 Rest in peace, Jordan. This is for you.
This tool is part of my personal workflow, and I built it to make complex setups easier to visualize and act on. I hope it provides you with clarity, structure, and confidence in your trades.
Happy trading,
— FX Monty
Super Neema!🟧 Super Neema! — Multi-Timeframe EMA-9 Overlay
🔍 What is "Neema"?
The term "Neema" has recently emerged among traders such as Jeff Holden—a top proprietary trading firm trader—whose colleagues colloquially use "Neema" as shorthand for the 9-period Exponential Moving Average (EMA). Due to its increasing popularity and reliability, the phrase caught on quickly as traders needed a quick, memorable name for such an essential tool.
📚 Why the 9-EMA?
Scalping around the 9-EMA is now one of the most widely used intraday trading techniques. Traders of various experience levels frequently rely on it because it effectively highlights short-term momentum shifts.
But there's a crucial nuance: traders across different assets or market periods don't always agree on which timeframe’s 9-EMA to follow. Depending on who's currently active in the market, the dominant "Neema" could be the 1-minute, 2-minute, 3-minute, or 5-minute 9-EMA. This variation arises naturally due to differences in trader populations, risk tolerance, style, and current market conditions.
👥 Social Convention & Normative Social Influence
Trading is fundamentally a social activity, and normative social influence plays a critical role in market behavior. Traders don’t operate in isolation; they follow patterns, respond to cues, and rely on shared conventions. The popularity of any given indicator—like the 9-EMA—is not just technical, but deeply social. Traders adapt to what's socially accepted, recognizable, and effective.
Over time, these conventions shift. What once was "the standard" timeframe can subtly evolve as dominant traders or institutions shift their preferred style or timeframe, creating "variants" of established trends. Understanding this dynamic is essential for market participants because recognizing where the majority of traders currently focus gives a critical edge.
📈 Why Does This Matter? (Market Evolution & Trader Adaptability)
Market trends aren't just technical—they're social constructs. As markets evolve, participants adapt their methods to fit new norms. Traders who recognize and adapt quickly to these evolving norms gain a decisive advantage.
By clearly visualizing multiple Neemas (9-EMAs across timeframes) simultaneously, you don't merely see EMA levels—you visually sense the current social convention of the market. This heightened awareness helps you stay adaptive and flexible, aligning your strategy dynamically with the broader community of traders.
🎨 Transparency Scheme (Visual Identification):
5-minute Neema: Most opaque, brightest line (slowest, most significant trend)
3-minute Neema: Slightly more transparent
2-minute Neema: Even more transparent
1-minute Neema: Most transparent, subtle background hint (fastest, quickest reaction)
This deliberate visual hierarchy makes it intuitive to identify immediately which timeframe is currently dominant, and therefore, which timeframe other traders are using most actively.
✅ Works on:
Any timeframe, any chart. Automatically plots the 1m–5m EMA-9 lines regardless of your current chart.
🧠 Key Insight:
Markets are driven by social trends and normative influence.
Identifying the currently dominant timeframe (the Neema most respected by traders at that moment) is a powerful, socially-informed edge.
Trader adaptability isn't just technical—it's social awareness in action.
Enjoy your trading, and welcome to Super Neema! ⚡
Position Size Calculator with Fees# Position Size Calculator with Portfolio Management - Manual
## Overview
The Position Size Calculator with Portfolio Management is an advanced Pine Script indicator designed to help traders calculate optimal position sizes based on their total portfolio value and risk management strategy. This tool automatically calculates your risk amount based on portfolio allocation percentages and determines the exact position size needed while accounting for trading fees.
## Key Features
- **Portfolio-Based Risk Management**: Calculates risk based on total portfolio value
- **Tiered Risk Allocation**: Separates trading allocation from total portfolio
- **Automatic Trade Direction Detection**: Determines long/short based on entry vs stop loss
- **Fee Integration**: Accounts for trading fees in position size calculations
- **Risk Factor Adjustment**: Allows scaling of position size up or down
- **Visual Display**: Shows all calculations in a clear, color-coded table
- **Automatic Risk Calculation**: No need to manually input risk amount
## Input Parameters
### Total Portfolio ($)
- **Purpose**: The total value of your investment portfolio
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
- **Example**: If your total portfolio is worth $100,000, enter 100000
### Trading Portfolio Allocation (%)
- **Purpose**: The percentage of your total portfolio allocated to active trading
- **Default**: 20.0%
- **Range**: 0.0% to 100.0%
- **Step**: 0.01
- **Example**: If you allocate 20% of your portfolio to trading, enter 20
### Risk from Trading (%)
- **Purpose**: The percentage of your trading allocation you're willing to risk per trade
- **Default**: 0.1%
- **Range**: Any positive value
- **Step**: 0.01
- **Example**: If you risk 0.1% of your trading allocation per trade, enter 0.1
### Entry Price ($)
- **Purpose**: The price at which you plan to enter the trade
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
### Stop Loss ($)
- **Purpose**: The price at which you will exit if the trade goes against you
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
### Risk Factor
- **Purpose**: A multiplier to scale your position size up or down
- **Default**: 1.0 (no scaling)
- **Range**: 0.0 to 10.0
- **Step**: 0.1
- **Examples**:
- 1.0 = Normal position size
- 2.0 = Double the position size
- 0.5 = Half the position size
### Fee (%)
- **Purpose**: The percentage fee charged per transaction
- **Default**: 0.01% (0.01)
- **Range**: 0.0% to 1.0%
- **Step**: 0.001
## How Risk Amount is Calculated
The script automatically calculates your risk amount using this formula:
```
Risk Amount = Total Portfolio × Trading Allocation (%) × Risk % ÷ 10,000
```
### Example Calculation:
- Total Portfolio: $100,000
- Trading Allocation: 20%
- Risk per Trade: 0.1%
**Risk Amount = $100,000 × 20 × 0.1 ÷ 10,000 = $20**
This means you would risk $20 per trade, which is 0.1% of your $20,000 trading allocation.
## Portfolio Structure Example
Let's say you have a $100,000 portfolio:
### Allocation Structure:
- **Total Portfolio**: $100,000
- **Trading Allocation (20%)**: $20,000
- **Long-term Investments (80%)**: $80,000
### Risk Management:
- **Risk per Trade (0.1% of trading)**: $20
- **Maximum trades at risk**: Could theoretically have 1,000 trades before risking entire trading allocation
## How Position Size is Calculated
### Trade Direction Detection
- **Long Trade**: Entry price > Stop loss price
- **Short Trade**: Entry price < Stop loss price
### Position Size Formulas
#### For Long Trades:
```
Position Size = -Risk Factor × Risk Amount / (Stop Loss × (1 - Fee) - Entry Price × (1 + Fee))
```
#### For Short Trades:
```
Position Size = -Risk Factor × Risk Amount / (Entry Price × (1 - Fee) - Stop Loss × (1 + Fee))
```
## Output Display
The indicator displays a comprehensive table with color-coded sections:
### Portfolio Information (Light Blue Background)
- **Portfolio (USD)**: Your total portfolio value
- **Trading Portfolio Allocation (%)**: Percentage allocated to trading
- **Risk as % of Trading**: Risk percentage per trade
### Trade Setup (Gray Background)
- **Entry Price**: Your specified entry price
- **Stop Loss**: Your specified stop loss price
- **Fee (%)**: Trading fee percentage
- **Risk Factor**: Position size multiplier
### Risk Analysis (Red Background)
- **Risk Amount**: Automatically calculated dollar risk
- **Effective Entry**: Actual entry cost including fees
- **Effective Exit**: Actual exit value including fees
- **Expected Loss**: Calculated loss if stop loss is hit
- **Deviation from Risk %**: Accuracy of risk calculation
### Final Result (Blue Background)
- **Position Size**: Number of shares/units to trade
## Usage Examples
### Example 1: Conservative Long Trade
- **Total Portfolio**: $50,000
- **Trading Allocation**: 15%
- **Risk per Trade**: 0.05%
- **Entry Price**: $25.00
- **Stop Loss**: $24.00
- **Risk Factor**: 1.0
- **Fee**: 0.01%
**Calculated Risk Amount**: $50,000 × 15% × 0.05% ÷ 100 = $3.75
### Example 2: Aggressive Short Trade
- **Total Portfolio**: $200,000
- **Trading Allocation**: 30%
- **Risk per Trade**: 0.2%
- **Entry Price**: $150.00
- **Stop Loss**: $155.00
- **Risk Factor**: 2.0
- **Fee**: 0.01%
**Calculated Risk Amount**: $200,000 × 30% × 0.2% ÷ 100 = $120
**Actual Risk**: $120 × 2.0 = $240 (due to risk factor)
## Color Coding System
- **Green/Red Header**: Trade direction (Long/Short)
- **Light Blue**: Portfolio management parameters
- **Gray**: Trade setup parameters
- **Red**: Risk-related calculations and results
- **Blue**: Final position size result
## Best Practices
### Portfolio Management
1. **Keep trading allocation reasonable** (typically 10-30% of total portfolio)
2. **Use conservative risk percentages** (0.05-0.2% per trade)
3. **Don't risk more than you can afford to lose**
### Risk Management
1. **Start with small risk factors** (1.0 or less) until comfortable
2. **Monitor your total exposure** across all open positions
3. **Adjust risk based on market conditions**
### Trade Execution
1. **Always validate calculations** before placing trades
2. **Account for slippage** in volatile markets
3. **Consider position size relative to liquidity**
## Risk Management Guidelines
### Conservative Approach
- Trading Allocation: 10-20%
- Risk per Trade: 0.05-0.1%
- Risk Factor: 0.5-1.0
### Moderate Approach
- Trading Allocation: 20-30%
- Risk per Trade: 0.1-0.15%
- Risk Factor: 1.0-1.5
### Aggressive Approach
- Trading Allocation: 30-40%
- Risk per Trade: 0.15-0.25%
- Risk Factor: 1.5-2.0
## Troubleshooting
### Common Issues
1. **Position Size shows 0**
- Verify all portfolio inputs are greater than 0
- Check that entry price differs from stop loss
- Ensure calculated risk amount is positive
2. **Very small position sizes**
- Increase risk percentage or risk factor
- Check if your risk amount is too small for the price difference
3. **Large risk deviation**
- Normal for very small positions
- Consider adjusting entry/stop loss levels
### Validation Checklist
- Total portfolio value is realistic
- Trading allocation percentage makes sense
- Risk percentage is conservative
- Entry and stop loss prices are valid
- Trade direction matches your intention
## Advanced Features
### Risk Factor Usage
- **Scaling up**: Use risk factors > 1.0 for high-confidence trades
- **Scaling down**: Use risk factors < 1.0 for uncertain trades
- **Never exceed**: Risk factors that would risk more than your comfort level
### Multiple Timeframe Analysis
- Use different risk factors for different timeframes
- Consider correlation between positions
- Adjust trading allocation based on market conditions
## Disclaimer
This tool is for educational and planning purposes only. Always verify calculations manually and consider market conditions, liquidity, and correlation between positions. The automated risk calculation assumes you're comfortable with the mathematical relationship between portfolio allocation and individual trade risk. Past performance doesn't guarantee future results, and all trading involves risk of loss.
Easy Position Size Calculator with Fees# Easy Position Size Calculator with Fees - Manual
## Overview
The Easy Position Size Calculator is a Pine Script indicator designed to help traders calculate the optimal position size for their trades while accounting for trading fees. This tool automatically determines whether you're planning a long or short position and calculates the exact position size needed to risk a specific dollar amount.
## Key Features
- **Automatic Trade Direction Detection**: Determines if you're going long or short based on entry price vs stop loss
- **Fee Integration**: Accounts for trading fees in position size calculations
- **Risk Management**: Calculates position size based on your specified risk amount
- **Risk Factor Adjustment**: Allows you to scale your position size up or down
- **Visual Display**: Shows all calculations in a clear, organized table
## Input Parameters
### Entry Price ($)
- **Purpose**: The price at which you plan to enter the trade
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
### Stop Loss ($)
- **Purpose**: The price at which you will exit the trade if it goes against you
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
### Risk ($)
- **Purpose**: The maximum dollar amount you're willing to lose on this trade
- **Default**: 0.0
- **Range**: Any positive value
- **Step**: 0.01
### Risk Factor
- **Purpose**: A multiplier to scale your position size up or down
- **Default**: 1.0 (no scaling)
- **Range**: 0.0 to 10.0
- **Step**: 0.1
- **Examples**:
- 1.0 = Normal position size
- 2.0 = Double the position size
- 0.5 = Half the position size
### Fee (%)
- **Purpose**: The percentage fee charged per transaction (buy/sell)
- **Default**: 0.01% (0.01)
- **Range**: 0.0% to 1.0%
- **Step**: 0.001
## How It Works
### Trade Direction Detection
The script automatically determines your trade direction:
- **Long Trade**: Entry price > Stop loss price
- **Short Trade**: Entry price < Stop loss price
### Position Size Calculation
#### For Long Trades:
```
Position Size = -Risk Factor × Risk Amount / (Stop Loss × (1 - Fee) - Entry Price × (1 + Fee))
```
#### For Short Trades:
```
Position Size = -Risk Factor × Risk Amount / (Entry Price × (1 - Fee) - Stop Loss × (1 + Fee))
```
### Fee Adjustment
The script accounts for fees on both entry and exit:
- **Long trades**: You pay fees when buying (entry) and selling (exit)
- **Short trades**: You pay fees when shorting (entry) and covering (exit)
## Output Display
The indicator displays a table with the following information:
### Trade Information
- **Trade Type**: Shows whether it's a LONG, SHORT, or INVALID trade
- **Entry Price**: Your specified entry price
- **Stop Loss**: Your specified stop loss price
- **Fee (%)**: The fee percentage being used
### Risk Parameters
- **Risk Amount**: The dollar amount you're willing to risk
- **Risk Factor**: The multiplier being applied
### Calculated Values
- **Effective Entry**: The actual cost per share including fees
- **Effective Exit**: The actual exit value per share including fees
- **Expected Loss**: The calculated loss if stop loss is hit
- **Deviation from Risk %**: Shows how close the expected loss is to your target risk
- **Position Size**: The number of shares/units to trade
## Usage Examples
### Example 1: Long Trade
- Entry Price: $100.00
- Stop Loss: $95.00
- Risk Amount: $500.00
- Risk Factor: 1.0
- Fee: 0.01%
**Result**: The script will calculate how many shares to buy so that if the stop loss is hit, you lose approximately $500 (accounting for fees). Position Size: 99.61152
### Example 2: Short Trade
- Entry Price: $50.00
- Stop Loss: $55.00
- Risk Amount: $300.00
- Risk Factor: 1.0
- Fee: 0.01%
**Result**: The script will calculate how many shares to short so that if the stop loss is hit, you lose approximately $300 (accounting for fees). Position Size: 59.87426
## Important Notes
### Validation Requirements
For the script to work properly, all of the following must be true:
- Entry price > 0
- Stop loss > 0
- Risk amount > 0
- Entry price ≠ Stop loss (to determine direction)
### Negative Position Sizes
The script may show negative position sizes, which is normal:
- **Negative values for long trades**: Represents shares to buy
- **Negative values for short trades**: Represents shares to short
### Risk Deviation
The "Deviation from Risk %" shows how closely the calculated position size matches your target risk. Small deviations are normal due to:
- Fee calculations
- Rounding
- Market precision
## Color Coding
The table uses color coding for easy identification:
- **Green**: Long trade information
- **Red**: Short trade information
- **Gray**: Invalid trade (when inputs are incorrect)
- **Blue**: Final position size
- **Red background**: Risk-related calculations
## Troubleshooting
### Common Issues
1. **Position Size shows 0**
- Check that all inputs are greater than 0
- Ensure entry price is different from stop loss
2. **Trade Type shows INVALID**
- Verify that entry price and stop loss are both positive
- Make sure entry price ≠ stop loss
3. **Large Risk Deviation**
- This is normal for very small position sizes
- Consider adjusting your risk amount or price levels
## Best Practices
1. **Always validate your inputs** before placing actual trades
2. **Double-check the trade direction** shown in the table
3. **Review the expected loss** to ensure it aligns with your risk management
4. **Consider the effective entry/exit prices** which include fees
5. **Use appropriate risk factors** - avoid extreme values that could lead to overexposure
## Disclaimer
This tool is for educational and planning purposes only. Always verify calculations manually and consider market conditions, liquidity, and other factors before placing actual trades. The script assumes that fees are charged on both entry and exit transactions.
My script/@version=5
indicator("20 SMA Cross 200 SMA", overlay=true)
sma20 = ta.sma(close, 20)
sma200 = ta.sma(close, 200)
plot(sma20, color=color.blue)
plot(sma200, color=color.red)
longSignal = ta.crossover(sma20, sma200)
plotshape(longSignal, title="20/200 Cross", location=location.belowbar, color=color.green, style=shape.labelup)
High/Low de la Bougie Daily d'Hier🧩 General Description
This indicator plots two horizontal lines on your chart every day:
One line at the High of yesterday’s daily candle
One line at the Low of yesterday’s daily candle
It is designed to help you quickly identify key market levels based on the previous day’s range — often used as:
Support/resistance zones
Breakout or rejection areas
Reference points for intraday strategies (e.g. New York session trading)
⚙️ How It Works
The indicator uses request.security to fetch data from the daily timeframe, regardless of the chart timeframe you're trading on (e.g. M15, H1).
It captures the high and low from yesterday’s daily candle.
These levels are displayed on your current chart using horizontal lines extended to the right, which automatically update every day.
🎨 Visual Style
High of yesterday: green, dashed line
Low of yesterday: red, dashed line
Lines are refreshed on every new bar to stay clean and updated