Questions tagged [pine-script-v5]

This tag should be used for questions relating to scripts and code built specifically on version 5 of Trading View's Pine Script language.

2372 questions
1
vote
1 answer

How do I switch to 1 alert instead of multiple alerts in Pine Script?

I am learning Pine Script and I just "finished" my first indicator. Everything seems to be doing it's job, except for the alerts. I want to get just 1 alert when it triggers and then wait for the close. However, right now I seem to be getting…
Molle de Jong
  • 31
  • 1
  • 5
1
vote
1 answer

I am new to coding and I can't get pass this error message: Syntax error at input 'new line'

Here is the indicator I am trying to code: //@version=5 indicator("Ell8 BEC", overlay=true) var float prevBearSize = na var float currBullSize = na if close[2] < open[2] prevBearSize := abs(close[2] - open[2]) if open[0] < close[0] …
1
vote
1 answer

How to code on pinescript the price difference between two different time in the same day?

I am beginning on pinescript and in coding, and I would like some help... I would want to know the impact on the market of the last 15 minutes of each trading day. So I would want to plot the price difference between the closing at 16:00 and the…
Nicolas
  • 13
  • 4
1
vote
0 answers

Get the time or identify pre or post market earnings reports

I'm looking for a way to identify if a companies earnings report is pre or post market. eps = request.earnings(syminfo.tickerid, earnings.actual, ignore_invalid_symbol = true) earningsDay = ta.change(eps) This seems to only be picking up pre market…
smashapalooza
  • 932
  • 2
  • 2
  • 12
1
vote
1 answer

How To Retrieve The First And Last Day Of The Entire Strategy Session?

I am attempting to find the very first day of the backtest, and then the very last day of the backtest. This will be determined by some type of method. NOT by a date range input setting, because it changes and sometimes there is no session set, the…
1
vote
1 answer

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 = input.float(-2,title="Filter Top",step=0.1) fthigh =…
1
vote
1 answer

How do you add alert to OBV-MACD indicator when direction changes

Hello im trying to add and alert to OBV-MACD indicator on pinescript when direction changes but i dont know how. I know probably simple but im new to pinescript so i dont know where to start I think it has to go somewhere here, where the plots…
1
vote
0 answers

Getting the pivot points for the last nth bars

if barstate.islast // Loop through the last 1000 bars for i = 0 to 1000 float _pivotHigh = na int _leftBars = 10 int _rightBars = 10 int _pivotRange = ( _leftBars + _rightBars ) float _leftEdgeValue =…
1
vote
1 answer

Pine Script. How to change future ema color when price exceed?

Let's say I have two emas, ema15 and ema50 both in red. ema15 = ta.ema(close,15) ema50 = ta.ema(close,50) plot(ema15, color = color.red) plot(ema50, color = color.red) Now ema15 crossunder ema50 30 bars ago and the price is below ema15. I want to…
Luke Li
  • 15
  • 2
1
vote
1 answer

Multiple long positions

I am a begginer in Pine script. I would like to know how to make my strategy to open a new long position even if the previous long position has not closed. I want the strategy to open a new long position every time the long coditions are met. Many…
ViRus
  • 11
  • 1
1
vote
1 answer

i have an Error à 73:12 Syntax error at input 'useHollow'

I have a persistent error on my code pine script v5 on the first letter of UseHollow only underlined I do not understand where the problem comes from if anyone can help me thank you in advance error return : Syntax error at input…
Cyril O
  • 11
  • 1
1
vote
0 answers

Pinescript Ichimoku Long Condition setting

I am trying to code a long condition using Ichimoku. I want to set a condition when the current closing price is :- a) Above the Tenkan sen (Conversion Line) - this is straight forward. b) Below the Chikou span (Lagging Span) - i am not able to…
samir7399
  • 13
  • 2
1
vote
1 answer

TradingView - How do I compute the highest % deviation from the 20 SMA over the past 200 bars?

I'm attempting to programmatically determine when the price on a given asset deviated the most from the 20 SMA. I wrote the code below which loops over the past 200 bars and determines the % difference between closing price and 20 SMA. All of the %…
mike
  • 2,722
  • 6
  • 31
  • 46
1
vote
1 answer

Previous week open and close in a pine script

new to pine. I can get the open/close of the previous trading day no problem as follows: openprice = request.security(syminfo.tickerid, "D", open[1]) But what I want is the previous weeks open and close. So if today is Wednesday I'm looking for the…
user2883072
  • 217
  • 3
  • 12
1
vote
1 answer

I want to make a PineScript V5 Strategy with ADX and RSI But keep receiving the same error

It just seems that I can't figure out the correct script for my strategy, which is the following: Buy signal when the ADX is above 46 and at the same time the RSI is oversold at or below 20 Works way better in Daily timeframe, get less signals but…