<metaname="description"content="Freqtrade is a free and open source crypto trading bot written in Python, designed to support all major exchanges and be controlled via Telegram or builtin Web UI">
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="default"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to dark mode"type="radio"name="__palette"id="__palette_0">
<labelclass="md-header__button md-icon"title="Switch to dark mode"for="__palette_1"hidden>
<inputclass="md-option"data-md-color-media=""data-md-color-scheme="slate"data-md-color-primary="blue-grey"data-md-color-accent="tear"aria-label="Switch to light mode"type="radio"name="__palette"id="__palette_1">
<labelclass="md-header__button md-icon"title="Switch to light mode"for="__palette_0"hidden>
<p>The <code>stoploss</code> configuration parameter is loss as ratio that should trigger a sale.
For example, value <code>-0.10</code> will cause immediate sell if the profit dips below -10% for a given trade. This parameter is optional.
Stoploss calculations do include fees, so a stoploss of -10% is placed exactly 10% below the entry point.</p>
<p>Most of the strategy files already include the optimal <code>stoploss</code> value.</p>
<divclass="admonition info">
<pclass="admonition-title">Info</p>
<p>All stoploss properties mentioned in this file can be set in the Strategy, or in the configuration.<br/>
<ins>Configuration values will override the strategy values.</ins></p>
</div>
<h2id="stop-loss-on-exchangefreqtrade">Stop Loss On-Exchange/Freqtrade<aclass="headerlink"href="#stop-loss-on-exchangefreqtrade"title="Permanent link">¶</a></h2>
<p>Those stoploss modes can be <em>on exchange</em> or <em>off exchange</em>.</p>
<p>These modes can be configured with these values:</p>
<p>Stoploss on exchange is only supported for the following exchanges, and not all exchanges support both stop-limit and stop-market.
The Order-type will be ignored if only one mode is available.</p>
<table>
<thead>
<tr>
<th>Exchange</th>
<th>stop-loss type</th>
</tr>
</thead>
<tbody>
<tr>
<td>Binance</td>
<td>limit</td>
</tr>
<tr>
<td>Binance Futures</td>
<td>market, limit</td>
</tr>
<tr>
<td>Bingx</td>
<td>market, limit</td>
</tr>
<tr>
<td>HTX (former Huobi)</td>
<td>limit</td>
</tr>
<tr>
<td>kraken</td>
<td>market, limit</td>
</tr>
<tr>
<td>Gate</td>
<td>limit</td>
</tr>
<tr>
<td>Okx</td>
<td>limit</td>
</tr>
<tr>
<td>Kucoin</td>
<td>stop-limit, stop-market</td>
</tr>
</tbody>
</table>
<divclass="admonition note">
<pclass="admonition-title">Tight stoploss</p>
<p><ins>Do not set too low/tight stoploss value when using stop loss on exchange!</ins><br/>
If set to low/tight you will have greater risk of missing fill on the order and stoploss will not work.</p>
</div>
<h3id="stoploss_on_exchange-and-stoploss_on_exchange_limit_ratio">stoploss_on_exchange and stoploss_on_exchange_limit_ratio<aclass="headerlink"href="#stoploss_on_exchange-and-stoploss_on_exchange_limit_ratio"title="Permanent link">¶</a></h3>
<p>Enable or Disable stop loss on exchange.
If the stoploss is <em>on exchange</em> it means a stoploss limit order is placed on the exchange immediately after buy order fills. This will protect you against sudden crashes in market, as the order execution happens purely within the exchange, and has no potential network overhead.</p>
<p>If <code>stoploss_on_exchange</code> uses limit orders, the exchange needs 2 prices, the stoploss_price and the Limit price.<br/>
<code>stoploss</code> defines the stop-price where the limit order is placed - and limit should be slightly below this.<br/>
If an exchange supports both limit and market stoploss orders, then the value of <code>stoploss</code> will be used to determine the stoploss type. </p>
<p>Calculation example: we bought the asset at 100$.<br/>
Stop-price is 95$, then limit would be <code>95 * 0.99 = 94.05$</code> - so the limit order fill can happen between 95$ and 94.05$. </p>
<p>For example, assuming the stoploss is on exchange, and trailing stoploss is enabled, and the market is going up, then the bot automatically cancels the previous stoploss order and puts a new one with a stop value higher than the previous stoploss order.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>If <code>stoploss_on_exchange</code> is enabled and the stoploss is cancelled manually on the exchange, then the bot will create a new stoploss order.</p>
<p>In case of stoploss on exchange there is another parameter called <code>stoploss_on_exchange_interval</code>. This configures the interval in seconds at which the bot will check the stoploss and update it if necessary.<br/>
The bot cannot do these every 5 seconds (at each iteration), otherwise it would get banned by the exchange.
So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute).
This same logic will reapply a stoploss order on the exchange should you cancel it accidentally.</p>
<pclass="admonition-title">Only applies to futures</p>
<p><code>stoploss_price_type</code> only applies to futures markets (on exchanges where it's available).
Freqtrade will perform a validation of this setting on startup, failing to start if an invalid setting for your exchange has been selected.
Supported price types are gonna differs between each exchanges. Please check with your exchange on which price types it supports.</p>
</div>
<p>Stoploss on exchange on futures markets can trigger on different price types.
The naming for these prices in exchange terminology often varies, but is usually something around "last" (or "contract price" ), "mark" and "index".</p>
<p>Acceptable values for this setting are <code>"last"</code>, <code>"mark"</code> and <code>"index"</code> - which freqtrade will transfer automatically to the corresponding API type, and place the <ahref="#stoploss_on_exchange-and-stoploss_on_exchange_limit_ratio">stoploss on exchange</a> order correspondingly.</p>
<p><code>force_exit</code> is an optional value, which defaults to the same value as <code>exit</code> and is used when sending a <code>/forceexit</code> command from Telegram or from the Rest API.</p>
<p><code>force_entry</code> is an optional value, which defaults to the same value as <code>entry</code> and is used when sending a <code>/forceentry</code> command from Telegram or from the Rest API.</p>
<p><code>emergency_exit</code> is an optional value, which defaults to <code>market</code> and is used when creating stop loss on exchange orders fails.
The below is the default which is used if not changed in strategy or configuration file.</p>
<p>This is very simple, you define a stop loss of x (as a ratio of price, i.e. x * 100% of price). This will try to sell the asset once the loss exceeds the defined loss.</p>
<p>You could also have a default stop loss when you are in the red with your buy (buy - fee), but once you hit a positive result (or an offset you define) the system will utilize a new stop loss, which can have a different value.
For example, your default stop loss is -10%, but once you have more than 0% profit (example 0.1%) a different trailing stoploss will be used.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refer to next section with <ahref="#trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset">offset enabled</a>.</p>
</div>
<p>Both values require <code>trailing_stop</code> to be set to true and <code>trailing_stop_positive</code> with a value.</p>
<spanclass="n">trailing_only_offset_is_reached</span><spanclass="o">=</span><spanclass="kc">False</span><spanclass="c1"># Default - not necessary for this example</span>
</code></pre></div>
<p>For example, simplified math:</p>
<ul>
<li>the bot buys an asset at a price of 100$</li>
<li>the stop loss is defined at -10%</li>
<li>the stop loss would get triggered once the asset drops below 90$</li>
<li>assuming the asset now increases to 102$</li>
<li>the stop loss will now be -2% of 102$ = 99.96$ (99.96$ stop loss will be locked in and will follow asset price increments with -2%)</li>
<li>now the asset drops in value to 101$, the stop loss will still be 99.96$ and would trigger at 99.96$</li>
</ul>
<p>The 0.02 would translate to a -2% stop loss.
Before this, <code>stoploss</code> is used for the trailing stoploss.</p>
<divclass="admonition tip">
<pclass="admonition-title">Use an offset to change your stoploss</p>
<p>Use <code>trailing_stop_positive_offset</code> to ensure that your new trailing stoploss will be in profit by setting <code>trailing_stop_positive_offset</code> higher than <code>trailing_stop_positive</code>. Your first new stoploss value will then already have locked in profits.</p>
<li>the stop loss is defined at -10%, so the stop loss would get triggered once the asset drops below 90$</li>
<li>assuming the asset now increases to 102$</li>
<li>the stoploss will now be at 91.8$ - 10% below the highest observed rate</li>
<li>assuming the asset now increases to 103.5$ (above the offset configured)</li>
<li>the stop loss will now be -2% of 103.5$ = 101.43$</li>
<li>now the asset drops in value to 102$, the stop loss will still be 101.43$ and would trigger once price breaks below 101.43$</li>
</ul>
</div>
<h3id="trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset">Trailing stop loss only once the trade has reached a certain offset<aclass="headerlink"href="#trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset"title="Permanent link">¶</a></h3>
<p>You can also keep a static stoploss until the offset is reached, and then trail the trade to take profits once the market turns.</p>
<p>If <code>trailing_only_offset_is_reached = True</code> then the trailing stoploss is only activated once the offset is reached. Until then, the stoploss remains at the configured <code>stoploss</code>.
This option can be used with or without <code>trailing_stop_positive</code>, but uses <code>trailing_stop_positive_offset</code> as offset.</p>
<li>the stop loss would get triggered once the asset drops below 90$</li>
<li>stoploss will remain at 90$ unless asset increases to or above the configured offset</li>
<li>assuming the asset now increases to 103$ (where we have the offset configured)</li>
<li>the stop loss will now be -2% of 103$ = 100.94$</li>
<li>now the asset drops in value to 101$, the stop loss will still be 100.94$ and would trigger at 100.94$</li>
</ul>
<divclass="admonition tip">
<pclass="admonition-title">Tip</p>
<p>Make sure to have this value (<code>trailing_stop_positive_offset</code>) lower than minimal ROI, otherwise minimal ROI will apply first and sell the trade.</p>
</div>
<h2id="stoploss-and-leverage">Stoploss and Leverage<aclass="headerlink"href="#stoploss-and-leverage"title="Permanent link">¶</a></h2>
<p>Stoploss should be thought of as "risk on this trade" - so a stoploss of 10% on a 100$ trade means you are willing to lose 10$ (10%) on this trade - which would trigger if the price moves 10% to the downside.</p>
<p>When using leverage, the same principle is applied - with stoploss defining the risk on the trade (the amount you are willing to lose).</p>
<p>Therefore, a stoploss of 10% on a 10x trade would trigger on a 1% price move.
If your stake amount (own capital) was 100$ - this trade would be 1000$ at 10x (after leverage).
If price moves 1% - you've lost 10$ of your own capital - therefore stoploss will trigger in this case.</p>
<p>Make sure to be aware of this, and avoid using too tight stoploss (at 10x leverage, 10% risk may be too little to allow the trade to "breath" a little).</p>
<h2id="changing-stoploss-on-open-trades">Changing stoploss on open trades<aclass="headerlink"href="#changing-stoploss-on-open-trades"title="Permanent link">¶</a></h2>
<p>A stoploss on an open trade can be changed by changing the value in the configuration or strategy and use the <code>/reload_config</code> command (alternatively, completely stopping and restarting the bot also works).</p>
<p>The new stoploss value will be applied to open trades (and corresponding log-messages will be generated).</p>
<p>Stoploss values cannot be changed if <code>trailing_stop</code> is enabled and the stoploss has already been adjusted, or if <ahref="../edge/">Edge</a> is enabled (since Edge would recalculate stoploss based on the current market situation).</p>
<scriptid="__config"type="application/json">{"base":"..","features":["content.code.annotate","search.share","content.code.copy","navigation.top","navigation.footer"],"search":"../assets/javascripts/workers/search.b8dbb3d2.min.js","translations":{"clipboard.copied":"Copied to clipboard","clipboard.copy":"Copy to clipboard","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.placeholder":"Type to start searching","search.result.term.missing":"Missing","select.version":"Select version"},"version":{"alias":true,"provider":"mike"}}</script>