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

How to get hourly RSI from different chart in TradingView Pine Script?

I'm writing a strategy on coin A at a 1min resolution. Now I need to get the hourly RSI on coin B. I've tried: btcusdtHour = security("BITTREX:BTCUSDT", "60", close) plot(rsi(btcusdtHour, 14)) But this doesn't give the results I expected: I end up…
Leigh Bicknell
  • 854
  • 9
  • 19
3
votes
2 answers

How to exit after certain days from `strategy.entry`

I can't seem to figure out the syntax for exit a trade from a certain time interval from the trade entry. Any help would be greatly appreciated. if (crossover(delta, 0)) strategy.entry("Long", strategy.long, comment="Long") …
Mike Mann
  • 528
  • 4
  • 18
3
votes
1 answer

How to draw MACD and EMA in one script ( Pine Editor)-Tradingview

I want to draw MACD and EMA in one script . i implement like below : //@version=3 study("Example of alertcondition") fast = 12, slow = 26 fastMA = ema(close, fast) slowMA = ema(close, slow) macd = fastMA - slowMA src = input(close) ma_2 = ema(src,…
ledien
  • 529
  • 2
  • 8
  • 19
2
votes
0 answers

Pine Script Still Repainting with Best Practices?

I asked a similar question before here, but I thought I had figured out the issue, and couldn't provide visual representations of the issue, so posting again here as the issue isn't fixed. This simple strategy (posted below) makes use of the…
windowshopr
  • 138
  • 7
2
votes
1 answer

Bybit Perp tickers ending with '.P', is there anyway to remove this?

I am attempting to automate my strategy and have added a comment into the strategy entry/exits with = "Buy {{ticker}} q=xxxx" as an example. I then use this {{strategy.order.comment}} in the alert message. What returns is a ticker code like…
Durrr
  • 23
  • 2
2
votes
1 answer

Error when going through a for loop with multiple "if" conditions in pine script

I'm telling you, I had a previous version that worked with multiple conditions to execute an entry, I'll give you an example: lo0 := deltaCloseMa0>=lo0CloseMa0Thresold and rsi>=lo0RsiThreshold lo1 := deltaCloseMa0>=lo1CloseMa0Thresold and…
CharLasky
  • 21
  • 1
2
votes
1 answer

Pine Script - only open and close trades between 7am and 10pm

I'm now coding a very basic moving average crossover trading system on an hourly chart. What I'd love to know is how to only open and close trades between 7am and 10pm. I've used the following code but it still shows trades opening outside these…
2
votes
0 answers

Drawing lines from pivot points that meet a specific conditions

I have successfully created a script that draws a line from one pivot point to another based on some conditions. The conditions are: The next (or following next) pivot points must have a high that is lower than the original pivot point high The…
2
votes
1 answer

Getting historical values from higher timeframes

I've built a custom indicator and I've plotted them using dots on top of candles. When a dot meets a certain criteria with another dot, I draw a trend line connecting them. That works.. What I would like to do is augment these lines from higher…
bdoooh
  • 21
  • 1
2
votes
2 answers

How to plot correctly a fill between two MAs in a diferent time frame in Pine Script?

i´m trying to plot a fill between two moving averages in a 2 minutes chart to identify a trend of the chart, the first one is a 5 minutes time frame 50 periods length MA and the second one is a 2 minutes time frame 2 periods length MA. When i try to…
2
votes
1 answer

Storing values in global array

I can't seem to get values to store in a global array. Code example below: strategy("Array Issue", overlay=true, margin_long=100, margin_short=100) var vars = array.new_int(5) var TRACK = 0 init() => if (barstate.isfirst) …
Sean Barnard
  • 59
  • 1
  • 1
  • 9
2
votes
2 answers

How to get webhook response data using tradingview and php

I'm trying to get Tradingview signals to my remote php script using webhook and trading view alerts. I can't succeed . I'm following this way In my trading view strategy I have this strategy.entry("Long", strategy.long, alert_message =…
gr68
  • 420
  • 1
  • 10
  • 25
2
votes
1 answer

Study Error: Bar index value of the 'left' argument (-1.0000) in box.new() is too far from the current bar index. Try using 'time' instead

This code generates the very rare error mentioned above, in some charts only - seems more prevalent in charts with many bars. I cannot find any references or documentation that points to a possible issue. I've tried setting the left value of…
2
votes
1 answer

Can someone please explain how does function history actually work in pinescript?

In official article, TradingView explains that if you don't call function on every bar, it will return inconsistent values, because it isn't called on every…
2
votes
1 answer

PineScript: Setting alerts with variables from script

I am trying to create an alert in the alert box as below: Test Signal (Nifty Spot price) {{time}}: {{ticker}} Recommendation {{strategy.order.action}} at CMP: {{close}} with SL:{{plot("StopLoss")}} Target(with 1:1 Risk-to-Reward Ratio):…
Pradip
  • 509
  • 1
  • 5
  • 22