ATR BandsIt has happened to everybody. You enter the market, the position gets a stop loss, then later the market goes in the direction you originally planned. Worse yet - you enter a position, the market goes in your favor, gets near the target, and then it reverses and you get stopped.
We brazilians call this a "violinado", or getting violinated. It happens either because:
1. You put the stop loss too close, or the target too far
2. You entered in the right direction, but at a wrong time
While the second point cannot be programmly adressed, the first can. One popular way of setting a stop loss is by using the average of the true range, it even has a built-in indicator in TV. The problem with it is that you can still get violinated, since as the trend develops, the stop loss only goes up, never down. So if you enter at the wrong time, one slip can still take you out of the market.
Since I got sick of losing money using a conventional stop loss, I made these ATR bands. When you add this indicator to your graph, 6 lines are going to show up, 3 above the price, 3 below it. These lines are calculated from the ATR of the last 20 periods (can be configurated). The upper lines are the high of the last candle + the ATR * the multiplicator factor, the lower lines are the low - ATR * multiplicator factor. There are three multiplicator factors: 1.0, 1.618 and 2.0, and you change them to be whatever you want.
The logic behind it is that theses bands represents the region in which the market is more likely to stay. So if you enter the market at 50.00, you can't expect it to reach 500.00 in the next hour if the ATR is 5.00. And if you set the stop loss at 49.99, it is very likely that the market is going to stop you. By using the ATR bands, you can get a more reasonable price range, so you would set the stop loss at 45.00 and the take profit level at 60.00.
There are two types os ATR you can use: the regular, calculated with RMA, and another using a custom WMA, which puts greater emphasis on large amplitudes. By default, the average uses the past 20 true ranges. You can also choose to use either the closing price or the extremes of the candle as a basis.
Another thing I've added is the violation statistics, which shows the percentages of the times that a band was violated in the next 5 candles (can be configurated). With this, you can get a broader view on the probability of the bands actually being reached.
You may have notice that the bands are lagged by 1 period. I did this so that there is no way you can use future data. You can disable it or increase it, but I recommend just letting it be 1. These bands are the range in which the price is most likely to stay in, if you change the lag you are essentially breaking it's whole purpose.
Stopsandlimits
Move Up StopsThis script creates a stop loss level and then moves it up in 5% increments as prices increase.
Basically, it checks to see if the lowest low of the last 7 days is above a certain level. If yes, it sets the stop at that level. It then checks for the next highest level and keeps going until the price is not above a level. Those variables are then set to the level below them.
Trailing stops are notorious for skewing backtest results. This script avoids that problem. Also, some exchanges do not offer trailing stops, so this script gives you a signal to let you know its time to manually move your stops up.
I will be using this for swing trades involving both crypto and stocks.