Questions tagged [pine-script-v5]

This tag should be used for questions relating to scripts and code built specifically on version 5 of Trading View's Pine Script language.

2372 questions
1
vote
1 answer

Is it possible to add multiple trendlines based on different time frames to this Pine Script?

I have been using this pine script recently, but I would like to be able to have multiple iterations of it on the same chart just from different time frames. Is this something that can be easily done? //Fill Arrays with latest LOWS/HIGHS //Get…
1
vote
3 answers

No color options on "style" tab

I am completely new to coding and I need some help. I put up a custom indicator for myself but I can't seem to find the color options under the "style " tab. Using the indicator separately you can see the color option though. Also I want to remove…
1
vote
0 answers

Pinescript: Combining 2 counters and resetting 1 of them

I get buy and sell signals from an indicator. Let's say I got a buy signal. Now I want to count the pivot highs after that signal. I can do this with the following code: var countPivotHigh = 0 countPivotHigh := ta.barssince(buySignal) <…
1
vote
2 answers

How teach to my script to open a position only if the previous one is closed?

I have to plot entries and exits by simulating a strategy within an indicator. The strategy buys if the candle is green and sells when the RSI indicator is overbought. The script plots each signal but does not follow a real strategy in which a new…
1
vote
1 answer

How to get only the last value of the series output of an expression?

I don't need a whole array of this expression, just its very recent (current) value. How to modify its code? UpperBollinger = ta.sma(close, 20) + 2 * ta.stdev(close, 20) (Of course, I can use it to get the same for the lower band.)
Vendrel
  • 865
  • 9
  • 19
1
vote
1 answer

How do I get the minimum value between 25 hours ago in Pine Script?

In my strategy, I want to set the stoploss as the minimum price between 24 hours. lowest = ta.lowest(low, 25) if (4.2 >= stoploss and stoploss >= 1.7) strategy.entry("LONG", strategy.long, when=long) strategy.exit("exit", "LONG", loss=…
bnagkeun
  • 11
  • 2
1
vote
1 answer

Timeframe ="" parameter not contain second time frame

Currently the parameter timeframe = "" of Indicator(title , overlay , timeframe="") doesn't include seconds time frame. timeframe parameter only have minutes , hours , weeks and months time frames. But does not include seconds, 1 second , 2…
1
vote
2 answers

Study Error while plotting HTF engulfing candles on LTF chart

i am getting a study error : Objects positioned using xloc.bar_index cannot be drawn further than 500 bars into the future. I have no idea where to even begin to fix this. Some help from experts here would be very helpful. indicator('MTF Engulfing…
Shikhar
  • 13
  • 3
1
vote
1 answer

label for all previous days

Guys I need help to add labels in script. Now the indicator is showing labels for today only. How do we enable labels for all previous days? When we tried using plotchar parameter, labels showing correctly for all previous days. But, I don't want to…
cryptoweeknd
  • 37
  • 1
  • 8
1
vote
2 answers

How to know if last trade closed was a long or short in strategy

Can anyone tell me how to know if last trade closed was a long or short in strategy please. Thank you.
Jakx
  • 13
  • 7
1
vote
1 answer

Pine script - check to see how many active trades I'm in

I want to limit the amount of trades my script can be in at any one time. I can get in and out of positions, but I want to limit total to 5 so I dont have too much risk or draw down. I use below to get in/out of trade. strategy.entry(id = "Long",…
bahamutcog
  • 11
  • 2
1
vote
1 answer

Volume increase/decrease by an absolute value

I have this code that creates long entries on either 24h volume increase or decrease by a percentage. Is there a way to adapt it so its for an absolute increase, e.g. when the volume increases by $1 million? lower_tf = input('5', title='Lower…
1
vote
1 answer

how i can add alert and plot for this strategy?

Code: //@version=5 strategy("BTCTEST", overlay=true) len = input(7) nATRs = input(0.4) atr = ta.sma(ta.tr, len)*nATRs if (not na(close[len])) strategy.entry("Long", strategy.long, stop=close+atr, comment = "Long") strategy.entry("Short",…
1
vote
1 answer

Error Message: In 'array.get()' function. Index 1 is out of bounds, array size is 1

I'm trying to allow for the manual deletion (or change of coordinates) of lines in an array through an manual input. when I plot the 'array.size' function, it shows the array size as 14, however when I try to turn off any of the lines in the array…
1
vote
1 answer

From plot() to line

Sorry to pester the forum here with more basic questions (I really am lost when it comes to pine script). So, currently I'm plotting the highs of all weekly red candles, however after reading through the documentation I realized that I'm unable to…
SomeGuy74
  • 27
  • 4