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
My pinescript strategy does not cancel the entry & exit orders when the conditions are no longer met
I am trying to create a simple inside bar breakout strategy that finds an inside bar and then enters long on the high of the inside bar and takes profit at the high of the candle prior to the inside bar. The stop loss is at the low of the inside…

rigatoni4
- 3
- 1
0
votes
0 answers
Qty_percent in strategy.close
what is "Error on bar 1403:invalid percent value. Expected from (0,100], passed 500.00?
I have this error when I setup percent in strategy.close (50%).
This is the string:
strategy.close("Short1", qty.percent= 50 , comment = "Close for 50%")
I have…
0
votes
1 answer
How do I create an indicator that overlay Horizontal line that auto-adjust to daily last close?
I want to create an indicator that draws a horizontal line showing the daily last closing price and the line auto adjusts daily.
I'm expecting something like these:
Daily Last Close Line:
Daily Last Close visible on lower timeframe:

Olorin
- 1
0
votes
1 answer
Pine Script EMA for one bar
I would like to calculate the EMA-13 for the bar from 21 days ago, how do I code this so I can use it after?
Thanks a lot
I would like to use this value

User1
- 23
- 2
0
votes
1 answer
When the RSI is Divergence, I want the position not to open until the certain candle time expires
In a Pine script,
I am running dca strategy within 1 minute time frame. When the RSI Deviation occurs in a different time frame (for example, 1 hour), I want the position not to be opened until the certain candle period ends (for example, 40…

turkprinting
- 7
- 3
0
votes
0 answers
convert a pinescript v2 script to pinescript v5
I can't convert this script to v5, do you have any ideas on how I can do it?
//@version=2
strategy("Fractal Breakout Strategy (by ChartArt)", shorttitle="CA_-_Fractal_Breakout_Strat", overlay=true)
// input
n_time = input(title='Always exit each…

team barigo
- 1
- 1
0
votes
0 answers
Im looking to add cyclic lines in pinescript, but I could not seem to find any api inside of pinescript to do so
So basically my goal, is to have multiple cyclic lines starting at a start date I chose in the code along with the width of the lines. I was wondering if there was a way to do it.
I tried to add vertical lines but that would not work if I am adding…
0
votes
1 answer
How to force a "Buy-Signal" to reactivate ASAP after a Trailing Stop-Loss closes in profit, if conditions for initial Entry are still being met?
I'm building a second-based strategy (currently on 5sec candles to limit the amount of alerts), it's working great in backtesting, but I think it can be optimized even further.
Let's say I work with an indicator which triggers a simple buySignal and…

Inerti4
- 5
- 3
0
votes
1 answer
Why does my strategy close at the end of the candle and not in real time?
and thank you for your welcome on this space. I'm an amateur and I'm only starting to make a few indicators. Currently I'm stuck on one thing, I'm looking to make a stop loss function that takes effect immediately when an event occurs, currently it…

Samuel
- 3
- 1
0
votes
1 answer
Pine script - using buy limit/sell limit is not firing at an exact price
I am trying to enter using a buy limit order at an exact price using pine script eg. 146.090 but even though the price has gone under and over it - it still does not execute.
I do not want to use close/high/low etc, just the exact price.
It would be…

Brad P
- 1
0
votes
1 answer
How to call high or low price of the bar selected from time input?
I want to calculate average price of a specific bar which I get by using confirm=true parameter from input.time. To calculate average I need high and low of that bar and to get that bar index of the selected bar is required. To get that bar index I…

Sanket Kolte
- 5
- 3
0
votes
0 answers
Pine Script V5 Find high from Zig Zag?
I want to draw only the peak points according to the zigzag pattern. How can I draw these lines up to this next peak by setting the retracement percentage of lookback candles to 20%?
enter image description here

user293473
- 3
- 5
0
votes
1 answer
In pine-scrip, how to alert only once per hour in a custom indicator?
I have some code and a variable buy inside, when buy=true then I send alert("Buy"). But during 1 hour it may trigger 5-10 times and it's really annoying. Don't you know how to send indicator's alert once per 1hr or selected time frame?
buy = true //…

BorHunter
- 893
- 3
- 18
- 44
0
votes
1 answer
How to force the TradingView strategy-tester to open/exit Long positions only ? (Remove short) + set TP/SL not giving any result
I've been trying to get backtest results for a Long-only strategy without success.
Also, I can't seem to set a "Take Profit" / Stop loss for some reason. I'm trading second-based intervals so I want a take profit of 0.01% and am using…

Inerti4
- 5
- 3
0
votes
1 answer
Compilation error. Line 42: Cannot use 'plot' in local scope
sorry if this is basic in pinescript, I'm in first steps of learning and playing around with OpenAI generated code...
I can't wrap my head around why it cant be compiled with a plot inside the if in script below:
//@version=5
// This script uses…

Dr. Degen
- 1
- 1