OPEN-SOURCE SCRIPT

Dow Theory Swing Trading-Dexter

This Pine Script strategy that implements a basic price action-based trading system inspired by Dow Theory, focusing on swing highs and swing lows. This strategy will generate buy and sell signals based on the formation of higher highs (HH) and higher lows (HL) for an uptrend, and lower highs (LH) and lower lows (LL) for a downtrend.

Swing Highs and Swing Lows:

The script identifies swing highs and swing lows using the ta.highest and ta.lowest functions over a specified lookback period.

A swing high is identified when the high of the current bar is the highest high over the lookback period.

A swing low is identified when the low of the current bar is the lowest low over the lookback period.

Trend Detection:

An uptrend is detected when the current low is higher than the last identified swing low.

A downtrend is detected when the current high is lower than the last identified swing high.

Buy and Sell Signals:

A buy signal is generated when the price closes above the last swing high during an uptrend.

A sell signal is generated when the price closes below the last swing low during a downtrend.

Plotting:

Swing highs and swing lows are plotted on the chart using plotshape.

Buy and sell signals are also plotted on the chart for visual reference.

How to Use:
Copy and paste the script into the Pine Script editor in TradingView.

Adjust the lookback period as needed to suit your trading style and timeframe.

Apply the script to your chart and it will generate buy and sell signals based on the price action.

NOTE: Please uncheck the all the unwanted symbol from chart for clear view .

Penafian