Logo hamster-bot
RU EN PT

Loading…

← All strategies

ZigZag, ZZ

The main idea of the strategy is to catch a strong trend move as early as possible and hold the position for the duration of the trend. A trade is opened when the price breaks levels built in advance from past price highs/lows.

It is based on logic similar to the ZigZag indicator:
● When the market starts to turn up, a local low is recorded
● When it turns down, a local high is recorded
These points become reference points. They form the levels the market has to break to confirm the move.

Reversible (flip long ↔ short)
The position is always open and flips from short to long and back. (Unless strategy modifiers are used - they are described below in the «Parameters and modifiers» block)

⚠️ The strategy produces losing trades when the market moves sideways and during V-shaped reversals.

Order type: Stop Market order (on some exchanges it may also be called a Conditional or Trigger order)

Example of conditional order placement

● Green marks where the conditional buy order is placed: a breakout of the last significant high.
● Red marks the sell order: the price breaks the last low.

After the strategy starts, if there is no position and the price is between the levels, 1 order to open a long position and 1 order to open a short are placed. If the price is not between the levels or there is an open position, 1 order is placed.

If a position is open, the strategy keeps only 1 order. By default its size = position size * 2, so that it flips the position (closes it and opens a new one of the same size).

Strategy Trend Zig Zag and ZZ - what is the difference

Strategy Trend Zig Zag (zigzag, selected by default when a bot is created) - a simple version with a minimum of settings, the counterpart of the «Simple trend strategy» script on TradingView. Levels are built the same way as in ZZ2, and the position is flipped by stop orders. The modifiers and filters from the «Parameters and modifiers» block are not used in it.

ZZ (zz) - the full version: two level types (ZZ2 and ZZ6) and all the modifiers, filters and position size settings described below.

Level types: ZZ2 and ZZ6

ZZ2 (default) - levels are built from the reversal points of the smoothed price. The algorithm is explained in detail in the «For the curious» block.
depth - reversal search depth (default 5)
detection, detection_type, detection_source - length, type (EMA by default) and price source of the smoothing line whose reversals define the points
rsi_len, rsi_value - an additional RSI condition for a reversal point. Not used when rsi_value = 0

ZZ6 - levels are built from two high/low channels: a fast one of length zz6_len and a slow one of length zz6_len_slow (if not set, zz6_len * 3). A level is fixed when the fast and slow channels coincide (the price made a new extreme) and the fast channel starts to turn.
In ZZ6 the position size depends on risk: the wider the distance between levels (and so the farther the stop), the smaller the lot.

Parameters and modifiers

Operating mode

Level settings

Entry filters

When a filter blocks an entry, the bot does not open a new position, but the order to close the current position at the opposite level stays in place.

Position size

Position closing

Backtest
Test in the built-in backtester

A PineScript script for testing the strategy on historical data in the TradingView strategy tester:

Recommendations: (not strict, you can break them for research purposes)
Working timeframe: 4h and higher.

Recommended timeframe

For the curious

The level-building algorithm of the ZZ2 strategy. It does not use the standard ZigZag indicator. The code shows how simple it is and that repainting is ruled out. But the levels are built with a delay of a few candles (this does not hurt the strategy at all)

Code fragment of the ZZ2 algorithm

Three sequentially smoothed EMAs are used. This gives strong smoothing and reduces noise.
The variable z records reversal points. If the EMA turns up → a local low (l) is taken. If it turns down → a local high (h). These points (l and h) become the basis for building the levels.


Backtest the strategy on historical data in the tester and run it in hamster-bot.