Overview
The script is designed to plot buy and sell signals based on two indicators: EMA (Exponential Moving Average) and MACD (Moving Average Convergence Divergence), along with ATR (Average True Range) based stop loss (SL) and take profit (TP) levels.
Steps to Use the Script
Set Up the Indicator:
The indicator is named "WM _FCPO TF15_EMA & MACD Crosscheck" and runs on a 15-minute timeframe (TF15).
The script calculates two EMAs (a short EMA and a long EMA) and uses the MACD to determine whether to enter a trade.
Input Customization:
ATR Multiplier for SL/TP: The multiplier that determines the distance for stop loss and take profit.
ATR Length: The length for the ATR calculation.
Short EMA Length: The period for the short-term EMA.
Long EMA Length: The period for the long-term EMA.
MACD Signal Length: The period for the MACD signal line.
Indicators Calculations:
EMAs: Short EMA and Long EMA are calculated using the ta.ema function.
MACD: The MACD line and signal line are calculated using the ta.macd function.
Conditions for Buy and Sell:
Buy Condition: A buy signal occurs when the MACD line crosses above the signal line, and the short EMA crosses above the long EMA.
Sell Condition: A sell signal occurs when the MACD line crosses below the signal line, and the short EMA crosses below the long EMA.
Entry Price:
When a buy or sell signal is triggered, the entry price is saved for both long and short positions.
Stop Loss & Take Profit Calculation:
Stop loss and take profit levels are dynamically calculated based on the ATR, with adjustable multipliers.
There are three take profit levels (TP1, TP2, and TP3), each at different multiples of the ATR.
Lines & Labels:
The script dynamically draws horizontal lines for Entry, Stop Loss, and Take Profit on the chart. These lines are drawn for the next 10 bars (or candles).
Labels display the entry price, stop loss, and take profit levels along with their respective distances from the entry price.
Signal Plotting:
The script plots Buy and Sell signals on the chart with shapes and colors.
For Buy signals, a small green label with an upward triangle is plotted below the bar.
For Sell signals, a small red label with a downward triangle is plotted above the bar.
How to Use the Script:
Add the Script to TradingView:
Open the TradingView website.
Go to the chart you want to apply the script to.
In the Pine Script Editor, paste the code.
Click on Add to Chart.
Adjust Inputs:
In the settings (the gear icon next to the indicator's name), you can adjust the ATR Multiplier, EMA Lengths, and MACD Signal Length according to your preferences or trading strategy.
Trading with the Indicator:
Buy Signal: When the MACD line crosses above the signal line and the short EMA crosses above the long EMA, a buy signal is triggered. You can then open a long position.
Sell Signal: When the MACD line crosses below the signal line and the short EMA crosses below the long EMA, a sell signal is triggered. You can open a short position.
Stop Loss and Take Profit: The stop loss and take profit levels are automatically calculated based on ATR, and lines will appear on the chart to help you visualize your risk management.
Example:
If the script generates a buy signal, you’ll see an Entry line, Stop Loss, and Take Profit levels drawn on the chart.
The stop loss and take profit levels adjust dynamically as the price moves, based on the ATR multiplier you set.
Final Notes:
The script assumes you are using a 15-minute chart.
The ATR (Average True Range) is used to determine volatility and calculate stop loss and take profit levels.
This script can be customized for different timeframes, markets, or trading strategies.
By using this script, you can automate part of your trading decisions and enhance your chart analysis with dynamic entry, stop loss, and take profit levels based on volatility.