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
0
votes
1 answer
How can I wrote in pinescript that a Moving Average is pointing upwards?
I'm making my first strategy in pinescript so im learning how to code. Theres a step in my strategy that the moving average need to be pointing upwards.
I was thinking that i could put that the value of the third previous ma candle was below the…
0
votes
2 answers
Wait for condition before strategy starts trading in PineScript
I want to wait untill a condition is met before the strategy begins trading.
Trying to make code that waits for the 15 sma to cross below the 12 sma (the Start Trading condition), and then once that happens the strategy can begin trading, but only…

Roboman Robo
- 599
- 2
- 5
- 16
0
votes
0 answers
Pine script v5 - Alert not sync with List of trade by time frame - how to fix
i am newbie in this case,
I use code from other and edit it
When i setting alert in time frame 4h, the result is no sync with the list of trade , it may be same 5m time frame.
i found it may be the Resolution input . i want alert same with the list…

Long token
- 5
- 2
0
votes
1 answer
How do I use a input to turn off Lines.new
Im trying to create a switch a On/off switch for Line.new but im not sure how to go about it
ShowAsiaRange = input.bool(true,'Show Asia Range', group= M1)
tl = line.new(LineFromDate, rth_low, LineToDate, rth_low, xloc=xloc.bar_time,…
0
votes
1 answer
Pine Script - Numbering Buy and Sell signals
I am trying to make this script to show long1 & long2 and short1 & short2
Please check images below.
Original Chart Signal Image
Original) long -> short -> long -> short -> long -> short
Modified Chart Signal Image
Modified) long1 -> short1 ->…

Jimmy Lee
- 5
- 2
0
votes
1 answer
Undeclared identifier problem when I start to add the resulting condition with if
Boll = color.black
if close[0] > high[30]
Boll := white
else if close[0] < low[30]
Boll := blue
else
Boll := brown
SqueezeExpand = color.white
if Boll == color.white and Boll1 == color.white and Boll2 == color.white and Boll3 ==…

ArchBack
- 25
- 5
0
votes
1 answer
Pine Script how to detect close lower than line(not other bar close)
Im not coder, just tryna solve my problem by myself
I need this thing to detect candle closing lower than one line and higher than other
So there is my code right now:
// This source code is subject to the terms of the Mozilla Public License 2.0 at…

Runabout
- 3
- 2
0
votes
1 answer
Plot a shape on a specific value and time
I want to plot a shape (any shape) on a specific value on a specific time. For example, I want to plot a shape on EURUSD with value 1.02903 on 30 Nov 2022 12:00. How do I do that from pine script? Thanks
I was trying to use plotshape and label but…

kash
- 1
0
votes
2 answers
Exit order when price is lower than entry bar low
I would like to set my stop-loss at the low of my entry bar.
what is the condition I need to use ?
I try
if strategy.position_size < 0
strategy.exit(id="Close Short", stop=low[1])
but this my stop-loss change everytime
0
votes
1 answer
Tradingview - Add savepoints for strategy
So i currently cannot figure out how to add variable savepoints via the input fields.
For example i want to enter a trade on a signal i declare (this is working). After this point i have lets say 5 variable save points in percentage values: 1%, 2%,…

slake
- 1
- 1
0
votes
1 answer
How to make table background condition with text inside?
Like from my previous question, I want the table cell to contain the symbol of the chart, and the table background to differ based on price>adj_bolliner as green and Price

ArchBack
- 25
- 5
0
votes
1 answer
How to get the peak that is closest to the current price in Pinescript
I am trying to get the peak price that is closest to the current price, above the current price, and within the last 15 candles
For example, there may be 3 peaks in the last 15 candles. I am trying to sort them to get the peak price that is closest…

Roboman Robo
- 599
- 2
- 5
- 16
0
votes
0 answers
How do I structure a strategy order in pine script to take a set profit with a stoploss
I am not see what I need with my strategy.exit order. Here is the the Entry and exit order.
strategy.entry("Enter Short 8", strategy.short, qty=8, limit=lastopen)
strategy.exit("Short Prof", from_entry="Enter Short 8", profit=25, stop=lastopen + 4 *…

Will
- 1
- 2
0
votes
1 answer
Pine Script Issue with "for" statement with error
Open Source code is below & getting error.
indicator("Advanced Donchian Channels", shorttitle = "[ADC]",overlay = true, max_lines_count = 500)
len = input.int(20, title ="Len", minval = 1, maxval = 166, group = "Advanced Donchian Channel")
fut_tog…

rr1050
- 3
- 3
0
votes
1 answer
How do I make ta.barssince count correctly in pine script? Sometimes it doesn't count the most recent condition
g1 = ta.barssince(close <= adj_bollinger1 or close <= adj_bolliner2)
g2 = ta.barssince(close >= adj_bollinger1 or close >= adj_bolliner2)
if close > adj_bollinger1 and close > adj_bolliner2
closeUPDWBollinger := green
…

ArchBack
- 25
- 5