SimpleCryptoLife

TrailingStops

SimpleCryptoLife Telah dikemas kini   
Library "TrailingStops"
This library contains functions to output trailing stop lines.

f_marketStructureStop(_restartMode, _flipMode, _restartLowIn, _restartHighIn)
  Parameters:
    _restartMode - Defines how the stop lines persist. Allowed values are:
  • "Always On" - The stop lines are always present and they just reset when they're crossed.
  • "Flip" - The stop lines flip when they're crossed.
  • "Manual" - The stop lines turn off when they're crossed, and turn back on again when _restartLowIn or _restartHighIn are passed into the function as true.
    _flipMode - Defines whether the stop lines are broken by wicks or closes. Allowed values are "Wick", and "Close".
    _restartLowIn - If _restartMode is "Manual", passing this parameter as true restarts the Low stop line.
    _restartHighIn - If _restartMode is "Manual", passing this parameter as true restarts the High stop line.
@returns - floats for the Low and High stop line.
Nota Keluaran:
v2

Updated:
f_marketStructureStop(_restartMode, _flipMode, _restartLowIn, _restartHighIn, _strictMode)
New parameter:
    _strictMode - If false, this library uses Enhanced Simple Highs/Lows from the MarketStructure library. If true, it uses True Highs/Lows.

Also added some explanation about the behaviour of the stop lines if you choose the Flip and Close options. In this case, the stop line that's displayed can regress on a wick, but the underlying value for flipping does not regress. This is by design and is not a bug. The function doesn't know when you might take a position in either direction. If you choose to take a long when the long stop line has been pierced by a wick but not a close, it will display the appropriate value for a stop on that bar, which is the bar's Low.
Nota Keluaran:
v3
Fixed default value for restartMode
Nota Keluaran:
v4

New function:
@function f_complexStop - Outputs a stop line using more complex criteria than f_marketStructureStop, but still based on market structure generated by Local Lows and Highs. This is NOT a market structure indicator (for that, I've written a free, open-source indicator, and you could easily construct one yourself using my MarketStructure library). This function gives intuitive, rule-based places to put a stop loss; that's all.
@param float _high - Defaults to the High of the current chart bar. Included for HTF compatibility.
@param float _low - Defaults to the Low of the current chart bar. Included for HTF compatibility.
@param float _close - Defaults to the Close of the current chart bar. Included for HTF compatibility.
@param string _flipMode="Wick" - Defines whether the stop lines are broken by wicks or closes. Allowed values are "Wick", and "Close". If you choose "Close", the stop line that's displayed can regress on a wick, but the underlying value for flipping does not regress. This is by design and is not a bug. The function doesn't know when you might take a position in either direction. If you choose to take a long when the long stop line has been pierced by a wick but not a close, it will display the appropriate value for a stop on that bar, which is the bar's Low.
@param float _lowBuffer - You can add a buffer to the low stop.
@param float _highBuffer - You can add a buffer to the high stop.
@returns - floats for the Low and High stop lines. Bools for whether the lines are active.

Differences between f_complexStop compared to f_marketStructureStop:
It's more complex ;-) It gets stopped out less because it uses the principle that the market goes through three phases : Compression, Expansion, and Trend. The stops do not trail, or trail less, in Compression.
It uses only Enhanced Highs and Lows and there is no option to use Strict Highs and Lows.
It does not flip; the lines are always on. Instead of being set to na, the lines have active and inactive states that are output.
You can add a buffer to the stops, to make it less likely to get stopped out.

Having trouble publishing this update #fingerscrossed

Perpustakaan Pine

Di dalam semangat sebenar TradingView, pengarang telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka, jadi pengaturcara-pengaturcara Pine yang lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau pada penerbitan-penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini di dalam penerbitan adalah ditadbir oleh Peraturan Dalaman.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Mahu gunakan perpustakaan ini?

Salin garisan ini dan tampalkan ia di dalam skrip anda.