Trade Direction

Trade Direction in Pine Algo - choose the market direction: Long only, Short only, or automatic selection via plugin. This allows testing of different market scenarios.

Pine Algo

Pine Algo umożliwia rozwijanie i optymalizowanie strategii automatycznych w PineScript na platformie TradingView.

Trade Direction in Pine Algo determines the direction in which the strategy executes trades - Long, Short, or automatically based on an external data source (Plugins). It is a key setting that affects how entry and exit signals are interpreted and how the strategy reacts to trend changes.

Choosing the right direction allows Pine Algo to adapt to current market conditions, test algorithm behavior under different scenarios, and create strategies that dynamically respond to trend direction.

Trade Direction Modes

The strategy supports three trade direction modes:

Long

Long In this mode, Pine Algo opens only long (buy) positions. All sell signals are ignored, and the strategy responds solely to signals confirming potential price increases. Long mode is best suited for uptrends, in markets with a natural appreciation tendency - e.g., stock indices, ETFs, or cryptocurrencies with long-term growth.

This setting allows focusing on one side of the market, reducing the risk of false entries during consolidation or trend reversals.

Short

Short Short mode works inversely - the strategy opens only short (sell) positions, reacting to downward signals. Buy signals are ignored, with the primary goal of profiting from price declines. This mode is useful in strong downtrends, corrections, or periods when assets show clear weakness.

Short mode can also be used for contrarian testing - for example, to see how the strategy behaves under reversed trend conditions relative to standard signals.

Source

Source Source mode is the most flexible trade direction setting, allowing the strategy to automatically adjust trade direction based on data from a selected external source (plugin or custom Pine Script indicator).

In this mode, Pine Algo is not limited to a single direction - it can dynamically switch between long and short positions depending on the source signal. This is especially useful in advanced setups where the user wants to integrate Pine Algo with a custom trend indicator or an external plugin defining trade direction.

Direction Source

The Direction Source field specifies the data source used to determine trade direction when Source mode is selected. This allows using data from a Pine Algo plugin to automatically decide whether the strategy should open Long or Short positions.

The source value is read on each candle, so the strategy’s direction can change dynamically in real time.

Example: The strategy creates Long orders if the current price is below the EMA, or Short orders if the price is above EMA 14.

Reverse Source

The Reverse Source option inverts the logic of the source signal. If the source indicates a Long position, activating Reverse Source will instead open a Short position, and vice versa.

This is particularly useful for:

  • Testing reversed strategies
  • Creating experimental Pine Algo variants that interact with other plugins

It allows users to easily see how the strategy would behave if trend logic is reversed, without modifying the script manually.

Summary

Trade direction parameters in Pine Algo give full control over how the strategy reacts to market signals. From simple one-direction settings to complex automatic control using external sources, this module provides maximum flexibility and precision for adapting the strategy to any market condition.

With Reverse Source, users can also easily test contrarian or experimental scenarios, making Pine Algo a powerful tool for both manual traders and fully automated trading systems.