TradingView
SimpleCryptoLife
31 Ara 2022 13:06

TrailingStops 

Bitcoin / United States DollarCoinbase

Açıklama

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.

Sürüm Notları

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.

Sürüm Notları

v3
Fixed default value for restartMode

Sürüm Notları

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
Yorumlar
SimpleCryptoLife
Ok so V4 and V5 got lost in the Matrix as I encountered errors publishing. We jumped straight from V3 to V6. So for V4 in the description, read V6.
thermal_winds
Thank you. Realistic trailing stop loss, flips on wicks
SimpleCryptoLife
@thermal_winds, Thank you. Hope it's useful!
kurtsmock
Love it.
SimpleCryptoLife
@kurtsmock, Thanks!
kurtsmock
@SimpleCryptoLife, Yea I spent a bit of this morning studying your code. I really like your thought process and writing style. Here's a look at what I have been working on in a similar vein
kurtsmock
// -- Breakout Tracking { c1_breakout = pd.pb_gt(close,high) c2_breakout = c1_breakout and scp > 0.50 c3_breakout = c1_breakout and scp > 0.80 c4_breakout = c3_breakout and aboveAvg breakout = c1_breakout or c2_breakout or c3_breakout or c4_breakout c1_breakdown = pd.pb_lt(close,low) c2_breakdown = c1_breakdown and scp < 0.50 c3_breakdown = c2_breakdown and scp < 0.20 c4_breakdown = c3_breakdown and aboveAvg breakdown = c1_breakdown or c2_breakdown or c3_breakdown or c4_breakdown
SimpleCryptoLife
@kurtsmock, Looks like a solid blend of market structure and trend, from what little I can tell
Daha Fazla