OPEN-SOURCE SCRIPT

Interactive SAR Stop-Loss [TANHEF]

アップデート済
This indicator is "Interactive" which means some inputs can are manually added through the first click after adding the indicator to the chart (SAR Trailing Stop-loss start point).
Unlike the normal Parabolic SAR, this indicator allows for the modification of the start point of the Parabolic SAR’s first bar calculation. Normally, the Parabolic SAR automatically has a start point after the first bar of an asset’s historical price that will then switch between trailing above and below price respectively. It must be noted that due to how the first position of the Parabolic SAR is calculated, on occasion the Parabolic SAR will immediately flip on the next bar to the opposite side relative to price that it was just located. Modifying the setting “⭐Initial Interactive SAR Position Source”, then selecting either 'Clicked' or 'ATR' level as the vertical start position will prevent this. See images below for more explanation.

Why use a trailing stop-loss?
A trailing stop-loss provides an exit when price moves against you but also enables you to move the exit point further into profit when price is moving in the desired direction of a trade. The Parabolic SAR ( stop and reverse ) which is used to determine price direction as well as when price direction is changing, is very effective at functioning as a trailing stop loss.


Indicator Explanation

スナップショット
Initially when this indicator is added to the chart, you will be prompted to select where to begin the SAR Trailing Stop-loss.
For a long stop-loss, select below price.
For a short stop-loss, select above price.
After this indicator is placed, it can be modified via dragging or from within the settings by modifying the time and the price input. Or simply re-add the indicator to the chart. Another option is to have this Parabolic SAR begin directly on the price that was initially ‘Clicked’ or the ‘ATR’ level, which requires selecting the option in settings labeled “⭐Initial Interactive SAR Position Source”

スナップショット
The SAR Stop Loss plotted. Note that the calculation that occurs on this first bar of the ‘Interactive SAR’ is as if the prior bar was the oldest historical bar of the asset. Due to the SAR’s calculations, if the ‘Normal SAR’ were to also flip sides over to the position that has been manually set for the ‘Interactive SAR’, they won’t necessarily have the same result.

スナップショット
An optional fixed profit target can be added within the settings. This profit target will only actively be plotted when the SAR Trailing Stop-loss has not be hit yet or until the profit target has been hit.

スナップショット
Here shows that the profit target was hit, then later on the SAR Trailing Stop-loss was hit.
Note, trailing stop-loss will continue to be plotted until it has been hit regardless of the profit target being hit or not.

スナップショット
Here is an example of when the Parabolic SAR will immediately flip on the next bar to the opposite side relative to price that it was just first located. This is due to how the Parabolic SAR is calculated and will also occur with the traditional Parabolic SAR that is not interactively (manually) given a start location. To prevent this, either relocate this time in which this SAR beings or consider modifying the SAR’s (start, increment, max) settings specifically.

スナップショット
Here instead of using the SAR’s calculation for an initial bar, the ‘ATR’ was selected as the start point within the setting “⭐Initial Interactive SAR Position Source”.

Alerts
1. 'Check' alerts to use within indicator settings (trailing stop hit and/or profit target hit).
2. Select 'Create Alert'
3. Set the condition to 'Interactive SAR''
4. Select create.
リリースノート
The default positioning value of the first bar of the Interactive SAR is now the ATR value at this bar instead of the result from the SAR's positioning calculation for the first bar of the SAR.
This change was made to provide more consistency due to the unexpected nature of the calculations that the SAR normally would perform for its first value.
リリースノート
A blue circle (🔵) is displayed at the initial *clicked* location (start point). Dragging this blue circle will also modify the start point of the SAR Trailing Stop-Loss.

The label now includes details on which '1st Bar Source' is set in settings (SAR, Clicked, or ATR). Additionally, hovering over the label explains these selections.
リリースノート
Alerts now have customizable messages.

Additional details can be added to the message using these words in between Curly (Brace) Brackets:
  • {{trail}} = SAR trailing stop-loss (price)
  • {{band}} = Lower or Upper trailing (word)
  • {{type}} = Long or Short stop-loss (word)
  • {{traildistance}} = Trailing Distance (%)
  • {{targetdistance}} = Target Distance (%)
  • {{starttime}} = Start time trailing (day:hour:minute)
  • {{target}} = Price target (price)
  • {{trigger}} = Wick or Close Trigger input option (input)
  • {{initial}} = Initial bar SAR source (input)
  • {{sarstart}} = SAR start (input)
  • {{sarmaximum}} = SAR maximum (input)
  • {{sarincrement}} SAR increment (input)
  • {{atrlength}} = ATR length (input)
  • {{atrmultiplier}} = ATR multiplier (input)
  • {{atrma}} = ATR MA type (input)
  • {{ticker}} = Ticker of chart (word)
  • {{exchange}} = Exchange of chart (word)
  • {{description}} = Description of ticker (words)
  • {{close}} = Bar close (price)
  • {{open}} = Bar open (price)
  • {{high}} = Bar high (price)
  • {{low}} = Bar low (price)
  • {{hl2}} = Bar HL2 (price)
  • {{volume}} = Bar volume (value)
  • {{time}} = Current time (day:hour:minute)
  • {{interval}} = Chart timeframe
  • {{newline}} = New line for text


Default Alert Message Input:
{{band}} SAR Trailing Stop Hit at {{trail}} ({{type}}){{newline}}{{ticker}}

Default Alert Message Output:
Lower SAR Trailing Stop Hit at 25 (Long)
BTCUSD
ATRatrstopparabolicParabolic Stop and Reverse (PSAR)SARstopstoplosstrailingtrailingstopwilder

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?


tanhef.com/

Scripts and content from TanHef are solely for information and education. Past performance does not guarantee of future results.
他のメディア:

免責事項