Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
49 views

Converting Smoothed Moving Average from MetaTrader/MetaQuotes to PineScript

I'm trying to write the SMMA(Smoothed Moving Average) that MetaTrader has to PineScript, because they are different. MT5 has the SMMA version that seems to be most popular:https://www.metatrader5.com/...
Peter Dimitriadis's user avatar
1 vote
0 answers
132 views

How do I combine an indicator (RSI) and study (EMA)?

Both scripts works on their own, together they do not. I want to combine an RSI indicator and EMA (candles chart) in one script. that RSI is under chart, and EMA is plotted in the chart. EMA not in/...
michael's user avatar
  • 11
0 votes
1 answer
27 views

Use SMA previous DOT as an exit price

Thank you for your help. What would be the correct coding for: "Use SMA previous DOT as an exit price" I want to use the "DOT price" of the previous candle as a trigger, not to ...
MAG Fortunate's user avatar
0 votes
0 answers
55 views

Draw vertical line offset by number of days on intraday charts

I created a short script that plots Moving Averages on all timeframes - specifically it draws Daily Moving Averages on intraday charts. I want to add to the script vertical lines in the same color as ...
ideapix's user avatar
1 vote
0 answers
75 views

I am trying to create a Pine script which with alert for an hourly basis - but want to check every hour if daily MACD is more than 40-how to do that?

I am trying to create a Pine script which with alert for an hourly basis - but want to check every hour if daily MACD is more than 40- how can I do that? Below is the script that I created but it is ...
Hemant Sancheti's user avatar
0 votes
0 answers
585 views

PineScript: Calculate the slope intensity (angle) of a moving average

I am fairly new to PineScript and am playing around with some indicators. For this task I am building out a 9/30 MA indicator. What I am trying to achieve is calculating the validity of a trend by ...
Marcell Erasmus's user avatar
1 vote
1 answer
44 views

Vvertical offset % function to a SMA

is it possible to add a vertical offset in % function to a SMA? My aim is to attach this SMA to a 1 period ATR. Thanks I'm not good with coding so I tried to use already existent indicators, which don'...
Davidator's user avatar
0 votes
1 answer
81 views

Moving Average LOOKBACK

Does anyone know how to write code that highlights the beginning candle of a "X" moving average? For example, using a 50MA, the indicator would look back and highlight the 50th candle from ...
Arturo Ramirez's user avatar
0 votes
0 answers
42 views

Calculate the difference between an oscillator's moving average of pivot highs and the moving average of pivot lows

I have an oscillator (trend). I am calculating the moving averages of the pivot highs and the pivot lows. That works. What doesn't work is when I want to calculate the difference between the two. One ...
Roman Mohren's user avatar
0 votes
1 answer
102 views

how to plot a label next to the last visible value of the moving average?

I want to plot a text label next to a moving average, but i want the label to continue being shown next to the moving average while I move the chart to left I tried //@version=5 indicator("My ...
Eduardo Moreira's user avatar
0 votes
1 answer
364 views

How can i plot a shape every x bars on pinescript?

