MacD Short and/or Long with Bi-Directional TP and SL
Oct 30, 2021

The MacD Short and/or Long with Bi-Directional TP and SL indicator provides a comprehensive framework for testing and executing MACD-based strategies with independent parameters for long and short directions. By allowing separate lengths, smoothing types, and exit conditions for each market direction, traders can optimize their approach based on the asymmetrical nature of market movements.
Usage
The script is designed for traders who want to refine their MACD strategy by treating long and short positions as distinct setups. Users can enable or disable either direction and apply specific Moving Average types (SMA or EMA) for the oscillator and signal lines.
Examples of usage include:
- Asymmetrical Optimization: Setting a faster MACD period for short entries to catch quick pullbacks while using a slower period for long entries to follow broader trends.
- Directional Risk Management: Applying a 20% take profit for short positions while using a tighter 5% stop loss for long positions, allowing for strategy flexibility in different market regimes.
- Visual Analysis: Comparing two different MACD configurations simultaneously on the same chart to determine which settings react better to price action.
Details
The indicator calculates two independent MACD sets. Each set includes a MACD line, a Signal line, and a Histogram. The strategy logic supports specific entry triggers such as the MACD line crossing a defined "Cross Point" or requiring a secondary confirmation where the Signal line must also cross.
A unique feature is the inclusion of "Cross Delays," which allows the strategy to wait for a specific number of bars after a crossover before triggering an entry. This can be used to filter out noise or wait for trend confirmation.
Settings
Inputs Long / Short
- Allow Long/Short: Enables or disables the execution and plotting for the respective direction.
- Fast/Slow Length: Determines the periods used for the underlying moving averages.
- Oscillator/Signal MA Type: Allows selection between SMA and EMA for the calculations.
- Cross Point: The level at which the MACD line must cross to trigger a signal (default is 0).
- MacD/Signal Cross Delay: Specifies the number of bars to delay the signal after a cross occurs.
- Signal Must Also Cross: When enabled, the strategy requires both the MACD and Signal lines to be across the Cross Point for an entry.
Stop/Profit Long / Short
- Use Stop Loss/Take Profit: Toggles the respective exit condition.
- Stop Loss % / Take Profit %: Sets the percentage-based distance for exits from the entry price.
FAQ
How do I use the MacD Short and/or Long with Bi-Directional TP and SL?
You can search for the script name in the TradingView indicators search bar. Once added, you can toggle long or short inputs in the settings menu to customize your strategy.
Can I see only one MACD histogram at a time?
Yes, you can navigate to the "Style" tab in the script settings and uncheck the visibility of the "Histogram Long" or "Histogram Short" to focus on a single direction.
Where can I access more tools like this?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.