OPEN-SOURCE SCRIPT
Atualizado Simple ZigZag Double

Strategy Description
A simple trend-following strategy with a minimal number of parameters.
The logic is based on the ZigZag concept, but interpreted in a different way so that the algorithm does not repaint and does not rely on pivot indicators.
The key difference from many similar approaches is that Long and Short levels have separate settings, allowing more flexible tuning of the strategy behavior.
By default, the strategy includes a 0.1% commission in the backtest.
Settings
Use Long – Enable or disable opening Long positions.
Use Short – Enable or disable opening Short positions.
Length – Affects the frequency of level creation and the position of the ZigZag point used by the algorithm.
Detection – Determines the price level. It controls how many candles after the ZigZag point are used to search for the minimum or maximum price.
Lot Long, % – Percentage of equity allocated to opening a Long position.
Lot Short, % – Percentage of equity allocated to opening a Short position.
Time Start – Start of the testing period.
Time End – End of the testing period.
Example: you can test only a specific time range (for example, August 2020).
Recommended Timeframes
The strategy is designed primarily for timeframes of 4H and higher.
Strategy Logic
The main idea of the strategy is to capture strong trending market movements as early as possible and hold the position during the trend.
Trades are opened when the price breaks predefined levels built from previous highs or lows.
The strategy generally keeps a position open and reverses from Short to Long (or vice versa) when an opposite signal occurs, unless additional modifications of the strategy are used.
⚠️ The strategy may generate losing trades during sideways markets and during sharp V-shaped reversals.
Order Type
The strategy uses Market Stop orders (on some exchanges these may be called Conditional or Trigger orders).
Green level – price where a conditional order to open a Long position is placed.
Red level – price where a conditional order to open a Short position is placed.
Order Logic
When the strategy starts:
If there is no open position and the price is between the levels, two orders are placed:
one order to open a Long position
one order to open a Short position
If the price is not between the levels, or if a position is already open, only one order will be placed.
When a position is open, the strategy maintains only one active order.
By default, the size of this order equals position size × 2, which allows the strategy to close the current position and immediately open a new one in the opposite direction when the level is triggered.
A simple trend-following strategy with a minimal number of parameters.
The logic is based on the ZigZag concept, but interpreted in a different way so that the algorithm does not repaint and does not rely on pivot indicators.
The key difference from many similar approaches is that Long and Short levels have separate settings, allowing more flexible tuning of the strategy behavior.
By default, the strategy includes a 0.1% commission in the backtest.
Settings
Use Long – Enable or disable opening Long positions.
Use Short – Enable or disable opening Short positions.
Length – Affects the frequency of level creation and the position of the ZigZag point used by the algorithm.
Detection – Determines the price level. It controls how many candles after the ZigZag point are used to search for the minimum or maximum price.
Lot Long, % – Percentage of equity allocated to opening a Long position.
Lot Short, % – Percentage of equity allocated to opening a Short position.
Time Start – Start of the testing period.
Time End – End of the testing period.
Example: you can test only a specific time range (for example, August 2020).
Recommended Timeframes
The strategy is designed primarily for timeframes of 4H and higher.
Strategy Logic
The main idea of the strategy is to capture strong trending market movements as early as possible and hold the position during the trend.
Trades are opened when the price breaks predefined levels built from previous highs or lows.
The strategy generally keeps a position open and reverses from Short to Long (or vice versa) when an opposite signal occurs, unless additional modifications of the strategy are used.
⚠️ The strategy may generate losing trades during sideways markets and during sharp V-shaped reversals.
Order Type
The strategy uses Market Stop orders (on some exchanges these may be called Conditional or Trigger orders).
Green level – price where a conditional order to open a Long position is placed.
Red level – price where a conditional order to open a Short position is placed.
Order Logic
When the strategy starts:
If there is no open position and the price is between the levels, two orders are placed:
one order to open a Long position
one order to open a Short position
If the price is not between the levels, or if a position is already open, only one order will be placed.
When a position is open, the strategy maintains only one active order.
By default, the size of this order equals position size × 2, which allows the strategy to close the current position and immediately open a new one in the opposite direction when the level is triggered.
Notas de Lançamento
New parameter strict_position. If enabled, it prohibits opening a long position if the strategy already requires an open long position. The same logic applies to short positions. This is necessary to prevent a trade from being entered into after the strategy is enabled that wasn't backtested.Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
hamster-bot.com/phoenix - инвестиционный алгофонд - консервативный доход
t.me/bothamster - канал бота
t.me/bothamster - канал бота
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
hamster-bot.com/phoenix - инвестиционный алгофонд - консервативный доход
t.me/bothamster - канал бота
t.me/bothamster - канал бота
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.