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

How to develop multiple timeframe RSI in pinescript for TradingView

I am trying to develop a multiple time-frame RSI using pine-script on trading view but I seem to have an issue with shorter term RSI in a longer term chart view. For example, the following code will display 5-min RSI. It will display the RSI…
LeanMan
  • 474
  • 1
  • 4
  • 18
5
votes
2 answers

Pine Script Entry Strategy Referencing Previous Exit Price

I am trying to build a strategy (long positions only) in TV wherein strategy.entry will consider the previous exit price. For example: strategy.entry("long", strategy.long, when = longcondition==true) strategy.close("long", strategy.close, when =…
emotheraphy
  • 97
  • 11
5
votes
1 answer

Pine Script beginner, plotshape

Looking for a workaround, can't use plotshape in this way because it doesn't work in a local scope. //@version=3 study("MA test ", overlay=true) FastMA = sma(close, 9) SlowMA = sma(close, 15) Diff = FastMA - SlowMA if Diff > 0 plotshape(Diff,…
sunspore
  • 127
  • 1
  • 4
  • 13
5
votes
1 answer

pinescript - plot cross when EMA crosses over SMA while above/ below 200 moving average

I am very NEW to pinescript and I am stuck at this point... I would like to plot a cross ONLY when 10 EMA crosses over 21 EMA while 21 is above 50 EMA and 50 EMA is above 200 EMA. This is to indicate Long signal. And at the same time, when 10 EMA…
forexfibs
  • 89
  • 1
  • 1
  • 3
5
votes
1 answer

How to get last value that equals the current value in TradingView Pine Script?

I am using Pine Script which is used in tradingview.com. My question is: how I can get the last value that equals the current value? I thought about using a for loop or something else. I tried this code but it returns an error: getval(x,y) => …
Bassel Alahmad
  • 155
  • 1
  • 2
  • 9
5
votes
5 answers

TradingView Pine Script : check previous strategy.entry price before new entry

Someone asked a similar question with no response and I am not allowed to add to it. Tradingview Pine script save close price at time of strategy entry I am trying to build a strategy that will buy multiple times (pyramiding) to average down before…
rigide
  • 61
  • 1
  • 1
  • 4
5
votes
1 answer

How TradingView Pine Script RMA function works internally?

I'm trying to re-implement the rma function from TradingView pinescript but I cannot make it output the same result as the original function. Here is the code I developed, the code is basically the ema function, but it differs greatly from the rma…
Sassa
  • 1,673
  • 2
  • 16
  • 30
4
votes
3 answers

Pine Script : Entering after x consecutive Green Bars / Candles

I am trying to enter a strategy after "X" consecutive bars. greenCandle = barstate.isconfirmed and (close > open) G = input(11, minval=1) strategy.entry("buy", true, 1, when = greenCandle[G] and close[0]>open[0]) This gives me an entry 11 bars…
hello11
  • 115
  • 4
  • 15
4
votes
1 answer

pine script close all position at the end of day

my problem is that I cannot close my open position at the end of a day because I am using the ranko chart pattern. as you know in ranko candle time is not fixed so how can I use IST time in pine script to exit every day at a particular time. in…
Kick
  • 43
  • 3
4
votes
4 answers

Plotting previous day high/low/close using pine script

I have a pine script to draw previous day high/open/low as shown below: //@version=4 strategy("Plot Lines", overlay=true) PDH = security(syminfo.tickerid,"D",high) PDO = security(syminfo.tickerid,"D",open) PDL =…
weizer
  • 1,009
  • 3
  • 16
  • 39
4
votes
2 answers

Pine Script: how to hide `input` values from the chart?

I have a number of inputs that include session ranges which tend to be long strings like "0930-1600:23456" that then all show up over the chart. While it's helpful to have these ranges configurable to make the script flexible, the clutter in the…
tantrix
  • 1,248
  • 12
  • 14
4
votes
2 answers

Can Pine script call back outside Api?

I want to use Pine script to build a strategy in Tradingview website, and use outside data. Can Pine script call back outside Api?
franklili
  • 41
  • 1
  • 2
4
votes
1 answer

Could not find function or function reference financial

I am just trying out Pine Script for the first time, and can't make this work – which should be trivial according to other examples. study("Price to Operating Income", overlay=true, scale=scale.left) op_income = financial(syminfo.tickerid,…
P A N
  • 5,642
  • 15
  • 52
  • 103
4
votes
1 answer

Creating shape or marks in custom indicator, (tradingview charting library (pinejs))

is there any way to create shape or create marks on chart in custom indicator using tradingview charting library. I am using this way to create custom indicators. Thanks in advance.
4
votes
1 answer

Difference between := and = operator in pine script

I'm super new to TradingView Pine Script and I didn't find a proper reference for understanding the difference between the := and = operators. Does anyone have a reference or description? Thanks in advance
Reza Heidari
  • 1,192
  • 2
  • 18
  • 23