Skip to content

Commit bd1751e

Browse files
committed
2 parents 2015b17 + aef38e1 commit bd1751e

File tree

13 files changed

+2054
-776
lines changed

13 files changed

+2054
-776
lines changed

README.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,44 @@
1313
![logo](images/PineCoders.png "PineCoders")
1414

1515

16-
<div align="center"><font size="+1"><strong>New to Pine?<br></strong></font> Begin your journey with our <a href="http://www.pinecoders.com/learning_pine_roadmap">Learning Pine Roadmap</a>.</div>
16+
<div align="center">
17+
<font size="+1"><strong>New to Pine?</strong></font><br>
18+
Begin your journey with our <a href="http://www.pinecoders.com/learning_pine_roadmap">Learning Pine Roadmap</a>.<br><br>
1719

18-
<div align="center"><font size="+1"><strong>Have a question?<br></strong></font> Go to our Pine <a href="http://www.pinecoders.com/faq_and_code">FAQ & Code</a>.</div>
20+
<font size="+1"><strong>Have a question on Pine?</strong></font><br>
21+
Your answer is probably already in our <a href="http://www.pinecoders.com/faq_and_code">FAQ & Code</a>.<br>
22+
If not, look up the <a href="https://www.tradingview.com/pine-script-reference/v4/">Reference Manual</a>, the <a href="https://www.tradingview.com/pine-script-docs/en/v4/Introduction.html">User Manual</a>, or search the Web.<br>
23+
As a last resort, ask in the <a href="https://www.tradingview.com/chat/#BfmVowG1TZkKO235">Pine Script chat room</a> on TradingView, or on <a href="https://stackoverflow.com/questions/tagged/pine-script?tab=Newest">Stack Overflow</a>.<br><br>
1924

20-
<div align="center"><font size="+1"><strong>Looking for reusable Pine code?<br></strong></font> The <a href="https://github.com/pinecoders/pine-utils">PineCoders Repository</a> on GitHub is your friend.</div>
25+
<font size="+1"><strong>Want to learn proper Pine coding style?</strong></font><br>
26+
Read our <a href="http://www.pinecoders.com/coding_conventions">Pine Coding Conventions</a>.<br><br>
2127

22-
<div align="center"><font size="+1"><strong>Want to learn proper Pine coding style?<br></strong></font> Read our <a href="http://www.pinecoders.com/coding_conventions">Pine Coding Conventions</a>.</div>
28+
<font size="+1"><strong>Want to stay abreast of Pine news?</strong></font><br>
29+
Subscribe to our <a href="https://t.me/PineCodersSquawkBox">PineCoders Squawk Box on Telegram</a>, or follow our <a href="https://twitter.com/PineCoders">Twitter account</a>.<br><br>
30+
31+
<font size="+1"><strong>Looking for a professional Pine programmer?</strong></font><br>
32+
See our <a href="https://www.pinecoders.com/resources/#trusted-pine-programmers-for-hire">Trusted Pine Programmers for Hire</a>.<br><br>
33+
34+
<font size="+1"><strong>Looking for more resources on Pine?</strong></font><br>
35+
Use our <a href="http://www.pinecoders.com/resources">Pine Resources</a>.<br><br>
36+
37+
<font size="+1"><strong>Want to make a suggestion to improve Pine, or report a bug?</strong></font><br>
38+
Send it by email to our <a href="https://trello.com/c/QA6bcL7l">Trello board</a>.<br><br>
39+
40+
<font size="+1"><strong>Interested in broadening your vistas?</strong></font><br>
41+
We have a guide on <a href="http://www.pinecoders.com/techniques/dsp">Digital Signal Processing in Pine</a> and a <a href="http://www.pinecoders.com/books">list of books</a>.
42+
</div>
2343

24-
<div align="center"><font size="+1"><strong>Looking for Pine-related tools or resources?<br></strong></font> Use our list of <a href="http://www.pinecoders.com/resources">Pine Resources</a> or see our <a href="http://www.pinecoders.com/techniques/dsp">Digital Signal Processing In Pine</a> guide.</div>
2544

2645
---
2746

