Join today
Strategies / Trend / SuperTrend SAR MACD

SuperTrend SAR MACD

A trade needs SuperTrend(3, 5) to turn after a limited run, Parabolic SAR on the right side of price, and a MACD histogram move above a set size. A smoothed buy and sell pressure reading must agree. This strategy has not been backtested yet.

TrendLong & shortSwingNot yet tested
This strategy has not been backtested yet. The rules and code are published now, and the numbers will appear here after the first runs.

Entry rules, long

  1. Members only
  2. Parabolic SAR is below the close
  3. MACD histogram rose by more than 0.045 points
  4. Smoothed buy-sell pressure is rising
  5. Previous bar range is above 2 pips
  6. No position is open

Entry rules, short

  1. Members only
  2. Parabolic SAR is above the close
  3. MACD histogram fell by more than 0.186 points
  4. Smoothed buy-sell pressure is falling
  5. Previous bar range is above 2 pips
  6. No position is open

Exit rules

  1. Stop loss of 10 points
  2. Members only

Parameters

positionSize
Size per point
1
stMultiplier
SuperTrend ATR multiplier
3
stPeriod
SuperTrend ATR length
5
sarStart
Parabolic SAR start factor
0.02
sarStep
Parabolic SAR step
0.02
sarMax
Parabolic SAR maximum factor
0.03
macdFast
MACD fast length
12
macdSlow
MACD slow length
26
macdLineArg
Third MACDline argument, as published
150
macdSignalPeriod
EMA of the MACD line used as signal
9
lookbackPeriod
Window for the pressure calculation
100
pressurePeriod
EMA length that smooths buy and sell pressure
500
minTrendBars
SuperTrend must have held its side longer than this
15
longMacdSlope
Minimum rise of the MACD histogram for longs (points)
0.045
shortMacdSlope
Minimum fall of the MACD histogram for shorts (points)
0.186
minRangePips
Previous bar range must exceed this (pips)
2
takeProfitPoints
Profit target (points)
10
stopLossPoints
Protective stop (points)
10

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// SuperTrend SAR MACD
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: Not yet tested
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false

// --- Parameters ---
positionSize = 1           // size per point
stMultiplier = 3           // SuperTrend ATR multiplier
stPeriod = 5               // SuperTrend ATR length
sarStart = 0.02            // Parabolic SAR start factor
sarStep = 0.02             // Parabolic SAR step
sarMax = 0.03              // Parabolic SAR maximum factor
macdFast = 12              // MACD fast length
macdSlow = 26              // MACD slow length
macdLineArg = 150          // third MACDline argument, as published
macdSignalPeriod = 9       // EMA of the MACD line used as signal
lookbackPeriod = 100       // window for the pressure calculation
pressurePeriod = 500       // EMA length that smooths buy and sell pressure
minTrendBars = 15          // SuperTrend must have held its side longer than this
longMacdSlope = 0.045      // minimum rise of the MACD histogram for longs (points)
shortMacdSlope = 0.186     // minimum fall of the MACD histogram for shorts (points)
minRangePips = 2           // previous bar range must exceed this (pips)
takeProfitPoints = 10      // profit target (points)
stopLossPoints = 10        // protective stop (points)
ONCE stNotRisingBars = 0   // bars in a row the SuperTrend has not risen
ONCE stNotFallingBars = 0  // bars in a row the SuperTrend has not fallen

// --- Indicators ---
stValue = SuperTrend[stMultiplier, stPeriod]
sarValue = SAR[sarStart, sarStep, sarMax]
macdMain = MACDline[macdFast, macdSlow, macdLineArg](close)
macdTrigger = ExponentialAverage[macdSignalPeriod](MACDline[macdFast, macdSlow, macdLineArg](close))
macdHistogram = macdMain - macdTrigger
barRange = Range

// Buying versus selling pressure over the lookback window, smoothed.
channelLow = Lowest[lookbackPeriod](low)
channelHigh = Highest[lookbackPeriod](high)
buyPressure = 100 * (3 * close - 2 * channelLow - open[lookbackPeriod - 1]) / CustomClose
sellPressure = 100 * (open[lookbackPeriod - 1] + 2 * channelHigh - 3 * close) / CustomClose
pressureSpread = ExponentialAverage[pressurePeriod](buyPressure) - ExponentialAverage[pressurePeriod](sellPressure)

IF stValue[2] >= stValue[1] THEN
  stNotRisingBars = stNotRisingBars + 1
ELSE
  stNotRisingBars = 0
ENDIF

IF stValue[1] >= stValue[2] THEN
  stNotFallingBars = stNotFallingBars + 1
ELSE
  stNotFallingBars = 0
ENDIF

17 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • Untested. There are no backtest results on this page.
  • Six conditions must line up for an entry, so trades may be rare.
  • The MACD thresholds (0.045 for longs, 0.186 for shorts) are in price points and will behave very differently from one instrument to another.
  • A 10-point stop and 10-point target are tight on most markets, so spread will matter.

Indicators used

SuperTrendParabolic SARMACDEMA

How to load it

  1. Copy the code with the copy button above the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Questions

About this strategy

Can it run in ProOrder?

The code is written for ProOrder, but it has not been compile-checked or backtested yet. Treat it as a starting point for your own tests.

Which instruments has it been tested on?

None yet. Results will be added once it has been through the test battery.

What position size does the code use?

It trades a size of 1 per point. With no backtest there is no drawdown figure yet, so start small in demo.

Related

Strategies like this one

Monday Dip Buy

Uses the same indicator.

n/a PF · 146 trades

Long-Term Moving Average Cross

Also a trend strategy.

12.31 PF · 61 trades

Slow MACD Slope

Also a trend strategy.

6.80 PF · 7,305 trades

Want to know when new tests like this go live? Join the ProRealAlgos waitlist.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs