OPEN-SOURCE SCRIPT

Camarilla Pivots + 20 EMA Strategy

92
This is an intraday volatility and trend-following system for commodities like Natural Gas, combining dynamic pivot levels (Camarilla) with a trend filter (20-period EMA) to improve risk-reward and reduce false breakouts.

Core Components
1. Camarilla Pivots:

These are special support and resistance levels (H3, H4, L3, L4) calculated each day based on the previous day's high, low, and close.

The pivots adapt to daily volatility, giving more relevant breakout and bounce zones than static lines.

H4: Aggressive resistance (used for breakout LONG entry)

H3: Moderate resistance/support (used for bounce or stoploss)

L4: Aggressive support (used for breakout SHORT entry)

L3: Moderate support/resistance (used for bounce or stoploss)

2. 20 EMA (Exponential Moving Average):

Plotted on the 30-minute chart, this acts as a trend filter.

If the price is above 20 EMA: Only look for long trades (bullish bias).

If below 20 EMA: Only look for short trades (bearish bias).

How the Strategy Works
Setup (30-Min Chart):

Camarilla pivots for the day are drawn on the chart.

20 EMA is also plotted.

Trade Filter:

Bullish: Trade ONLY if price is above 20 EMA.

Bearish: Trade ONLY if price is below 20 EMA.

Entry:

LONG: Enter when price breaks and closes above the H4 pivot AND is above 20 EMA.

SHORT: Enter when price breaks and closes below the L4 pivot AND is below 20 EMA.

Stop Loss:

LONG: Place stoploss at H3 (the next lower Camarilla resistance).

SHORT: Place stoploss at L3 (the next higher Camarilla support).

Target:

Always set a profit target at 2x the distance (risk) between entry and stoploss (strict R:R 2).

For example, if your entry is at H4 and stoploss at H3, your target is entry + 2*(entry - stoploss).

Alerts & Visuals:

The strategy plots entry arrows, stoploss and target lines for immediate visual reference.

Alerts trigger on breakout signals so you never miss a trade.

Why This Works Well for Natural Gas
Adapts to volatility: The pivots change daily, handling wide-ranging and choppy price moves better than fixed breakouts.

Trend filter: EMA prevents counter-trend whipsaws, only trades with market momentum.

Risk control: Every trade must meet strict risk-reward criteria, so losses are contained and winners can outweigh losers.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.