Questions tagged [pine-script]

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script. Please do not use the [tradingview-api] tag for Pine-related questions.

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script.

6637 questions
0
votes
0 answers

How to plot label.new() under double if blocks in pine script

I want to plot the label with the following pine script that I can record it when I export the data and make an alert when the label comes out: if array.size(zigzagpivots) > i_loopback * 2 + 2 lastConfirmedPivot = array.get(zigzagpivots, 1) …
0
votes
0 answers

Consecutive amount of X bars or more

Still not having much luck with my strategy I'm building out. I think staring at the screen for hours on end isn't helping. I asked about this the other day but since then I've changed my code and added more conditions. Basically, my conditions of…
maxi974
  • 3
  • 3
0
votes
1 answer

How to write a Pine script to get the list of stocks meeting certain criteria?

I am new to Pine script and a regular user of Tradingview. Shall anybody guide me on how to use the pinescript to get the list of stocks meeting certain criteria? regards I have never used the pine script so far. As mentioned above, need to learn…
0
votes
0 answers

I want the box to be deleted after is 5 times break through box

I'm new to pine programming and I struggle with this for hours. I want each drawn box to be valid until it is broken 5 times with closed candle. `var bool gapImbBull = na var bool gapImbBear = na // look for bullish GIBs if last_bar_index -…
0
votes
0 answers

Max Run Up function in pinescript

I have code that uses the strategy.opentrades.max_runup() function but my problem is that it only updated on bar close even when using calculate on every tick. I was wondering if anyone knew how to fix that or an alternative that calculates on every…
0
votes
1 answer

PineScript v5 - Cannot call 'fill' with argument 'hline1'='upperInner'. An argument of 'series float' type was used but a 'hline' is expected

I'm writting a PineScript code using Bollinger Bands and i have a problem with fill() command. Error is saying: "Cannot call 'fill' with argument 'hline1'='upperInner'. An argument of 'series float' type was used but a 'hline' is expected." I tried…
0
votes
1 answer

Consecutive green/red bars or more since x

PLaying around with a new strategy. One of the conditions is to check if we have had 3 or more consecutive red bars (for long entry), then entering on the first green bar. I've managed to code a basic strategy which I've attached that allows you to…
maxi974
  • 3
  • 3
0
votes
0 answers

Pinescript V5: Struggling with the correct calculation for plotting the Maximum Drawdown

Here is my calculation which i am using to plot the maximum drawdown in a table on my chart: MD_total_equity = strategy.equity - strategy.openprofit var MD_ATH = MD_total_equity MD_ATH := math.max(MD_total_equity, nz(MD_ATH[1])) Final_MD =…
Kevin.G
  • 5
  • 1
0
votes
1 answer

repaint the signal sometimes Need help to convert Pinescript to none repaint

`//@version=2 strategy("") threshold = input(title="Price Difference Threshold", type=float, defval=0, step=0.001) getDiff() => yesterday=security(tickerid, 'D', close[1]) today=security(tickerid, 'D',…
0
votes
1 answer

Calculate several symbols in one script

I'd like to program an indicator (not a strategy) in order to backtest a portfolio of five different symbols in one script. The aim is to find out how my trading strategy performs across various symbols and time ranges. Let's say my strategy is to…
0
votes
0 answers

Using for loop to iterate number of occurrences in ta.valuewhen

I'm trying to set up a table with a flexible amount of rows depending on the number of trades that happened within a time window. The variable TradeNumber holds the number of trades. My plan was using a for loop to create the necessary amount of…
0
votes
1 answer

Request.Security repainting the screener result when referring higher timeframe

I am trying to get the Previous Day High and Low using Request.Security. Here is my Code. dh_func(sym) => sema = ta.ema(close, ema_len) ////////// /// Get Days High/// [h1,h2,l1,l2] = request.security(sym, 'D',…
naim shaikh
  • 1,103
  • 2
  • 9
  • 20
0
votes
1 answer

Check for mobile vs desktop

In pine script, is there a way to check if the user is currently on a mobile app so I can set a specific label size depending on form factor? I tried looking for functions but cant find anything that resolves the form factor to build into my if…
0
votes
1 answer

Why does this Pine Script indicator work for some ticker symbols and not others?

I have a Pine Script indicator that displays correctly for the SP:SPX ticker but not the CBOE:SPX ticker. These are the same ticker but are coming from different feeds. Correct indicator display Incorrect indicator display // This source code is…
0
votes
1 answer

Draw a vertical line in PineScript v5 when returning time with 'time' and 'time_close'?

Here is an example code: [pdOT, pdCT] = request.security(syminfo.tickerid, 'D', [time[1], time_close[1]]) How can I draw a line at pdOT and cdOT? I have tried using line.new(), plot(), bgcolor() all to no avail.
Lew2234
  • 21
  • 4