OPEN-SOURCE SCRIPT
Script_Algo - Gap Strategy - Long Only

🚀 Enhanced Gap Trading Strategy for US Session Open🚀
An advanced strategy based on gaps that appear at the opening of the US stock market session. In many cases, under certain market conditions, the gap acts as a strong zone of support or resistance.
🎯 Key Improvement: The script opens trades only after confirmed bullish gaps, when the close of the second candle is above the **high of the candle on which the trading day opened. This confirms the strength of the bulls, allowing for a higher win rate with a good risk-to-reward ratio.
➡️ The strategy works only in LONG!
How the Script Works (Step-by-Step):
1. Detection of a Bullish Gap (`high[1] < low`)
Logic:The high of the previous candle is below the low of the current one. This means the price opened with a gap up.
2. Entry Conditions
The strategy does not enter immediately upon gap appearance but waits for confirmation:
* Long (Buy):** `bullGap and close > high[1]`
* A bullish gap AND the price of the current candle closes above the high of the previous candle. This confirms bull strength.
* Entry occurs at the **close** of the candle that formed the gap.
3. Filters
To avoid false signals, the strategy uses a SuperTrend filter:
* For entry: The price must be **above the SuperTrend line**. This ensures the overall trend is bullish.
4. Risk Management
Stop-Loss: Set at the low of the previous candle (`low[1]`). The idea is that if the price returns there, the gap will be filled, and the reason for the buy will disappear.
* Take-Profit: Calculated based on a risk-reward ratio (`riskRewardRatio`).
* Example for Long: If the risk (distance from entry price to stop) is 10 points, and R/R = 2, then take-profit will be set 20 points away from the entry price into the profit zone.*
5. Execution
The strategy prohibits opening new positions (`ignoreNewSignals`) if one is already open. This prevents overlapping trades.
6. Visualization
The chart displays:
* Entry arrows 🟢
* Stop-loss and take-profit levels for the current position
* A green background when SuperTrend is bullish
* Blue crosses `❌` marking the gaps.
⚠️ Potential Weaknesses & Important Notes
* "Runaway Gap": Sometimes a gap does not fill but is the start of a new powerful trend. In this case, the strategy may prematurely close the position by stop-loss, although it was possible to earn more. However, show me a strategy that works without losing trades. Let's laugh together 😄)
* Entry on Close: The strategy enters at the closing price of the candle. During periods of high volatility, the price by the time of closing may have already moved far from the gap, which worsens the risk/profit ratio. Unfortunately, this strategy can only be traded manually, as I am unaware of any services today that allow trading CFDs or stocks via WEBHOOK like crypto exchanges. If you know, please write.
* Parameter Optimization: The SuperTrend parameters and risk/reward must be carefully selected for a specific asset and timeframe.
* The strategy works well on stocks, does **not work on crypto**. I haven't tested it on other assets.
* As seen on the strategy results since February 2024, over a year and a half the strategy could have potentially brought *170% profit on NVDA stocks. The win rate is over 50% with a risk/reward ratio of 1:4.
* Someone might say NVDA stocks themselves grew by 200% during this period. I will answer this: which of us knew it would be like this a year and a half ago? Many stocks fell to the bottom during this period. For example, the once promising Virgin Galactic stocks fell by **1000%** from $35 to $3.5. Are you ready to take such risks?
* Secondly, with this strategy, you can allocate significantly less capital by trading CFDs and risking much smaller amounts.
* The strategy showed good results during a **bullish trend**, but it is unknown how it will behave in a **falling market**. Therefore, I do not recommend using it if you see that the global trend has changed to a downward one.
**ALWAYS REMEMBER that past strategy results do not necessarily repeat in the future. The market is constantly changing, so constantly monitor the situation, test on history, and adjust settings for each asset.**
**Advice:** Remember the bugs that exist in any algorithmic trading strategies, even if the script is well-tested and the algorithm is proven. No one knows what non-standard situations may happen on the market tomorrow. Try to trade only on proven, highly liquid assets to avoid excessive volatility, strong slippage, high spreads, and commissions.
---
🚨 **DISCLAIMER**
The author of the strategy does not urge anyone to use this algorithm and is not responsible for any possible financial losses as a result of its application! Any decisions to use this strategy are made personally by the owners of TradingView and crypto exchange accounts!
**Conclusion: ✅**
This is a well-structured, professional strategy that combines a simple basic idea (trading at the gap support zone) with a trend filter to increase the probability of successful trades. Its effectiveness highly depends on the correct setup of filters for the chosen instrument and the direction of the global trend.
**This is not the final version.** I have thoughts on how to improve this strategy, so **subscribe** so you don't miss updates. If you have any ideas on how to improve this or my other strategy, don't hesitate to write to me. I will try to implement it in the script. If you see any bugs or inconsistencies in my algorithm, please write to me about it - I will try to fix it as soon as possible.
I wish everyone good luck and a beautiful, clean trend without drawdowns! 📈✨
An advanced strategy based on gaps that appear at the opening of the US stock market session. In many cases, under certain market conditions, the gap acts as a strong zone of support or resistance.
🎯 Key Improvement: The script opens trades only after confirmed bullish gaps, when the close of the second candle is above the **high of the candle on which the trading day opened. This confirms the strength of the bulls, allowing for a higher win rate with a good risk-to-reward ratio.
➡️ The strategy works only in LONG!
How the Script Works (Step-by-Step):
1. Detection of a Bullish Gap (`high[1] < low`)
Logic:The high of the previous candle is below the low of the current one. This means the price opened with a gap up.
2. Entry Conditions
The strategy does not enter immediately upon gap appearance but waits for confirmation:
* Long (Buy):** `bullGap and close > high[1]`
* A bullish gap AND the price of the current candle closes above the high of the previous candle. This confirms bull strength.
* Entry occurs at the **close** of the candle that formed the gap.
3. Filters
To avoid false signals, the strategy uses a SuperTrend filter:
* For entry: The price must be **above the SuperTrend line**. This ensures the overall trend is bullish.
4. Risk Management
Stop-Loss: Set at the low of the previous candle (`low[1]`). The idea is that if the price returns there, the gap will be filled, and the reason for the buy will disappear.
* Take-Profit: Calculated based on a risk-reward ratio (`riskRewardRatio`).
* Example for Long: If the risk (distance from entry price to stop) is 10 points, and R/R = 2, then take-profit will be set 20 points away from the entry price into the profit zone.*
5. Execution
The strategy prohibits opening new positions (`ignoreNewSignals`) if one is already open. This prevents overlapping trades.
6. Visualization
The chart displays:
* Entry arrows 🟢
* Stop-loss and take-profit levels for the current position
* A green background when SuperTrend is bullish
* Blue crosses `❌` marking the gaps.
⚠️ Potential Weaknesses & Important Notes
* "Runaway Gap": Sometimes a gap does not fill but is the start of a new powerful trend. In this case, the strategy may prematurely close the position by stop-loss, although it was possible to earn more. However, show me a strategy that works without losing trades. Let's laugh together 😄)
* Entry on Close: The strategy enters at the closing price of the candle. During periods of high volatility, the price by the time of closing may have already moved far from the gap, which worsens the risk/profit ratio. Unfortunately, this strategy can only be traded manually, as I am unaware of any services today that allow trading CFDs or stocks via WEBHOOK like crypto exchanges. If you know, please write.
* Parameter Optimization: The SuperTrend parameters and risk/reward must be carefully selected for a specific asset and timeframe.
* The strategy works well on stocks, does **not work on crypto**. I haven't tested it on other assets.
* As seen on the strategy results since February 2024, over a year and a half the strategy could have potentially brought *170% profit on NVDA stocks. The win rate is over 50% with a risk/reward ratio of 1:4.
* Someone might say NVDA stocks themselves grew by 200% during this period. I will answer this: which of us knew it would be like this a year and a half ago? Many stocks fell to the bottom during this period. For example, the once promising Virgin Galactic stocks fell by **1000%** from $35 to $3.5. Are you ready to take such risks?
* Secondly, with this strategy, you can allocate significantly less capital by trading CFDs and risking much smaller amounts.
* The strategy showed good results during a **bullish trend**, but it is unknown how it will behave in a **falling market**. Therefore, I do not recommend using it if you see that the global trend has changed to a downward one.
**ALWAYS REMEMBER that past strategy results do not necessarily repeat in the future. The market is constantly changing, so constantly monitor the situation, test on history, and adjust settings for each asset.**
**Advice:** Remember the bugs that exist in any algorithmic trading strategies, even if the script is well-tested and the algorithm is proven. No one knows what non-standard situations may happen on the market tomorrow. Try to trade only on proven, highly liquid assets to avoid excessive volatility, strong slippage, high spreads, and commissions.
---
🚨 **DISCLAIMER**
The author of the strategy does not urge anyone to use this algorithm and is not responsible for any possible financial losses as a result of its application! Any decisions to use this strategy are made personally by the owners of TradingView and crypto exchange accounts!
**Conclusion: ✅**
This is a well-structured, professional strategy that combines a simple basic idea (trading at the gap support zone) with a trend filter to increase the probability of successful trades. Its effectiveness highly depends on the correct setup of filters for the chosen instrument and the direction of the global trend.
**This is not the final version.** I have thoughts on how to improve this strategy, so **subscribe** so you don't miss updates. If you have any ideas on how to improve this or my other strategy, don't hesitate to write to me. I will try to implement it in the script. If you see any bugs or inconsistencies in my algorithm, please write to me about it - I will try to fix it as soon as possible.
I wish everyone good luck and a beautiful, clean trend without drawdowns! 📈✨
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。