에디터즈 픽
OPEN-SOURCE SCRIPT

Bjorgum AutoTrail

업데이트됨
One Time Trade Risk Management

Incorporating the new interactive feature, this script is meant as a one time trailing stop for the active trader to manage positional risk of an ongoing trade. As a crypto trader or Fx trader, many may find themselves in a position late into the evening, or perhaps daily life is calling while a trade progresses in their favor. Adding a trailing stop to a position thats trending can help to keep you in the trade and lock in gains if things turn around when you are unable to react.

To use the trail, the user would add the script to the chart. Once added, a set of crosshairs will appear allowing the user to choose a point to begin. Often choosing to start a trail from a swing high/ low can be an ideal option. This tends to provide some protection for a stop by placing it under support for a long trade or above resistance for a short trade.

Price based trail

스냅샷

The trail will automatically plot and the offset is a factor of the distance from price action selected by the crosshairs. If placed above price action the script will plot a short trail, if placed below it will trail for a long position.

Additionally, there are several other trail types other than price based. There is also percent based, which offsets the trail as a percent from close. A hard stop is placed at the cross hair value, then once the distance is exceeded by the percentage specified, the trail begins.

There are 2 more volatility based trails. There is a PSAR trail which can provide quicker and tighter stops that accelerate with the trend locking in gains faster, and an ATR trail that keeps a distance from price action as a function of volatility. Volatility levels can be adjusted from the menu.

Volatility based trail (ATR)

스냅샷

Volatility based trail (PSAR)

스냅샷

Lastly, within the code for more the more technical savvy, is some starting setups for string alerts to be sent to exchanges via 3rd party or custom API applications. Some string manipulation is required for specific providers to meet their requirements, but there is some building block alerts that will take the ticker symbol, recognize the asset your trading (Fx, Crypto, etc) and take input quantity or exchange names from the settings via inputs.

Complex strings can be built to perform almost any trade related task when to comes to alerts via web hook. A little setup this way with some technology to back your system can mean a semi-automated half man, half machine setup that actually manages your trail stop while you cannot. For those that don’t go this far, there is some basic alert functionality that well trigger when a trail is hit so you can react and make a decision.

Please note that for now, interactive mode is engaged only when the script is added to the chart. Additional stops, or for adjustments to be made it is best to add a new version. Also as real trades could be at play managing an actual position, alerts are designed to go off only once to ensure no duplicate orders are sent meaning alerts are not reoccurring. Once an alert is triggered, a new trail is to be set up.

A modified version of the TradingView built in SAR equation was used in this script. To provide the value of the SAR on the stop candle, it was necessary to alter the equation to extract this value as the regular SAR “flips” at this point. Thank you to TradingView for supplying access to the built in formula so that this SAR could behave the same as the built-in function outside of these alterations

Example of SAR value maintained in trigger candle

스냅샷

Cheers and happy trading.
릴리즈 노트
Added variable source input to allow open and close to be a choice in addition to the original high/low default.
릴리즈 노트
Added time check to make Runtime error more robust. Runtime error will occur if stop is placed between the high and the low of the initialization candle as this triggers a stopped condition within the code.
릴리즈 노트
Added color differentiation between short and long bias - adjustable from settings menu
릴리즈 노트
Implemented a new level check which changes the starting point for ATR and Percent type trailing stops. Previously, if the price point for these two trail types was ABOVE the calculated ATR or percent trail start point, the start point would drop down to the calculated point causing an increase in risk. Now the script will use the point selected with the mouse to start the stop loss, and the script will begin trailing at such a time that the start point is exceeded by the calculated trailing value. If the calculated value is greater than where the cursor is placed, the start point will be risk adjusted upwards to the calculated value.

스냅샷
automatedAverage True Range (ATR)BESTbotcryptoeffectiveParabolic Stop and Reverse (PSAR)riskscripttrailingstopVolatility Stop

오픈 소스 스크립트

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

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


면책사항