Questions tagged [pine-script]

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script. Please do not use the [tradingview-api] tag for Pine-related questions.

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script.

6637 questions
0
votes
1 answer

Using more than one time input in the chart

time_selection_1 = input.time(timestamp("Jun 01 2023 10:00:00 UTC+3"), 'Date/Time') time_selection_2 = input.time(timestamp("Jun 02 2023 10:00:00 UTC+3"), 'Date/Time') var bool highlight_date = na if time_selection_1 == time highlight_date :=…
x945
  • 27
  • 6
0
votes
1 answer

How to plot candles selectively using plotcandle

I am trying to find a way to plot candles only when that candle is a high-peak candle. Lets say I compute if the candle is high peak or not via is_high_peak = (high[1] > high[2]) and (high <= high[1]) Would it be possible to use plotcandle such…
sey eeet
  • 229
  • 2
  • 8
0
votes
2 answers

My script is not able to find any trades while testing in tradingview. What is wrong in my code?

Conditions - I want to find the first green candle after any red candle. Once that is found I want to look for a second green candle after the first green candle.The high of the second green candle should be more than the high of the first green…
0
votes
0 answers

Round strategy position size

How could we round strategy position size to 0 or 1 or 2 precision? Eg: Strategy is setting with Properties (Order size: 100% if equity) place order B1 165.967 , but I want to round it to 165 and send it when signal alert immediately. I have tried…
Tien Tran
  • 36
  • 4
0
votes
0 answers

strategy.exit doesn't close at take profit/stop loss

I have a strategy that calculates whether to take a long/short and is then attempting to open a position and close that position. It doesn't seem to work so if anyone can spot anything. float stopLoss = na float takeProfit = na if…
user2883072
  • 217
  • 3
  • 12
0
votes
1 answer

How to return a value only the first time a condition is met in INTRADAY in pine script

I am trying to draw day's fresh high and low on 5 min time frame. But the problem that I am facing is this: it generates new fresh high/low. Requirement: I want one of the following solution a) either it stops after FIRST high or b) gives me the…
0
votes
0 answers

Unable to capture real-time intra-bar values with varip variable [pinescript]

I'm trying to use varip variables to capture intrabar data in real time. A simplified example would be capturing the high at the 2 minute point of a 5 minute bar. The simplified code below illustrates what works, and what…
paamachat
  • 53
  • 11
0
votes
1 answer

Issue with switch statement in Pine Script version 5

I am not very experienced with coding (my first time trying the switch function) and can't figure out what is wrong with this piece of code. The error is "Syntax error at input 'US02Y'. Also, the last parenthesis of the switch statement is…
Skylimit
  • 39
  • 6
0
votes
1 answer

Pinescript 2 to Pinescript 5

Is anyone familiar with Pinescript 5.I mean,I can't figure out why this work in Pinescript 2 and not in Pinescript 5 buying = l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1] Error : Undeclared identifier 'buying'
Chris
  • 3
  • 2
0
votes
1 answer

Pinescript - Series float used when fun_arg[] expected

I am trying to convert Williams Percent Range values to the positive domain using the attached scripts. It does need a bit of tweaking, however when attempting to pass a float array as a parameter to the custom function the following error is…
0
votes
1 answer

Draggable Input Price from Market Price

I am trying to create a horizontal line that the user can drag, and the price should be saved as a variable. StopPrice = input.price(title="Stop Price", defval=1.08, confirm = true) So here, Im starting at a default value of 1.08, But I want the…
Nez
  • 39
  • 5
0
votes
1 answer

plotcandle does not work when I interact with the chart

I am trying to change the color of candles based on vwap and previous day vwap. I am able to do that with barcolor function. I now need to change color of the wicks also and cannot use barcolor. I tried to use plotcandle and it works but for some…
0
votes
0 answers

create a covariance test between a current time section and past time (1-20 years back) section of the same stock in pine script

I would like to run a covariance test between any current time section of a stock/etf, example SPY 5-3-2023, and any past historical section of the same stock, example 9-25-17. I have run into limitations before using lagged time values in pinscript…
0
votes
1 answer

Hedge Mode on Pine Script

I am writting a script based on a strategy that worked perfectly on calculations and also on backtest. Now once the code was done I realyzed that strategy.entry() function reverts the position but I expected to open an independet position on the…
0
votes
0 answers

Plotting candles from indicator ranges per bar using LTF close data?

So I've been experimenting with the idea of tracking an indicator's range per bar and displaying that data as candles, (in my case WaveTrend, although the principle should apply to any calculation on close values), and have been able to achieve this…