Supertrend / Position SizingSuperTrend with position sizing calculator.
This is based on SuperTrend by Kivanc. I only added the position size calculation and displaying the result.
Loss
Tiger's Stop - Objective Stoploss SettingTrading is a lot about risk management too. I created this script to help with setting and moving a proper stop-loss. It plots an area that is a result of adding and subtracting both average true range and something I call "false range".
►The Average True Range is calculated as the candle's high-low. If there is a gap, it is added to complete the result.
►My own False Range just candle bodies. It is calculated as an absolute value of (close-open).
Then, Rolling Moving Average is applied on both ATR and False Range to get an idea of how far the price tends to extend out of pure randomness. The resulting value is multiplied by a Multiplier.
The next step is an addition of the values to the higher part of the candle for short or a lower part of the candle for long. I prefer a special calculation instead of using Highs and Lows because it allows for more precise observation and stop-loss set up for less wicky symbols.
►►►Additional Functions
• Smoothing - applies moving average to candles from which range distance is calculated. This can achieve good smoothness but higher values will lead to using outdated price in the SL area calculation.
• Enable/Disable - if you know the direction you are going to trade in, it is good to disable either Long Stop-Loss Area or Short Stop-Loss Area. Just untick it in the settings.
►►►Actual Using
Before using the script to set your stop-loss, check the historical data and find a similar set-up. Is it engulfing you use as a trigger? Find a different one and see how effective the stop-loss based on the ATR*multiplier was. This will help you to optimize Multiplier value. A picture shows such research for a double top. You should find more similar situations to find an optimal value.
Ultimately, the indicator still gives you relatively a lot of freedom with your stop-loss settings (at least, that is with the default settings). You need to decide how loose stop-loss you want to set. Average True Range is the furthermost part which will make for a very large stop-loss, on the other hand, False Range might be triggered by a villainous wick unnecessarily. The choice should depend on the specific symbol you trade and perhaps, you will learn to set stops regardless of the indicator.
A little trick : 1. You can set the loosest stop-loss and set a TradingView alert for where the tightest stop-loss would be. When alerted, you will get the opportunity to reconsider the trade and take a loss if needs be or exit if a candle closes there. 2. Mostly for cryptocurrencies, you can set the tightest stop-loss to protect yourself from sudden spikes. If the price approaches it slowly enough, you can move the stop-loss to the further part of the channel. This is not the same as moving stop-loss indefinitely with hopes of reversal if you plan it from the beginning and a smaller stop is meant to protect you from spikes that are not always predictable and drive to both directions.
►►►Advantages of trailing stop-loss
I usually stick with my original stop-loss instead of moving to break even. If my entry area was functional support once, it may work again and is, therefore, still a good entry zone. But an alternative used to preserve as much of the profit as possible is trailing.
Trailing is setting a specific value in ticks or a calculation of how to move the stop-loss whenever the price moves in your favor. Tiger's Stop can be used this way. Whenever there is a new value as the candle closes and that value is closer to price than your current stop-loss, you can update it. However, if it moves further from your price, don't change the stop-loss. This can be a little tiresome if you do it manually but should be worth the effort.
I usually start trailing only after the price moves significantly in my favor that allowing it to return to the entry price would not make any sense.
►►►Feedback and optimization
The preview chart is chosen entirely at random and the values are not optimized for any specific symbol. If you opt to use it, let me know which values work for you the best, I'll add it to the description when I update it.
Furthermore, let me know if you think any sort of alerts would be useful with my script.
Good luck!
Safe stop-loss (12h)Where to put your stop-loss to avoid accidental exit. Configure your risk level. If you are in a long position and significant profit, increase the parameters to reduce the risk of accidental exit.
Indicator - ATR Profit Loss - DGHi Traders,
This is an on chart indicator that can be used for setting take profit and stop losses very easily using the Average True Range Indicator (ATR). Using a volatility adjusted TP and SL will allow you to set your targets and losses based on market conditions. In the settings, you are able to adjust how much of a multiplier you require depending on your risk tolerance and strategy. For those that follow the NNFX method, the defult settings are preset to 1xATR TP and 1.5xATR SL.
How to use:
- For longs, 'isLong' box must be ticked, for shorts, this box is unticked
- For longs, green line is TP, red line is SL
- For shorts, red line is TP, green line is SL
Regards,
Dillon Grech
Anti-Volume Stop LossFINALLY!
As everyone who tried to create, understand, or even find the Buff Pelz Dormeier Anti-volume stop-loss indicator knows that - it's not easy. Personally, I have partially, or perhaps completely figured out, the tips Buff had given in Investing with Volume Analysis book.
AVSL now is ready.
Please do some test and give me a feedback how it works in your trade strategy.
Anti-Volume stop loss - AVSL
from Investing with Volume Analysis book CHAPTER 20 • RISKY BUSINESS 253-256:
"It is important in any risk-management process to predetermine an objective decision point level (a stop loss) to exit, thereby protecting principal in case you are wrong. My objective sell point is determined by using a quantitative formula I refer to as Anti-Volume Stop Loss (AVSL). Having a quantitative, yet intelligent sell point eliminates the emotional struggles involved in deciding when to exit a position.
AVSL is a technical methodology that incorporates the concepts of support, volatility, and, most importantly, the inverse relationship between price and volume. The AVSL combines the concepts of the VPCI (Volume Price Confirmation Indicator) and John Bollinger’s Bollinger Bands to create a trailing stop loss.
AVSL = Lower Bollinger Band – (Price, Length, Standard Deviation)
Where:
Length = Round (3 + VPCI)
Price = Average (Lows × 1 / VPC × 1 / VPR, Length)
Standard Deviation = 2 × (VPCI × VM)
One of the most difficult decisions is determining what one’s maximum loss threshold should be. Some say 2 percent; others say 20 percent. I believe the more volatile a security, the looser the stop should be. A nonvolatile security, such as Coca-Cola, might move 7 percent a year, while a volatile security such as Google might move 7 percent in a day. If you use a 7 percent stop for Coca-Cola, it might take a year to be stopped out while the security underperforms.
However, if you use 7 percent for Google, you can be stopped out intraday, not allowing the investment an opportunity to develop. By using the lower Bollinger Band of the securities lows, the AVSL considers each individual security’s own volatility. Thus, a volatile security would be granted more room of the stocks low while a stable security would have a tighter leash (see Figure 20.7).
The next important step is employing the price-volume relationship into the calculation. Volume gauges the power behind price moves. In accounting for this, when a security is in an uptrend and has positive volume characteristics, it is given more room. However, if the security exhibits contracting volume characteristics, then the stop is tightened. In this way, if a negative news event affects an unhealthy security, the stop is tighter, thus preserving more of your profits.
However, if the negative news event affects a security whose price-volume relationship is healthy, the stop has been loosened, avoiding the temporary whipsaw of an otherwise strong position. In these ways, AVSL lets the market decide when to exit your position.
AVSL tailors each security for support, volatility, and the pricevolume relationship based on an investor’s time frame as calculated from the chart data. For example, my portfolio positions are continually re-evaluated with this AVSL methodology, which yields the possibility of raising the decision point threshold periodically based on the time frame of my investment objective. With my short-term Giddy-up portfolios, I use daily chart data and seek to raise my maximum loss stop on a daily basis.
My intermediate ETF and stock positions are calculated off of weekly data and then re-evaluated weekly. With my longer term stock portfolios, the decision point is calculated off data revised monthly. This analytical approach that uses measurable facts over emotion or gut instincts allows me to maintain my objectivity. Thus objectivity, not emotion, informs my investment decisions."
How look mine AVSL:
Price component = low × 1/VPC × 1/VPR : for VPC > 1 and VPC < -1 | low × 1 × 1/VPR : for 1 > VPC > 0 | low × -1 × 1/VPR : for 0 > VPC > -1
AVSL Price = sma((low × 1/VPC × 1/VPR) , length) / 100
length = round : for VPCI > 0 | round [ absolute ] : for VPCI < 0 | 3 : for VPCI=0
Standard Deviation = mult × VPCI × VM)
AVSL = sma(Actual low price - AWSL Price + Standard Deviation, 26)
It's hard to say is it the same as in Buff Pelz Dormeier book, but I encourage you to modify the script for better results.
Stop Loss PanelHere is a label panel that shows the stop-loss number for Long or Short trades based on volatility using average true range and and a mult of that.
Triple ATR multiplier - 3 ATR Values in OneHere you can choose to plot 3 different ATR values in 1 window. I use this indicator to get the values of my stop loss and take profits.
You can change the multiplier value for each ATR Line and the length of the base ATR.
Ty
ATR with Take and StopThis simple indicator will plot the take profit and stop loss values based on the ATR indicator.
It's possible to set how many times the ATR value will be applied to the closing price and
what trade type is used, Long or Short.
Rate of Return (RoR) by DGTA rate of return (RoR) is the net gain or loss of an investment over a specified time period, expressed as a percentage of the investment’s initial cost
Moving Stop Loss (Most) by ceyhunATR is an indicator that has been removed and replaced with a moving average.Bar colors and infopanel have been added.
//Barcolor
Green = ExMov > Most and close > Most and low > Most
Blue = ExMov > Most and close > Most and low < Most
Red = Most > ExMov and close < Most and high < Most
Yellow = Most > ExMov and close < Most and high > Most
//It gives White color where there is deterioration.
//InfoPanel
Buy Price = Blue draws the circles at the purchase price.
Profit Long>20 = Risk level taken as a percentage, I got the highest 20%, you can determine as you wish.
Sell Price = Red draws the circles at the purchase price.
Profit Short>20 = Risk level taken as a percentage, I got the highest 20%, you can determine as you wish.
==Atr Original Code==
CDC ATR Trailing Stop V2.1 (2013)
==Most Code==
MOST by Anıl ÖZEKŞİ
Barcolor
Barcolor
Percent Trailing Stop (%) - For Study Scripts===========
Percent Trailing Stop (%) - { FOR STUDY SCRIPTS }
===========
Wow - this is an example of how to implement Alerts relating to a Trailing Stop (%) within your Study Script. It's taken a bit of effort to get this working but I think we got there!
Alerts include Open Long/Short, Trailing Stop Hit, and (the most important one) Movement of Trailing Stop! <- this is actually really quite good, by the way! :)
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT profitable and NOT recommended!
You should be using this code as a way of adding a Trailing Stop to your own scripts - hope it helps!
Set your "Open Long/Short" Alert to "Once per Bar Close" - Set your "Trailing Stop Hit" Alert to "Once per Bar" - Set your "Move TSL" Alert to "Once per Bar Close". - You're all done! Enjoy.
-----------
Good Luck and Happy Trading!
Fixed Percent Stop Loss & Take Profit % - For Study Scripts===========
Fixed Percent Stop Loss & Take Profit % - { FOR STUDY SCRIPTS! }
===========
A neat example of how to set up Fixed Stops and Take Profit as a percent of the entry price - This is for setting Alerts within your own Study Script for when either your SL or TP get hit.
Yup, that's about it!
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT profitable and NOT recommended!
You should be using this code as a way of adding Stops and Takes to your own scripts - hope it helps!
Set your "Open Long/Short" Alerts to be triggered "Once per Bar Close" - Set your "SL/TP" Alerts to trigger "Once per Bar".
--
We wrote this with a bit of a rush on! ~ If you spot any mistakes/bugs just let us know and we'll get round to them asap!
-----------
Good Luck and Happy Trading!
Percent Trailing Stop %===========
Percent Trailing Stop %
===========
Another Stop Loss Indicator today - our last Fixed SL/TP script went down quite well, this one is for adding a Percent Trailing Stop from Entry Price to your own strategy.
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT profitable and NOT recommended!
You should be using this code as a way of adding a % Trailing Stop to your own scripts - hope it helps!
You should also notice that a generally considered losing strategy (a simple MA cross) could actually become profitable with careful money management - try combining this Trailing Stop script with our Fixed Stop/Take Profit script for really accurate management of your capital.
-----------
Good Luck and Happy Trading!
Fixed Percent Stop Loss & Take Profit %===========
Fixed Percent Stop Loss & Take Profit %
===========
A neat example of how to set up Fixed Stops and Take Profit as a percent of the entry price.
Yup, that's about it!
You can ignore the actual entry/exit orders - they're based on a simple MA cross and are therefore NOT relevant, NOT really profitable and NOT recommended!
You should be using this code as a way of adding Stops and Takes to your own scripts - hope it helps!
-----------
Good Luck and Happy Trading!
Bitcoin Production Cost OscillatorFor Trav,
Oscillator version of "Bitcoin Production Cost".
Based on raw data from CBECI.
Follow me to read more about the calculation logic.
Scripting Tutorial B - TManyMA - Commission/FeesThis script is for a triple moving average strategy where the user can select from different types of moving averages, price sources, lookback periods and resolutions.
Features:
- 3 Moving Averages with variable MA types, periods, price sources, resolutions and the ability to disable each individually.
- Crossovers are plotted on the chart with detailed information regarding the crossover (Ex: 50 SMA crossed over 200 SMA )
- Forecasting available for all three MAs. MA values are forecasted 5 values out and plotted as if a continuation to the MA.
- Forecast bias also applies to all forecasting. Bias means we can forecast based on an anticipated bullish , bearish or neutral direction in the market.
- To understand bias, please read the source code, or if you can't read the code just send me a message on here or Twitter . Twitter should be linked to my profile.
- Ribbons added and on by default. Optional setting to disable the ribbons. 5 ribbons between MA1 and MA2 and another 5 between MA2 and MA3.
- Ribbons are alpha-color coded based on their relation to their default MAs.
- Ribbons are only visible between MAs if the MAs being compared share the same Type, Resolution, and Source because there is no way to consolidate those three in a simple manner.
- Ribbon values are calculated based on calculated MA Periods between the MAs.
- Converted the existing study into a strategy.
- Strategy only enters long positions with a market order when MA crossovers occur.
- Strategy exits positions when crossunders occur.
- Trades 100% of the equity with one order/position by default.
- Ability to disable trading certain crosses with input checks.
- Ability to exit trades with a take profit or stop loss.
- User input to allow quick changes to the take profit or stop loss percentages.
- Strategy now calculates on every tick
- Strategy also includes fixed commission values based on Coinbase standard order fees
This script is meant as an educational script with well-formatted styling, and references for specific functions.
*** PLEASE NOTE - THIS STRATEGY IS MEANT FOR LEARNING PURPOSES. DEPENDING ON IT'S CONFIGURATION IT MAY OR MAY NOT BE USEFUL FOR ACTUAL TRADING. THE STRATEGY IS NOT FINANCIAL ADVICE ***
Scripting Tutorial A - TManyMA - StopsThis script is for a triple moving average strategy where the user can select from different types of moving averages, price sources, lookback periods and resolutions.
Features:
- 3 Moving Averages with variable MA types, periods, price sources, resolutions and the ability to disable each individually.
- Crossovers are plotted on the chart with detailed information regarding the crossover (Ex: 50 SMA crossed over 200 SMA )
- Forecasting available for all three MAs. MA values are forecasted 5 values out and plotted as if a continuation to the MA.
- Forecast bias also applies to all forecasting. Bias means we can forecast based on an anticipated bullish, bearish or neutral direction in the market.
- To understand bias, please read the source code, or if you can't read the code just send me a message on here or Twitter. Twitter should be linked to my profile.
- Ribbons added and on by default. Optional setting to disable the ribbons. 5 ribbons between MA1 and MA2 and another 5 between MA2 and MA3.
- Ribbons are alpha-color coded based on their relation to their default MAs.
- Ribbons are only visible between MAs if the MAs being compared share the same Type, Resolution, and Source because there is no way to consolidate those three in a simple manner.
- Ribbon values are calculated based on calculated MA Periods between the MAs.
- Converted the existing study into a strategy.
- Strategy only enters long positions with a market order when MA crossovers occur.
- Strategy exits positions when crossunders occur.
- Trades 100% of the equity with one order/position by default.
- Ability to disable trading certain crosses with input checks.
- Ability to exit trades with a take profit or stop loss.
- User input to allow quick changes to the take profit or stop loss percentages.
This script is meant as an educational script with well-formatted styling, and references for specific functions.
*** PLEASE NOTE - THIS STRATEGY IS MEANT FOR LEARNING PURPOSES. DEPENDING ON IT'S CONFIGURATION IT MAY OR MAY NOT BE USEFUL FOR ACTUAL TRADING. THE STRATEGY IS NOT FINANCIAL ADVICE ***
ATR ChannelsATR Channels help you to identify where to place your stop-loss or trailing stop-loss based on price volatility, according to the Average True Range (ATR).
Moving Gain Loss PercentTracks the percentage gain/loss in three ranges:
single candle (can be turned on or off)
custom range of candles
custom range of candles
For example, with a range of 3 candles, and the serie:
1 - close 10
2 - close 5
3 - close 20
The moving gain would be:
1 - close 10 - gain 10, infinite%
2 - close 5 - gain 5, infinite%
3 - close 18 - gain 8, 80%
Or, for example if the range is 12 candles on a monthly chart, then the result is the Year-To-Date gain/loss plotted as a percentage.