GapDetectGap Severity Analysis Library
This library, GapDetect , simplifies the identification and evaluation of overnight gaps by leveraging statistical metrics such as standard deviation and percentage moves. It is ideal for detecting large abnormal gaps which may be used to modify how strategies may decide to enter or exit.
Key Features:
Overnight Gap Detection
Provides two core functions:
today : Computes the value of today's overnight gap.
todayPercent : Computes the percentage change for today's overnight gap.
Volatility Analysis
Includes functions for statistical gap analysis:
normal : Calculates the normal daily standard deviation of the overnight gap, filtering outliers using customizable thresholds.
normalPercent : Similar to normal , but for percentage-based gap moves.
Gap Severity Metric
severity : a positive or negative value that represents the ratio of the current overnight move compared to the standard deviation of previous ones.
Customizable Parameters
Supports custom session specifications, resolutions, and outlier thresholds.
Overnight
Overnight Positioning w EMA - Strategy [presentTrading]I've recently started researching Market Timing strategies, and it’s proving to be quite an interesting area of study. The idea of predicting optimal times to enter and exit the market, based on historical data and various indicators, brings a dynamic edge to trading. Additionally, it is integrated with the 3commas bot for automated trade execution.
I'm still working on it. Welcome to share your point of view.
█ Introduction and How it is Different
The "Overnight Positioning with EMA " is designed to capitalize on market inefficiencies during the overnight trading period. This strategy takes a position shortly before the market closes and exits shortly after it opens the following day. What sets this strategy apart is the integration of an optional Exponential Moving Average (EMA) filter, which ensures that trades are aligned with the underlying trend. The strategy provides flexibility by allowing users to select between different global market sessions, such as the US, Asia, and Europe.
It is integrated with the 3commas bot for automated trade execution and has a built-in mechanism to avoid holding positions over the weekend by force-closing positions on Fridays before the market closes.
BTCUSD 20 mins Performance
█ Strategy, How it Works: Detailed Explanation
The core logic of this strategy is simple: enter trades before market close and exit them after market open, taking advantage of potential price movements during the overnight period. Here’s how it works in more detail:
🔶 Market Timing
The strategy determines the local market open and close times based on the selected market (US, Asia, Europe) and adjusts entry and exit points accordingly. The entry is triggered a specific number of minutes before market close, and the exit is triggered a specific number of minutes after market open.
🔶 EMA Filter
The strategy includes an optional EMA filter to help ensure that trades are taken in the direction of the prevailing trend. The EMA is calculated over a user-defined timeframe and length. The entry is only allowed if the closing price is above the EMA (for long positions), which helps to filter out trades that might go against the trend.
The EMA formula:
```
EMA(t) = +
```
Where:
- EMA(t) is the current EMA value
- Close(t) is the current closing price
- n is the length of the EMA
- EMA(t-1) is the previous period's EMA value
🔶 Entry Logic
The strategy monitors the market time in the selected timezone. Once the current time reaches the defined entry period (e.g., 20 minutes before market close), and the EMA condition is satisfied, a long position is entered.
- Entry time calculation:
```
entryTime = marketCloseTime - entryMinutesBeforeClose * 60 * 1000
```
🔶 Exit Logic
Exits are triggered based on a specified time after the market opens. The strategy checks if the current time is within the defined exit period (e.g., 20 minutes after market open) and closes any open long positions.
- Exit time calculation:
exitTime = marketOpenTime + exitMinutesAfterOpen * 60 * 1000
🔶 Force Close on Fridays
To avoid the risk of holding positions over the weekend, the strategy force-closes any open positions 5 minutes before the market close on Fridays.
- Force close logic:
isFriday = (dayofweek(currentTime, marketTimezone) == dayofweek.friday)
█ Trade Direction
This strategy is designed exclusively for long trades. It enters a long position before market close and exits the position after market open. There is no shorting involved in this strategy, and it focuses on capturing upward momentum during the overnight session.
█ Usage
This strategy is suitable for traders who want to take advantage of price movements that occur during the overnight period without holding positions for extended periods. It automates entry and exit times, ensuring that trades are placed at the appropriate times based on the market session selected by the user. The 3commas bot integration also allows for automated execution, making it ideal for traders who wish to set it and forget it. The strategy is flexible enough to work across various global markets, depending on the trader's preference.
█ Default Settings
1. entryMinutesBeforeClose (Default = 20 minutes):
This setting determines how many minutes before the market close the strategy will enter a long position. A shorter duration could mean missing out on potential movements, while a longer duration could expose the position to greater price fluctuations before the market closes.
2. exitMinutesAfterOpen (Default = 20 minutes):
This setting controls how many minutes after the market opens the position will be exited. A shorter exit time minimizes exposure to market volatility at the open, while a longer exit time could capture more of the overnight price movement.
3. emaLength (Default = 100):
The length of the EMA affects how the strategy filters trades. A shorter EMA (e.g., 50) reacts more quickly to price changes, allowing more frequent entries, while a longer EMA (e.g., 200) smooths out price action and only allows entries when there is a stronger underlying trend.
The effect of using a longer EMA (e.g., 200) would be:
```
EMA(t) = +
```
4. emaTimeframe (Default = 240):
This is the timeframe used for calculating the EMA. A higher timeframe (e.g., 360) would base entries on longer-term trends, while a shorter timeframe (e.g., 60) would respond more quickly to price movements, potentially allowing more frequent trades.
5. useEMA (Default = true):
This toggle enables or disables the EMA filter. When enabled, trades are only taken when the price is above the EMA. Disabling the EMA allows the strategy to enter trades without any trend validation, which could increase the number of trades but also increase risk.
6. Market Selection (Default = US):
This setting determines which global market's open and close times the strategy will use. The selection of the market affects the timing of entries and exits and should be chosen based on the user's preference or geographic focus.
OverNightSession @joshuuuThis indicator highlights the Overnightsession (ONS), taught by TheCurrenyMerchant.
The Overnightsession is from 4-8 am UTC-5. This session can be used to form trades, e.g. after one side has been taken out.
It has the options to display Projection and the equilibrium level. Equilibrium level (50%) can be used to identify if price is currently in premium/discount of the range and the projections (standard deviations of the range) can be used to identify possible targets.
A classic setup he teaches is:
Price trades agressively out of the range taking liquidity. As soon as we trade above the high of the candle that took liquidity, that candle can be considered an orderblock, where the 50% level can be used for long setups.
⚠️ Open Source ⚠️
Coders and TV users are authorized to copy this code base, but a paid distribution is prohibited. A mention to the original author is expected, and appreciated.
⚠️ Terms and Conditions ⚠️
This financial tool is for educational purposes only and not financial advice. Users assume responsibility for decisions made based on the tool's information. Past performance doesn't guarantee future results. By using this tool, users agree to these terms.
Pre-market Highs & Lows on regular trading hours (RTH) chartShows pre-market highs and lows on RTH or ETH chart
-Pre-market duration user input (default is 16 'bar hours'; covering the time from S&P RTH close at 4pm >> 9:30am RTH open next day
-Displays on both RTH and ETH charts
-Written for ES (ES1! or e.g ESM2023), but tested and working on SPY, SPX
-Works across timeframes
Example usage on Electronic trading hours (ETH) chart; showing the 'bar hours' user input lookback duration visually
Seasonality - Session Performance - Morning Afternoon EveningUse this indicator on Intraday Timeframe. Higher the timeframe, more the data
This script calculates the performance of an instrument for different sessions.
Session inputs can be updated to study performance of
- Morning vs Afternoon vs Evening
- Pre-Market vs Market vs Post-Market (provided the data feed supports pre and post market)
- Overnight vs Intraday
Three session inputs are provided to tweak the session range
Performance is calculated as session close / session open - 1
Session timeframes can be set for various countries. Make sure the session timeframe aligns with the Candle open/close for the timeframe you choose. Some examples below
US Markets: 0930-1130 1130-1430 1430-1630 Timeframe 1 hour
India Markets: 0915-1030 1030-1415 1415-15:30 Timeframe 75min
ILM Overnight vs Intraday Performance - Tabular FormUse this indicator on Daily Timeframe
This script compares Overnight vs Intraday Performance based on the Day of the Week (DOW) - Sun - Sat of index/stock/currency/commodity symbols.
ON column indicates Overnight performance = open/close -1
ID column indicates Intraday performance = close-open/1
The calculations are detailed in the tooltips of the individual table cells.
Federal Funds Rate and Overnight Bank Fund RateAMEX:SPY
Comparison of the Overnight Bank Fund Rate and the Effective Federal Funds Rate.
The Fed sets a discount rate of 100 basis points above the effective federal funds rate to discourage ("penalize") banks from borrowing from its reserves. If lending banks have excess in their reserves, the borrowing banks have ease in negotiating a lower rate overnight to maintain its requirements. For this reason its a good indicator of the economy. If it becomes more difficult for banks to maintain the required reserve amount they may charge borrowing banks higher rates.
Both the Effective Federal Funds Rate and Overnight Bank Fund Rate use the same data. Except, the OBFR includes overnight Eurodollar transaction data and certain overnight “selected deposit” transactions that are placed at domestic bank branches controlled by a U.S. banking office.
The indicator includes the lower and upper bound target rate set by the Federal Reserve.
An interesting note:
Notice the jump in the Overnight Bank Rate followed by Fed buying to provide liquidity and lower rates in Sept 2019.
Equity Index Extended HoursHighlights the extended hours/Globex session for US Equity Index Futures.
Overnight Bollinger Band ExtremesThis script is a combination of my overnight fakeout script and bollinger band color bars. It's designed to be used on CME/CBOT Equity Indexes during their GLOBEX session. It uses the built in Bollinger Band script and highlights bars that exceed the upper/lower bands during the overnight session.
Equity Index Overnight FakeoutThis script highlights when price violates the highest high or lowest low within the user's selected lookback period, with the caveat that it occurs during the GLOBEX session. The script is designed to work exclusively with the trading hours for CME and CBOT Equity Index futures. I'm planning to make a more customizable version down the line.
My reasoning behind this very simple script is that the low liquidity and participation of the overnight session creates a tendency for moves at extremes to mean revert. Let me know what you think.
Market Profile for Futures with Session and After Hours SplitAdapted existing Market Profile scripts to be move suitable for Futures Markets with Session and After Hours split
Script Provides split Market Profiles for Session and After Hours
Users can customize the Session and AH hours inputs to suit any ticker and their interpretation of prime and non-prime hours