I want to plot a shape with a text next to my Moving Average every 40 bars, just like that:PLOTTING TEXT EVERY 40 BARS for i = 0 to 4000 by i + 40 _text1 = label.new(bar_index[i],_m1, style = ...
Eduardo Moreira's user avatar
-1 votes
1 answer
65 views

Trying to solve error messages for a Pinescript indicator

I keep getting error messages writing the code for an indicator. I would like it to print a triangle when four conditions become true. Condition 1 = 20ema crossunder 100ema 3 bars ago Condition 2 = ...
M H Sham's user avatar
-1 votes
1 answer
72 views

Start of Moving Average

Is there a pine script v5 that highlights a look back candle or vertical line of "x" moving average. For example, using a 50MA, the chart will highlight the 50th candle to signify the ...
Arturo Ramirez's user avatar
0 votes
0 answers
42 views

TV Alert after MA 200 crosses price and new candlestick opens

The code gives me alert when MA 50 crosses over MA 200. I want it modify to receive alert based on the condition that MA 200 crosses price and a new candlestick opens above MA 200. This is my current ...
Hilary2b's user avatar
0 votes
1 answer
3k views

How to create array of variables in pine script

I have created in tradingview (pine script) three Exponential Moving Averages and I want to create an array from such EMA's. I have tried this: //@version=5 indicator("My script") ema3 = ta....
Giampaolo Levorato's user avatar
1 vote
1 answer
835 views

Multi-Timeframe request.security() function issue - Moving Average Slope/RSI Strategy

I have an issue that's arising from my script process. It utilises code that determines a sloped Moving Average from the 336 day EMA. ft = input.float(2,title="Filter Top",step=0.1) fb = ...
spenke's user avatar
  • 11
0 votes
1 answer
640 views

create a running (moving) average with a continuously updating length from fixed date in time to create a distribution mean

I want to take a stock chart and create an indicator that will display the MEAN/average of ROC(rate of change) of daily closing prices, as a continuously updating length moving average (a running ...
lvbx9's user avatar
  • 59
0 votes
1 answer
369 views

how to create a custom simple moving average in pinescript

I'd like to create a simple moving average please in Pine for Tradingview. The moving average is the average of: 13-period high, 13-period low, 65-period high and 65-period low. (so these 4 numbers ...
user20298545's user avatar
0 votes
1 answer
58 views

Why does this conditional statement return with the undeclared identifier error for ColorA?

This is an extract from the code that is specifically causing me problems. Please bear in mind that this for Pinescript. The aim is for both of the moving averages that I'm coding to be green when ...
Whallet 's user avatar
0 votes
2 answers
623 views

How would I combine 2 colour moving averages into 1 line that changes colour

New programmer here! Thanks to the great stack overflow community, we were able to create an indicator with multiple colour moving averages. Now I would like to go one step further. I want both the ...
Whallet 's user avatar
0 votes
1 answer
1k views

How to represent a positively and negatively sloped simple moving average on pinescript

I'm in the starting phases of creating my own strategy using pine script. The long condition for the strategy is that the simple moving averages must be positively sloped and the short condition is ...
Whallet 's user avatar
0 votes
1 answer
262 views

How to add daily ema25 to indicator across every timeframe

I am trying to update my personal indicator to include the daily ema25 for every time frame(1H/4H etc) and I have been unable to correctly plot the ema. can anyone identify what is wrong with the code ...
Average_JO_Trades's user avatar
0 votes
0 answers
560 views

PineScript - Why EMAs calculated from chart vs request.security function don't give the same value?

See the following code, if you select in Tradingview SPY as the chart ticker. The values for the EMA(200) calculated with the security function vs the ones calculated with with the CLOSE variable from ...
Nelson Pesce's user avatar
0 votes
1 answer
1k views

How to detect if a moving average has been touched or broken

If the Stochastic has crossed in the direction of the trend and price has been pulled back from the trend into a moving average then an entry is valid. A pull back is shown in the image 1. I have ...
Dev The Hall's user avatar
0 votes
1 answer
1k views

Create MACD band on Tradingview

My idea is to make the MACD histogram oscillating in a range from 0-100 just like the RSI. I did it successfully, but compared to normal MACD histogram it is too low and hard to see because most ...
NqHai's user avatar
  • 67
2 votes
2 answers
24k views

Pine Script - Buy/Sell indicator for TradingView that meets multiple conditions

I am trying to build a BUY/SELL Indicator for TradingView by using three indicators, EMA, MACD and Supertrend. Condition 1: The Fast EMA crosses up the Slow EMA. Condition 2: The MACD line is above ...
Amlan Dutta's user avatar
0 votes
1 answer
7k views

Pine Script - How to add input with multiple options and match user selection?

I am trying to add an input with multiple options as shown below and to display a plot based on user selection in TradingView: What I have tried is: emaInput = input.string("50 EMA", "...
Amlan Ranjan Dutta's user avatar
1 vote
1 answer
1k views

How to Turn Off a plot by default in the Style window of a indicator in TradingView Pine Editor?

I have a custom script for Multiple EMA under a single indicator. Here's my sript: //@version=4 //EMA study("Multiple EMA", overlay=true) plot(ema(close, 9), color = color.green, linewidth=...
AmlanRD's user avatar
  • 41
2 votes
0 answers
1k views

Pandas Exponential Moving Average (EWM) unable to copy classical tradingview EMA

I am trying to copy the functionality of classical EMA from trading. In trading view DOCS they say for EMA: It calculates by sing a formula: EMA = alpha * x + (1 - alpha) * EMA[1], where alpha = 2 / (...
luky's user avatar
  • 2,370
0 votes
2 answers
207 views

Asset Price - Simple Moving Average Script

I'm trying to find the deviation between the current price and the simple moving average. My attempted code is below, error message "Could not find function or function reference 'sma'." Not ...
Paul Smith's user avatar
0 votes
1 answer
339 views

Backtest not showing any results for a SMA crossover script in tradingview

Trying below script in Pine Script version 5. No errors in scripts. But, it doesn't show any results in backtest. Can anyone please help? code bold italic quote ****//@version=5 strategy(shorttitle='...
Sunil Doddapaneni's user avatar
1 vote
4 answers
5k views

python - calculating smma (smoothed moving average)

I'm trying to program the smma (smoothed moving average) in Python. I take the formula from a pine script in tradingview. smma = 0.0 smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1)...
Greggy's user avatar
  • 341
0 votes
1 answer
1k views

How to crossover moving average with a specific candle height? Pinescript

I have my strategy set however I would like to test entering trades when a candlestick crosses over the hma49 by a specific amount of ticks. Such as 4. Can I make this an input so I can adjust the ...
Paul Cas's user avatar
0 votes
1 answer
401 views

How to extend a moving average using its last 2 data points as gradient to draw trend line

extend.right does not work when trying to extend the MA out on a current trend. I believe the answer is to draw a line extending out from the MA coordinates into the future (to the right). The ...
Joat Goat's user avatar
0 votes
1 answer
512 views

Pine Script, how to make a moving average exponential deviated in the RSI Indicator?

This is the code I have made. In this image you can see the 14 moving average exponential, I want 2 more 14 moving average exponential but deviated. the result would be like this result image. //@...
RobertoMilan's user avatar
3 votes
2 answers
3k views

Tradingview pinescript's RMA (Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length) in python, pandas

I've been trying to get same results from tradingviews RMA method but I dont know how to accomplish it In their page RMA is computed as: plot(rma(close, 15)) //the same on pine pine_rma(src, length) =...
edgarmtze's user avatar
  • 25k
1 vote
1 answer
351 views

I would like the indicator to send buy/sell-signals when the HullMA changes color

The code looks like this: study(title = "Hull MA", shorttitle="HMA", overlay = true, resolution="60") length = input(48, minval=1) price = input(close, title="Source&...
Daniel Bauer's user avatar
0 votes
1 answer
664 views

Last (the newest) cross of simple moving averages in pine script

Assume that we have sma(close,12) and sma(close,100) in pine script. I used cross()function to have the cross of these two moving averages. What I am interested in is to just mark the first cross (the ...
Arash's user avatar
  • 1
1 vote
1 answer
15k views

TradingView Pine Script strategy multiple time frames

I am trying to apply Bollinger bands in Tradingnview using Pine script. I have calculated all the variables (simple moving average, upper and lower bounds) and used close/open price using a 1-day ...
Nikita Sydorenko's user avatar
-2 votes
1 answer
305 views

can you use pine-script to alert you that an indicator has passed a certain level for the first time in a few months?

so im trying to write a script which can alert me when the sma of the williams%r crosses above -20 or bellow -80, for the first time in 1 month for example. is this possible with pinescript?. thanks ...
Noah Weigert's user avatar
1 vote
0 answers
801 views

Plot labels when 2 Moving Averages cross one another — Pinescript v4 (TradingView)

LonesomeTheBlue wrote a pretty nifty script for plotting Moving Averages on different timeframes. More about his script here: Moving Average MTF Live [Experimental] by LonesomeTheBlue I'm trying to ...
Craig Shields's user avatar
0 votes
1 answer
355 views

Assigning first candle previous color background

I have this simple code that shows the long term trend of price with the integration of a Bollinger Band to have an exclusion zone. Price though, might be entering briefly this band to then exit it ...
Daniel's user avatar
  • 51
2 votes
0 answers
537 views

Recursive function from Pine-script to Python

I am trying to convert the following Pine function (exponentially weighted moving average with alpha = 1 / length) into Python to apply to a Pandas column of a dataframe df (the src in the Pine code ...
Baka's user avatar
  • 73
-1 votes
1 answer
2k views

Three moving average cross over in trading view using pine script version @4

//@version=4 study(title="MA Cross", overlay=true, resolution="") fastMA = sma(close, 55) medMA= sma(close, 89) slowMA = sma(close,233) plot(fastMA, color = color.red) plot(medMA, ...
Nihar Halani's user avatar
3 votes
0 answers
2k views

How TradingView Pine Script RMA works?

I faced the problem that I wanted to implement the same indicators as in the trading view, but I can't correctly implement the RMA indicator. If I refer to the documentation, I get the following code: ...
Philipp's user avatar
  • 31
1 vote
1 answer
4k views

Calculate angle of moving average

I'm trying to calculate the angle of a moving average (n) between the last 2 candles. I've been using this formula and it gives me a correct angle between 2 candles of a moving average(2) but if I ...
Daniel's user avatar
  • 51
0 votes
1 answer
109 views

Plot only when ma5 > ma10

I just want to plot moving average 5 line only when it's above moving average 10. When it's under moving average 10, I don't want it to appear. Can I adjust the transparency condition..? or is ...
Gen Tradex's user avatar
0 votes
1 answer
571 views

Moving average line is only shown till last ticker.id close

I am working on a moving average indicator which shows the MA line of a given time frame. For some reason is the MA line only displaced till the last ticker.id period close. So when for example I have ...
Dennis's user avatar
  • 5
1 vote
1 answer
1k views

My C# Weighted Moving Average result is different than TradingView's, how does TradingView calculate WMA?

Finance charts on TradingView provide a weighted moving average (WMA) value based on a series of past stock prices. I've written a C# method (shown below) to calculate these WMA values so they are ...
pedroballgame's user avatar
0 votes
1 answer
629 views

Pinecript : how can I get the max value of all the sma with length between 1 and i?

I'm trying to write a script which would return the highest value of any moving average whose length is between 1 and a specified number i.e something that would work like this : maxMA = max(sma(close,...
Tommy's user avatar
  • 1