├── src └── pinescripts │ ├── indicators │ ├── premium │ │ └── .gitkeep │ └── free │ │ └── conners-relative-strength-index.pine │ └── strategies │ ├── free │ ├── 09_etfs │ │ └── .gitkeep │ ├── 03_indices │ │ └── .gitkeep │ ├── 05_crypto │ │ └── .gitkeep │ ├── 06_forex │ │ └── .gitkeep │ ├── 10_options │ │ └── .gitkeep │ ├── 01_all_markets │ │ └── .gitkeep │ ├── 04_commodities │ │ └── .gitkeep │ ├── 07_government_bonds │ │ └── .gitkeep │ ├── 08_corporate_bonds │ │ └── .gitkeep │ └── 02_stocks │ │ ├── inside-days.pine │ │ ├── bullish_engulfing.pine │ │ └── stan-weinstein.pine │ └── premium │ ├── 05_crypto │ └── .gitkeep │ ├── 06_forex │ └── .gitkeep │ ├── 09_etfs │ ├── .gitkeep │ └── lazy-trend-follower.md │ ├── 03_indices │ └── .gitkeep │ ├── 04_commodities │ └── .gitkeep │ ├── 10_options │ └── .gitkeep │ ├── 07_government_bonds │ └── .gitkeep │ ├── 08_corporate_bonds │ └── .gitkeep │ ├── 01_all_markets │ └── linear_regression.md │ └── 02_stocks │ ├── trend-risk-protection.md │ ├── improved_index_trend.md │ ├── face_the_train.md │ ├── lazy_trend_follower.md │ └── counter_punsh.md ├── .gitattributes ├── .gitignore ├── .editorconfig ├── .github └── workflows │ └── stale.yml ├── LICENSE.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md └── README.md /src/pinescripts/indicators/premium/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/09_etfs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/03_indices/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/05_crypto/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/06_forex/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/10_options/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/05_crypto/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/06_forex/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/09_etfs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/01_all_markets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/04_commodities/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/03_indices/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/04_commodities/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/10_options/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/07_government_bonds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/08_corporate_bonds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/07_government_bonds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/08_corporate_bonds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically detect line endings 2 | * text=auto 3 | 4 | # Explicitly declare binary files 5 | *.png binary 6 | *.jpg binary 7 | *.gif binary 8 | 9 | # Ignore whitespace differences in certain files 10 | *.txt -diff 11 | *.md -diff 12 | 13 | # Specify specific merge strategies for certain files 14 | *.docx merge=word 15 | *.xlsx merge=xlsx 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore files generated by the IDE 2 | .idea/ 3 | 4 | # Ignore compiled binaries and libraries 5 | *.exe 6 | *.dll 7 | *.so 8 | *.dylib 9 | 10 | # Ignore dependency directories 11 | node_modules/ 12 | vendor/ 13 | 14 | # Ignore build artifacts 15 | build/ 16 | dist/ 17 | 18 | # Ignore logs and temporary files 19 | *.log 20 | *.tmp 21 | 22 | # Ignore sensitive or private information 23 | config.ini 24 | secrets.txt 25 | 26 | # Ignore OS-specific files 27 | .DS_Store 28 | Thumbs.db 29 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs 2 | 3 | # Top-most EditorConfig file 4 | root = true 5 | 6 | # Set the default charset to UTF-8 7 | [*] 8 | charset = utf-8 9 | 10 | # Indentation settings 11 | [*.md] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.js] 16 | indent_style = space 17 | indent_size = 2 18 | 19 | [*.css] 20 | indent_style = space 21 | indent_size = 2 22 | 23 | [*.html] 24 | indent_style = space 25 | indent_size = 2 26 | 27 | # End of line (EOL) settings 28 | [*] 29 | end_of_line = lf 30 | insert_final_newline = true 31 | 32 | # Trim trailing whitespaces 33 | [*] 34 | trim_trailing_whitespace = true 35 | 36 | # Set the maximum line length to 80 characters 37 | [*.{js,css,html}] 38 | max_line_length = 80 39 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues and pull requests 7 | 8 | on: 9 | schedule: 10 | - cron: '15 14 * * *' 11 | 12 | jobs: 13 | stale: 14 | 15 | runs-on: ubuntu-latest 16 | permissions: 17 | issues: write 18 | pull-requests: write 19 | 20 | steps: 21 | - uses: actions/stale@v5 22 | with: 23 | repo-token: ${{ secrets.GITHUB_TOKEN }} 24 | stale-issue-message: 'Stale issue message' 25 | stale-pr-message: 'Stale pull request message' 26 | stale-issue-label: 'no-issue-activity' 27 | stale-pr-label: 'no-pr-activity' 28 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/09_etfs/lazy-trend-follower.md: -------------------------------------------------------------------------------- 1 | # Lazy Trend Follower Strategy 2 | 3 | The Lazy Trend Follower Strategy is a simple trend-following approach that enters and exits long positions based on the relationship between the closing price and a moving average (SMA). 4 | 5 | ## Inputs 6 | 7 | - **Moving Average Length (M):** Defines the period for calculating the Simple Moving Average (SMA), adjustable through the Strategy Tester. 8 | 9 | ## Strategy Logic 10 | 11 | ### Moving Average Calculation 12 | 13 | - **Simple Moving Average (SMA):** Calculated using the user-defined length `M` and based on the closing prices. 14 | 15 | ### Long Position 16 | 17 | - **Entry Condition:** 18 | - Enter a long position when the closing price is greater than the SMA. 19 | 20 | - **Exit Condition:** 21 | - Close the long position when the closing price falls below the SMA. 22 | 23 | ## Execution 24 | 25 | - **Enter Long:** When the closing price is above the SMA. 26 | - **Close Long:** When the closing price is below the SMA. 27 | 28 | ### Additional Notes 29 | - **Position Size:** Set to 100% of equity, allowing for full allocation in trades. 30 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/02_stocks/inside-days.pine: -------------------------------------------------------------------------------- 1 | //@version=6 2 | strategy("Stocks - Inside Day Strategy", shorttitle = "Stocks - Inside Day", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value= 100) 3 | 4 | //------------------------------------------- 5 | // User Inputs 6 | //------------------------------------------- 7 | rsiLength = input.int(5, "RSI Length", minval=1) 8 | overboughtLevel = input.float(80, "Overbought Threshold", minval=1) 9 | 10 | //------------------------------------------- 11 | // Conditions 12 | //------------------------------------------- 13 | // 'isInsideDay' checks that today's high-low is inside yesterday's high-low 14 | bool isInsideDay = high[1] > high and low[1] < low 15 | 16 | // Calculate RSI 17 | rsiValue = ta.rsi(close, rsiLength) 18 | 19 | //------------------------------------------- 20 | // Orders 21 | //------------------------------------------- 22 | // Enter a long position if it's an inside day 23 | if isInsideDay 24 | strategy.entry("Long", strategy.long) 25 | 26 | // Close the long position if RSI is over the specified threshold 27 | if rsiValue > overboughtLevel 28 | strategy.close("Long") 29 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/02_stocks/bullish_engulfing.pine: -------------------------------------------------------------------------------- 1 | //@version=6 2 | strategy("Stocks - Bullish Engulfing", shorttitle = "Stocks - Bull. Eng.", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value= 100) 3 | 4 | //------------------------------------------- 5 | // User Inputs 6 | //------------------------------------------- 7 | rsiLength = input.int(2, title="RSI Length", minval=1) 8 | rsiExitThreshold = input.float(90, title="RSI Exit Threshold", minval=1, maxval=100) 9 | 10 | //------------------------------------------- 11 | // Conditions 12 | //------------------------------------------- 13 | // A bullish engulfing pattern requires: 14 | // - The previous candle to be bearish (close[1] < open[1]) 15 | // - The current candle's close to exceed the previous candle's open (close > open[1]) 16 | // - The current candle's open to be below the previous candle's close (open < close[1]) 17 | isBullishEngulfing = close[1] < open[1] and close > open[1] and open < close[1] 18 | 19 | // RSI Calculation 20 | rsiValue = ta.rsi(close, rsiLength) 21 | 22 | //------------------------------------------- 23 | // Orders 24 | //------------------------------------------- 25 | // Enter a long position on a bullish engulfing pattern 26 | if isBullishEngulfing 27 | strategy.entry("Long", strategy.long) 28 | 29 | // Close the long position when RSI is above the specified threshold 30 | if rsiValue > rsiExitThreshold 31 | strategy.close("Long") 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | ## MIT License 4 | 5 | MIT License 6 | 7 | [Copyright (c) 2023] [LouisLetcher] 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | 11 | 1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 | 13 | 2. This permission applies exclusively to the free strategies and indicators in this repository that are licensed under the MIT License. 14 | 15 | 3. Any premium strategies, indicators, or scripts provided in this repository or through related services are proprietary and are not covered under this license. These premium offerings are subject to separate licensing terms, and unauthorized use, distribution, or modification is prohibited. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## Introduction 4 | 5 | This code of conduct outlines our expectations for all participants within our community, as well as the consequences for unacceptable behavior. We are committed to providing a welcoming and inclusive environment for everyone, regardless of gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, age, or religion. 6 | 7 | We expect all participants to adhere to this code of conduct in all community venues—online and offline—as well as in all one-on-one communications pertaining to community business. 8 | 9 | ## Expected Behavior 10 | 11 | - Be respectful and considerate towards others. 12 | - Exercise empathy and kindness in your interactions. 13 | - Use welcoming and inclusive language. 14 | - Be open to constructive feedback and different perspectives. 15 | - Be mindful of your words and actions, and their impact on others. 16 | - Support and encourage each other. 17 | 18 | ## Unacceptable Behavior 19 | 20 | - Harassment, discrimination, or any form of offensive or derogatory language or behavior. 21 | - Personal attacks or insults. 22 | - Trolling, flaming, or other disruptive behavior. 23 | - Unsolicited or inappropriate sexual advances or attention. 24 | - Publishing or threatening to publish others' private information without their consent. 25 | - Any other behavior that could reasonably be considered inappropriate in a professional setting. 26 | 27 | ## Consequences of Unacceptable Behavior 28 | Violations of this code of conduct may result in temporary or permanent bans from the community, at the discretion of the community organizers. Serious or repeated violations may also have legal consequences. 29 | 30 | ## Reporting Guidelines 31 | 32 | If you believe someone is violating the code of conduct, please contact [insert contact information]. All reports will be kept confidential and will be promptly reviewed and addressed by the community organizers. 33 | 34 | ## Scope 35 | 36 | This code of conduct applies to all community members, both online and offline, as well as in all one-on-one communications pertaining to community business. 37 | 38 | ## Acknowledgements -------------------------------------------------------------------------------- /src/pinescripts/indicators/free/conners-relative-strength-index.pine: -------------------------------------------------------------------------------- 1 | //@version=5 2 | indicator(title="Connors Relative Strength Index", shorttitle="CRSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) 3 | 4 | //@description=This script implements the Connors Relative Strength Index indicator for stocks. It combines three components: RSI, Up/Down RSI, and Percent Rank of ROC to form the Connors RSI, which is used to determine overbought or oversold conditions. 5 | //@tags=connorsrsi, rsi, trading, stocks, strategy 6 | 7 | // Input parameters 8 | src = close // Source for calculations, usually the closing price 9 | lenrsi = input(3, "RSI Length") // Length of the RSI calculation 10 | lenupdown = input(2, "UpDown Length") // Length for the up/down RSI calculation 11 | lenroc = input(100, "ROC Length") // Length for the Percent Rank calculation based on Rate of Change (ROC) 12 | 13 | // Function to calculate the up/down sequence 14 | updown(s) => 15 | var float ud = na // Initialize the ud variable with 'na' to ensure it's reset on first execution 16 | if (s == s[1]) // If the current value is equal to the previous value 17 | ud := 0 18 | else if (s > s[1]) // If the current value is greater than the previous value 19 | ud := na(ud[1]) or ud[1] <= 0 ? 1 : ud[1] + 1 20 | else // If the current value is less than the previous value 21 | ud := na(ud[1]) or ud[1] >= 0 ? -1 : ud[1] - 1 22 | ud 23 | 24 | // Calculate the individual components of Connors RSI 25 | rsi = ta.rsi(src, lenrsi) // Standard RSI 26 | updownrsi = ta.rsi(updown(src), lenupdown) // RSI based on the up/down sequence 27 | percentrank = ta.percentrank(ta.roc(src, 1), lenroc) // Percent Rank of the Rate of Change (ROC) 28 | 29 | // Combine the three components to form the Connors RSI 30 | crsi = math.avg(rsi, updownrsi, percentrank) 31 | 32 | // Plot the Connors RSI 33 | plot(crsi, "CRSI", color = #2962FF) 34 | 35 | // Draw horizontal lines and background fill 36 | band1 = hline(70, "Upper Band", color = #787B86) 37 | hline(50, "Middle Band", color=color.new(#787B86, 50)) 38 | band0 = hline(30, "Lower Band", color = #787B86) 39 | fill(band1, band0, color.rgb(33, 150, 243, 90), title = "Background") 40 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/01_all_markets/linear_regression.md: -------------------------------------------------------------------------------- 1 | # 📈 Unlock the Power of the **Linear Regression Strategy**! 📉 2 | 3 | Are you ready to elevate your trading game with a proven, data-driven approach? Introducing our **Linear Regression Strategy**—a versatile tool designed for **All Markets**, including Stocks, Forex, Commodities, ETFs, and more! 4 | 5 | ## 🔍 **What is the Linear Regression Strategy?** 6 | 7 | The **Linear Regression Strategy** leverages the power of statistical analysis to identify optimal entry and exit points in the market. By combining a **20-period Linear Regression Line** with a **200-period Simple Moving Average (SMA)**, this strategy filters trends and captures profitable opportunities in both bullish and bearish environments. 8 | 9 | ### **Key Features:** 10 | - **Dual Trend Filters:** Utilize short-term regression and long-term SMA to confirm market direction. 11 | - **Flexible Timeframes:** Perfect for daily (1D) and 4-hour (4H) charts, adaptable to your trading style. 12 | - **Long & Short Entries:** Seamlessly switch between long and short positions based on market conditions. 13 | - **Robust Exit Signals:** Protect your gains with intelligent exit strategies tied to regression line movements. 14 | 15 | ## 🚀 **Why Choose This Strategy?** 16 | - **Versatility:** Applicable across multiple asset classes and market conditions. 17 | - **Simplicity:** Easy-to-understand logic that’s straightforward to implement. 18 | - **Backtested Performance:** Proven effectiveness through rigorous backtesting. 19 | 20 | ## 🎁 **Exclusive Access on Patreon!** 21 | 22 | Want to take your trading to the next level? Subscribe to our Patreon community and gain **exclusive access** to: 23 | - **Complete PineScript Code:** Get the full, optimized PineScript v6 code for the Linear Regression Strategy. 24 | - **Detailed Implementation Guides:** Step-by-step instructions to customize and deploy the strategy. 25 | - **Ongoing Support:** Join a community of like-minded traders and receive continuous updates and support. 26 | - **Additional Strategies:** Unlock a library of advanced trading strategies tailored for various markets and timeframes. 27 | 28 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and start maximizing your trading potential with cutting-edge strategies! 29 | 30 | --- 31 | 32 | *Transform your trading journey with expert-designed strategies. Don't miss out—subscribe now and stay ahead of the market!* 33 | 34 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to PineScript Strategies and Indicators Repository 2 | 3 | Thank you for your interest in contributing to the PineScript Strategies and Indicators Repository! We welcome contributions from the community to help expand the collection of free strategies and indicators available. 4 | 5 | ## How to Contribute 6 | 7 | To contribute to this repository, please follow these steps: 8 | 9 | 1. **Fork the repository on GitHub.** 10 | 11 | 2. **Create a new branch** with a descriptive name for your contribution: 12 | 13 | 3. **Add your PineScript strategy or indicator file** to the repository. Ensure that it is clearly documented and includes a description of its functionality within the script. 14 | 15 | 4. **Update the README.md file** to include a description of your contribution. Follow the existing format in the README file. 16 | 17 | 5. **Commit your changes** and push them to your forked repository: 18 | 19 | 6. **Open a pull request** to merge your changes into the main repository. 20 | 21 | 7. **Wait for the maintainers to review** your contribution. They may provide feedback or request modifications before merging. 22 | 23 | 8. Once your contribution is accepted, it will be merged into the main repository and made available to others. 24 | 25 | Please ensure that your contribution follows these guidelines: 26 | 27 | - **Documentation:** Include proper documentation within your PineScript file, explaining how to use the strategy or indicator and any relevant parameters or settings. 28 | 29 | - **Testing:** Test your strategy or indicator thoroughly before submitting to ensure it functions as intended and produces accurate results. 30 | 31 | - **Free Contributions Only:** This repository is intended for free strategies and indicators. If you wish to contribute a commercial strategy or indicator, please contact the maintainers directly to discuss collaboration options. 32 | 33 | - **Respectful Collaboration:** Be respectful and considerate towards other contributors and maintainers. Maintain a positive and collaborative attitude throughout the process. 34 | 35 | By contributing to this repository, you agree to license your contributions under the [MIT License](LICENSE), applicable to free contributions. 36 | 37 | ## Code of Conduct 38 | 39 | Please note that we have a [Code of Conduct](CODE_OF_CONDUCT.md) in place to ensure a welcoming and inclusive environment for all contributors. By participating in this project, you are expected to uphold this code of conduct. 40 | 41 | If you encounter any issues or have questions regarding the contribution process, please feel free to reach out to the maintainers. 42 | 43 | Happy contributing! 44 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/02_stocks/trend-risk-protection.md: -------------------------------------------------------------------------------- 1 | # 📘 Strategy Overview: Stocks - Trend Risk Protection (SPY) 2 | 3 | ## 🔍 What is This Strategy? 4 | 5 | The **Stocks - Trend Risk Protection (SPY)** strategy is designed to identify and capitalize on sustained trends in the SPDR S&P 500 ETF Trust (SPY). By leveraging a long-term Simple Moving Average (SMA) and confirming consecutive price actions, this strategy aims to enter trades in the direction of the prevailing trend while protecting against significant reversals. 6 | 7 | ## 🎯 Key Components: 8 | 9 | ### Long-Term Trend Filter: 10 | 11 | - **200-Period SMA:** Acts as the primary trend indicator. Prices above the SMA suggest a bullish trend, while prices below indicate a bearish trend. 12 | 13 | ### Confirmation Bars: 14 | 15 | - **Consecutive Price Confirmation:** Ensures that the trend is sustained by requiring the price to remain above or below the SMA for a specified number of consecutive bars (e.g., 4 additional bars). 16 | 17 | ### Trade Execution: 18 | 19 | - **Entry Signal:** Enter a long position when the price is consistently above the SMA for the defined confirmation period. 20 | - **Exit Signal:** Close the long position when the price consistently drops below the SMA for the defined confirmation period. 21 | 22 | ### Visual Aids: 23 | 24 | - **SMA Plot:** Visual representation of the 200-period SMA. 25 | - **Background Coloring:** Highlights potential entry (green) and exit (red) zones for easy identification. 26 | 27 | ## 💡 Why Use This Strategy? 28 | 29 | - **Trend Confirmation:** Reduces false signals by requiring multiple consecutive confirmations. 30 | - **Simplicity:** Easy to understand and implement, making it suitable for traders of all levels. 31 | - **Risk Protection:** Helps in avoiding significant drawdowns by adhering to the trend. 32 | - **Flexibility:** Parameters like SMA length and confirmation bars are customizable to fit different trading styles and market conditions. 33 | 34 | ## 🚀 Enhance Your Trading with Exclusive Strategies! 35 | 36 | Unlock the full potential of the **Linear Regression Strategy** and many more advanced trading strategies by joining our **Patreon Community**. As a subscriber, you'll gain access to: 37 | 38 | - **Complete PineScript Codes:** Receive fully optimized and clean PineScript v6 codes for a variety of strategies. 39 | - **Detailed Implementation Guides:** Step-by-step tutorials to customize and deploy strategies effectively. 40 | - **Ongoing Support:** Engage with a community of like-minded traders and receive continuous updates and assistance. 41 | - **Advanced Strategies Library:** Access a growing library of sophisticated trading strategies tailored for different markets and timeframes. 42 | 43 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and start maximizing your trading potential with cutting-edge strategies! 44 | 45 | --- 46 | 47 | *Transform your trading journey with expert-designed strategies. Don't miss out—subscribe now and stay ahead of the market!* 48 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/free/02_stocks/stan-weinstein.pine: -------------------------------------------------------------------------------- 1 | //@version=6 2 | strategy("Stocks - Stan Weinstein Stage 2 Breakout Strategy", shorttitle = "Stocks - Stan Weinstein Stage 2", overlay=false, default_qty_type = strategy.percent_of_equity, default_qty_value= 100) 3 | 4 | //------------------------------------------- 5 | // Inputs 6 | //------------------------------------------- 7 | comparativeTickerId = input.symbol("SPY", title="Comparative Symbol") 8 | rsPeriod = input.int(50, title="RS Lookback Period", minval=1) 9 | volumeMaLength = input.int(5, title="Volume MA Length", minval=1) 10 | priceMaLength = input.int(30, title="Price MA Length", minval=1) 11 | highestLookback = input.int(52, title="Lookback for Highest High", minval=1) 12 | 13 | //------------------------------------------- 14 | // Request Data 15 | //------------------------------------------- 16 | // We fetch both the current (base) symbol and the comparative symbol 17 | baseClose = request.security(syminfo.tickerid, timeframe.period, close) 18 | comparativeClose = request.security(comparativeTickerId, timeframe.period, close) 19 | 20 | //------------------------------------------- 21 | // Relative Strength Calculation 22 | //------------------------------------------- 23 | // RS = (baseClose/baseClose[rsPeriod]) / (comparativeClose/comparativeClose[rsPeriod]) - 1 24 | // A value above 0 indicates the base asset is outperforming the comparative asset. 25 | rsValue = (baseClose / baseClose[rsPeriod]) / (comparativeClose / comparativeClose[rsPeriod]) - 1 26 | 27 | // Plot a dotted zero line for reference 28 | hline(0, color=color.black, linestyle=hline.style_dotted) 29 | 30 | // Plot the Relative Strength value 31 | plot(rsValue, title="RS", color=#1155CC) 32 | 33 | //------------------------------------------- 34 | // Indicators: Volume & Price MAs 35 | //------------------------------------------- 36 | // Simple moving average for volume 37 | volMA = ta.sma(volume, volumeMaLength) 38 | // Simple moving average for price 39 | priceMA = ta.sma(close, priceMaLength) 40 | 41 | //------------------------------------------- 42 | // Trade Conditions 43 | //------------------------------------------- 44 | // Highest high over the specified lookback (ignoring current bar with [1]) 45 | highestHigh = ta.highest(high[1], highestLookback) 46 | 47 | // Long condition: 48 | // 1. Price above its MA 49 | // 2. RS above 0 50 | // 3. Current volume above its MA 51 | // 4. Price breaking above recent highest high 52 | bool longEntryCondition = (close > priceMA) and (rsValue > 0) and (volume > volMA) and (close > highestHigh) 53 | 54 | // Exit condition when price crosses below its MA 55 | bool longExitCondition = (close < priceMA) 56 | 57 | //------------------------------------------- 58 | // Orders 59 | //------------------------------------------- 60 | // If all conditions are met, enter a long 61 | if longEntryCondition 62 | strategy.entry("Long", strategy.long) 63 | 64 | // If exit condition is met, close the long 65 | if longExitCondition 66 | strategy.close("Long") 67 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/02_stocks/improved_index_trend.md: -------------------------------------------------------------------------------- 1 | # 📘 Strategy Overview: Stocks - Improved Index Trend (SPY) 2 | 3 | ## 🔍 What is This Strategy? 4 | 5 | The **Stocks - Improved Index Trend (SPY)** strategy is crafted to identify and leverage sustained trend movements in the SPDR S&P 500 ETF Trust (SPY). By utilizing a combination of a **Fast Simple Moving Average (SMA)** and a **Slow Simple Moving Average (SMA)**, this strategy aims to enter and exit trades based on the crossover signals, ensuring alignment with the prevailing market trend. 6 | 7 | ## 🎯 Key Components: 8 | 9 | ### Long-Term Trend Filter: 10 | 11 | - **Slow SMA (194-Period):** Serves as the primary trend indicator. When the price is above this SMA, it suggests a bullish trend, and when below, a bearish trend. 12 | 13 | ### Short-Term Trend Confirmation: 14 | 15 | - **Fast SMA (57-Period):** Acts as a secondary trend indicator. Crossovers between the Fast SMA and Slow SMA signal potential trend changes. 16 | 17 | ### Trade Execution: 18 | 19 | - **Entry Signal:** 20 | - **Long Entry:** When the **Fast SMA (57)** crosses **above** the **Slow SMA (194)**, indicating the start of an upward trend. 21 | 22 | - **Exit Signal:** 23 | - **Close Long Position:** When the **Fast SMA (57)** crosses **below** the **Slow SMA (194)**, signaling a potential trend reversal. 24 | 25 | ### Visual Aids: 26 | 27 | - **SMA Plots:** 28 | - **Fast SMA (Blue):** Clearly distinguishes short-term trends. 29 | - **Slow SMA (Red):** Highlights the long-term trend direction. 30 | 31 | - **Background Highlighting:** *(Optional)* 32 | - **Green Background:** Marks potential long entry points. 33 | - **Red Background:** Indicates exit points to close long positions. 34 | 35 | ## 💡 Why Use This Strategy? 36 | 37 | - **Trend Confirmation:** Utilizes dual SMA crossovers to validate trend strength, reducing the likelihood of false signals. 38 | - **Simplicity:** Straightforward logic that is easy to understand and implement, making it ideal for traders of all experience levels. 39 | - **Risk Protection:** Helps in avoiding significant drawdowns by adhering to the dominant market trend and exiting before major reversals. 40 | - **Flexibility:** Customizable SMA lengths allow adaptation to different trading styles and varying market conditions. 41 | - **Visual Clarity:** Clear SMA plots and optional background highlights make it easy to identify trade signals on the chart. 42 | 43 | ## 🚀 Enhance Your Trading with Exclusive Strategies! 44 | 45 | Unlock the full potential of the **Improved Index Trend (SPY)** strategy and gain access to a multitude of advanced trading strategies by joining our **Patreon Community**. As a subscriber, you'll benefit from: 46 | 47 | - **Complete PineScript Codes:** Receive fully optimized and clean PineScript v6 codes for a variety of strategies. 48 | - **Detailed Implementation Guides:** Step-by-step tutorials to customize and deploy strategies effectively. 49 | - **Ongoing Support:** Engage with a community of like-minded traders and receive continuous updates and assistance. 50 | - **Advanced Strategies Library:** Access a growing library of sophisticated trading strategies tailored for different markets and timeframes. 51 | 52 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and take your trading to the next level with expert-designed strategies! 53 | 54 | --- 55 | 56 | *Empower your trading journey with data-driven strategies and community support. Don't miss out—subscribe now and stay ahead of the market!* 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PineScript Strategies and Indicators Repository 2 | 3 | This repository is dedicated to storing and sharing PineScript strategies and indicators for use on platforms such as TradingView. 4 | 5 | ## Table of Contents 6 | 7 | - [PineScript Strategies and Indicators Repository](#pinescript-strategies-and-indicators-repository) 8 | - [Table of Contents](#table-of-contents) 9 | - [Introduction](#introduction) 10 | - [Getting Started](#getting-started) 11 | - [Contributing](#contributing) 12 | - [License](#license) 13 | - [Support My Work](#support-my-work) 14 | - [Premium Strategies](#premium-strategies) 15 | 16 | ## Introduction 17 | 18 | In this repository, you will find a collection of PineScript strategies and indicators that can be used for algorithmic trading or technical analysis on TradingView. Each script is contained in its own file, with a descriptive name and proper documentation within the code. 19 | 20 | Feel free to explore, test, and refine the scripts for your own trading systems or analysis. These scripts are provided “as is” and should be thoroughly tested and evaluated before using them in live trading. 21 | 22 | ## Getting Started 23 | 24 | 1. **Clone the Repository:** 25 | Download or clone the repository to your local machine. 26 | 27 | 2. **Open the PineScript Editor:** 28 | Access the PineScript editor in TradingView (or another compatible platform). 29 | 30 | 3. **Copy the Code:** 31 | Open the desired strategy or indicator file from this repository and copy its code. 32 | 33 | 4. **Paste and Customize:** 34 | Paste the code into the PineScript editor. Adjust parameters and settings as needed. 35 | 36 | 5. **Save and Apply:** 37 | Save the script with a suitable name, apply it to your chart, and review its performance. 38 | 39 | 6. **Test and Validate:** 40 | Run the script on historical data and different market conditions to ensure it meets your needs before using it with real capital. 41 | 42 | ## Contributing 43 | 44 | Contributions are welcome! Please keep the following in mind: 45 | 46 | 1. **Free Strategies and Indicators:** 47 | If you have created a PineScript strategy or indicator that you wish to share for free, feel free to submit it. 48 | 49 | 2. **Commercial Strategies and Indicators:** 50 | If you would like to contribute a premium script or one intended for commercial use, please contact me directly to discuss collaboration options. 51 | 52 | 3. **Branching and Pull Requests:** 53 | For free contributions, fork the repository, create a new branch, and submit a pull request. 54 | 55 | 4. **Documentation:** 56 | Include clear documentation within the code and a brief description in the README. 57 | 58 | 5. **License Compliance:** 59 | Ensure that your contributions comply with the license terms outlined below. 60 | 61 | ## License 62 | 63 | This repository is divided into two categories: 64 | 65 | - **Free Strategies and Indicators:** 66 | Licensed under the [MIT License](LICENSE). You are free to use, modify, and distribute these as long as you comply with the MIT license terms. 67 | 68 | - **Premium Strategies and Indicators:** 69 | These are proprietary and available only to paying patrons or clients. Unauthorized use, distribution, or modification is prohibited. 70 | 71 | If you have questions about licensing or would like to discuss commercial options, please contact me directly. 72 | 73 | ## Support My Work 74 | 75 | If you find these PineScript strategies and indicators useful, consider supporting my work. 76 | 77 | [![Buy Me A Coffee](https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png)](https://www.buymeacoffee.com/greenscale) 78 | 79 | Your support allows me to dedicate more time to creating, improving, and sharing valuable scripts with the community. 80 | 81 | ## Premium Strategies 82 | 83 | To access advanced, premium PineScript strategies and indicators, consider becoming a patron. By joining, you will gain exclusive access to strategies not available in the public repository—ideal for traders seeking an edge in the markets. 84 | 85 | [![Become a Patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/LouisLetcher) 86 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/02_stocks/face_the_train.md: -------------------------------------------------------------------------------- 1 | # 📘 Strategy Overview: Stocks - Lazy Trend Follower Strategy 2 | 3 | ## 🔍 What is This Strategy? 4 | 5 | The **Stocks - Lazy Trend Follower Strategy** is designed to capture and capitalize on sustained trend movements in the stock market, specifically tailored for the SPDR S&P 500 ETF Trust (SPY). By utilizing a **Simple Moving Average (SMA)** or **Exponential Moving Average (EMA)** as a primary trend indicator, this strategy aims to enter long positions when the price is above the moving average and exit when it falls below, ensuring alignment with the prevailing market trend. 6 | 7 | ## 🎯 Key Components: 8 | 9 | ### 1. Moving Average-Based Trend Filter 10 | 11 | - **Moving Average Period (Default: 10):** Acts as the primary trend indicator. 12 | - **SMA (Simple Moving Average):** Smooths out price data to identify the direction of the trend. 13 | - **EMA (Exponential Moving Average):** Gives more weight to recent prices, making it more responsive to price changes. 14 | 15 | ### 2. Confirmation Bars 16 | 17 | - **Confirmation Period (Default: 1):** Ensures that the trend is sustained by requiring the price to remain above or below the moving average for a specified number of consecutive bars. 18 | - **Long Entry Confirmation:** Price must be above the moving average for the current and previous `confirmation` bars. 19 | - **Long Exit Confirmation:** Price must be below the moving average for the current and previous `confirmation` bars. 20 | 21 | ### 3. Trade Execution 22 | 23 | - **Entry Signal:** 24 | - **Long Position:** Enter a long position when the price is consistently above the moving average for the defined confirmation period. 25 | 26 | - **Exit Signal:** 27 | - **Close Long Position:** Exit the long position when the price consistently drops below the moving average for the defined confirmation period. 28 | 29 | ### 4. Visual Aids 30 | 31 | - **Moving Average Plot:** Visual representation of the chosen moving average (SMA or EMA) for easy trend identification. 32 | - **Background Highlighting (Optional):** 33 | - **Green Background:** Marks potential long entry points. 34 | - **Red Background:** Indicates exit points to close long positions. 35 | 36 | *Note: Background highlighting lines are commented out in the script. Uncomment them to enable visual cues on the chart.* 37 | 38 | ## 💡 Why Use This Strategy? 39 | 40 | - **Trend Confirmation:** Utilizes moving average crossovers and consecutive confirmations to validate trend strength, reducing the likelihood of false signals. 41 | - **Simplicity:** Straightforward logic that is easy to understand and implement, making it ideal for traders of all experience levels. 42 | - **Risk Protection:** Helps in avoiding significant drawdowns by adhering to the dominant market trend and exiting before major reversals. 43 | - **Flexibility:** Customizable parameters such as moving average type, period, and confirmation bars allow adaptation to different trading styles and market conditions. 44 | - **Visual Clarity:** Clear moving average plots and optional background highlights make it easy to identify trade signals on the chart. 45 | 46 | ## 🚀 Enhance Your Trading with Exclusive Strategies! 47 | 48 | Unlock the full potential of the **Lazy Trend Follower Strategy** and gain access to a multitude of advanced trading strategies by joining our **Patreon Community**. As a subscriber, you'll benefit from: 49 | 50 | - **Complete PineScript Codes:** Receive fully optimized and clean PineScript v6 codes for a variety of strategies. 51 | - **Detailed Implementation Guides:** Step-by-step tutorials to customize and deploy strategies effectively. 52 | - **Ongoing Support:** Engage with a community of like-minded traders and receive continuous updates and assistance. 53 | - **Advanced Strategies Library:** Access a growing library of sophisticated trading strategies tailored for different markets and timeframes. 54 | 55 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and take your trading to the next level with expert-designed strategies! 56 | 57 | --- 58 | 59 | *Empower your trading journey with data-driven strategies and community support. Don't miss out—subscribe now and stay ahead of the market!* 60 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/02_stocks/lazy_trend_follower.md: -------------------------------------------------------------------------------- 1 | # 📘 Strategy Overview: Stocks - Lazy Trend Follower Strategy 2 | 3 | ## 🔍 What is This Strategy? 4 | 5 | The **Stocks - Lazy Trend Follower Strategy** is designed to capture and capitalize on sustained trend movements in the stock market, specifically tailored for the SPDR S&P 500 ETF Trust (SPY). By utilizing a **Simple Moving Average (SMA)** or **Exponential Moving Average (EMA)** as a primary trend indicator, this strategy aims to enter long positions when the price is above the moving average and exit when it falls below, ensuring alignment with the prevailing market trend. 6 | 7 | ## 🎯 Key Components: 8 | 9 | ### 1. Moving Average-Based Trend Filter 10 | 11 | - **Moving Average Period (Default: 10):** Acts as the primary trend indicator. 12 | - **SMA (Simple Moving Average):** Smooths out price data to identify the direction of the trend. 13 | - **EMA (Exponential Moving Average):** Gives more weight to recent prices, making it more responsive to price changes. 14 | 15 | ### 2. Confirmation Bars 16 | 17 | - **Confirmation Period (Default: 1):** Ensures that the trend is sustained by requiring the price to remain above or below the moving average for a specified number of consecutive bars. 18 | - **Long Entry Confirmation:** Price must be above the moving average for the current and previous `confirmation` bars. 19 | - **Long Exit Confirmation:** Price must be below the moving average for the current and previous `confirmation` bars. 20 | 21 | ### 3. Trade Execution 22 | 23 | - **Entry Signal:** 24 | - **Long Position:** Enter a long position when the price is consistently above the moving average for the defined confirmation period. 25 | 26 | - **Exit Signal:** 27 | - **Close Long Position:** Exit the long position when the price consistently drops below the moving average for the defined confirmation period. 28 | 29 | ### 4. Visual Aids 30 | 31 | - **Moving Average Plot:** Visual representation of the chosen moving average (SMA or EMA) for easy trend identification. 32 | - **Background Highlighting (Optional):** 33 | - **Green Background:** Marks potential long entry points. 34 | - **Red Background:** Indicates exit points to close long positions. 35 | 36 | *Note: Background highlighting lines are commented out in the script. Uncomment them to enable visual cues on the chart.* 37 | 38 | ## 💡 Why Use This Strategy? 39 | 40 | - **Trend Confirmation:** Utilizes moving average crossovers and consecutive confirmations to validate trend strength, reducing the likelihood of false signals. 41 | - **Simplicity:** Straightforward logic that is easy to understand and implement, making it ideal for traders of all experience levels. 42 | - **Risk Protection:** Helps in avoiding significant drawdowns by adhering to the dominant market trend and exiting before major reversals. 43 | - **Flexibility:** Customizable parameters such as moving average type, period, and confirmation bars allow adaptation to different trading styles and market conditions. 44 | - **Visual Clarity:** Clear moving average plots and optional background highlights make it easy to identify trade signals on the chart. 45 | 46 | ## 🚀 Enhance Your Trading with Exclusive Strategies! 47 | 48 | Unlock the full potential of the **Lazy Trend Follower Strategy** and gain access to a multitude of advanced trading strategies by joining our **Patreon Community**. As a subscriber, you'll benefit from: 49 | 50 | - **Complete PineScript Codes:** Receive fully optimized and clean PineScript v6 codes for a variety of strategies. 51 | - **Detailed Implementation Guides:** Step-by-step tutorials to customize and deploy strategies effectively. 52 | - **Ongoing Support:** Engage with a community of like-minded traders and receive continuous updates and assistance. 53 | - **Advanced Strategies Library:** Access a growing library of sophisticated trading strategies tailored for different markets and timeframes. 54 | 55 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and take your trading to the next level with expert-designed strategies! 56 | 57 | --- 58 | 59 | *Empower your trading journey with data-driven strategies and community support. Don't miss out—subscribe now and stay ahead of the market!* 60 | -------------------------------------------------------------------------------- /src/pinescripts/strategies/premium/02_stocks/counter_punsh.md: -------------------------------------------------------------------------------- 1 | # 📘 Strategy Overview: Stocks - Counter Punch Strategy 2 | 3 | ## 🔍 What is This Strategy? 4 | 5 | The **Stocks - Counter Punch Strategy** is designed to identify and capitalize on extreme market conditions within the SPDR S&P 500 ETF Trust (SPY). By leveraging the Relative Strength Index (RSI) and multiple Simple Moving Averages (SMAs), this strategy aims to enter trades when the market is oversold or overbought and exit based on trend confirmations. This approach helps in mitigating risks associated with sudden market reversals. 6 | 7 | ## 🎯 Key Components: 8 | 9 | ### 1. RSI-Based Entry Signals 10 | 11 | - **RSI Period (2):** Utilizes a short RSI period to detect extreme market conditions quickly. 12 | - **Long Entry:** When RSI drops below **10**, indicating an oversold condition. 13 | - **Short Entry:** When RSI rises above **90**, indicating an overbought condition. 14 | 15 | ### 2. Moving Averages for Trend Confirmation 16 | 17 | - **Short-Term SMA (9-Period):** Acts as a trend confirmation tool. 18 | - **Long Exit:** When the price crosses **above** the Short-Term SMA, signaling the end of the oversold condition. 19 | - **Short Exit:** When the price crosses **below** the Short-Term SMA, signaling the end of the overbought condition. 20 | 21 | - **Long-Term SMA (200-Period):** Serves as the primary trend indicator. 22 | - **Long Entry Condition:** Ensures that the price is **above** the Long-Term SMA before entering a long position. 23 | - **Short Entry Condition:** Ensures that the price is **below** the Long-Term SMA before entering a short position. 24 | 25 | ### 3. Trade Execution 26 | 27 | - **Entry Signals:** 28 | - **Long Position:** Enter when RSI < 10 **and** price > 200 SMA. 29 | - **Short Position:** Enter when RSI > 90 **and** price < 200 SMA. 30 | 31 | - **Exit Signals:** 32 | - **Long Exit:** Exit when price > 9 SMA. 33 | - **Short Exit:** Exit when price < 9 SMA. 34 | 35 | ### 4. Visual Aids 36 | 37 | - **SMA Plots:** 38 | - **Short-Term SMA (Blue):** Helps in identifying trend confirmations. 39 | - **Long-Term SMA (Red):** Provides a clear indication of the primary trend. 40 | 41 | - **Background Highlighting:** *(Optional)* 42 | - **Green Background:** Marks potential long entry points. 43 | - **Red Background:** Marks potential short entry points. 44 | 45 | *Note: Background highlighting lines are commented out in the script. Uncomment them to enable visual cues on the chart.* 46 | 47 | ## 💡 Why Use This Strategy? 48 | 49 | - **Quick Detection of Extremes:** The short RSI period allows for rapid identification of overbought and oversold conditions. 50 | - **Trend Confirmation:** Combining multiple SMAs ensures that trades are aligned with the prevailing market trend, reducing false signals. 51 | - **Risk Mitigation:** Exiting trades based on trend confirmations helps in avoiding significant drawdowns during market reversals. 52 | - **Simplicity and Flexibility:** The strategy is straightforward to understand and implement, with customizable parameters to fit different trading styles and market conditions. 53 | - **Visual Clarity:** Clear SMA plots and optional background highlights make it easy to identify trade signals on the chart. 54 | 55 | ## 🚀 Enhance Your Trading with Exclusive Strategies! 56 | 57 | Unlock the full potential of the **Counter Punch Strategy** and gain access to a multitude of advanced trading strategies by joining our **Patreon Community**. As a subscriber, you'll benefit from: 58 | 59 | - **Complete PineScript Codes:** Receive fully optimized and clean PineScript v6 codes for a variety of strategies. 60 | - **Detailed Implementation Guides:** Step-by-step tutorials to customize and deploy strategies effectively. 61 | - **Ongoing Support:** Engage with a community of like-minded traders and receive continuous updates and assistance. 62 | - **Advanced Strategies Library:** Access a growing library of sophisticated trading strategies tailored for different markets and timeframes. 63 | 64 | 👉 **[Join Our Patreon Today](https://www.patreon.com/LouisLetcher)** and take your trading to the next level with expert-designed strategies! 65 | 66 | --- 67 | 68 | *Empower your trading journey with data-driven strategies and community support. Don't miss out—subscribe now and stay ahead of the market!* 69 | --------------------------------------------------------------------------------