Pinescript Risk Reward boxes + Custom 'Time Elapsed' MarkersUsing Pinescript to create custom Risk Reward Ratio (RRR) boxes with custom vertical time markers to help traders stay mindful of how long they've been in a trade.
//Usage:
-Add indicator to chart and you'll be prompted to click three times:
-- 1: Choose time (clicking last bar will mark entry as current candle's open).
-- 2: Click BOX TOP of RRR box on chart (long or short is toggled later).
-- 3: Click BOX BOTTOM of RRR box on chart (long or short is toggled later).
- then toggle Long or short in the dialog box.
-toggle on/off vertical time line markers (as reminder of how long you've been sat in your trade).
-User input choice of time line marker spacings (in minutes).
//Notes:
-Percentage reward and percentage risk are displayed in each of the risk reward boxes. Risk-Reward ratio is also displayed in the upper box.
-Bars to extend the RRR box to the right is also a custom user input.
-Note the 'entry' of the trade will always be the open of the candle you click on (the first click on loading the indicator).
-You can drag the vertical entry time and the horizontal box-top and box-bottom times dynamically, as you like, as trade progresses.
//Use-Case:
-I wanted a RRR box which gave me custom vertical time markers to keep me mindful of overstaying my welcome in a trade that likely was running out of steam and wasn't likely to go my way. Forcing me to stay nimble. I have found in daytrading that if a trade doesn't go your way promptly, it's often not a good one to hold.
Riskrewardratio
Scalper's toolkit - ATR WidgetWidget specifically designed for scalping. Many settings to fit the instrument and view preferences to make it fit into your chart window how you like, even on mobile.
** I have 5 other features to add into this in the very near future, as I use this as my primary tool for Risk reward. This script will be updated in the near future as more features are coded into it. See bottom for notes on plans
Features:
Displays a quick view of the ATR value on the chart, in decimal PIPs or directly in Points - a key value for scalping using the DOM for point value settings and one click trading on fast time frames.
Automatic calculation of stop and target distance for a predetermined Risk Reward Ratio (Set with the settings panel), and then also displayed in PIPs or Points for easy use in quick trading.
Works on most all instruments/pairs/cryptos with multiple precision levels for correct values to be shown in the widget.
Fully customizable -
ATR period Base setting, just like a normal ATR indicator
Display in : PIPs or Points
ATR based stop distance, using a multiplier. 2 is the most common multiplier used, and the default setting.
Risk Reward Calculation using the Stop Loss value.
-Quickly helps with proper target and stop sizing for the volatility in the price on the current trade entry point.
-Set to any ratio you wish, from 1:0.1 all the way to 1:100 or more, unlimited R ratio settings to fit your strategy and risk tolerances.
Position anywhere on the chart window with 9 preset locations available (Pine script limitation)
Show as a column layout or a row layout
Customize the Size, with 5 preset widget sizes, from tiny to huge (Pine script limitation)
-Mobile Friendly - Tiny or Small may be too small on PC, but can be used for Mobile so the widget does not become too large over the chart.
Custom text, background, and boarder colors
Custom Boarder Size - 0 size is no boarder
Set up:
-Open the settings panel.
First section is the basic settings for the ATR - the length (Default is 14) and to use a PIP value display, or Point value display.
Here you also see a "Precision" Setting. **Because each instrument returns different precision ATR values, it is difficult to determine with code what those values will be ahead of time to do the math in the background. Even some 2 decimal instruments return 5 decimal ATR values, so this setting filters that** Just use the dropdown and choose how many decimal places the instrument has from 2 - 5 decimals
The second section is for risk and reward calculations, and can be disabled if you do not want to see these values.
The first value is the "ATR Multiplier" Typically, a 2x multiplier is used on the ATR to determine how far away to place your stop loss from the entry, placing it out of harm's way from normal market activity.
The second value is the Reward target distance, based from the stop loss size. This quickly calculates your target to match your intended reward ratio, saving some manual work to calculate this by hand every trade.
** Note: because of the math used in the code, you may see odd values on some instruments, like indexes. If you have the precision correct, try changing the "Show in Pips" to "Show in Points", as this may solve the issue.
The last two sections are purely for how the widget looks and how/where it shows on the screen. These can be set however you like. To have no boarder, just set the "Frame size" value to 0.
Additional Updates planned:
Pip value calculation (2 feature uses)
-This will serve 2 purposes. The widget will calculate the value of the trade based on the lot size. It will also have a risk limit, so if the ATR get's too high for the current risk settings, It will show red to warn you of a high risk situation before you trade.
Example, you have a set limit of 3 dollars per trade using .02 lot sizing. If the ATR get's too high, The Stop value will be more risk than you would like to use at that trade sizing. Reduce the trade size, or wait for ATR to come lower.
Purpose 2: lot size calculation, so if you wanted to maximize the use of risk available. If you wanted to risk 600 for example, it would use the ATR you have set for the risk, and determine the proper lot size for the amount of volatility in the market. This way, you Risk Exactly, or as close as possible to 600 for the the current trade conditions.
Extra use for this value: Show the Current trade amounts at risk and for gain in money values on the side of the pip/point value. Know what you're risking and also trading for in monetary value.
ATR candle Comparison- Early momentum Detection (2 feature uses)
Will show an additional section on the bottom of the widget to show how each candle compares to the one before, up to the last 5, and show if ATR went down, up, or stayed the same over the last 5 candles.
Show an additional symbol to indicate the current candle status in comparison to the close of the last candle. Real time of if the ATR is getting larger, smaller, or staying the same.
Basic Position Calculator (BPC)In trading, proper position sizing is essential to managing risk and maximizing returns. The script provided is a Basic Position Calculator that allows traders to quickly and easily calculate their position size, stop loss, take profit, and risk reward ratio for a given trade.
The script starts by defining several inputs for the user to customize the calculations. The first input is the "Account Size", which specifies the total amount of funds available for the trade. The next input is "Risk Amount %", which is the percentage of the account size that the trader is willing to risk per trade. The "Stop Loss" input specifies the maximum amount of loss that the trader is willing to accept, while the "Reward" input is the desired profit target for the trade. Finally, there is a "Position" input that allows the user to specify where on the chart the table of calculations will be displayed.
The script then calculates the position size, stop loss, take profit and risk reward ratio using the user-specified inputs. The position size is calculated by dividing the risk amount by the stop loss. The stop loss is calculated by multiplying the stop loss percentage by the close price, and the take profit is calculated by multiplying the stop loss percentage by the close price and the reward. Risk-reward ratio is the ratio of amount of profit potential to the amount of risk in a trade.
The script then creates a table and displays the calculated values on the chart at the specified location. The table includes the following information: account size, position size, account risk %, stop loss, stop loss %, take profit, take profit % and risk reward ratio. This allows the trader to quickly and easily see all the key calculations for their trade in one place.
Overall, the Basic Position Calculator script is a valuable tool for any trader looking to quickly and easily calculate their position size, stop loss, take profit, and risk reward ratio for a given trade. The ability to customize the inputs and display the calculations on the chart makes it a useful and user-friendly tool for managing risk and maximizing returns.
Close to SupertrendMany a times, we have seen that the price closing in towards supertrend reverses.
This indicator gives signal that identifies high / low of any candle if near the down / up supertrend line by a defined margin using arrow signals.
I've simply re-used readily available supertrend indicator source code and just modified it to these signals. So, almost all of the source code is not mine.
Enter the short / long position when arrow signal appears.
SL / trend reversal will be mandatorily at close of a candle above or below the supertrend line, and the supertrend changes direction.
Hope this indicator comes handy for you.
BTCUSD Risk Oscillator- To be used with the BTCUSD All Time History Index (on the daily)
- Estimates the current risk of BTCUSD
- The risk model oscillates between 0 and 1 (0 is the lowest risk, 1 is the highest)
- Historically, buying when the risk is low and selling when the risk is high yields good ROI
- User inputs generally do not need to be changed, they are used to create integers for the normalization process
Auto Position Sizing Risk RewardThe Auto Position Sizing Risk Reward indicator shows different Risk levels 1, 1.5, 2 and 3 based on your risk amount and uses an auto Stoploss level based on the ATR.
You can set the values for the "Note or Title", "Risk Amount", "Entry", "Target Price", "Stop Loss Distance", "Default Risk/Reward" and ATR settings.
The "auto" part comes into play when you haven't yet set an Entry value, which will make everything update according to the latest Closing price of the asset.
Once you set the Entry price, the Risk/Reward levels will stop updating their positions and stay in place. This allows you to dynamically see your potential Risk/Reward as the market progresses, as well as locking in your Risk/Reward levels once you are ready to enter a position.
Your Position Size as well as actual Stoploss level and Cost is displayed along with the other values in the textbox that floats next to the R/R levels.
This indicator was inspired by and relies heavily on the work done by zzzcrypto123 and NXT2017 in their indicators, but I felt that this version is unique enough to hopefully be of use to the general community.
I hope this helps you to trade better! Please feel free to improve it and provide suggestions.