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
0
votes
1 answer

How to get the value of the closest recent peak in Pinescript?

I want to get the value of the peak that is closest to the current price and within the last 15 candles. The problem is I am getting the value of peaks outside of my limit of the last 15 candles and they are not the closest peak to the current…
0
votes
1 answer

Reset price percentage change at the start of each day

I am calculating the percentage change between the open and current close. I want this reset to 0 start of each day. Bellow is my current code. symbol_a = input.symbol("CME_MINI:ES1!", "Symbol 1") daily_open_a = request.security(symbol_a, 'D',…
Jack Mahon
  • 27
  • 6
0
votes
0 answers

pine-script create a multiple time frame indicator with 2 skew / skews and roc as source

I want to create a skew / skewness indicator that will show the skew of a certain length of stock prices both on a lower timeframe, (ex 1 minute) and also an upper timeframe (ex 30 minute). However I would like the timeframes to be customizable…
0
votes
1 answer

Strategy won't add to chart - "User cancelled operation"

I'm working on the following strategy combining the indicators "UT Bot Alerts" and "STC Indicator - A Better MACD [SHK]" //@version=5 // This source code is subject to the terms of the Mozilla Public License 2.0 at…
sshym
  • 1
0
votes
1 answer

Can pinescript v5 create strategy base on other Buy / sell signal from other Buy / sell Strategy?

I want to create another BTC Strategy based altcoin strategy. I plan to use the strategy on the Heikin Ashi Strategy in altcoin's. Altcoin's tactical logic is to check BTC's strategy is buy/sell, if altcoin's HA Strategy signal also matches BTC's…
0
votes
1 answer

How to display alerts? Alert() function does nothing

I try to get alerts for some conditions but nothing happens. Manual didn't help. This test code doesn't trigger any error message but no alerts displayed. alert(close[1] < open[1] ? "Close was lower than Open" : na,…
Vendrel
  • 865
  • 9
  • 19
0
votes
2 answers

Inconsistent str.tonumber() behaviour in pine script

In the example below pine script converts str.tonumber('15min') correctly to 15.00 as it should. However if we provide the argument as a function parameter it fails to convert. Bug has been reported. //@version=5 indicator("My script", "m",…
elod008
  • 1,227
  • 1
  • 5
  • 15
0
votes
0 answers

Problem with getting an item from an array based on string

Could someone explain to me why line 17 generates an error. The array is 11 elements. Let's skip the last item. //@version=5 indicator("SplitArrayTest", overlay = true) printTable2(txt) => var table t = table.new(position.bottom_right, 1, 1),…
Akzylus
  • 21
  • 3
0
votes
0 answers

TradingView strategy alert's delay

I have a TradingView strategy. The problem is that 5-15 minutes pass between the execution of the order and the triggering of the alert. This is a lot for my strategy. The strategy script is quite voluminous. What could be the cause of this problem?…
0
votes
1 answer

How do I make the variables inside the main variable optional?

Green = Bar_Color == color.new(#04E819, 0) MA_Long = MA_Entry == 'Aggressive' ? l_C <= SMA_Out : c_C <= SMA_Out Stoch_Long = Stoch_MTF_6H <= Stoch_Lower Close_Long = Stoch_MTF_3H >= Stoch_Upper Long_signal = Green and MA_Long and Stoch_Long and…
Brenda L.
  • 1
  • 3
0
votes
1 answer

How would I plot a horizontal line on the chart with a Specific time like New york time and have a labels?

So I'm trying to figure out how to plot lines on a chart and have them appear at the daily high but at a specific time like new York time 5p im also trying to add labels to these lines now if I knew how to post my whole code I would have but Im new…
0
votes
0 answers

Pandas columns have the same constant values when porting Pine Script code to Python

I am trying to create Half Trend indicator by porting it from Pine Script into Python. Here is the Tradingview Pine Script Half Trend code I'm trying to create in Python: //@version=4 // Copyright (c) 2021-present, Alex Orekhov…
YoYoYo
  • 439
  • 2
  • 11
0
votes
0 answers

how does max drawdown in tradingview calculate?

When I studied the strategy Tester report values , and reproduced the Max Drawdown example, I found that the max drawdown calculation in the official example was different from the result I reproduced. My code is as follows (symbol is UBER…
chooly
  • 1
  • 1
0
votes
0 answers

Getting error "study references too many candles in history (18861)

Getting error when attempting to plot new line using created variables for x1,y1,x2,y2 parameters. //instantiates peaks from which first line is to be drawn highest_peak = ta.highest(close,20) highest_bar = bar_index[highest_peak] //instantiates…
0
votes
1 answer

Adjust axes limits from a script

Is it possible to adjust the price axis limits from within a script? For example, I would like to adjust the limits of the price (y) axis based on the highest high and lowest low of the currently visible candles. If possible, how do I do this?…
silverstreak
  • 121
  • 1
  • 9