I need ATR distance to moving average alert indicator For example the indicator will alert me when price is 1 ATR away from EMA 50 I tried maddash. But it is not supported anymore. Anyone can recommend me an indicator that fot my purpose? Thx!
This code does what you want in TradingView, open up Pine Editor on the chart paste it in and click add to chart. It will plot the EMA and the EMA +/- 1 ATR, as well as providing an alert whenever the price crosses either of those bands. You can customize the EMA length and ATR length, as well as the multiplier for the ATR band. //@version=5 indicator("ATR Distance to EMA Alert", shorttitle="ADTEMA Alert", overlay=true) // customizable settings emaLength = input(50, title="EMA Length") atrLength = input(14, title="ATR Length") atrMultiplier = input(1.0, title="ATR Multiplier") // calculations priceEma = ta.ema(close, emaLength) priceAtr = ta.atr(atrLength) upperBand = priceEma + priceAtr * atrMultiplier lowerBand = priceEma - priceAtr * atrMultiplier // plot EMA line and ATR bands plot(priceEma, color=color.blue) plot(upperBand, color=color.red) plot(lowerBand, color=color.green) // alert conditions alertcondition(ta.crossover(close, upperBand), title="Price Up Alert", message="Price has moved 1 ATR above EMA!") alertcondition(ta.crossunder(close, lowerBand), title="Price Down Alert", message="Price has moved 1 ATR below EMA!")
// PowerCode MultiCharts inputs: ATRLength(14), // Length of the ATR calculation EMALength(50); // Length of the EMA calculation var: ATRValue(0), // Current ATR value EMAValue(0), // Current EMA value ATRDistance(0); // Distance between price and EMA in ATR // Calculate ATR ATRValue = AverageTrueRange(ATRLength); // Calculate EMA EMAValue = XAverage(close, EMALength); // Calculate distance between price and EMA in ATR ATRDistance = (close - EMAValue) / ATRValue; // Alert when price is 1 ATR away from EMA 50 if absvalue(ATRDistance) >= 1 then Alert("Price is 1 ATR away from EMA 50"); This code calculates the ATR and EMA values based on the specified lengths. It then calculates the distance between the close price and the EMA in terms of ATR. If the absolute value of the ATR distance is greater than or equal to 1, it triggers an alert. This code calculates the ATR and EMA values based on the specified lengths. It then calculates the distance between the close price and the EMA in terms of ATR. If the absolute value of the ATR distance is greater than or equal to 1, it triggers an alert. You can customize the input parameters, such as ATRLength and EMALength, to fit your specific requirements. Simply apply this indicator to your chart in MultiCharts and it will generate an alert when the price is 1 ATR away from the EMA 50.