Long-Only Opening Range Breakout (ORB) with Pivot PointsIntraday Trading Strategy: Long-Only Opening Range Breakout (ORB) with Pivot Points
Background:
Opening Range Breakout (ORB) is a popular long-only trading strategy that capitalizes on the early morning volatility in financial markets. It's based on the idea that the initial price movements during the first few minutes or hours of the trading day can set the tone for the rest of the session. The strategy involves identifying a price range within which the asset trades during the opening period and then taking long positions when the price breaks out to the upside of this range.
Pivot Points are a widely used technical indicator in trading. They represent potential support and resistance levels based on the previous day's price action. Pivot points are calculated using the previous day's high, low, and close prices and can help traders identify key price levels for making trading decisions.
How to Use the Script:
Initialization: This script is written in Pine Script, a domain-specific language for trading strategies on the TradingView platform. To use this script, you need to have access to TradingView.
Apply the Script: You can do this by adding it to your favorites, then selecting the script in the indicators list under favorites or by searching for it by name under community scripts.
Customize Settings: The script allows you to customize various settings through the TradingView interface. These settings include:
Opening Session: You can set the time frame for the opening session.
Max Trades per Day: Specify the maximum number of long trades allowed per trading day.
Initial Stop Loss Type: Choose between using a percentage-based stop loss or the previous candles low for stop loss calculations.
Stop Loss Percentage: If you select the percentage-based stop loss, specify the percentage of the entry price for the stop loss.
Backtesting Start and End Time: Set the time frame for backtesting the strategy.
Strategy Signals:
The script will display pivot points in blue (R1, R2, R3, R4, R5) and half-pivot points in gray (R0.5, R1.5, R2.5, R3.5, R4.5) on your chart.
The green line represents the opening range.
The script generates long (buy) signals based on specific conditions:
---The open price is below the opening range high (h).
---The current high price is above the opening range high.
---Pivot point R1 is above the opening range high.
---It's a long-only strategy designed to capture upside breakouts.
---It also respects the maximum number of long trades per day.
The script manages long positions, calculates stop losses, and adjusts long positions according to the defined rules.
Trailing Stop Mechanism
The script incorporates a dynamic trailing stop mechanism designed to protect and maximize profits for long positions. Here's how it works:
1. Initialization:
The script allows you to choose between two types of initial stop loss:
---Percentage-based: This option sets the initial stop loss as a percentage of the entry price.
---Previous day's low: This option sets the initial stop loss at the previous day's low.
2. Setting the Initial Stop Loss (`sl_long0`):
The initial stop loss (`sl_long0`) is calculated based on the chosen method:
---If "Percentage" is selected, it calculates the stop loss as a percentage of the entry price.
---If "Previous Low" is selected, it sets the stop loss at the previous day's low.
3. Dynamic Trailing Stop (`trail_long`):
The script then monitors price movements and uses a dynamic trailing stop mechanism (`trail_long`) to adjust the stop loss level for long positions.
If the current high price rises above certain pivot point levels, the trailing stop is adjusted upwards to lock in profits.
The trailing stop levels are calculated based on pivot points (`r1`, `r2`, `r3`, etc.) and half-pivot points (`r0.5`, `r1.5`, `r2.5`, etc.).
The script checks if the high price surpasses these levels and, if so, updates the trailing stop accordingly.
This dynamic trailing stop allows traders to secure profits while giving the position room to potentially capture additional gains.
4. Final Stop Loss (`sl_long`):
The script calculates the final stop loss level (`sl_long`) based on the following logic:
---If no position is open (`pos == 0`), the stop loss is set to zero, indicating there is no active stop loss.
---If a position is open (`pos == 1`), the script calculates the maximum of the initial stop loss (`sl_long0`) and the dynamic trailing stop (`trail_long`).
---This ensures that the stop loss is always set to the more conservative of the two values to protect profits.
5. Plotting the Stop Loss:
The script plots the stop loss level on the chart using the `plot` function.
It will only display the stop loss level if there is an open position (`pos == 1`) and it's not a new trading day (`not newday`).
The stop loss level is shown in red on the chart.
By combining an initial stop loss with a dynamic trailing stop based on pivot points and half-pivot points, the script aims to provide a comprehensive risk management mechanism for long positions. This allows traders to lock in profits as the price moves in their favor while maintaining a safeguard against adverse price movements.
End of Day (EOD) Exit:
The script includes an "End of Day" (EOD) exit mechanism to automatically close any open positions at the end of the trading day. This feature is designed to manage and control positions when the trading day comes to a close. Here's how it works:
1. Initialization:
At the beginning of each trading day, the script identifies a new trading day using the `is_newbar('D')` condition.
When a new trading day begins, the `newday` variable becomes `true`, indicating the start of a new trading session.
2. Plotting the "End of Day" Signal:
The script includes a plot on the chart to visually represent the "End of Day" signal. This is done using the `plot` function.
The plot is labeled "DayEnd" and is displayed as a comment on the chart. It signifies the EOD point.
3. EOD Exit Condition:
When the script detects that a new trading day has started (`newday == true`), it triggers the EOD exit condition.
At this point, the script proceeds to close all open positions that may have been active during the trading day.
4. Closing Open Positions:
The `strategy.close_all` function is used to close all open positions when the EOD exit condition is met.
This function ensures that any remaining long positions are exited, regardless of their current profit or loss.
The function also includes an `alert_message`, which can be customized to send an alert or notification when positions are closed at EOD.
Purpose of EOD Exit
The "End of Day" exit mechanism serves several essential purposes in the trading strategy:
Risk Management: It helps manage risk by ensuring that positions are not left open overnight when markets can experience increased volatility.
Capital Preservation: Closing positions at EOD can help preserve trading capital by avoiding potential adverse overnight price movements.
Rule-Based Exit: The EOD exit is rule-based and automatic, ensuring that it is consistently applied without emotions or manual intervention.
Scalability: It allows the strategy to be applied to various markets and timeframes where EOD exits may be appropriate.
By incorporating an EOD exit mechanism, the script provides a comprehensive approach to managing positions, taking profits, and minimizing risk as each trading day concludes. This can be especially important in volatile markets like cryptocurrencies, where overnight price swings can be significant.
Backtesting: The script includes a backtesting feature that allows you to test the strategy's performance over historical data. Set the start and end times for backtesting to see how the long-only strategy would have performed in the past.
Trade Execution: If you choose to use this script for live trading, make sure you understand the risks involved. It's essential to set up proper risk management, including position sizing and stop loss orders.
Monitoring: Monitor the long-only strategy's performance over time and be prepared to make adjustments as market conditions change.
Disclaimer: Trading carries a risk of capital loss. This script is provided for educational purposes and as a starting point for your own long-only strategy development. Always do your own research and consider seeking advice from a qualified financial professional before making trading decisions.
Longsetup
3kilos BTC 15mThe "3kilos BTC 15m" is a comprehensive trading strategy designed to work on a 15-minute timeframe for Bitcoin (BTC) or other cryptocurrencies. This strategy combines multiple indicators, including Triple Exponential Moving Averages (TEMA), Average True Range (ATR), and Heikin-Ashi candlesticks, to generate buy and sell signals. It also incorporates risk management features like take profit and stop loss.
Indicators
Triple Exponential Moving Averages (TEMA): Three TEMA lines are used with different lengths and sources:
Short TEMA (Red) based on highs
Long TEMA 1 (Blue) based on lows
Long TEMA 2 (Green) based on closing prices
Average True Range (ATR): Custom ATR calculation with EMA smoothing is used for volatility measurement.
Supertrend: Calculated using ATR and a multiplier to determine the trend direction.
Simple Moving Average (SMA): Applied to the short TEMA to smooth out its values.
Heikin-Ashi Close: Used for additional trend confirmation.
Entry & Exit Conditions
Long Entry: Triggered when the short TEMA is above both long TEMA lines, the Supertrend is bullish, the short TEMA is above its SMA, and the Heikin-Ashi close is higher than the previous close.
Short Entry: Triggered when the short TEMA is below both long TEMA lines, the Supertrend is bearish, the short TEMA is below its SMA, and the Heikin-Ashi close is lower than the previous close.
Take Profit and Stop Loss: Both are calculated as a percentage of the entry price, and they are set for both long and short positions.
Risk Management
Take Profit: Set at 1% above the entry price for long positions and 1% below for short positions.
Stop Loss: Set at 3% below the entry price for long positions and 3% above for short positions.
Commission and Pyramiding
Commission: A 0.07% commission is accounted for in the strategy.
Pyramiding: The strategy does not allow pyramiding.
Note
This strategy is designed for educational purposes and should not be considered as financial advice. Always do your own research and consider consulting a financial advisor before engaging in trading.
Bullish Divergence Short-term Long Trade FinderThis script is a Bullish divergence trade finder built to find small periods where Bitcoin will likely rise from. It looks for bullish divergence followed by a higher low as long as the hour RSI value is below the 40 mark, if then it will enter an long. It marks out Buy signals on the RSI if the value dips below 'RSI Bull Condition Minimum' (Default 40) on the current time frame in view. It also marks out Sell signals found when the RSI is above the 'RSI Bearish Condition Minimum' (Default 50). The sell signals are bearish divergence that has occurred recently on the RSI. When a long is in play it will sell if it finds bearish divergence or the time frame in view reaches RSI value higher than the 'RSI Sell Value'(Default 75). You can set your stop loss value with the 'Stop loss Percentage' (default 5).
Available inputs:
RSI Period: relative strength measurement length(Typically 14)
RSI Oversold Level: the bottom bar of the RSI (Typically 30)
RSI Overbought Level: the top bar of the RSI (Typically 70)
RSI Bearish Condition Minimum: The minimum value the script will use to look for a pivot high that starts the Bearish condition to Sell (Default 50)
RSI Bearish Condition Sell Min: the minimum value the script will accept a bearish condition (Default 60)
RSI Bull Condition Minimum: the minimum value it will consider a pivot low value in the RSI to find a divergence buy (Default 40)
Look Back this many candles: the amount of candles thee script will look back to find a low value in the RSI (Default 25)
RSI Sell Value: The RSI value of the exit condition for a long when value is reached (Default 75)
Stop loss Percentage: Percentage value for amount to lose (Default 5)
The formula to enter a long is stated below:
If price finds a lower low and there is a higher low found following a lower low and price has just made another dip and price closes lower than the last divergence and Relative strength index hour value is less than 40 enter a long.
The formula to exit a long is stated below:
If the value drops below the stop loss percentage OR (the RSI value is greater than the value of the parameter 'RSI Sell Value' or bearish divergence is found greater than the parameter 'RSI Bearish Condition Minimum' )
This script was built from much strategy testing on BTC but works with alts (occasionally) also. It is most successful to my knowledge using the 15 min and 7 min time frames with default values. Hope it helps! Follow for further possible updates to this script or other entry or exit strategies.
snapshot:
I only have a Pro trading view account so I cannot share a larger data set about this script because the buy signals happen pretty rarely. The most amount that I could find within a view for me was 40 trades within a viewable time. The suggested/default parameters that I have do not occur very often so it limits the data set. Adjustments can be made to the parameters so that trades can be entered more often. The scripts success is dependent on the values of the parameters set by the user. This script was written to be used for BTC/USD or BTC/USDT trading. I am unable to share a larger dataset without putting out results that are intended to fail or having a premium account so reaching the 100 trade minimum is not possible with my account.
Low volatility Buy w/ TP & SL (Coinrule)The compression of volatility usually leads to expansion. When the breakout comes, it can ignite strong trends. One way to catch a coin trading in an accumulation area is to spot three moving averages with values close to each other. The strategy uses a combination of Moving Averages to spot the best time to buy a coin before its breakout.
Buy Condition
The MA200 is greater than the MA100
The MA50 is greater than the MA100
According to backtesting results, the 1-hour time frame is the best to run this strategy.
Sell Condition
Take Profit: the price increases 8% from the entry price
Stop Loss: the price drops 4% from the entry price
The strategy has a profitability of 40-60% (depending on the market conditions). Having a ratio of two between Take profit and Stop Loss helps keeping the strategy profitable in the long term.