OPEN-SOURCE SCRIPT
Yuri Garcia Narrow State Strategy (YGILS)

Overview
The Yuri Garcia Institutional Liquidity Strategy (YGILS) is a trend-following and volatility-expansion methodology designed to identify high-probability trading opportunities during periods of market compression and directional momentum.
The strategy combines trend analysis, volatility measurements, momentum confirmation, and risk management into a structured framework that helps traders identify potential institutional participation while maintaining disciplined execution.
The primary objective is not to predict every market move, but rather to participate when multiple conditions align in favor of a directional expansion.
---
Strategy Philosophy
Markets alternate between periods of compression and expansion.
During compression, price contracts, volatility decreases, and market participants become indecisive.
During expansion, volatility increases, momentum accelerates, and directional opportunities emerge.
The strategy is specifically designed to identify the transition from low-volatility environments to high-volatility environments.
The Narrow State identifies compression.
The Elephant Bar identifies expansion.
The highest-quality opportunities typically occur when an Elephant Bar appears shortly after a period of compression and in the direction of the prevailing trend.
---
Core Components
Trend Identification
The strategy uses:
• 20 EMA (Short-Term Momentum)
• 200 SMA (Long-Term Trend)
Bullish Environment
✓ Price above 200 SMA
✓ 20 EMA above 200 SMA
Bearish Environment
✓ Price below 200 SMA
✓ 20 EMA below 200 SMA
This trend filter prevents traders from taking long positions against a bearish market and short positions against a bullish market.
---
Narrow State
A Narrow State occurs when the distance between the EMA 20 and SMA 200 contracts below a user-defined percentage threshold.
Formula:
Distance % = |EMA20 − SMA200| ÷ SMA200 × 100
The Narrow State represents a market compression phase.
Historically, significant market moves frequently begin after periods of compression.
The strategy seeks to participate during the transition from compression into expansion.
Important
The optimal Narrow State threshold depends on the instrument, timeframe, and market volatility.
Lower values produce stricter setups and fewer signals.
Higher values produce more signals but may increase market noise.
Traders are encouraged to optimize this setting based on the specific market being traded.
---
Elephant Bars
An Elephant Bar represents a significant expansion in volatility and directional conviction.
The candle body must exceed the Average True Range (ATR) multiplied by the Elephant Bar Multiplier selected by the user.
Formula:
Candle Body Size > ATR × Elephant Multiplier
Example
ATR = 20 points
Elephant Multiplier = 1.5
Required Body Size = 30 points
Any candle whose body exceeds 30 points is classified as an Elephant Bar.
---
Bullish Elephant Bar
Requirements:
✓ Bullish Candle
✓ Body exceeds ATR threshold
✓ Bullish Trend Active
Bullish Elephant Bars suggest aggressive buying pressure and potential institutional participation.
---
Bearish Elephant Bar
Requirements:
✓ Bearish Candle
✓ Body exceeds ATR threshold
✓ Bearish Trend Active
Bearish Elephant Bars suggest aggressive selling pressure and potential institutional participation.
---
Why Elephant Bars Matter
Institutional traders typically enter positions using significant volume and liquidity.
This often creates unusually large candles relative to recent market activity.
Elephant Bars help identify those moments where participation increases dramatically and may signal the beginning of a directional expansion phase.
---
RBI and GBI Confirmation Patterns
The strategy includes continuation confirmations.
RBI (Red Bar Ignored)
Bullish Continuation Pattern
Requirements:
• Previous candle closes bearish
• Current candle closes bullish
• Current candle closes above previous high
• Bullish trend remains active
This pattern suggests buyers have regained control.
---
GBI (Green Bar Ignored)
Bearish Continuation Pattern
Requirements:
• Previous candle closes bullish
• Current candle closes bearish
• Current candle closes below previous low
• Bearish trend remains active
This pattern suggests sellers have regained control.
---
Entry Conditions
Long Positions
A BUY signal occurs when:
✓ Bullish Trend Active
✓ Narrow State Active
✓ Bullish Elephant Bar OR RBI Pattern
✓ No Existing Long Position
---
Short Positions
A SELL signal occurs when:
✓ Bearish Trend Active
✓ Narrow State Active
✓ Bearish Elephant Bar OR GBI Pattern
✓ No Existing Short Position
---
Risk Management
The strategy uses ATR-based stop loss calculations that automatically adapt to changing market volatility.
Formula:
Stop Loss = Entry ± ATR × Multiplier
This helps maintain consistent risk management across different instruments and market conditions.
---
Take Profit Logic
The strategy uses configurable Risk-to-Reward ratios.
Formula:
Target = ATR × Multiplier × Risk Reward Ratio
Example:
Risk = 50 points
Target = 100 points
Reward Ratio = 2:1
This allows traders to maintain a structured and repeatable approach to position management.
---
Inputs and Customization
ATR Length
Controls volatility calculations.
Higher values create smoother signals.
Lower values create faster reactions.
---
ATR Multiplier
Controls stop-loss distance.
Higher values provide more room for volatility.
Lower values create tighter risk control.
---
Risk Reward Ratio (RRR)
Controls profit target distance relative to stop-loss distance.
Common values:
• 2.0
• 3.0
• 4.0
---
Elephant Bar Multiplier
Controls how large a candle must be before being classified as an Elephant Bar.
Higher values:
• Fewer signals
• Stronger momentum requirements
Lower values:
• More signals
• Faster entries
---
Narrow State Percentage
Controls how close the EMA 20 and SMA 200 must be before a compression phase is recognized.
Smaller values:
• Stricter setups
• Higher selectivity
Larger values:
• More opportunities
• Increased signal frequency
---
Best Practice
The strategy performs best when used as a confirmation tool rather than a prediction tool.
Wait for trend alignment.
Wait for compression.
Wait for volatility expansion.
Then execute according to the rules.
Patience and discipline are often more important than prediction.
The market rewards consistency more than excitement.
---
Disclaimer
This strategy is intended for educational and research purposes only.
Past performance does not guarantee future results.
Always perform your own testing, validation, and risk management before trading live capital.
The Yuri Garcia Institutional Liquidity Strategy (YGILS) is a trend-following and volatility-expansion methodology designed to identify high-probability trading opportunities during periods of market compression and directional momentum.
The strategy combines trend analysis, volatility measurements, momentum confirmation, and risk management into a structured framework that helps traders identify potential institutional participation while maintaining disciplined execution.
The primary objective is not to predict every market move, but rather to participate when multiple conditions align in favor of a directional expansion.
---
Strategy Philosophy
Markets alternate between periods of compression and expansion.
During compression, price contracts, volatility decreases, and market participants become indecisive.
During expansion, volatility increases, momentum accelerates, and directional opportunities emerge.
The strategy is specifically designed to identify the transition from low-volatility environments to high-volatility environments.
The Narrow State identifies compression.
The Elephant Bar identifies expansion.
The highest-quality opportunities typically occur when an Elephant Bar appears shortly after a period of compression and in the direction of the prevailing trend.
---
Core Components
Trend Identification
The strategy uses:
• 20 EMA (Short-Term Momentum)
• 200 SMA (Long-Term Trend)
Bullish Environment
✓ Price above 200 SMA
✓ 20 EMA above 200 SMA
Bearish Environment
✓ Price below 200 SMA
✓ 20 EMA below 200 SMA
This trend filter prevents traders from taking long positions against a bearish market and short positions against a bullish market.
---
Narrow State
A Narrow State occurs when the distance between the EMA 20 and SMA 200 contracts below a user-defined percentage threshold.
Formula:
Distance % = |EMA20 − SMA200| ÷ SMA200 × 100
The Narrow State represents a market compression phase.
Historically, significant market moves frequently begin after periods of compression.
The strategy seeks to participate during the transition from compression into expansion.
Important
The optimal Narrow State threshold depends on the instrument, timeframe, and market volatility.
Lower values produce stricter setups and fewer signals.
Higher values produce more signals but may increase market noise.
Traders are encouraged to optimize this setting based on the specific market being traded.
---
Elephant Bars
An Elephant Bar represents a significant expansion in volatility and directional conviction.
The candle body must exceed the Average True Range (ATR) multiplied by the Elephant Bar Multiplier selected by the user.
Formula:
Candle Body Size > ATR × Elephant Multiplier
Example
ATR = 20 points
Elephant Multiplier = 1.5
Required Body Size = 30 points
Any candle whose body exceeds 30 points is classified as an Elephant Bar.
---
Bullish Elephant Bar
Requirements:
✓ Bullish Candle
✓ Body exceeds ATR threshold
✓ Bullish Trend Active
Bullish Elephant Bars suggest aggressive buying pressure and potential institutional participation.
---
Bearish Elephant Bar
Requirements:
✓ Bearish Candle
✓ Body exceeds ATR threshold
✓ Bearish Trend Active
Bearish Elephant Bars suggest aggressive selling pressure and potential institutional participation.
---
Why Elephant Bars Matter
Institutional traders typically enter positions using significant volume and liquidity.
This often creates unusually large candles relative to recent market activity.
Elephant Bars help identify those moments where participation increases dramatically and may signal the beginning of a directional expansion phase.
---
RBI and GBI Confirmation Patterns
The strategy includes continuation confirmations.
RBI (Red Bar Ignored)
Bullish Continuation Pattern
Requirements:
• Previous candle closes bearish
• Current candle closes bullish
• Current candle closes above previous high
• Bullish trend remains active
This pattern suggests buyers have regained control.
---
GBI (Green Bar Ignored)
Bearish Continuation Pattern
Requirements:
• Previous candle closes bullish
• Current candle closes bearish
• Current candle closes below previous low
• Bearish trend remains active
This pattern suggests sellers have regained control.
---
Entry Conditions
Long Positions
A BUY signal occurs when:
✓ Bullish Trend Active
✓ Narrow State Active
✓ Bullish Elephant Bar OR RBI Pattern
✓ No Existing Long Position
---
Short Positions
A SELL signal occurs when:
✓ Bearish Trend Active
✓ Narrow State Active
✓ Bearish Elephant Bar OR GBI Pattern
✓ No Existing Short Position
---
Risk Management
The strategy uses ATR-based stop loss calculations that automatically adapt to changing market volatility.
Formula:
Stop Loss = Entry ± ATR × Multiplier
This helps maintain consistent risk management across different instruments and market conditions.
---
Take Profit Logic
The strategy uses configurable Risk-to-Reward ratios.
Formula:
Target = ATR × Multiplier × Risk Reward Ratio
Example:
Risk = 50 points
Target = 100 points
Reward Ratio = 2:1
This allows traders to maintain a structured and repeatable approach to position management.
---
Inputs and Customization
ATR Length
Controls volatility calculations.
Higher values create smoother signals.
Lower values create faster reactions.
---
ATR Multiplier
Controls stop-loss distance.
Higher values provide more room for volatility.
Lower values create tighter risk control.
---
Risk Reward Ratio (RRR)
Controls profit target distance relative to stop-loss distance.
Common values:
• 2.0
• 3.0
• 4.0
---
Elephant Bar Multiplier
Controls how large a candle must be before being classified as an Elephant Bar.
Higher values:
• Fewer signals
• Stronger momentum requirements
Lower values:
• More signals
• Faster entries
---
Narrow State Percentage
Controls how close the EMA 20 and SMA 200 must be before a compression phase is recognized.
Smaller values:
• Stricter setups
• Higher selectivity
Larger values:
• More opportunities
• Increased signal frequency
---
Best Practice
The strategy performs best when used as a confirmation tool rather than a prediction tool.
Wait for trend alignment.
Wait for compression.
Wait for volatility expansion.
Then execute according to the rules.
Patience and discipline are often more important than prediction.
The market rewards consistency more than excitement.
---
Disclaimer
This strategy is intended for educational and research purposes only.
Past performance does not guarantee future results.
Always perform your own testing, validation, and risk management before trading live capital.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.