This tag should be used for questions relating to scripts and code built specifically on version 5 of Trading View's Pine Script language.
Questions tagged [pine-script-v5]
2372 questions
1
vote
1 answer
Histogram in a table or table.cell
I want to change somes plot (line) on histogram. I can do that, no problem.
plot(MC, color=color_bar, linewidth=1, style=plot.style_histogram, title='1')
And i want that this histogram is on the bottom of the charts with a small height.
So the…

chprot
- 29
- 5
1
vote
1 answer
Grid trading bot - auto parameters calculation
I'm trying to figure out how the Binance Grid Trading Bot calculates its auto parameters. I found the following link which tells us the formula.
How are auto parameters calculated?
Upper Band = MA + BBM * Standard Deviation
Lower Band = MA - BBM *…

nop
- 4,711
- 6
- 32
- 93
1
vote
0 answers
Move stop loss after take profit is hit
I would like to move my stop loss to where my first take profit is IF it reaches it. And also as of now when my stop loss is hit it only sells half the position and then the left is left lingering until it hits the second take profit if it ever…

mrdood
- 13
- 2
1
vote
1 answer
PineScript: Remove duplicate from an array
In a PineScript (v5), when I am trying to remove a duplicate using the following code snippet, getting a below error:
removeDuplicates(arrayData) =>
copyArrayData = array.copy(arrayData)
for i = 0 to (array.size(arrayData) == 0 ? na :…

Pradip
- 509
- 1
- 5
- 22
1
vote
1 answer
How disable/enable input using condition?
Until a few days ago I thought that Pinescript Inputs were not conditional, in fact it is not possible to do something like this.
bool_x = input.bool(true, "On")
if bool_x
integer_x = input.int(0, 'lenght', minval=1)
else
// Do nothing. Don't…

Turi
- 57
- 7
1
vote
1 answer
How to extend default “Backtesting range” for Strategy Tester of TradingView
There is a heap of posts on how to set a specific time interval (Date Range) in PineScript for Strategy Tester. But it works only within a default time interval specified by TradinView. I don’t find how to extend the default time interval (ca. 6500…

duracer
- 19
- 7
1
vote
1 answer
Extension of plotted levels on pinescript
Please help me to extend the plotted line till the end of present trading session. So that, the levels may appear on the chart from the beginning of current trading session.
//@version=5
indicator(title="fff", overlay=true)
// Get user…

AKHIL ASHOK
- 15
- 3
1
vote
1 answer
How do trail_points and trail_offset work with Takeprofit and Stoploss
I'm new to Pine Scripts and I'm trying to write a Strategy to test a new Indicator, the below is my code
if Up and (downbefore == true)
strategy.entry("buy",strategy.long,1000000)
strategy.exit("Exit buy", from_entry="buy", profit = 150000,…

The Collector
- 11
- 3
1
vote
1 answer
Color options disappear in Settings > Style when using chart.bg_color or input.color() + color.rgb()
when using chart.bg_color or deriving a new color with color.rgb() from a user input input.color() for filling two plots with fill(), the color options disappear in Settings > Style. Is this normal behavior and has a reason to it or is this a bug? I…

Phil5590
- 11
- 1
1
vote
1 answer
line 39: 'if' cannot be used as a variable or function name
Can anyone please help me understand what is the issue with the code I have written below.
My apologies, I am a new coder and I'm finding the debugging process to be difficult. The error I'm getting is in the Title.
line 39: 'if' cannot be used as a…

Jonathan Calleja
- 25
- 5
1
vote
2 answers
get the top 100 crypto coins for momentum ranked portfolio
i would like to build a momentum ranked portfolio and need the top 100 or even top 200 crypto coins in my script. just like here:
https://www.tradingview.com/markets/cryptocurrencies/prices-all/
as they the top 100 is dynamic i would like to put the…

Manuel Hruby
- 11
- 1
1
vote
1 answer
Pine Script. strategy.exit for Trailing Stop and Partial Take Profit
I'm trying to have two exits on my strategy, one as a partial take profit and the other a trailing stop loss. I found some codes on the internet and I'm trying to put them together, but the trailing stop loss isn't working. It seams is something…

xBruV
- 11
- 4
1
vote
1 answer
Pine Scripting - Error An argument of 'series float' type was used but 'input float' is expected
I'm trying to plot horizontal line on daily 20 ema price, but getting error while doing so ' Error An argument of 'series float' type was used but 'input float' is expected'
I'm a beginner, any help is appreciated..
How to plot the same on multiple…

Raj L
- 11
- 1
1
vote
1 answer
Stop Loss and revers positions in the strategy
I would like my Stop loss reverse my position. Is it possible to do?
When SL Long go to Short and when SL Short go to Long. I was looking for a solution, but unfortunately I did not find it. Thank You!
strategy.entry('Long', strategy.long,…

WojteG
- 17
- 3
1
vote
0 answers
Within one script, is it possible to send to multiple discord channels?
I have multiple conditions within one script. When one condition is triggered, it will alert and send info to a single discord channel.
My end goal, is to have Condition A sent to Discord Channel A and Condition B sent to Discord Channel B.
Are…

pilotodin5
- 21
- 2