28-
PineCoders is a [TradingView](https://www.tradingview.com/)-supported group of programmers using TradingView's [Pine Script](https://www.tradingview.com/pine-script-docs/en/v4/Introduction.html) programming language. We help TV members learn Pine, provide tools and resources for beginning as well as pro coders, and collaborate with TradingView to make using Pine indicators and strategies easier for both coders and the at-large TV community.
2947

30-
The [Suggestions For Improvement To Pine](https://trello.com/b/Jmv6c8Cx) Trello board is co-managed by PineCoders and TradingView. This [card](https://trello.com/c/r0jKAKhK) explains how the board works, how any Trello user can comment and vote on suggestions, or contribute new ones.
48+
PineCoders is a [TradingView](https://www.tradingview.com/)-supported group of programmers who code in [Pine Script](https://www.tradingview.com/pine-script-docs/en/v4/Introduction.html), which is used to write trading indicators and strategies for the TradingView financial charting platform.
49+
50+
We collaborate with TradingView's Pine team to steer the future of the language and make Pine indicators and strategies easier to use for the at-large TV community of traders.
3151

32-
We also pilot the [PineCoders](https://www.tradingview.com/u/PineCoders/#published-scripts) TV moderator account, from which we moderate script publications, answer questions in the [Pine Script TV chat](https://www.tradingview.com/chat/#BfmVowG1TZkKO235), publish [open source tools and examples in Pine](https://www.tradingview.com/u/PineCoders/#published-scripts), and follow [leading publishers](https://www.tradingview.com/u/PineCoders/#following-people) of open source scripts on TV, who's code you can learn a great deal from. We also answer questions on Pine at [Stack Overflow](https://stackoverflow.com/questions/tagged/pine-script?sort=Newest).
52+
We pilot the [PineCoders](https://www.tradingview.com/u/PineCoders/#published-charts) moderator account on TV, from where we moderate scripts published in the [Public Library](https://www.tradingview.com/scripts/), answer questions in the [Pine Script chat](https://www.tradingview.com/chat/#BfmVowG1TZkKO235), publish [open source tools and examples in Pine](https://www.tradingview.com/u/PineCoders/#published-scripts), and follow [leading publishers](https://www.tradingview.com/u/PineCoders/#following-people) of open-source scripts on TV.
3353

34-
PineCoders works daily with TradingView's Pine team to identify and validate anomalies, and test upcoming new features.
54+
[Pine v4 Reference Manual](https://www.tradingview.com/pine-script-reference/v4/)
55+
[Pine v4 User Manual](https://www.tradingview.com/pine-script-docs/en/v4/Introduction.html)
3556

36-
Our managed [PineCoders Repository](https://github.com/pinecoders/pine-utils) on GitHub contains:
37-
- [Snippets](https://github.com/pinecoders/pine-utils/tree/master/snippets) of reusable code
38-
- Tricks and techniques to help you accomplish frequently needed tasks

books/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!-- Global site tag (gtag.js) - Google Analytics -->
2+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147975914-1"></script>
3+
<script>
4+
window.dataLayer = window.dataLayer || [];
5+
function gtag(){dataLayer.push(arguments);}
6+
gtag('js', new Date());
7+
8+
gtag('config', 'UA-147975914-1');
9+
</script>
10+
11+
[<img src="https://www.pinecoders.com/images/PineCodersLong.png">](https://www.pinecoders.com/)
12+
13+
# Books
14+
15+
16+
## Building Trading Systems
17+
18+
**Trading Systems and Methods, 6th Edition**, Perry J. Kaufman
19+
The Bible of system traders. A classic that's been around since 1978 and is still being updated. A general survey of all aspects of systems trading.
20+
21+
**Building Winning Algorithmic Trading Systems**, Kevin J. Davey
22+
His personal methodology for developing systems. Takes us through the complete process and covers all the critical parts of developing small-scale systems, which includes much more than the trading strategy. Has good advice on backtesting.
23+
24+
**Advances in Financial Machine Learning**, Marcos Lopez de Prado
25+
Whereas Davey's approach is small-scale, Prado writes about building larger-scale systems using big data, for example. But he covers essential areas of systems trading with a fresh and realistic perspective that will be useful, even to traders building smaller-scale systems. Includes a section on how to avoid pitfalls in backtesting.
26+
27+
**Quantitative Trading**, Ernest P. Chan
28+
This book is similar to the Kevin Davey book, but written by a quant. Chan paints broad strokes in discussing many of the facets of running a small-scale automated operation.
29+
30+
**Professional Automated Trading: Theory and Practice**, Eugene A. Durenard
31+
Durenard explains how he develops medium-scale adaptive systems using LISP. Plenty examples of code. Good concepts by a real practicioner.
32+
33+
**Trend Following, 5th Edition: How to Make a Fortune in Bull, Bear and Black Swan Markets**, Michael Covel
34+
This book is essentially 3 books in one, it has interviews with many of the greatest traders, evidence based arguments for using trend following, and the facets of system trading. Spoiler alert: If you are looking for the holy grail the author does not include it.
35+
36+
37+
## Trading techniques and indicators usable in automated trading
38+
39+
**New Concepts in Technical Trading Systems**, J. Welles Wilder Jr.
40+
Curiously published in 1978, the same year as Kaufman's *Trading Systems and Methods*, this seminal piece has also become a classic, with many of the indicators presented in here for the first time becoming household names: RSI, ATR, DI, ADX and Parabolic SAR. A brilliant book and an intimate journey into Wilder's original thinking process. He has a knack for keeping calculations simple, yet aiming at the jugular, masterfully capturing the essence of whatever he sets his sights on measuring.
41+
42+
**Volume Price Analysis Across The Markets: 4 Books Box Set**, [Anna Coulling](https://www.annacoulling.com)
43+
Contains great information on how to interpret and use volume for an edge in price action trading. Explains how to spot and utilize the actions of Market Makers.
44+
45+
**YTC Price Action Trader**, [Lance Beggs](http://www.ytcpriceactiontrader.com)
46+
All around book describing how to read market moves. Apart from other popular techniques like SR, etc, Beggs explains the concepts of strength & weakness and candle sentiment analysis. Laid out in a way, which can be coded into trading system. As an example, this is a [script covering candle sentiment](https://www.tradingview.com/script/5fSgjYoM-YTC-Candlestick-Sentiment/).
47+
48+
49+
50+
## Explorations
51+
52+
**Incerto Series**, Nassim Nicholas Taleb
53+
An illuminating journey into opacity, uncertainty, randomness, and our general ignorance or misconceptions surrounding them. A humbling study of our shortcomings in appraising the past, present and future. The stimulating and funny work of an unashamedly radical thinker who, after making piles of "fuck you money", decided to take some time off from trading to walk slowly and rethink large parts of what we consider to be knowledge—and what is knowable.
54+
55+
**Thinking in Bets: Making Smarter Decisions When You Don't Have All the Facts**, Annie Duke
56+
An ex-poker player and psychologist has a look at how to improve our thinking in situations where we don't have perfect information but still need to make decisions. She explores our learning process and how we can better distinguish between the quality of outcomes and the quality of our decisions, which because of randomness often cannot be linked.
57+
58+
**The Disciplined Trader: Developing Winning Attitudes**, Mark Douglas
59+
An oft-vehiculated myth about automated trading is that it takes emotions out of the picture. Reality is different. Unchecked emotions and counter-productive thoughts can prevent you from modeling or adequately managing trading systems. This book focuses on the mental processes that can impact your trading. Douglas doesn't mention automated trading at all, and goes whole chapters at a time without even mentioning trading, but his book takes you on an introspective journey that has good probabilities of changing you for the best.

coding_conventions/README.md

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
gtag('config', 'UA-147975914-1');
99
</script>
1010

11-
[<img src="http://pinecoders.com/images/PineCodersLong.png">](http://pinecoders.com)
11+
[<img src="https://www.pinecoders.com/images/PineCodersLong.png">](https://www.pinecoders.com/)
1212

1313
# Pine Script Coding Conventions
14-
1514
The goal of these Coding Conventions is to present a set of best practices and style guidelines for Pine Script. By making Pine scripts easier to read, these guidelines make open source code more usable, while also providing safeguards that minimize the risk of errors for developers.
1615

1716
### Table of Contents
@@ -20,6 +19,7 @@ The goal of these Coding Conventions is to present a set of best practices and s
2019
- [Naming Conventions](#naming-conventions)
2120
- [Spacing](#spacing)
2221
- [Line Wrapping](#line-wrapping)
22+
- [Example Scripts](#example-scripts)
2323

2424

2525
<br>
@@ -53,17 +53,17 @@ Here is an example of a complete script:
5353
study("MACD")
5454

5555
// ————— Inputs
56-
fast = input(12, "Fast Length")
56+
i_fast = input(12, "Fast Length")
5757
// Calculates slow length from fast length and normalizes it if needed.
5858
f_getSlowLength(_len) =>
5959
_tempLen = _len * 2
6060
if _tempLen < 20 or _tempLen > 30
6161
_tempLen := 25
6262
_tempLen
63-
slow = f_getSlowLength(fast)
63+
slow = f_getSlowLength(i_fast)
6464

6565
// ————— Calculations
66-
fastMa = ema(close, fast)
66+
fastMa = ema(close, i_fast)
6767
slowMa = ema(close, slow)
6868
macd = fastMa - slowMa
6969
signal = sma(macd, 9)
@@ -73,7 +73,6 @@ plot(macd, color = color.blue)
7373
plot(signal, color = color.orange)
7474
```
7575

76-
**[Back to top](#table-of-contents)**
7776

7877
<br>
7978

@@ -83,87 +82,90 @@ plot(signal, color = color.orange)
8382

8483
We recommend using camelCase for variable names. Example: `emaLength`, `obLevel`, `showSignal2`, `aLongVariableName`.
8584

85+
For large projects, you may find it useful to use prefixes for a few types of variables, to make them more readily identifiable. The following prefixes can then be used:
86+
87+
- `i_` for variables initialized through `input()` calls.
88+
- `c_` for variables containing colors.
89+
- `p_` for variables used as `plot` or `hline` identifiers for use in `fill()` calls.
90+
- All caps for constants, i.e., variables often initialized at the beginning of scripts whose value will not change during execution.
91+
92+
8693
### Function Names
8794

8895
For function names, we recommend using a Hungarian-style `f_` prefix in combination with the usual camelCase. The `f_` prefix guarantees disambiguation between user-defined and built-in functions. Example: `f_sinh`, `f_daysInMonth`.
8996

9097
### Function Parameter Names
9198

9299
Function parameters should be prefixed with the underscore in order to differentiate them from global scope variables. Example:
93-
94-
```
100+
```js
95101
daysInMonth(_year, _month) =>
96102
```
97103

98104
### Function Dependencies
99105

100106
When a function requires global scope variables to perform its calculations, these dependencies should be documented in comments. Dependencies are to be avoided whenever possible, as they jeopardize function portability and make code more difficult to read.
101-
102-
```
103-
lenMultiplier = input(2, "Length Multiplier")
107+
```js
108+
i_lenMultiplier = input(2, "Length Multiplier")
104109

105110
f_getSlowLength(_len) =>
106-
// Dependencies: lenMultiplier (initialized in inputs).
107-
_tempLen = _len * lenMultiplier
111+
// Dependencies: i_lenMultiplier (initialized in inputs).
112+
_tempLen = _len * i_lenMultiplier
108113
if _tempLen < 20 or _tempLen > 30
109114
_tempLen := 25
110115
_tempLen
111116
```
112117

113118
This is a preferable way to write the same function, which eliminates dependencies:
114-
115-
```
119+
```js
116120
f_getSlowLength(_len, _mult) =>
117121
_tempLen = _len * _mult
118122
if _tempLen < 20 or _tempLen > 30
119123
_tempLen := 25
120124
_tempLen
121125
```
126+
122127
### Local Scope Variable Names
123128

124129
The same underscore prefix used for function parameters should also be used for all local variables. Example:
125-
```
130+
```js
126131
f_getSlowLength(_len) =>
127132
_tempLen = _len * 2
128133
if _tempLen < 20 or _tempLen > 30
129134
_tempLen := 25
130135
_tempLen
131136
```
132-
```
137+
```js
133138
if something
134139
_myLocalVar = something
135140
```
136-
```
141+
```js
137142
for _i = 0 to 100
138143
_myLocalVar = something[_i]
139144
```
140145

141-
**[Back to top](#table-of-contents)**
142146

143147
<br>
144148

145149
## Spacing
146150

147151
A space should be used on both sides of all operators, whether they be assignment, arithmetic (binary or unary) or logical. A space should also be used after commas. Example:
148-
149-
```
152+
```js
150153
a = close > open ? 1 : -1
151154
var newLen = 2
152155
newLen := min(20, newlen + 1)
153156
a = - b
154157
c = d > e ? d - e : d
155158
index = bar_index % 2 == 0 ? 1 : 2
156159
plot(series, color = color.red)
157-
158160
```
159161

162+
160163
<br>
161164

162165
## Line Wrapping
163166

164167
When lines need to be continued on the next, use two spaces to indent each continuation line. Example:
165-
166-
```
168+
```js
167169
plot(
168170
series = close,
169171
title = "Close",
@@ -173,8 +175,7 @@ plot(
173175
```
174176

175177
Tabs may be used to line up elements in order to increase readability.
176-
177-
```
178+
```js
178179
plot(
179180
series = close,
180181
title = "Close",
@@ -183,4 +184,16 @@ plot(
183184
)
184185
```
185186

187+
<br>
188+
189+
## Example Scripts
190+
191+
Some authors use the Coding Conventions systematically:
192+
- [Bar Balance [LucF]](https://www.tradingview.com/script/lcgCwWwI-Bar-Balance-LucF/)
193+
- [[e2] Absolute Retracement](https://www.tradingview.com/script/X87V5IBs-e2-Absolute-Retracement/)
194+
- [Color Gradient (16 colors) Framework - PineCoders FAQ](https://www.tradingview.com/script/EjLGV9qg-Color-Gradient-16-colors-Framework-PineCoders-FAQ/)
195+
196+
197+
<br>
198+
186199
**[Back to top](#table-of-contents)**

0 commit comments

Comments
 (0)