a_maxwell

PSAR-risk strategy

a_maxwell 업데이트됨   
This indicator is a tool to know at all times at what price to close a trade, using entry and exit SAR values as hard limits, to protect profits or to not risk more than expected.
Parameters:
  • Source: a PSAR source with calibrated parameters to use as entry and hard exit. Be it the TradingView's official one or TradingView's legacy SAR ported by me (Legacy PSAR).
  • Commission: broker/exchange commission to account for when executing buy/sell orders.
  • Risk: a statistically determined risk of how much loss to tolerate with the current SAR parameters. This doesn't account for commission, it's just a raw loss below entry price. A stop-limit sale is suggested at this price.
  • Milestone #: when reaching a certain percentage above entry, what is the new exit criteria (M# exit). Each milestone must be of a higher value than the previous one, in order to be considered.
  • M# exit: negative values don't account for commission and are raw losses below entry price. Values greater than or equal to zero represent the percentage of the peak profit, with commission accounted for, to sell at. A value of zero means recouping the original investement.

Alerts:
  • Entry condition: SAR-signaled entry. Market price entry or a pre-programmed stop-loss buy at the previous SAR value is suggested.
  • Soft exit condition: this tool's exit. Limit price exit at this tool's current value or a pre-programmed stop-limit sale at the latest available value is suggested.
  • Hard exit condition: SAR-signaled exit. Market price exit or a pre-programmed stop-loss sale at the previous SAR value is suggested

Case study
Let's assume a commission of 0.1%, a studied risk of -5% with the current SAR parameters (you have observed that most good entries don't need to come near 5% down before starting an upside swing), only one programmed milestone at 3% securing a profit of 25% of the peak profit reached.
Let's say that we have an entry executed at $100 with the current SAR value 3% below the current candle. Since -3% > -5% programmed risk, the exit will be marked at the SAR value. If in that candle or in a future one, we reach $103 (3% milestone met) the current peak profit is ~2.8% (($103/$100) * (1 - 0.001)^2) so an exit will be marked at 25% of 2.8%, meaning 0.7% or an exit price of $100.9, if that's higher than the current SAR. The greater value between the current SAR or this indicator calculated value is the current exit price.
릴리즈 노트:
Entry detection logic made for robust for very rare corner cases.
릴리즈 노트:
Added alert for when a new milestone has been met, suggesting an update of the exit condition as soon as possible.
릴리즈 노트:
Improved alert messages and triggering.
릴리즈 노트:
When soft exit condition is equal to hard exit condition, only a hard exit alert will be triggered.
릴리즈 노트:
* Risk now accounts for commission, showing true risk.
* After seeing in practice the live "re-drawing", soft exit condition has been consolidated for same behavior in live and historic bars.
릴리즈 노트:
Corrected exit condition drawing if the exit happens in a bull candle. This could cause a discrepancy between soft exit alert and value in graphic in very rare cases.
릴리즈 노트:
  • Soft exit alert simply trigger with a bearish candle and its low being less than its PRS value. Either current low must be less than previous PRS value or current close must be lower than current PRS value to account for a valid exit.
  • New milestone alert won't trigger if the previous SAR value (current "hard exit") is already greater than the milestone-based "soft exit".
릴리즈 노트:
Usability and presentation improvements:
  • Default format of PRS value is now price with a precision of 2 (two decimal digits). This avoids alerts with price with 8 decimal digits.
  • All parameters are now validated to prevent erratic behavior due to illegal values.
  • Some parameters now have increments in order of their expected values or suggested step size. Examples: "Commission" moves in increments of 0.1 (%) and "Risk" in increments of 0.5 (%), instead of the default step size of 1.
릴리즈 노트:
Removed price formatting, so that it can also work correctly with crypto values.
릴리즈 노트:
Indicator outputs more information for the alerts, without adding noice to the chart. All alerts now send exact execution price information; ideal for consumption by bots or additional reference for users.
릴리즈 노트:
Fix for the new "Hard Exit" output information: it was not plotting after the soft exit condition.
릴리즈 노트:
Hard exit price was already cleared by the time it was attempted to be shown in the hard exit alert; now that value will be cleared in the next candlestick.
릴리즈 노트:
Small code rework: hard exit value available for the alert but not plotted in the candlestick of the event.
릴리즈 노트:
Migration to new TradingView alert system in preparation to script migration from indicator to strategy. New alerts can be sent to either a Discord webhook or as a TradingView notification. They no longer need to be configured by the user, a single alert covers all events (entry, new milestone, soft exit, and hard exit), triggered once per bar.
릴리즈 노트:
  • Minor fix in graphical representation of a hard exit
  • Input parameters have been organized for a more logical understanding, after TradingView's new feature implementation
릴리즈 노트:
Changes:
  • Alerts now give chart periodicity information, should you wish to send alerts for the same asset in different timeframes.
  • Only crypto alerts are formatted with as many decimals as possible; any other asset type is formatted as currency (two decimal digits).
  • Support for TradingView's new chart color transparency.
릴리즈 노트:
Hard exit (market value) sale price fixed in alerts.
릴리즈 노트:
alerts now provide trade performance (profit) at close (sell alert).
보호된 스크립트입니다
이 스크립트는 클로즈 소스로 게시되며 자유롭게 사용할 수 있습니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다. 소스 코드는 보거나 수정할 수 없습니다.
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

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