Artharjan Profit & Loss CalculatorHi,
Artharjan Profit and Loss Calculator allows users to calculate Profit and Loss of their trades and see it on the chart itself
Users are supposed to select either Long or Short, Enter quantity and enter traded price. The live P&L will be plotted on the chart.
Happy trading :-)
Rahul
Loss
MultiPrice AlertThis is an alert script using Pinescript version 4. This enables one to set 5 alerts (1 StopLoss, 4 Targets), on 3 different symbols, at using a single alert in the UI.
Every visible line will only appear on the symbols that are selected. After setting targets when making an alert, select this indicator as a condition. Change the name to whatever you want, usually the names of the set of tickers.
The Alert message is dyanmic showing which Symbol with each type of alert, at whatever price.
Ability to disable the targets + symbols.
Alerts work by Stop Loss crossing under price and Targets Cross Over. Enabling the "Short" Targets reverses this.
The line that is being displayed is actually the price of the asset being moved over x number of bars. I have not found a way to plot a traditional horizontal line, as the code for it uses a fixed price.
As it being a user input, it is a variable. Any help with this would be appreicated.
Alerts are set to once per bar.
Known bug that sometimes if the prices that you set are inside the current candle stick, then your alert will immeaditally fire, either change the timeframe or let it fire and wait fo
After a target is hit, I reccomend setting the alert to 0 and REMAKING the alert. You MUST REMAKE THE ALERT AFTER ANY CHANGES. This script WILL NOT CHANGE ALERTS AS YOU CHANGE SETTINGS.
TradingView Alerts are not this smart , at least I haven't found a way to do this yet.
Auto Stop
A simple script using the last three bars(including the current) and draws a line on the chart under that for an easy automated stop loss point
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.
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!
ATR By Time [Chart]What is ATR By Time (Chart)?
This premium indicator is a companion script to my ATR By Time indicator.
This companion script draws your stop loss price to the chart directly. In the above example, the black line represents a regular 1x ATR stop loss above and below price action, while the colored lines are the 1x ATR By Time indicator values when set to use the "Smallest ATR" in the settings menu.
When set to "Smallest ATR", the script calculates the regular ATR and the ATR By Time of Day and compares the distance of the two values. It then selects whichever value is smaller to be used as the stop loss, and adds or subtracts it to the most recent swing high or low (or the closing price if desired).
This allows for tighter stops and larger position sizing during certain times of day for aggressive traders when set to Smallest ATR, or wider stop losses during more volatile periods of the day for conservative traders when set to Largest ATR.
Stop Loss Distance Options:
- Regular ATR
- ATR By Time
- Smallest ATR
- Largest ATR
More Information
Similar to my RVOL By Time indicator, the ATR By Time indicator works on any market that has consistent trading session lengths . So it works best on Forex & Crypto, but also works on some Stock and Futures markets.
Instead of calculating the ATR based on recent price data like the regular ATR indicator, it calculates an ATR value for each candle based on that candle’s time of day .
For example, if you set the Lookback setting on this indicator to 14, then instead of calculating the ATR based on the past 14 candles, it will calculate an ATR value based on the past 14 trading sessions for each candle (as an average).
So in other words, your 10:00AM candle will show the average of the past 14 10:00AM candles rather than the past 14 candles leading up to that 10:00AM candle.
This is extremely useful for day traders in particular as it allows you to gauge the average range of candles during certain times of day instead of only by the most recent price action.
It also draws a regular ATR (optional) – so this is essentially an enhanced ATR script that gives you multiple readings on price volatility.
If you are interested in trying the script or you want more information on how the script works, there is more information available on my website including instructions on how to apply for a free trial: ATR By Time Feature Page .
Good luck with your 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!
Percent MrEmamThis is my Gain/Loss indicators that is utilizing with version 4 of pine script, it simply writes the percentage on the last candle as label. If loss passes 100% in reality you lost all your money, so the indicators will show "LIQUIDATED" instead of the percentage.
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 ***