Bjorgum

Bjorgum AutoTrail

Bjorgum Wizard 已更新   
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.


Can buy me a coffee here...


paypal.me/JBjorgum


BTC: bc1qfdf6rnzyhsj67y9atdrdyugy8x9hsvry4h3fvz

开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?