OPEN-SOURCE SCRIPT

HOD/LOD/PMH/PML/PDH/PDL Strategy by @tradingbauhaus

This script is a trading strategy tradingbauhaus designed to trade based on key price levels, such as the High of Day (HOD), Low of Day (LOD), Premarket High (PMH), Premarket Low (PML), Previous Day High (PDH), and Previous Day Low (PDL). Below, I’ll explain in detail what the script does:

Core Functionality of the Script:
Calculates Key Price Levels:

HOD (High of Day): The highest price of the current day.

LOD (Low of Day): The lowest price of the current day.

PMH (Premarket High): The highest price during the premarket session (before the market opens).

PML (Premarket Low): The lowest price during the premarket session.

PDH (Previous Day High): The highest price of the previous day.

PDL (Previous Day Low): The lowest price of the previous day.

Draws Horizontal Lines on the Chart:

Plots horizontal lines on the chart for each key level (HOD, LOD, PMH, PML, PDH, PDL) with specific colors for easy visual identification.

Defines Entry and Exit Rules:

Long Entry (Buy): If the price crosses above the PMH (Premarket High) or the PDH (Previous Day High).

Short Entry (Sell): If the price crosses below the PML (Premarket Low) or the PDL (Previous Day Low).

Long Exit: If the price reaches the HOD (High of Day) during a long position.

Short Exit: If the price reaches the LOD (Low of Day) during a short position.

How the Script Works Step by Step:
Calculates Key Levels:

Uses the request.security function to fetch the HOD and LOD of the current day, as well as the highs and lows of the previous day (PDH and PDL).

Calculates the PMH and PML during the premarket session (before 9:30 AM).

Plots Levels on the Chart:

Uses the plot function to draw horizontal lines on the chart representing the key levels (HOD, LOD, PMH, PML, PDH, PDL).

Each level has a specific color for easy identification:

HOD: White.

LOD: Purple.

PDH: Orange.

PDL: Blue.

PMH: Green.

PML: Red.

Defines Trading Rules:

Uses conditions with ta.crossover and ta.crossunder to detect when the price crosses key levels.

Long Entry: If the price crosses above the PMH or PDH, a long position (buy) is opened.

Short Entry: If the price crosses below the PML or PDL, a short position (sell) is opened.

Long Exit: If the price reaches the HOD during a long position, the position is closed.

Short Exit: If the price reaches the LOD during a short position, the position is closed.

Executes Orders Automatically:

Uses the strategy.entry and strategy.close functions to open and close positions automatically based on the defined rules.

Advantages of This Strategy:
Based on Key Levels: Uses important price levels that often act as support and resistance.

Easy to Visualize: Horizontal lines on the chart make it easy to identify levels.

Automated: Entries and exits are executed automatically based on the defined rules.

Limitations of This Strategy:
Dependent on Volatility: Works best in markets with significant price movements.

False Crosses: There may be false crosses that generate incorrect signals.

No Advanced Risk Management: Does not include dynamic stop-loss or take-profit mechanisms.

How to Improve the Strategy:
Add Stop-Loss and Take-Profit: To limit losses and lock in profits.

Filter Signals with Indicators: Use RSI, MACD, or other indicators to confirm signals.

Optimize Levels: Adjust key levels based on the asset’s behavior.

In summary, this script is a trading strategy that operates based on key price levels, such as HOD, LOD, PMH, PML, PDH, and PDL. It is useful for traders who want to trade based on significant support and resistance levels.
Bands and ChannelsBreadth IndicatorsbreakoutstrategyChart patternsema-crossovermacd-convergencemovingaveragecrossoverpullbackstrategytrendfollowingtrendreversal

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer