OPEN-SOURCE SCRIPT

Turtle System

업데이트됨
First pinescript strategy I've ever written so still learning what is possible.

This strategy is based on the famous turtle system and tried to stay true
to the rules within the confines of what pinescript will allow me to do.

Features:
Green lines represents the 20/55 day highs (configurable)
Red lines represent the 10/20 day lows (configurable)
Purple line represents stop (defaults to 2N away configurable)
Pyramids up to 5 long positions (each 1N away configurable).
Arrows:
Up Arrow Green - 20 day long position entered
Up Arrow Purple - 55 day long position entered
Down Arrow Green - Winning trade exited out.
Down Arrow Red - Losing Trade either stopped out or exited out.
Code tracks successful wins as it is only allowed to enter positions if the last trade was not a wining trade.
One limitation, only supports Long trades although wouldn't be a lot of work to also make it support Short.AAPL

Love to hear feedback on improvements, particularly to make it more robust.



릴리즈 노트
Small change to update the way the labels present for each trade.
릴리즈 노트
Removed some unnecessary code.
릴리즈 노트
Documented the system and added comments to the logic.
릴리즈 노트
Fixed one minor logic bug.
릴리즈 노트
Updated the chart.
릴리즈 노트
Fixed a couple more logic issues.
릴리즈 노트
Fixed bug was adding 6 units max, should only add 5.
릴리즈 노트
Rewrite to consolidate rules and improved the aesthetics to make it easier to visually see breakouts.
릴리즈 노트
Breakouts now occur when the bar moves into the green. One of the rules of turtle system is to not take trades where the last trade was a winning trade, rather skip the next trade. Logic is implemented and you can visually see the trades skipped because the labels are greyed out (L1 labels). If the trade keeps going, it will take the L2 trade as according to the rules.
릴리즈 노트
Fixed issue of code not adhering to the dates used.
릴리즈 노트
More cleanup and now uses next day market order to close position rather that an exit order. exit orders were somewhat unpredictable in terms of when they were filled.
릴리즈 노트
little more cleanup.
릴리즈 노트
Fixed bug in calculating avg price.
릴리즈 노트
1) Fixed bug not always taking L2 trades in strategy tester (visually could see them but strategy entry would not always take it)
2) Added lines to show next buy price as well as the stop price (these are the dashed lines).

Couple things to note about this script so far, which vary slightly from the original turtle rules.
a) All entries to positions are triggered if the close > L1 or L2, NOT the high. This has an interesting side effect. If high crosses over the L1 or L2, but doesn't close above it, this extreme point (high of day) must be crossed in subsequent days to generate a trade. Backtesting, I like this as it forces the trade to really stretch and be bullish, also helps reduce some of the noise in this day to day trading.
b) The actually buy in trading view occurs at the open the next day.

릴리즈 노트
Fixed issue that L2 trades take precedence.
릴리즈 노트
Minor changes.
릴리즈 노트
Fixed issue where L2 trades where using L1 stop.
릴리즈 노트
The latest version handles position sizing based on N. It computes position size as follows
# of shares=(risk/n), where risk=capital*riskPercent and n=ATR14.
릴리즈 노트
Improvements to calculating position size.
릴리즈 노트
Figured out a way to have pine script tell me capital left for determining position sizing.
릴리즈 노트
Entry points are taken on close instead of next day's open. Strategy takes entry based on high/lows > L1 or L2 rather than close.
릴리즈 노트
More updates. Added max units configuration. Cleaned up code a bit. Added alerts. Uses new functionality in strategy to determine cost basis, position sizing based on turtle rules, etc.
릴리즈 노트
More improvements.
릴리즈 노트
Updated version
릴리즈 노트
Make ATR period configurable (defaults to 14)
릴리즈 노트
Someone reported the last version had a bug and wouldn't load, so hopefully this fixes it.
릴리즈 노트
Bug fix.
릴리즈 노트
Fixed issue with position sizing. Fixed crash in 5 minute time frame. Fixed crash in some futures charts.
Trend Analysisturtleturtlesturtlesallthewaydownturtlesoupturtletraderturtletradingfx

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항