Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6883e4d

Browse files
Merge pull request #12 from LucFF/master
"images" folder additions, README beautifying
2 parents dfd4070 + 035b05d commit 6883e4d

File tree

7 files changed

+100
-3
lines changed

7 files changed

+100
-3
lines changed

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
![logo](images/pinelong.png "Pine")
1+
![logo](images/PineCoders.png "Pine")
22

33
# pine-utils
4-
A set of reusable code snippets, guides and tricks & tips to help Pine Script developers.
4+
Reusable code snippets and tricks & tips to help Pine Script developers.
5+
6+
See our [web site](http://pinecoders.com) for access to our guides and Pine FAQ & Code.

‎guides/faq_and_code/README.md‎

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44

55
## Introduction
66

7-
This is a compendium of frequently asked questions on Pine. Answers are short and often come with examples of code or links where relevant information can be found.
7+
This is a compendium of frequently asked questions on Pine. Answers often give code examples or link to the best sources on the subject.
88

99
### Table of Contents
1010

1111
- [Built-in variables](#built-in-variables)
1212
- [Built-in functions](#built-in-functions)
13+
- [Operators](#operators)
1314
- [Plotting](#plotting)
1415
- [Indicators (a.k.a. studies)](#indicators)
1516
- [Strategies](#strategies)
1617
- [Alerts](#alerts)
1718
- [Techniques](#techniques)
1819

1920

21+
<br><br>
2022
## BUILT-IN VARIABLES
2123

2224

@@ -36,28 +38,108 @@ threeGreenCandles = greenCandle and greenCandle[1] and greenCandle[2]
3638
3739

3840

41+
<br><br>
3942
## BUILT-IN FUNCTIONS
4043

4144

45+
### Why do I get an error message when using highest() or lowest()?
46+
Most probably because you are trying to use a series instead of an integer as the second parameter (the length). Either use an integer or use the RicardoSantos replacements [here](https://www.tradingview.com/script/32ohT5SQ-Function-Highest-Lowest/). If you don't know Ricardo, take the time to look at his indicators while you're there. Ricardo is among the most prolific and ingenious Pinescripters out there.
4247

48+
49+
<br><br>
50+
## OPERATORS
51+
52+
53+
54+
### What's the difference between `==`, `=` and `:=`?
55+
`==` is used to test for true/false conditions.<br>
56+
`=` is used to declare and initialize variables.<br>
57+
`:=` is used to assign values to variables after initialization, transforming them into *mutable variables*.
58+
```
59+
//@version=3
60+
study("")
61+
a = 0
62+
b = 1
63+
plot(a == 0 ? 1 : 2)
64+
plot(b == 0 ? 3 : 4, color = orange)
65+
a := 2
66+
plot(a == 0 ? 1 : 2, color = aqua)
67+
```
68+
69+
70+
<br><br>
4371
## PLOTTING
4472

4573

4674

4775
### Can I plot diagonals between two points on the chart?
4876
Yes, using the [`line.new()`](https://www.tradingview.com/pine-script-reference/v4/#fun_line{dot}new) function available in v4.
4977

78+
### How do I plot a support line?
79+
To plot a continuous line in Pine, you need to either:
80+
1. Look back into elapsed bars to find an occurrence that will return the same value over consecutive bars so you can plot it, or
81+
1. Find levels and save them so that you can plot them. In this case your saving mechanism will determine how many levels you can save.
82+
These are examples of three different techniques used to determine and draw support lines:
83+
- [Backtest Rookies](https://backtest-rookies.com/2018/10/05/tradingview-support-and-resistance-indicator/),
84+
- [Auto-Support v 0.2 by jamc](https://www.tradingview.com/script/hBrQx1tG-Auto-Support-v-0-2/)
85+
- [S/R Barry by likebike](https://www.tradingview.com/script/EHqtQi2g-S-R-Barry/)
86+
87+
### How many plots, security() calls, variables or lines of code can I use?
88+
The limit for plots is 64. Note than one plot statement can use up more than one allowed plot, depending on how it is structured.
89+
The limit for `security()` calls is 40.
90+
The limit for variables is 1000.
91+
We do not know of a limit to the number of lines in a script. There is, however a limit of 50K compiled tokens, but they don't correspond to code lines.
92+
93+
### How can I use colors in my indicator plots?
94+
See [Working with colours](https://kodify.net/tradingview/colours/) by kodify.
95+
96+
### How do I make my indicator plot over the chart?
97+
Use `overlay=true` in `strategy()` or `study()` declaration statement, e.g.,:
98+
```
99+
study("My Script", overlay=true)
100+
```
101+
If your indicator was already in a Pane before applying this change, you will need to use Add to Chart again for the change to become active.
102+
50103

51104

105+
<br><br>
52106
## INDICATORS
53107

54108

55109

56110
### Can I create an indicator that plots like the built-in Volume or Volume Profile indicators?
57111
No.
58112

113+
### How do I feed the output of one script to another script?
114+
Use the following in your code:
115+
```
116+
ExternalIndicator = input(close, "External Indicator")
117+
```
118+
From the script's *Inputs* you will then be able to select a plot from another indicator if it present on your chart.
119+
You can use only one such statement in your script. If you use more than one, the other indicator plots will not be visible from the *Inputs* dropdown.
120+
You cannot use this technique in strategies.
121+
122+
### Can I write a script that plots like the built-in Volume Profile or Volume indicators?
123+
No. TradingView uses special code for these that is not available to standard Pine scripts.
124+
125+
### How can I use one script's output as an input into another?
126+
See how our [Signal for Backtesting-Trading Engine](https://www.tradingview.com/script/y4CvTwRo-Signal-for-Backtesting-Trading-Engine-PineCoders/) can be integrated as an input to our [Backtesting-Trading Engine](https://www.tradingview.com/script/dYqL95JB-Backtesting-Trading-Engine-PineCoders/).
127+
128+
### Is it possible to export indicator data to a file?
129+
No. The only way for now is through screen scraping.
130+
131+
### Can my script place something on the chart when it is running from a pane?
132+
The only thing that can be changed on the chart from within a pane is the color of the bars. See the [`barcolor()`](https://www.tradingview.com/pine-script-docs/en/v4/annotations/Barcoloring_a_series_with_barcolor.html) function.
133+
134+
### Can I merge 2 or more indicators into one?
135+
Sure, but start by looking at the scale each one is using. If you're thinking of merging a moving average indicator designed to plot on top of candles and in relation to them, you are going to have problems if you also want to include and indicator showing volume bars in the same script because their values are not on the same scale.
59136

137+
Once you've made sure your scales will be compatible (or you have devised a way of normalizing/re-scaling them), it's a matter of gathering the code from all indicators into one script and removing any variable name collisions so each indicator's calculations retain their independence and integrity.
60138

139+
> Note that if the indicators you've merged are CPU intensive, you may run into runtime limitations when executing the compound script.
140+
141+
142+
<br><br>
61143
## STRATEGIES
62144

63145

@@ -81,8 +163,20 @@ EnterLong = GoLong and TradeDateIsAllowed()
81163
```
82164
> Note that with this code snippet, date filtering can be enabled/disabled using a checkbox. This way you don't have to reset dates when filtering is no longer needed; just uncheck the box.
83165
166+
### How do I write code for a signal with 2 conditions that occur at different times?
167+
Backtest Rookies has a [blog post](https://backtest-rookies.com/2018/10/26/tradingview-opening-a-window/) on the subject.
168+
169+
### How can I save the entry price in a strategy?
170+
See [How to Plot Entry Price](https://www.tradingview.com/script/bHTnipgY-HOWTO-Plot-Entry-Price/) by vitvlkv
171+
172+
### How do I convert a strategy to a study in order to generate alerts for discretionary trading or a third-party execution app/bot?
173+
The best way to go about this is to write your strategies in such a way that their behavior depends the least possible on `strategy.*` variables and `strategy.*()` call parameters, because these cannot be converted into an indicator.
174+
175+
The PineCoders [Backtesting-Trading Engine](https://www.tradingview.com/script/dYqL95JB-Backtesting-Trading-Engine-PineCoders/) is a framework that allows you to easily convert betweeen strategy and indicator modes because it manages trades using custom Pine code that does not depend on an involved setup of `strategy.*()` call parameters.
176+
84177

85178

179+
<br><br>
86180
## ALERTS
87181

88182

@@ -116,6 +210,7 @@ If one of the generic indicators supplied with the Screener suits your needs and
116210

117211

118212

213+
<br><br>
119214
## TECHNIQUES
120215

121216

‎images/Pine.png‎

22.4 KB
Loading[フレーム]

‎images/PineCoders.png‎

57.2 KB
Loading[フレーム]
File renamed without changes.

‎images/PineLong.png‎

39.9 KB
Loading[フレーム]

‎images/pine.png‎

-27.5 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /