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
Finding a series of previous highs (not higher highs) after a condition is met
I've been working on this for the past week but can't see if figure out how to do this in Pine. When only the most recent occurrence of a condition is true, how do I identity and reference the past 8 previous candle highs which is higher than the…

TFG
- 3
- 1
0
votes
1 answer
PineScript Version 5
Could someone help me to correct the problem I am having with pinescript when updating the version as it tells me that the "when" will soon be obsolete and I have to replace it with "if", but the problem is that I do not want to lose the…

yeerliin
- 3
- 1
0
votes
1 answer
How to set the strategy.entry to initiate a trade on the nextbar
As seen in the picture below, the trade was initiated one bar after the desired bar. The black arrow indicates the right order place ( open of that day) but for some reason the trade was initiated only on the bar afterward ( blue arrow). How can I…

migdal menora
- 169
- 4
- 16
0
votes
0 answers
How can I close the position with 4 criteria in pine script?
After entry, I would like to set the Stop Loss according to 4 different criteria and it will automatically close the position after the criteria are met. But the strategy.exit with stop loss part seems not accurate.
If the price immediately falls…

Ying
- 15
- 4
0
votes
0 answers
ToS to Pine help conversion
Looking for help converting a this section of a ToS script to pine.
Seems like I could use USI:TICK.NY for data?
input len = 50;
input capMultiplier = 5.0;
def isTickChart = if GetAggregationPeriod() <= 5000 then 1 else 0;
def timer =…

mrpink
- 1
- 1
0
votes
0 answers
Strategy Entry based on Intraday Gaps?
Intra-day gaps can be defined as difference between Open and Close price of previous candle.
if first Intra-day Candle
- If Open > Close of previous Session = GapUp
- If Open < Close of previous Session = GapDown
if GapUp
- - first trade is…
0
votes
1 answer
Custom Position Sizes with Pine and WunderTrading
I've a finished strategy in Pine that backtests well, and I'd like to automate it by sending alerts to Wundertrading. The strategy calculates a custom position-size for each order, based on the current equity and a percentage per-order to risk. The…

Matt
- 48
- 4
0
votes
1 answer
Using pinescript 5 how can I mark the 3:45am candle, preferably with a shape ontop or beneath like a diamond or star something?
I just want to know how I can mark a candle that opened on a specific time.
For example:
We have a 3:45am candle that's marked with a diamond.
Appreciate the help :)
I have tried on my own and tried finding a solution but I'm new to pinescript (and…

isit_reallyme
- 3
- 2
0
votes
1 answer
How to make 240minute display monthly level?
Is there a way to make 4 hour (240 minutes) display the monthly level? I have 15 minutes displaying Daily level and every other minutes displaying weekly level, but I want 240minutes or above to be displaying monthly level if possible. My code is…

Philo
- 5
- 2
0
votes
1 answer
why this indicator gives a Ø value and yet still paints a green line
I have an indicator that I copied and modified. It plots a green line when the "IF_RSI" variable is greater than 0.8.
However, when I scan through the bars, sometimes the value of the indicator shows +1, sometimes -1 and sometimes Ø. Only the -1…

Adam B
- 93
- 1
- 3
- 13
0
votes
0 answers
How to undo reverses position in Pine Script?
I need to use limit orders and stops. I got a code in which only one position is opened and it does not close. what is the problem?
screenshot from Tradingview here
var inLong = false
var inShort = false
IsFlat() =>
strategy.position_size ==…

Alex
- 1
- 2
0
votes
1 answer
how to compare HH and LL to previous HH and LL using an event as lookback
I'm looking for a way to compare the highest high of a current event to the highest high to the previous event but i can't figure out how to look for this since i can only find ways to use bars as a lookback period instead of the previous…

Pitt
- 13
- 5
0
votes
1 answer
How to access next candles data in tradingview by using pine script
How to access next candles data in trading view by using pine script.
For example access historical close price in pine we use close[1],close[2],close[3],close[4],close[5] what I am looking for is opposite of this.
For me to test efficiency of…

Jake
- 155
- 4
- 14
0
votes
0 answers
PineScript - How to link scripts with input.source?
I'm trying to link scripts as described in input.source section, but my list of sources has only "internal" values. I'm testing it with the same ALMA script as shown on the documentation screenshots. What I'm doing wrong?
I was trying to read value…

Mr.R.
- 1
- 1
0
votes
0 answers
Tradingview (TV): Pinescript v5 Strategy Repainting
When I enable an alert on the below strategy, I am told that it can potentially repaint, but I am not sure which function could be causing this. Does anyone have any ideas?
The strategy looks at RSI values on a given timeframe, VWAP, and time of day…

omohammed101
- 1
- 1