US Small-Cap Stock TradingView Strategy

Job ID: 40504535

Budget: €30 – €250 EUR

TradingView Strategy Development Specification
Objective

Develop a TradingView strategy (Pine Script v5 or v6) primarily designed for U.S. small-cap stocks.

The concept is based on the compression and expansion of multiple exponential moving averages (EMAs) to identify the beginning of strong momentum trends and remain in the trade for as long as the trend remains valid.

Please review the attached chart examples carefully, as they illustrate the specific market structures and behaviors that the strategy should detect.

Moving Averages Used
EMA 5
EMA 20
EMA 34
EMA 50
EMA 200
Buy Conditions

A long position should be initiated when a valid EMA compression pattern is detected.

Compression is defined as a situation where the EMA 5, EMA 20, EMA 34, and EMA 50 converge into a relatively tight range before a directional move begins.

The entry should occur when this compression transitions into bullish expansion and the EMAs align in a bullish order.

Desired bullish alignment:

EMA 5 > EMA 20 > EMA 34 > EMA 50 > EMA 200

The goal is to identify the beginning of a strong trend following a period of consolidation.

Primary Trend Filter

The strategy must never take long trades in bearish market conditions.

The EMA 200 should be used as the primary trend filter.

Long positions should only be considered when the overall market structure remains bullish and the EMA stack is positioned above the EMA 200.

Exit Conditions

The exit logic should adapt to two different market structures.

Scenario 1 – EMA Compression Structure

When the EMAs remain relatively close together, exits may occur more aggressively.

In this environment, a loss of momentum detected through the EMA 5 changing slope or changing color may be sufficient to trigger an exit.

Scenario 2 – EMA Expansion Structure

When the EMAs become widely separated and maintain strong bullish alignment, the trend should be considered mature and healthy.

In this environment:

Normal pullbacks should be ignored.
Small retracements should not trigger exits.
The strategy should remain in the trade while momentum remains intact.

An exit should only be considered when a pullback becomes significantly deeper than previous pullbacks, indicating potential momentum exhaustion and a possible end of the trend.

The objective is to avoid exiting prematurely during normal trend pauses and to capture the majority of large trend-day moves.

Trend Philosophy

When the EMAs are tightly compressed, momentum shifts occur more quickly and exits can be more responsive.

When the EMAs are widely separated and expanding, normal pullbacks should be treated as healthy trend behavior rather than reversal signals.

The strategy should recognize these two market regimes and adapt its exit logic accordingly.

Visual Output

The chart should remain as clean as possible.

Preferred visual elements:

BUY signal
SELL signal

Avoid unnecessary visual clutter whenever possible.

Alerts

Create TradingView alerts for:

BUY
SELL

Alerts must be compatible with automation through TradeSpot.

Trading Sessions

The strategy must function during:

Pre-market
Regular market hours
After-hours / Post-market

No session restrictions should be imposed.

Important Notes

The attached chart examples demonstrate two distinct market structures:

EMA Compression
EMA Expansion

The strategy should identify and treat these environments differently.

Particular attention should be given to the distinction between:

Normal pullbacks
Abnormally deep pullbacks
Trend continuation
Momentum exhaustion
Key Development Question

A critical part of this project is determining how to objectively measure EMA compression and EMA expansion.

Possible approaches may include:

Percentage distance between EMAs
Relative EMA spread
Statistical volatility measurements
Custom expansion/compression scoring

The final implementation should avoid subjective interpretation and rely on clear, quantifiable rules.

The goal is to create a repeatable, objective strategy capable of identifying strong trend-day opportunities while avoiding premature exits.
Related categories: Pine Script Trading