Skip to content

Commit d88b67f

Browse files
authored
Merge pull request #1 from pinecoders/master
Sync
2 parents e84a282 + c912109 commit d88b67f

File tree

9 files changed

+1412
-70
lines changed

9 files changed

+1412
-70
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
<link rel="icon" href="http://pinecoders.com/favicon.ico?v=2" />
212

313
![logo](images/PineCoders.png "PineCoders")
@@ -11,15 +21,15 @@
1121

1222
<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>
1323

14-
<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>.</div>
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>
1525

1626
---
1727

1828
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.
1929

2030
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.
2131

22-
We also pilot the [PineCoders](https://www.tradingview.com/u/PineCoders/#published-scripts) TV moderator account, from which we 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).
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).
2333

2434
PineCoders works daily with TradingView's Pine team to identify and validate anomalies, and test upcoming new features.
2535

coding_conventions/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
[<img src="http://pinecoders.com/images/PineCodersLong.png">](http://pinecoders.com)
212

313
# Pine Script Coding Conventions
@@ -36,7 +46,7 @@ The Pine compiler is not very strict on exact positioning of specific statements
3646

3747
Here is an example of a complete script:
3848

39-
```
49+
```js
4050
//@version=4
4151
// MACD indicator, a Gerald Appel concept.
4252
// Author: TradingView, mods by PineCoders, v1.0, 2019.07.31
@@ -59,8 +69,8 @@ macd = fastMa - slowMa
5969
signal = sma(macd, 9)
6070

6171
// ————— Plots
62-
plot(macd, color=color.blue)
63-
plot(signal, color=color.orange)
72+
plot(macd, color = color.blue)
73+
plot(signal, color = color.orange)
6474
```
6575

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

faq_and_code/README.md

Lines changed: 859 additions & 40 deletions
Large diffs are not rendered by default.

learning_pine_roadmap/README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
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+
111
[<img src="http://pinecoders.com/images/PineCodersLong.png">](http://pinecoders.com)
212

313
# Learning Pine Roadmap
@@ -22,8 +32,8 @@ There are many resources to learn Pine. These are the most important. While you
2232
1. The two primary sources of information on Pine are the [Pine v4 User Manual](https://www.tradingview.com/pine-script-docs/en/v4/index.html) and [Pine v4 Reference Manual](https://www.tradingview.com/pine-script-reference/v4/).<br>
2333
Follow the instructions in the User Manual's [Quickstart Guide](https://www.tradingview.com/pine-script-docs/en/v4/Quickstart_guide.html) page to put your first script in action on a chart, and follow the links in that page to familiarize yourself with Pine's key concepts.
2434
1. Once you start working in the Pine Editor, you can bring up the Reference Manual by Ctrl/&#8984;-clicking on any colored language keyword. From the editor, you can also view a list of keyboard shortcuts by selecting *Pine Editor Keyboard Shortcuts* from the *Help* menu. The editor's *Help* menu will link you to v4 and v3 documentation, and to forums where you can ask questions on Pine.
35+
1. PineCoders maintains a [FAQ & Code](http://www.pinecoders.com/faq_and_code) and a [Resources document](http://www.pinecoders.com/resources/) where you will find links to educational material and tools.
2536
1. [Kodify.net](https://kodify.net/tradingview-programming-articles/) is the largest repository of Pine-related articles out there. In more than 200 articles related to Pine programming, they explore Pine features thoroughly and also present techniques for realizing common tasks in Pine.
26-
1. PineCoders maintains a <a href="http://www.pinecoders.com/faq_and_code">FAQ & Code</a>.
2737
1. YouTube has content by Pine coders. These are a few introductory-level ones:
2838
[How To Use Tradingview Pine Script - Introduction](https://www.youtube.com/watch?v=Kwlxngw1YBY) and its [Part 2](https://www.youtube.com/watch?v=3wW10q9QDA8). A search for `pine introduction tradingview` will turn up a few others.
2939
1. [Backtest Rookies](https://backtest-rookies.com/category/tradingview/) also has some articles on Pine. They produce quality material illustrating many of the typical things Pine coders want to do or explore.
@@ -40,7 +50,7 @@ There are 4 supported versions of Pine, from 1 to 4. A compiler directive used i
4050

4151
## Pine runtime environment
4252

43-
Pine indicator code executes once for each bar of the dataset, starting from the beginning of the chart’s history. When the realtime bar is reached, *indicator* scripts executes every time price changes, while *strategy* scripts may be configured to behave like indicators, or to run only at the close of the realtime bar (the default). See [here](https://www.tradingview.com/pine-script-docs/en/v4/language/Execution_model.html) for more information.
53+
Pine indicator code executes once for each bar of the dataset, starting from the beginning of the chart’s history. When the realtime bar is reached, *indicator* scripts execute every time price changes, while *strategy* scripts may be configured to behave like indicators, or to run only at the close of the realtime bar (the default). See [here](https://www.tradingview.com/pine-script-docs/en/v4/language/Execution_model.html) for more information.
4454

4555
## Series
4656

@@ -59,6 +69,7 @@ Whether you are new to programming or a veteran, the PineCoders <a href="http://
5969
## Code examples
6070

6171
- [TradingView Pine v4 example of a simple script](https://www.tradingview.com/pine-script-docs/en/v4/Quickstart_guide.html).
72+
- The PineCoders [FAQ & Code](http://www.pinecoders.com/faq_and_code) contains many Pine snippets.
6273
- The [PineCoders open source repository](https://github.com/pinecoders/pine-utils) contains reusable code snippets and example code.
6374
- On TradingView, PineCoders publishes [Pine examples and tools](https://www.tradingview.com/u/PineCoders/#published-scripts) and also follows [top Pine coders](https://www.tradingview.com/u/PineCoders/#following-people) who publish mostly open source code. Studying their code is one the best ways to learn.
6475
- Kodify has an article on [Pine operators](https://kodify.net/tradingview/operators/operators-operands/) that can help you get started.
@@ -74,10 +85,9 @@ Here are a few methods for troubleshooting pine-related issues:
7485
![search](search_for_scripts.png "Search for scripts")
7586

7687
- Use Google. You'll often end up on either kodify.net, backtestrookies.com, stackoverflow.com, getsatisfaction.com or the TV wiki. If you are searching for indicators on TradingView, you can use Google with: `site:tradingview.com intitle:indicatorname` for better results.
77-
- Search [Pastebin](https://pastebin.com/) using the proper keywords and `version=X`, replacing `X` with the version of Pine you are working on.
78-
- Plot your way out of the problem. Try simple temporary plots of data, just to see where you're at. It’s a good way to get a feel for what's going on inside the runtime loop. Use a simple `plot(var)`, or `plotchar(var, "var description", "")` to show the value in the indicator values and in the Data Window (look it up; it's real useful) without plotting anything in your indicator's space.
88+
- Plot your way out of the problem. Try simple temporary plots of data, just to see where you're at. It’s a good way to get a feel for what's going on inside the runtime loop. Use a simple `plot(var)`, or `plotchar(var, "var description", "")` to show the value in the indicator values and in the Data Window (look it up; it's real useful) without plotting anything in your indicator's space. PineCoders has a [section on debugging techniques](http://www.pinecoders.com/faq_and_code/#debugging).
7989
- Backtest Rookies has an [article on debugging techniques](https://backtest-rookies.com/2018/02/09/tradingview-pinescript-debugging-plotting-tips-tricks/).
80-
- Ask questions in either the TradingView [Pine Script chat](https://www.tradingview.com/chat/#BfmVowG1TZkKO235), on [StackOverflow](https://stackoverflow.com/questions/tagged/pine-script) or in the [Pinescripters Telegram group](https://t.me/pinescripters). When you ask questions, take the time to state your problem concisely and clearly. The better you explain it, the more chances you have of getting an answer. The people answering questions in the different groups will not teach you Pine; you need to learn on your own as we’ve all done, but they can help you out when you are stuck.
90+
- Ask questions in either the TradingView [Pine Script chat](https://www.tradingview.com/chat/#BfmVowG1TZkKO235) or on [StackOverflow](https://stackoverflow.com/questions/tagged/pine-script). When you ask questions, take the time to state your problem concisely and clearly. The better you explain it, the more chances you have of getting an answer. The people answering questions in the different groups will not teach you Pine; you need to learn on your own as we’ve all done, but they can help you out when you are stuck.
8191

8292
## Conversion from other platforms
8393

pine_lexer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pygments.lexer import RegexLexer
2+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
3+
Number, Literal, Punctuation, Generic, Other, Error
4+
5+
# Many examples are here https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/lexers/
6+
class PinePygmentsLexer(RegexLexer):
7+
name = 'pine'
8+
9+
tokens = {
10+
'root': [
11+
(r'\#([0-9a-fA-F]{8})|\#([0-9a-fA-F]{6})', Literal), # Color literal
12+
(r'[0-9]+', Number.Integer),
13+
(r'(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?', Number.Float),
14+
(r'\s+', Text.Whitespace),
15+
(r'//.*?$', Comment),
16+
(r'(for|if|else|var)\b', Keyword),
17+
(r'(open|high|low|close|volume|time|hl2|hlc3|ohlc4)\b', Name.Constant), # Built-in series 'open', 'high', ...
18+
(r'(study|strategy|plot|plotshape|plotchar|plotarrow|fill|hline|input)\b', Name.Entity), # Annotation function
19+
(r'[\w\.]+', Name.Other),
20+
(r'\+|\-|\*|\/|\%|\=|\[|\]|and|or|not|\?|\:|\<|\>|\!', Operator),
21+
(r'\(|\)|\,', Punctuation),
22+
(r'"(\\\\|\\"|[^"])*"', String.Double),
23+
(r"'(\\\\|\\'|[^'])*'", String.Single),
24+
]
25+
}

pine_style.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pygments.style import Style
2+
from pygments.token import Keyword, Name, Comment, String, Error, \
3+
Number, Literal, Operator, Generic, Whitespace
4+
5+
# Many examples are here https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/default.py
6+
7+
class PineStyle(Style):
8+
background_color = "#f8f8f8"
9+
default_style = ""
10+
11+
styles = {
12+
Whitespace: "#bbbbbb",
13+
Comment: "italic #408080",
14+
15+
Keyword: "bold #008000",
16+
17+
Operator: "#666666",
18+
19+
Literal: "#ff00ff", # Color literal
20+
Name: "#101010",
21+
Name.Constant: "bold #800000", # Built-in series 'open', 'high', ...
22+
Name.Entity: "bold #008000", # Annotation function
23+
24+
String: "#BA2121",
25+
Number: "#6666FF",
26+
27+
Error: "border:#FF0000"
28+
}

0 commit comments

Comments
 (0)