Pinbar trailing stop strategy
Jun 4, 2022

The Pinbar trailing stop strategy indicator automates the detection of pinbar candlestick patterns to execute trades with customizable risk-management parameters, including dynamic trailing stops.
Usage
The Usage section describes how the script can be used to identify trend reversals or continuations through pinbar patterns. A long position is initiated when a bullish pinbar is detected, while a short position is initiated upon a bearish pinbar. Users can define specific multipliers to set exit targets based on the volatility of the signal candle.
Trade Management
The script allows for flexible exit logic. Users can choose between fixed limit orders or trailing stops. The trailing stop feature is designed to lock in profits as the price moves in the favorable direction after reaching a specified threshold. Additionally, the strategy can be configured to close existing positions if an opposing signal occurs, ensuring the user is always aligned with the most recent price action signal.
Details
The script identifies pinbars based on the relationship between the candle body and its total range. For a bullish pinbar, the body must reside in the upper 30% of the candle's range, and the low must be lower than the previous bar's low. Conversely, a bearish pinbar requires the body to be in the lower 30% of the range, with a high exceeding the previous bar's high.
The exit levels are calculated using the "signal candle" size (High - Low). The Take Profit is determined by multiplying this size by the user-defined Profit Multiplier, while the Stop Loss uses the Loss Multiplier. When trailing stops are enabled, the strategy.exit function monitors the trail_price to adjust the exit point dynamically.
Settings
Profit options
- Profit multiplier: Sets the target price as a multiple of the signal candle size relative to the entry price.
- Loss multiplier: Sets the stop loss level as a multiple of the signal candle size relative to the entry price.
Trading options
- Use trailing stops?: When enabled, converts the take profit level into a trailing trigger to capture extended trends.
- Close trade if opposite signal occurs?: If enabled, a long trade will close immediately upon a bearish pinbar signal, and vice versa.
- Enter long trades?: Toggles the execution of bullish entry signals.
- Enter short trades?: Toggles the execution of bearish entry signals.
Backtest Time Period
- Begin Backtest at Start Date: Enables a filter to restrict trade execution to a specific timeframe.
- Start Date: Defines the exact date and time the strategy begins processing signals for backtesting.
FAQ
How do I identify a valid signal on the chart? The script plots a green up-arrow below the bar for bullish pinbar signals and a red down-arrow above the bar for bearish pinbar signals.
Can I use this for automated trading? Yes, the script includes alert conditions for both bullish and bearish detections which can be linked to external execution bridges.
How can I access the Pinbar trailing stop strategy? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

