OPEN-SOURCE SCRIPT

Four WMA Strategy with TP and SL

מעודכן
Basically I read a research paper on how they used different moving averages for long entries and short entries, and it kind of dawned on me that I always used the same one for long entry or exit, or even swing trading. So I smashed this together to see what would happen.
The strategy combines the use of four different WMAs for identifying trade entry points, along with a predefined take profit (TP) and stop loss (SL) for risk management. Here's a detailed description of its features and how it operates:

Main Features

1. **WMAs as the Core Indicator**:
- The strategy uses four WMAs with different lengths. Two WMAs (`longM1` and `longM2`) are used for long entry signals, and the other two (`shortM1` and `shortM2`) for short entry signals.
- The lengths of these WMAs are adjustable through input parameters.

2. **Trade Entry Conditions**:
- A long entry is signaled when the shorter WMA crosses under the longer WMA .
- Conversely, a short entry is signaled when the shorter WMA crosses under the longer WMA.

3. **Take Profit and Stop Loss**:
- The strategy includes a take profit and stop loss mechanism.
- The TP and SL levels are set as a percentage of the entry price, with the percentage values being adjustable through input parameters.

4. **Visual Representation**:
- The WMAs are plotted on the chart for visual aid, each with a distinct color for easy identification.

How It Works

- The strategy continuously monitors the crossing of WMAs to detect potential entry points for long and short positions.
- Upon detecting a long or short condition, it automatically enters a trade and sets the corresponding TP and SL levels based on the current price and the specified percentages.
- The strategy then actively manages the trade, exiting the position when either the TP or SL level is reached.

Drawbacks

- **Overreliance on WMAs**: The strategy heavily relies on WMAs for trade signals. While WMAs are useful for identifying trends, they might not always provide timely entry and exit signals.
- **Market Conditions**: It may not perform well in highly volatile or sideways markets where WMA crossovers could lead to false signals.
- **Risk Management**: The fixed percentage for TP and SL might not be suitable for all market conditions. Traders might need to adjust these values frequently based on market volatility and their risk tolerance.
Apparently I need to emphasize to use brains when using indicators and setting them up to achieve the results you can or want. Also risk of 12% is considered very high so I lowered the numbers to 5%, which tanked the profits, try adjusting them on your own. Check the properties settings for more info on comission and slippage.

Conclusion

The "Four WMA Strategy with TP and SL" is suitable for traders who prefer a moving average-based approach to trading, combined with a straightforward mechanism for risk management through take profit and stop loss. However, like all strategies, it should be used with an understanding of its limitations and ideally tested thoroughly in various market conditions before applying it to live trading.
הערות שחרור
1. Upgraded to Pine Script Version 6
The script was updated to use Pine Script version 6, enabling the use of newer features and functionalities.
2. Added Configurable Moving Average Types
The new version allows users to select from various moving average types (SMA, EMA, WMA, VWMA, and RMA) via an input setting.
Instead of hardcoding a single moving average type (WMA in the previous version), the script dynamically calculates the selected MA type based on user input.
3. Added Toggle for TP and SL Activation
A toggle was introduced to enable or disable the Take Profit (TP) and Stop Loss (SL) functionality.
This provides users more control, allowing them to test the strategy with or without these conditions.
4. Added Trade Direction Selection
Users can now specify whether the strategy should trade Long Only, Short Only, or Both.
This feature filters the trading logic to execute only the desired direction of trades, improving flexibility.
5. Introduced Alternate Exit Conditions
An optional feature was added to use alternate exit conditions.
Users can select one of the moving averages as a basis for determining these alternate exit points, providing more versatility in trade management.
The script integrates this feature with an additional input toggle for activation.
6. Improved Commenting and Logging
Entry and exit comments were enhanced with more detailed identifiers, making it easier to track and debug trade activity on the chart.
7. Improved Plotting
Moving averages are now plotted with clear titles in the chart legend, making it easier to identify them visually.
Summary of Changes
The updated script introduces several enhancements:

New Features:

Configurable moving average types.
Trade direction filtering.
Alternate exit logic.
Toggle for activating/deactivating TP and SL.
Improved Usability:

Enhanced comments for better debugging.
Clearer plotting of moving averages.
This patch update focuses on making the strategy more flexible, user-friendly, and adaptable to different trading preferences.
Weighted Moving Average (WMA)

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור