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
6
votes
2 answers

Still no series to int typecasting in Pinescript 4?

I'm trying to use a series as integer. Pinescript 4 is out but still no way to do this: //@version=4 study("Test Script", overlay=true) l = 1 l := nz(l[1]) + 1 l := l>20?1:l ma = sma(close, l) plot(ma, linewidth=4, color=color.black) I…
Don Coder
  • 526
  • 5
  • 24
6
votes
2 answers

Pine script - strategy entry using heikin ashi but strategy tester uses the real price not ha bar open

So the following code in Pine-script on TradingView uses the Heikin-Ashi candle-bar open price instead of the actual real open in the strategy tester panel. Is there a way to get the strategy tester to use the real price? This link explains the…
Steve Yarnall
  • 61
  • 1
  • 1
  • 2
6
votes
2 answers

TradingView help using multiple strategy.exit calls

I'm having an odd issue modifying an open position in TradingView's strategy tester. Let me explain the context first: The following line opens an order based on my entry condition, entryLong. strategy.entry("ID", strategy.long, comment="L_Entry",…
Dasan
  • 61
  • 1
  • 2
6
votes
6 answers

How to draw a vertical line in TradingView pine script?

I'm trying to use the web based TradingView platform to make my own custom scripts to display various financial market properties. This is possible through its pine scripting engine/interpreter. At the moment I'm trying to simply display a vertical…
not2qubit
  • 14,531
  • 8
  • 95
  • 135
5
votes
1 answer

Could not find function or function reference 'ema'

I'm getting the error line 13: Could not find function or function reference 'ema'. When I know for a fact ema is a function. I'm trying to do a simple strategy, where it enters a long trade if the price is above the 200 DEMA, and there is a "buy"…
Washy
  • 61
  • 1
  • 1
  • 3
5
votes
1 answer

sending Strategy data using Webhooks for Pinescript 4.0

I am using Tradingview Pinescript 4.0. This message was made with reference to : https://stackoverflow.com/questions/66926863/combining-data-from-different-tradingview-4-0-indicators-for-the-purpose-of-crea Basically, what I would like to do is use…
Casey Harrils
  • 2,793
  • 12
  • 52
  • 93
5
votes
0 answers

How exactly does trail_price, trail_offset work in pinescript?

Thank you all for your help so far. I have been coding many different strategies in pinescript so far, and I have read through pinescript manual and many google articles, but I am still confused as to how trailing stop work in pinescript. For…
5
votes
1 answer

How to get the default_qty_value in PineScript?

I'm coding a strategy and I want to perform calculations based on the default_qty_value, which is set in the strategy settings. Yes, I know I can use the strategy.position_avg_price to get the position size, but these calculations must be done…
Eduardo
  • 184
  • 8
5
votes
1 answer

TradingView. Pine-Script: Plotshape, using location.absolute and a boolean condition at the same time..?

In the TradingView PineScript programming language, the Plotshape command format is: plotshape(series, title, style, location, .... Where "Series is treated as a series of boolean values for all location values except location.absolute. " So with…
Ray Johnson
  • 97
  • 1
  • 9
5
votes
1 answer

Pinescript set a position size

My strategy() is fully working but now I'm trying to manage how money is put in the trade. HERE'S MY CURRENT SITUATION : I have a SL set at the lowest low of the last 10 bars and a TP set at 1.5xSL. My strategy.exit : strategy.exit("EXIT…
PepeW
  • 477
  • 1
  • 8
  • 24
5
votes
6 answers

How to find last bar of a day using pine script

I need to close my position at a specific time, for example, I want to close all my position at 15:15. is there inbuilt function in pine script to check time?
user1051673
  • 91
  • 1
  • 1
  • 4
5
votes
2 answers

Reference indicator from within a Pine script

Let's say I want to include the AO indicator as part of the criteria for my Pine script. How can a pine script access indicators? Can a strategy or study import a series generated by another Pine script or built-in indicators?
tiz.io
  • 12,510
  • 1
  • 18
  • 9
5
votes
2 answers

how to format the float to 3 decimal in pinescript

I m using this alertcondition to ask the value from a plot, but the returned value has more than 3 decimal places. Can I format it to make the output only display precision until 3 decimals only? alertcondition(crossover(d2,d3), title="monitor",…
ZKTON
  • 61
  • 1
  • 2
5
votes
5 answers

Is there a function in PineScript for calculating the number of bars displayed?

What I want to get is the length of the series displayed on screen. Is this possible or must one specify length?
Phil Cogan
  • 51
  • 1
  • 4
5
votes
1 answer

How to get previous candles data in indicator?

I'm writing an indicator that needs to read the previous 32 candles ohlc data to make a forecast. How can I get the previous 32 candles ohlc data in TradingView > PineScript Editor > Indicator ?
Neo.Mxn0
  • 953
  • 2
  • 8
  • 25