R:R Trading System FrameworkFirst off, huge thanks to @fikira! He was able to adapt what I built to work much more efficiently, allowing for more strategies to be used simultaneously. Simply put, I could not have gotten to this point without you. Thanks for what you do for the TV community. Second, I am fairly new to pinescript writing, so I welcome criticism, thoughtful input and improvement suggestions. I would love to grow this concept into something even better, if possible. So please let me know if you have any ideas for improvement. However I do juggle a lot of different things outside of TV, so implementations may be delayed.
I have decided, at this time, not to add alerts. First, because I feel most people looking to adapt this framework can add their own pretty easily. Also, given how customized the framework is currently, while also attempting to account for all the possible ways in which people may want alerts to function after they customize it, it seems best to leave them out as it doesn't exactly fit the idea of a framework.
For best viewing, I recommend hovering over the script's name > ... > Visual order > Bring to front. Also I found hollow candles with mono-toned colors (like pictured) are more visually appealing for me personally. I HIGHLY RECOMMEND USING WITH BAR REPLAY TO BETTER UNDERSTAND THE FRAMEWORK'S FUNCTIONALITY.
▶️ WHAT THIS FRAMEWORK IS
- A huge collection of concepts and capabilities for those trying to better understand, learn, or teach pinescript.
- A system designed to showcase Risk:Reward concepts more holistically by providing all of the most popular components of retail trading to include backtesting, trade visual plotting, position tracking, market condition shifts, and useful info while positioned to help highlight changes in your risk:reward based decision-making processes.
- A system that can showcase individual strategies regardless of trade direction, allowing you to develop hedging strategies without having multiple indicators that do not correlate with each other.
- Designed around the idea that you trade less numbers of assets but manage your positions and risk based on multiple concurrently running strategies to manage your risk exposure and reward potential.
- An attempt to combine all the things you need to execute with an active trading management style.
- A framework that uses backtested results (in this case the number of averaged bars it takes to hit key levels) in real-time to inform your risk:reward decision-making while in-trade (in this case in your Trade Tracking Table using dynamic color to show how you might be early, on-time, or late compared to the average amount of backtested time it normally takes to hit that specific key level).
▶️ WHAT THIS FRAMEWORK IS NOT
- A complete trading product. DO NOT USE as-is. It is a FRAMEWORK for you to generate ideas of your own and fairly easily implement your own triggering conditions in the appropriate sections of the script.
▶️ USE CASES
- If you decide you like the Stop, Target, Trailing Stop, and Risk:Reward components as-is, then just understanding how to plug in your Entry and Bullish / Bearish conditions (Triangles) and adjust the input texts to match your custom naming will be all you need to make it your own!
- If you want to adapt certain components, then this system gives you a great starting point to adapt your different concepts and ideas from.
▶️ SYSTEM COMPONENTS
- Each of the system's components are described via tooltips both in the input menu and in the tables' cells.
- Each label on the chart displays the corresponding price at those triggered conditions on hover with tooltips.
- The Trailing Stop only becomes active once it is above the Entry Price for that trade, and brightens to show it is active. The STOP line (right of price) moves once it takes over for the Entry Stop representing the level of the Trailing Stop at that time for that trade.
- The Lines / Labels to the right of price will brighten once price is above for Longs or below for Shorts. The Trade Tracking Table cells will add ☑️ once price is above for Longs or below for Shorts.
- The brighter boxes on the chart show the trades that occurred based on your criteria and are color coded for all components of each trade type to ensure your references are consistent. (Defaults are TV built-in strategies)
- The lighter boxes on the chart show the highest and lowest price levels reached during those trades, to highlight areas where improvements can be made or additional considerations can be accounted for by either adjusting Entry triggers or Bullish / Bearish triggers.
- Default Green and Red Triangles (Bullish / Bearish) default to having the same triggering condition as the Entry it corresponds to. This is to highlight either a pyramiding concept, early exit, or you can change to account for other things occurring during your trades which could help you with Stop and Target management/considerations.
TradingView and many of its community members have done a lot for me, so this is my attempt to give back.
Educational
Copy/Paste Levels Creator ToolThis indicator is for making levels to enter into the Copy/Paste Levels Indicator, This description will serve as a guide on how to use this tool to export levels for sharing!
Copy/Paste Levels Indicator:
Once you add this indicator to your chart it will pop up with a confirmation box for quick access to adding levels, You can see a snapshot of the settings UI on the left in the chart in this post.
If you want to just add the indicator to your chart press "apply" and you will be able to add levels by going into the settings for the indicator. Otherwise, Just fill out the settings and only check on the boxes you need (minimum 1).
All values are default, and the only boxes that need to be filled out are the Ticker and Lvls.
In the lvls box, insert your levels separated by commas(,) it is preferred that you do not have any spaces in the lvls box, however in the code, I have a piece to remove spaces from this box.
Now The Important Part!
As you may notice, this indicator does not display anything. Its main function is to export formatted text to be entered into the Copy/Paste Levels Indicator.
The way we do this is through email alerts .
After inputting levels to Export, Go to a live chart and set an alert for this indicator, check the box for "Email Alerts".
This will send the alert message to your email when it fires.
After the alert fires,
Check your email, you will have a message containing the formatted levels, ready to be copy and pasted into the other indicator!
How does the alert fire?
I have the alert function set to fire on every calculation of the indicator because of this,
This indicator will alert immediately , on any LIVE chart.
Note: After the alert fires, it is probably a good idea to immediately delete the alert, or else you will get an alert on ever candle with the same information you have already exported.
What if its after market and the chart is not ticking?
When making levels on off hours, remember to set the alert (for this indicator) on a live chart such as BTC.
Remember: The chart you are on does not have to be the one you are making levels for. This indicator is simple an interface.
Enjoy!
RSI - colour fillThis script showcases the new (overload) feature regarding the fill() function! 🥳
2 plots could be filled before, but with just 1 colour per bar, now the colour can be a gradient type.
In this example we have 2 plots
- rsiPlot , which plots the rsi value
- centerPlot, which plots the value 50 ('centre line')
Explanation of colour fill in the zone 50-80
Default when rsi > 50
- a bottom value is set at 50 (associated with colour aqua)
- and a top value is set at 80 (associated with colour red)
This zone (bottom -> top value) is filled with a gradient colour (50 - aqua -> 80 - red)
When rsi is towards 80, you see a red coloured zone at the rsi value,
while when rsi is around 50, you'll only see the colour aqua
The same principle is applied in the zone 20-50 when rsi < 50
Cheers!
Educational: FillThis script showcases the latest feature of colour fill between lines with gradient
There are 17 ema's, all with adjustable lengths.
In the settings there are 3 options: '1' , '2' , and '1 & 2' :
Option '1'
Here the highest - lowest lines are filled with a gradient colour,
dependable where the 3rd highest/lowest ema is situated in regard of these 2 lines:
Option '2'
Here the colour fill is applied between every ema and the one next to it.
The gradient colour is dependable where the ema is situated in regard of the highest - lowest line:
Option '1 & 2'
A combination of both options:
The setting 'switch colours at ema x' regulates the switch between bullish and bearish colours.
When close is above the chosen ema -> bullish colours, when below -> bearish colours.
Examples of other settings of 'switch colours at ema x' :
Colour switch when close above/below:
ema 14
ema 11
ema 8
ema 5
ema 2
The colours can be set below, both for option '1' and '2'
Cheers!
PlanB Quant Investing 101 v2This script has been Inspired by PlanB Article Quant Investing 101.
With this script, I implemented Plan B strategy outlined in that article, trying to reproduce his findings independently and allowing TradeView Users to do the same.
PlabB is aware of this effort, and he's positive about it, via Twitter commenting, liking and sharing of this resource .
Trading Idea:
This script uses RSI index to determine the Buy And Sell signal.
As per the original PlanB article:
IF ( RSI was above 90% last six months AND drops below 65%) THEN sell,
IF ( RSI was below 50% last six months AND jumps +2% from the low) THEN buy, ELSE hold
My simple code is aimed at replicating his study in Pine so that every TV user can check his signal.
Normalized, Variety, Fast Fourier Transform Explorer [Loxx]Normalized, Variety, Fast Fourier Transform Explorer demonstrates Real, Cosine, and Sine Fast Fourier Transform algorithms. This indicator can be used as a rule of thumb but shouldn't be used in trading.
What is the Discrete Fourier Transform?
In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency. The interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence. An inverse DFT is a Fourier series, using the DTFT samples as coefficients of complex sinusoids at the corresponding DTFT frequencies. It has the same sample-values as the original input sequence. The DFT is therefore said to be a frequency domain representation of the original input sequence. If the original sequence spans all the non-zero values of a function, its DTFT is continuous (and periodic), and the DFT provides discrete samples of one cycle. If the original sequence is one cycle of a periodic function, the DFT provides all the non-zero values of one DTFT cycle.
What is the Complex Fast Fourier Transform?
The complex Fast Fourier Transform algorithm transforms N real or complex numbers into another N complex numbers. The complex FFT transforms a real or complex signal x in the time domain into a complex two-sided spectrum X in the frequency domain. You must remember that zero frequency corresponds to n = 0, positive frequencies 0 < f < f_c correspond to values 1 ≤ n ≤ N/2 −1, while negative frequencies −fc < f < 0 correspond to N/2 +1 ≤ n ≤ N −1. The value n = N/2 corresponds to both f = f_c and f = −f_c. f_c is the critical or Nyquist frequency with f_c = 1/(2*T) or half the sampling frequency. The first harmonic X corresponds to the frequency 1/(N*T).
The complex FFT requires the list of values (resolution, or N) to be a power 2. If the input size if not a power of 2, then the input data will be padded with zeros to fit the size of the closest power of 2 upward.
What is Real-Fast Fourier Transform?
Has conditions similar to the complex Fast Fourier Transform value, except that the input data must be purely real. If the time series data has the basic type complex64, only the real parts of the complex numbers are used for the calculation. The imaginary parts are silently discarded.
What is the Real-Fast Fourier Transform?
In many applications, the input data for the DFT are purely real, in which case the outputs satisfy the symmetry
X(N-k)=X(k)
and efficient FFT algorithms have been designed for this situation (see e.g. Sorensen, 1987). One approach consists of taking an ordinary algorithm (e.g. Cooley–Tukey) and removing the redundant parts of the computation, saving roughly a factor of two in time and memory. Alternatively, it is possible to express an even-length real-input DFT as a complex DFT of half the length (whose real and imaginary parts are the even/odd elements of the original real data), followed by O(N) post-processing operations.
It was once believed that real-input DFTs could be more efficiently computed by means of the discrete Hartley transform (DHT), but it was subsequently argued that a specialized real-input DFT algorithm (FFT) can typically be found that requires fewer operations than the corresponding DHT algorithm (FHT) for the same number of inputs. Bruun's algorithm (above) is another method that was initially proposed to take advantage of real inputs, but it has not proved popular.
There are further FFT specializations for the cases of real data that have even/odd symmetry, in which case one can gain another factor of roughly two in time and memory and the DFT becomes the discrete cosine/sine transform(s) (DCT/DST). Instead of directly modifying an FFT algorithm for these cases, DCTs/DSTs can also be computed via FFTs of real data combined with O(N) pre- and post-processing.
What is the Discrete Cosine Transform?
A discrete cosine transform ( DCT ) expresses a finite sequence of data points in terms of a sum of cosine functions oscillating at different frequencies. The DCT , first proposed by Nasir Ahmed in 1972, is a widely used transformation technique in signal processing and data compression. It is used in most digital media, including digital images (such as JPEG and HEIF, where small high-frequency components can be discarded), digital video (such as MPEG and H.26x), digital audio (such as Dolby Digital, MP3 and AAC ), digital television (such as SDTV, HDTV and VOD ), digital radio (such as AAC+ and DAB+), and speech coding (such as AAC-LD, Siren and Opus). DCTs are also important to numerous other applications in science and engineering, such as digital signal processing, telecommunication devices, reducing network bandwidth usage, and spectral methods for the numerical solution of partial differential equations.
The use of cosine rather than sine functions is critical for compression, since it turns out (as described below) that fewer cosine functions are needed to approximate a typical signal, whereas for differential equations the cosines express a particular choice of boundary conditions. In particular, a DCT is a Fourier-related transform similar to the discrete Fourier transform (DFT), but using only real numbers. The DCTs are generally related to Fourier Series coefficients of a periodically and symmetrically extended sequence whereas DFTs are related to Fourier Series coefficients of only periodically extended sequences. DCTs are equivalent to DFTs of roughly twice the length, operating on real data with even symmetry (since the Fourier transform of a real and even function is real and even), whereas in some variants the input and/or output data are shifted by half a sample. There are eight standard DCT variants, of which four are common.
The most common variant of discrete cosine transform is the type-II DCT , which is often called simply "the DCT". This was the original DCT as first proposed by Ahmed. Its inverse, the type-III DCT , is correspondingly often called simply "the inverse DCT" or "the IDCT". Two related transforms are the discrete sine transform ( DST ), which is equivalent to a DFT of real and odd functions, and the modified discrete cosine transform (MDCT), which is based on a DCT of overlapping data. Multidimensional DCTs ( MD DCTs) are developed to extend the concept of DCT to MD signals. There are several algorithms to compute MD DCT . A variety of fast algorithms have been developed to reduce the computational complexity of implementing DCT . One of these is the integer DCT (IntDCT), an integer approximation of the standard DCT ,: ix, xiii, 1, 141–304 used in several ISO /IEC and ITU-T international standards.
What is the Discrete Sine Transform?
In mathematics, the discrete sine transform (DST) is a Fourier-related transform similar to the discrete Fourier transform (DFT), but using a purely real matrix. It is equivalent to the imaginary parts of a DFT of roughly twice the length, operating on real data with odd symmetry (since the Fourier transform of a real and odd function is imaginary and odd), where in some variants the input and/or output data are shifted by half a sample.
A family of transforms composed of sine and sine hyperbolic functions exists. These transforms are made based on the natural vibration of thin square plates with different boundary conditions.
The DST is related to the discrete cosine transform (DCT), which is equivalent to a DFT of real and even functions. See the DCT article for a general discussion of how the boundary conditions relate the various DCT and DST types. Generally, the DST is derived from the DCT by replacing the Neumann condition at x=0 with a Dirichlet condition. Both the DCT and the DST were described by Nasir Ahmed T. Natarajan and K.R. Rao in 1974. The type-I DST (DST-I) was later described by Anil K. Jain in 1976, and the type-II DST (DST-II) was then described by H.B. Kekra and J.K. Solanka in 1978.
Notable settings
windowper = period for calculation, restricted to powers of 2: "16", "32", "64", "128", "256", "512", "1024", "2048", this reason for this is FFT is an algorithm that computes DFT (Discrete Fourier Transform) in a fast way, generally in 𝑂(𝑁⋅log2(𝑁)) instead of 𝑂(𝑁2). To achieve this the input matrix has to be a power of 2 but many FFT algorithm can handle any size of input since the matrix can be zero-padded. For our purposes here, we stick to powers of 2 to keep this fast and neat. read more about this here: Cooley–Tukey FFT algorithm
SS = smoothing count, this smoothing happens after the first FCT regular pass. this zeros out frequencies from the previously calculated values above SS count. the lower this number, the smoother the output, it works opposite from other smoothing periods
Fmin1 = zeroes out frequencies not passing this test for min value
Fmax1 = zeroes out frequencies not passing this test for max value
barsback = moves the window backward
Inverse = whether or not you wish to invert the FFT after first pass calculation
Related indicators
Real-Fast Fourier Transform of Price Oscillator
STD-Stepped Fast Cosine Transform Moving Average
Real-Fast Fourier Transform of Price w/ Linear Regression
Variety RSI of Fast Discrete Cosine Transform
Additional reading
A Fast Computational Algorithm for the Discrete Cosine Transform by Chen et al.
Practical Fast 1-D DCT Algorithms With 11 Multiplications by Loeffler et al.
Cooley–Tukey FFT algorithm
Ahmed, Nasir (January 1991). "How I Came Up With the Discrete Cosine Transform". Digital Signal Processing. 1 (1): 4–5. doi:10.1016/1051-2004(91)90086-Z.
DCT-History - How I Came Up With The Discrete Cosine Transform
Comparative Analysis for Discrete Sine Transform as a suitable method for noise estimation
Copy/Paste LevelsCopy/Paste Levels allows levels to be pasted onto your chart from a properly formatted source.
This tool streamlines the process of adding lines to your chart, and sharing lines from your chart.
More than one ticker at a time!
This indicator will only draw lines on charts it has values for!
This means you can input levels for every ticker you need all at once, one time, and only be displayed the levels for the current chart you are looking at. When you switch tickers, the levels for that ticker will display. (Assuming you have levels entered for that ticker)
The formatting is as follows:
Ticker,Color,Style,Width,Lvl1,Lvl2,Lvl3;
Ticker - Any ticker on Tradingview can be used in the field
Color - Available colors are: Red,Orange,Yellow,Green,Blue,Purple,White,Black,Gray
Style - Available styles are: Solid,Dashed,Dotted
Width - This can be any negative integer, ex.(-1,-2,-3,-4,-5)
Lvls - These can be any positive number (decimals allowed)
Semi-Colons separate sections, each section contains enough information to create at least 1 line.
Each additional level added within the same section will have the same styling parameters as the other levels in the section.
Example:
2 solid lines colored red with a thickness of 2 on QQQ, 1 at $300 and 1 at $400.
QQQ,RED,SOLID,-2,300,400;
IMPORTANT MUST READ!!!
Remember to not include any spaces between commas and the entries in each field!
ex. ; QQQ, red, dotted, -1, 325; <- Wrong
ex. ;QQQ,red,dotted,-1,325;)<- Right
However,
All fields must be filled out, to use default values in the fields, insert a space between the commas.
ex. ;QQQ,red,dotted,,325; <- Wrong
ex. ;QQQ,red,dotted, ,325; <- Right
While spaces can not be included line breaks can!
I recommend for easier typing and viewing to include a line break for each new line (if changing styling or ticker)
Example:
2 solid lines, one red at $300, one green at $400, both default width. Written in a single line AND using multiple lines, both give the same output.
QQQ,red,solid, ,300;QQQ,green,solid, ,400;
or
QQQ,red,solid, ,300;
QQQ,green,solid, ,400;
In this following screenshot you can see more examples of different formatting variations.
The textbox contains exactly what is pasted into the settings input box.
As you can see, capitalization does not matter.
Default Values:
Color = optimal contrast color, If this field is filled in with a space it will display the optimal contrast color of the users background.
Style = solid
Width = -1
More Examples:
Multi-Ticker: drawing 3 lines at $300, all default values, on 3 different tickers
SPY, , , ,300;QQQ, , , ,300;AAPL, , , ,300
or
SPY, , , ,300;
QQQ, , , ,300;
AAPL, , , ,300
Multiple levels: There is no limit* to the number of levels that can be included within 1 section.
* only TV default line limit per indicator (500)
This will be 4 lines all with the same styling at different values on 2 separate tickers.
SPY,BLUE,SOLID,-2,100,200,300,400;QQQ,BLUE,SOLID,-2,100,200,300,400
or
SPY,BLUE,SOLID,-2,100,200,300,400;
QQQ,BLUE,SOLID,-2,100,200,300,400
Semi-colons must separate sections, but are not required at the beginning or end, it makes no difference if they are or are not added.
SPY,BLUE,SOLID,-2,100,200,300,400;
QQQ,BLUE,SOLID,-2,100,200,300,400
==
SPY,BLUE,SOLID,-2,100,200,300,400;
QQQ,BLUE,SOLID,-2,100,200,300,400;
==
;SPY,BLUE,SOLID,-2,100,200,300,400;
QQQ,BLUE,SOLID,-2,100,200,300,400;
All the above output the same results.
Hope this is helpful for people,
Enjoy!
LONG SAZB $This strategy combines the use of:
-The MTF EMA to detect trends.
-The MACD to create Long and Short Buy signals.
-The ATR for setting Stop Losses and Take Profits.
This works well with many different crypto and fiat pairs, but it must be optimized for the certain behavior of the currency pair. Its optimal use is strong trends, not so profitable when sideways.
This strategy was developed with the 5-minute Bitcoin / TetherUS Perpetual futures for Binance (Crypto trading platform).
This is the first version, updates will come.
MTF EMA
The MTF EMA (Multi-TimeFrame Exponential Moving Average ) is a great indicator to see the overall trend of an asset, you can see the status of a moving average for all timeframes on one chart.
Normally when you check a moving average of the price it's on some specific timeframe. The MTF EMA allows you to see moving average status for all timeframes in a single place. You can simplify your visual representation and know if an asset or a pair is overall bullish or bearish , with this improving your entry and exit signal decisions.
This strategy uses the 1 hour and 15 min EMA with different values. Experimenting with these is important to understand the currency pairs.
Up trend:
Price (source) > 1h MTF and 1h MTF < 15m MTF
Down trend:
Price (source) < 1h MTF and 1h MTF > 15m MTF
MACD
Using MACD (Moving Average Convergence Divergence) as a reference, the strategy identifies when the MACD line crosses over (a factor in a buy signal) and under (a factor in a Sell signal) the Signal line. This shows a shift in positive (cross over) and negative (cross under) of a security.
This strategy uses values of 12 on the Fast MA, 26 on the Slow MA, and 9 in the Signal Line MA.
The optional ribbon is for a more visual representation of the MACD .
The MACD and Signal line have the option to have a crossover limit to cancel buy signals depending on the value they crossed at according to the 0 line of the MACD . This is to avoid fake signals.
ATR TP/SL
Using ATR to define the stop loss and take profit is that it should allow you to set them at a realistic distance from price. Simply put, a pair experiencing a high level of volatility has a higher ATR, and a low volatility stock has a lower ATR.
The indicator does not indicate the price direction; rather it is used primarily to measure volatility caused by gaps and limit up or down moves. All this is used to allow the Stop Loss “breathing space” so trades don't get unnecessarily stopped, and allow the Take Profit to be at a more realistic, flexible, and profitable price.
This strategy uses different values for Longs and Shorts depending on the market behavior, optionally analyzes swing lows and highs according to the value of the candle lookback and sets the ATR depending on them, they must be tested to optimum. Also the ATR has a multiplicator to find the most efficient price levels.
Trade Setup
Shorts and Longs can be turned OFF and ON.
There is an optional maximum % loss for trades, the trade is closed when the high-low average of a candle is over this %.
Longs
This strategy indicates a Long Buy signal when these conditions are met:
- Uptrend signal from MTF EMA .
- MACD Crossover of Signal ( MACD > Signal) while being under the MACD crossover limit.
A Long exit signal is indicated when:
- Price crosses over the ATR Take Profit limit.
- Price crosses under the ATR Stop Loss limit.
- Price crosses under optional max % long loss.
Shorts
This strategy indicates a Long Buy signal when these conditions are met:
- Downtrend signal from MTF EMA .
- Signal Crossover of MACD ( MACD < Signal) while being over the MACD crossover limit.
A Short exit signal is indicated when:
- Price crosses under the ATR Take Profit limit.
- Price crosses over the ATR Stop Loss limit.
- Price crosses over optional max % short loss.
Disclaimer
1. I am not a licensed financial advisor or broker dealer. I do not tell you when or what to buy or sell. I developed this software which enables you to execute manual or automated trades multiple trades using TradingView. The software allows you to set the criteria you want for entering and exiting trades.
2. Do not trade with money you cannot afford to lose.
3. I do not guarantee consistent profits or that anyone can make money with no effort. I am not selling the holy grail.
4. Every system can have winning and losing streaks.
5. Money management plays a large role in the results of your trading. For example: lot size, account size, broker leverage, and broker margin call rules all have an effect on results. Also, your Take Profit and Stop Loss settings for individual pair trades and for overall account equity have a major impact on results. If you are new to trading and do not understand these items, then I recommend you seek education materials to further your knowledge.
**YOU NEED TO FIND AND USE THE TRADING SYSTEM THAT WORKS BEST FOR YOU AND YOUR TRADING TOLERANCE.**
**I HAVE PROVIDED NOTHING MORE THAN A TOOL WITH OPTIONS FOR YOU TO TRADE WITH THIS PROGRAM ON TRADINGVIEW.**
I am 100 % open to suggestions to improve the script.
If you encounter any problems or would like to see the script, share them with me at "steven17zmuda@gmail.com".
Items in this description text may not be written directly by me, but may be taken from education sites.
EMA Cross (data chaining template)Hello Traders! This is the source code for a simple EMA Cross indicator that can be chained to other indicators or another instance of itself as a filter.
The code is fully commented to guide you in building your own chain of indicators based on your ideas and trading plans.
All the best,
Val - Protervus Trading
Investing - Correlation Table This correlation tables idea is nothing new, many sites provides it.
However, I couldn't find any simple correlation indicator on TradingView despite how simple this indicator is.
This indicator works as its called. Calculating the correlation between 2 projects (can be used in stocks as well) using the 'ta.correlation' feature built into pinescript.
When it comes to investing, we do not want our stocks / crypto project to be heavily correlated to each other.
If they are heavily correlated to each other, then there isn't much point in diversifying.
That being said, it can be useful for traders who trade multiple pairs.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
In this indicator, consist of 5 primary input and 15 secondary input (Symbol List).
Correlation Source:
This input options allow you to change how the correlation is calculated. By default, it uses 'close'.
Correlation Percentage(%):
This input options allows you configure how many (%) of correlation is considered as 'decoupled'.
This correlation will only move between -100% ~ 100%.
100% refers to it moving together.
-100% refers to it moving the opposite direction.
For example, Project A rises in Price, what is the possibility of Project B following:
A 100% correlation between Project A and Project B, refers to Project B will follow Project A movement.
A 50% correlation between Project A and Project B, refers to there is only 50% chance for Project B to follow Project A movement.
A -20% correlation between Project A and Project B, refers to there is a 20% chance of Project B moving the opposite direction of Project A
(Refers to the table on chart above to better understand what the numbers means. DOT/USD has a 100% correlation to DOT/USD. However. MXCUSDT has a -37.2% correlation to DOT/USD.)
Amounts Bars To Check:
This input options will check the amount of bars since the last bar in the chart.
If you want to know the correlation of the past 100 days in a daily chart, you will enter '100' into this options and it will check only the past 100 days.
Symbol List
This will allow you to input all the project symbol ticker ID to add into the correlation table.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Originally, I wish to use for loop to go through the symbol list to reduce the amount of code required. However, due to limitation of 'request.security' feature, I had to abandon that idea and use hard-coded for requesting security and use a while loop to identify the symbol correlation value in the array set then set the table value accordingly.
If there is any script writer could improve this or any unclear explanation, feel free to drop a comment below.
Alternative MTF Table█ OVERVIEW
This indicator is an educational indicator which was stripped down from Regression Channel Alternative MTF to display 3 timeframes based on timeframe scenarios.
The timeframe scenarios are defined based on Position, Swing and Intraday Trader.
█ INSPIRATION
It is possible to use array.new_bool, array.indexof and switch to get this outcome. Credits to TradingView .
Future's spread with base contract (MOEX)English:
Indicator calculates spread between future and it's theoretical price baased on base contract, number of days to expiration and central bank key rate.
I didn't find any means of getting base contract of security on chart so I hardcoded futures and corresponding base contracts.
Hardcoded futures are MOEX (Moscow Exchange) only and key rate used in script is Russian Central Bank's key rate from 2013, but I believe you can easily adapt it to any other key rate history. I can share source code of tiny C++20 utility for easy generation of get_rate(time) function from more human-readable date format rather then UNIX timestamp used in PineScript.
Only quarterly futures are supported. Only in "SIU2022" like notation. "SI1!" like aliases are not supported.
Русский:
Индикатор отображает спред фьючерса к его теоретической цене с учётом усыхания на каждый день.
Не нашёл, как определить базовый актив фьючерса средствами TradingView - поэтому это соответствие захардкожено вручную.
Поддерживаются только квартальные фьючерсы, только MOEX, только хардкор.
Поддерживается история ключевой ставки ЦБ РФ с 2013 года.
Используйте коды фьючерсов вида "SIU2022".
Не поддерживаются альясы вроде "SI1!", "EU1!".
Fourier Extrapolator of Price w/ Projection Forecast [Loxx]Due to popular demand, I'm pusblishing Fourier Extrapolator of Price w/ Projection Forecast.. As stated in it's twin indicator, this one is also multi-harmonic (or multi-tone) trigonometric model of a price series xi, i=1..n, is given by:
xi = m + Sum( a*Cos(w*i) + b*Sin(w*i), h=1..H )
Where:
xi - past price at i-th bar, total n past prices;
m - bias;
a and b - scaling coefficients of harmonics;
w - frequency of a harmonic ;
h - harmonic number;
H - total number of fitted harmonics.
Fitting this model means finding m, a, b, and w that make the modeled values to be close to real values. Finding the harmonic frequencies w is the most difficult part of fitting a trigonometric model. In the case of a Fourier series, these frequencies are set at 2*pi*h/n. But, the Fourier series extrapolation means simply repeating the n past prices into the future.
This indicator uses the Quinn-Fernandes algorithm to find the harmonic frequencies. It fits harmonics of the trigonometric series one by one until the specified total number of harmonics H is reached. After fitting a new harmonic , the coded algorithm computes the residue between the updated model and the real values and fits a new harmonic to the residue.
see here: A Fast Efficient Technique for the Estimation of Frequency , B. G. Quinn and J. M. Fernandes, Biometrika, Vol. 78, No. 3 (Sep., 1991), pp . 489-497 (9 pages) Published By: Oxford University Press
The indicator has the following input parameters:
src - input source
npast - number of past bars, to which trigonometric series is fitted;
Nfut - number of predicted future bars;
nharm - total number of harmonics in model;
frqtol - tolerance of frequency calculations.
The indicator plots two curves: the green/red curve indicates modeled past values and the yellow/fuchsia curve indicates the modeled future values.
The purpose of this indicator is to showcase the Fourier Extrapolator method to be used in future indicators.
Fourier Extrapolator of Price [Loxx]Fourier Extrapolator of Price is a multi-harmonic (or multi-tone) trigonometric model of a price series xi, i=1..n, is given by:
xi = m + Sum( a *Cos(w *i) + b *Sin(w *i), h=1..H )
Where:
xi - past price at i-th bar, total n past prices;
m - bias;
a and b - scaling coefficients of harmonics;
w - frequency of a harmonic;
h - harmonic number;
H - total number of fitted harmonics.
Fitting this model means finding m, a , b , and w that make the modeled values to be close to real values. Finding the harmonic frequencies w is the most difficult part of fitting a trigonometric model. In the case of a Fourier series, these frequencies are set at 2*pi*h/n. But, the Fourier series extrapolation means simply repeating the n past prices into the future.
This indicator uses the Quinn-Fernandes algorithm to find the harmonic frequencies. It fits harmonics of the trigonometric series one by one until the specified total number of harmonics H is reached. After fitting a new harmonic, the coded algorithm computes the residue between the updated model and the real values and fits a new harmonic to the residue.
see here: A Fast Efficient Technique for the Estimation of Frequency , B. G. Quinn and J. M. Fernandes, Biometrika, Vol. 78, No. 3 (Sep., 1991), pp. 489-497 (9 pages) Published By: Oxford University Press
The indicator has the following input parameters:
src - input source
npast - number of past bars, to which trigonometric series is fitted;
nharm - total number of harmonics in model;
frqtol - tolerance of frequency calculations.
The indicator plots the modeled past values
The purpose of this indicator is to showcase the Fourier Extrapolator method to be used in future indicators. While this method can also prediction future price movements, for our purpose here we will avoid doing.
Nifty - Gap up Screener
Sample Stock Screener NSE is used to identify the list of Gap up Stocks from provided list. Modify script for other conditions
original credits: achalmeena ( )
Intraday Buy/Sell using Gann Angles - RiTzIntraday Buy/Sell Levels using Gann Angles based on Todays Open/previous Day High/Low/Close prices
How to use this :
The Buy/Sell levels will be calculated on 1 of 4 things (you can choose any one which you prefer)
1. Todays Open price
2. Previous Day High
3. Previous Day Low
4. Previous Day Close
The Buy/Sell levels will be displayed in these ways
1. In a Table
2. on the Chart
You can turn them on/off according to your preference!
I can't seem to find the original documentation or a link to it.
i have it's excel file, in which we have to enter following data :
1. Todays Open price
2. Previous Day High
3. Previous Day Low
4. Previous Day Close
and the buy/sell levels are calculated by using the above data in following manner :
Based On Today's Opening Price
(lets call it TDO)
Degree's````````````````` Degree Factor```````````````````````` Buy````````````````````````` Sell
11.25```````````````````` =degree/180=11.25/180=0.0625````````` =(sqrt(TDO)-0.0625)^2``````` =(sqrt(TDO)+0.0625)^2````` SL
22.5````````````````````` =degree/180=22.5/180=0.125``````````` =(sqrt(TDO)+0.125)^2```````` =(sqrt(TDO)-0.125)^2`````` Buy/Sell At
45``````````````````````` =degree/180=45/180=0.25`````````````` =(sqrt(TDO)+0.25)^2````````` =(sqrt(TDO)-0.25)^2``````` Target-1
90``````````````````````` =degree/180=90/180=0.5``````````````` =(sqrt(TDO)+0.5)^2`````````` =(sqrt(TDO)-0.5)^2```````` Target-2
135`````````````````````` =degree/180=135/180=0.75````````````` =(sqrt(TDO)+0.75)^2````````` =(sqrt(TDO)-0.75)^2``````` Target-3
180`````````````````````` =degree/180=180/180=1```````````````` =(sqrt(TDO)+1)^2```````````` =(sqrt(TDO)-1)^2`````````` Target-4
225`````````````````````` =degree/180=225/180=1.25````````````` =(sqrt(TDO)+1.25)^2````````` =(sqrt(TDO)-1.25)^2``````` Target-5
270`````````````````````` =degree/180=270/180=1.5`````````````` =(sqrt(TDO)+1.5)^2`````````` =(sqrt(TDO)-1.5)^2```````` Target-6
315`````````````````````` =degree/180=315/180=1.75````````````` =(sqrt(TDO)+1.75)^2````````` =(sqrt(TDO)-1.75)^2``````` Target-7
360`````````````````````` =degree/180=360/180=2```````````````` =(sqrt(TDO)+2)^2```````````` =(sqrt(TDO)-2)^2`````````` Target-8
sqrt = square root
TDO = Today's Opening Price
PDH = Previous Days High
PDL = Previous Days Low
PDC = Previous Days Close
Based On Previous Days High Price
(lets call it PDH)
Degree's````````````````` Degree Factor```````````````````````` Buy````````````````````````` Sell
11.25```````````````````` =degree/180=11.25/180=0.0625````````` =(sqrt(PDH)-0.0625)^2``````` =(sqrt(PDH)+0.0625)^2````` SL
22.5````````````````````` =degree/180=22.5/180=0.125``````````` =(sqrt(PDH)+0.125)^2```````` =(sqrt(PDH)-0.125)^2`````` Buy/Sell At
45``````````````````````` =degree/180=45/180=0.25`````````````` =(sqrt(PDH)+0.25)^2````````` =(sqrt(PDH)-0.25)^2``````` Target-1
90``````````````````````` =degree/180=90/180=0.5``````````````` =(sqrt(PDH)+0.5)^2`````````` =(sqrt(PDH)-0.5)^2```````` Target-2
135`````````````````````` =degree/180=135/180=0.75````````````` =(sqrt(PDH)+0.75)^2````````` =(sqrt(PDH)-0.75)^2``````` Target-3
180`````````````````````` =degree/180=180/180=1```````````````` =(sqrt(PDH)+1)^2```````````` =(sqrt(PDH)-1)^2`````````` Target-4
225`````````````````````` =degree/180=225/180=1.25````````````` =(sqrt(PDH)+1.25)^2````````` =(sqrt(PDH)-1.25)^2``````` Target-5
270`````````````````````` =degree/180=270/180=1.5`````````````` =(sqrt(PDH)+1.5)^2`````````` =(sqrt(PDH)-1.5)^2```````` Target-6
315`````````````````````` =degree/180=315/180=1.75````````````` =(sqrt(PDH)+1.75)^2````````` =(sqrt(PDH)-1.75)^2``````` Target-7
360`````````````````````` =degree/180=360/180=2```````````````` =(sqrt(PDH)+2)^2```````````` =(sqrt(PDH)-2)^2`````````` Target-8
Based On Previous Days Low Price
(lets call it PDL)
Degree's````````````````` Degree Factor```````````````````````` Buy````````````````````````` Sell
11.25```````````````````` =degree/180=11.25/180=0.0625````````` =(sqrt(PDL)-0.0625)^2``````` =(sqrt(PDL)+0.0625)^2````` SL
22.5````````````````````` =degree/180=22.5/180=0.125``````````` =(sqrt(PDL)+0.125)^2```````` =(sqrt(PDL)-0.125)^2`````` Buy/Sell At
45``````````````````````` =degree/180=45/180=0.25`````````````` =(sqrt(PDL)+0.25)^2````````` =(sqrt(PDL)-0.25)^2``````` Target-1
90``````````````````````` =degree/180=90/180=0.5``````````````` =(sqrt(PDL)+0.5)^2`````````` =(sqrt(PDL)-0.5)^2```````` Target-2
135`````````````````````` =degree/180=135/180=0.75````````````` =(sqrt(PDL)+0.75)^2````````` =(sqrt(PDL)-0.75)^2``````` Target-3
180`````````````````````` =degree/180=180/180=1```````````````` =(sqrt(PDL)+1)^2```````````` =(sqrt(PDL)-1)^2`````````` Target-4
225`````````````````````` =degree/180=225/180=1.25````````````` =(sqrt(PDL)+1.25)^2````````` =(sqrt(PDL)-1.25)^2``````` Target-5
270`````````````````````` =degree/180=270/180=1.5`````````````` =(sqrt(PDL)+1.5)^2`````````` =(sqrt(PDL)-1.5)^2```````` Target-6
315`````````````````````` =degree/180=315/180=1.75````````````` =(sqrt(PDL)+1.75)^2````````` =(sqrt(PDL)-1.75)^2``````` Target-7
360`````````````````````` =degree/180=360/180=2```````````````` =(sqrt(PDL)+2)^2```````````` =(sqrt(PDL)-2)^2`````````` Target-8
Based On Previous Days Close Price
(lets call it PDC)
Degree's````````````````` Degree Factor```````````````````````` Buy````````````````````````` Sell
11.25```````````````````` =degree/180=11.25/180=0.0625````````` =(sqrt(PDC)-0.0625)^2``````` =(sqrt(PDC)+0.0625)^2````` SL
22.5````````````````````` =degree/180=22.5/180=0.125``````````` =(sqrt(PDC)+0.125)^2```````` =(sqrt(PDC)-0.125)^2`````` Buy/Sell At
45``````````````````````` =degree/180=45/180=0.25`````````````` =(sqrt(PDC)+0.25)^2````````` =(sqrt(PDC)-0.25)^2``````` Target-1
90``````````````````````` =degree/180=90/180=0.5``````````````` =(sqrt(PDC)+0.5)^2`````````` =(sqrt(PDC)-0.5)^2```````` Target-2
135`````````````````````` =degree/180=135/180=0.75````````````` =(sqrt(PDC)+0.75)^2````````` =(sqrt(PDC)-0.75)^2``````` Target-3
180`````````````````````` =degree/180=180/180=1```````````````` =(sqrt(PDC)+1)^2```````````` =(sqrt(PDC)-1)^2`````````` Target-4
225`````````````````````` =degree/180=225/180=1.25````````````` =(sqrt(PDC)+1.25)^2````````` =(sqrt(PDC)-1.25)^2``````` Target-5
270`````````````````````` =degree/180=270/180=1.5`````````````` =(sqrt(PDC)+1.5)^2`````````` =(sqrt(PDC)-1.5)^2```````` Target-6
315`````````````````````` =degree/180=315/180=1.75````````````` =(sqrt(PDC)+1.75)^2````````` =(sqrt(PDC)-1.75)^2``````` Target-7
360`````````````````````` =degree/180=360/180=2```````````````` =(sqrt(PDC)+2)^2```````````` =(sqrt(PDC)-2)^2`````````` Target-8
example based On Today's Opening Price = 4339
Degree's```````` Degree Factor```````` Buy`````````` Sell
11.25``````````` 0.0625``````````````` 4330.77`````` 4347.24```````` SL
22.5```````````` 0.125```````````````` 4355.48`````` 4322.55```````` Buy/Sell At
45`````````````` 0.25````````````````` 4372.00`````` 4306.13```````` Target-1
90`````````````` 0.5`````````````````` 4405.12`````` 4273.38```````` Target-2
135````````````` 0.75````````````````` 4438.37`````` 4240.76```````` Target-3
180````````````` 1```````````````````` 4471.74`````` 4208.26```````` Target-4
225````````````` 1.25````````````````` 4505.24`````` 4175.88```````` Target-5
270````````````` 1.5`````````````````` 4538.86`````` 4143.64```````` Target-6
315````````````` 1.75````````````````` 4572.61`````` 4111.51```````` Target-7
360````````````` 2```````````````````` 4606.48`````` 4079.52```````` Target-8
Note : ignore the '`' , inserted them to fill up the spaces , it was looking very weird!, tried to fix it as much as I can.
Note :- Please correct me if I'm wrong , as I've already mentioned I don't have it's original documentation.
if anyone can find it or already has it then please feel free to share it.
VIDYA Trend StrategyOne of the most common messages I get is people reaching out asking for quantitative strategies that trade cryptocurrency. This has compelled me to write this script and article, to help provide a quantitative/technical perspective on why I believe most strategies people write for crypto fail catastrophically, and how one might build measures within their strategies that help reduce the risk of that happening. For those that don't trade crypto, know that these approaches are applicable to any market.
I will start off by qualifying up that I mainly trade stocks and ETFs, and I believe that if you trade crypto, you should only be playing with money you are okay with losing. Most published crypto strategies I have seen "work" when the market is going up, and fail catastrophically when it is not. There are far more people trying to sell you a strategy than there are people providing 5-10+ year backtest results on their strategies, with slippage and commissions included, showing how they generated alpha and beat buy/hold. I understand that this community has some really talented people that can create some really awesome things, but I am saying that the vast majority of what you find on the internet will not be strategies that create alpha over the long term.
So, why do so many of these strategies fail?
There is an assumption many people make that cryptocurrency will act just like stocks and ETFs, and it does not. ETF returns have more of a Gaussian probability distribution. Because of this, ETFs have a short term mean reverting behavior that can be capitalized on consistently. Many technical indicators are built to take advantage of this on the equities market. Many people apply them to crypto. Many of those people are drawn down 60-70% right now while there are mean reversion strategies up YTD on equities, even though the equities market is down. Crypto has many more "tail events" that occur 3-4+ standard deviations from the mean.
There is a correlation in many equities and ETF markets for how long an asset continues to do well when it is currently doing well. This is known as momentum, and that correlation and time-horizon is different for different assets. Many technical indicators are built based on this behavior, and then people apply them to cryptocurrency with little risk management assuming they behave the same and and on the same time horizon, without pulling in the statistics to verify if that is actually the case. They do not.
People do not take into account the brokerage commissions and slippage. Brokerage commissions are particularly high with cryptocurrency. The irony here isn't lost to me. When you factor in trading costs, it blows up most short-term trading strategies that might otherwise look profitable.
There is an assumption that it will "always come back" and that you "HODL" through the crash and "buy more." This is why Three Arrows Capital, a $10 billion dollar crypto hedge fund is now in bankruptcy, and no one can find the owners. This is also why many that trade crypto are drawn down 60-70% right now. There are bad risk practices in place, like thinking the martingale gambling strategy is the same as dollar cost averaging while also using those terms interchangeably. They are not the same. The 1st will blow up your trade account, and the 2nd will reduce timing risk. Many people are systematically blowing up their trade accounts/strategies by using martingale and calling it dollar cost averaging. The more risk you are exposing yourself too, the more important your risk management strategy is.
There is an odd assumption some have that you can buy anything and win with technical/quantitative analysis. Technical analysis does not tell you what you should buy, it just tells you when. If you are running a strategy that is going long on an asset that lost 80% of its value in the last year, then your strategy is probably down. That same strategy might be up on a different asset. One might consider a different methodology on choosing assets to trade.
Lastly, most strategies are over-fit, or curve-fit. The more complicated and more parameters/settings you have in your model, the more likely it is just fit to historical data and will not perform similar in live trading. This is one of the reasons why I like simple models with few parameters. They are less likely to be over-fit to historical data. If the strategy only works with 1 set of parameters, and there isn't a range of parameters around it that create alpha, then your strategy is over-fit and is probably not suitable for live trading.
So, what can I do about all of this!?
I created the VIDYA Trend Strategy to provide an example of how one might create a basic model with a basic risk management strategy that might generate long term alpha on a volatile asset, like cryptocurrency. This is one (of many) risk management strategies that can reduce the volatility of your returns when trading any asset. I chose the Variable Index Dynamic Average (VIDYA) for this example because it's calculation filters out some market noise by taking into account the volatility of the underlying asset. I chose a trend following strategy because regressions are capturing behaviors that are not just specific to the equities market.
The more volatile an asset, the more you have to back-off the short term price movement to effectively trend-follow it. Otherwise, you are constantly buying into short term trends that don't represent the trend of the asset, then they reverse and loose money. This is why I am applying a trend following strategy to a 4 hour chart and not a 4 minute chart. It is also important to note that following these long term trends on a volatile asset exposes you to additional risk. So, how might one mitigate some of that risk?
One of the ways of reducing timing risk is scaling into a trade. This is different from "doubling down" or "trippling down." It is really a basic application of dollar cost averaging to reduce timing risk, although DCA would typically happen over a longer time period. If it is really a trend you are following, it will probably still be a trend tomorrow. Trend following strategies have lower win rates because the beginning of a trend often reverses. The more volatile the asset, the more likely that is to happen. However, we can reduce risk of buying into a reversal by slowly scaling into the trend with a small % of equity per trade.
Our example "VIDYA Trend Strategy" executes this by looking at a medium-term, volatility adjusted trend on a 4 hour chart. The script scales into it with 4% of the account equity every 4-hours that the trend is still up. This means you become fully invested after 25 trades/bars. It also means that early in the trade, when you might be more likely to experience a reversal, most of your account equity is not invested and those losses are much smaller. The script sells 100% of the position when it detects a trend reversal. The slower you scale into a trade, the less volatile your equity curve will be. This model also includes slippage and commissions that you can adjust under the "settings" menu.
This fundamental concept of reducing timing risk by scaling into a trade can be applied to any market.
Disclaimer: This is not financial advice. Open-source scripts I publish in the community are largely meant to spark ideas that can be used as building blocks for part of a more robust trade management strategy. If you would like to implement a version of any script, I would recommend making significant additions/modifications to the strategy & risk management functions. If you don’t know how to program in Pine, then hire a Pine-coder. We can help!
Future Risk CalculatorCreated out of revenge against the difficulty of controlling psychology, greed, and risk management. Designed for cryptocurrency futures trading by following the risk management principles from Kevin Sailly. Very welcome if there are suggestions and input to improve the quality of this "indicator". Please use wisely.
How to use:
1. Open indicator settings.
2. Fill out all the forms. (Note: I make Max Loss Risk only has 5 options. Because, you know, to control the greed. You can choose by considering your risk profiles and market condition)
3. All of the information and calculation will appear on the label (right side of the bar chart) and top-right box.
4. You can adjust the three prices (target, entry, and stop) by clicking any part of the indicator. There will be three dots in the middle of the chart window (align with three prices). Click that dots and drag them up/down to customize according to your wishes. The price order must be correct, for LONG direction the price order from the top is target-entry-stop. Vice versa for SHORT direction. There will be "SETUP ERROR" text in the top-right box if the price order is not correct.
"Never, ever argue with your trading system." (by Michael Covel)
Regards,
Ircham
Fed Net Liquidity IndicatorThis indicator aims to present a "Net Liquidity" indicator comprised of the Fed Balance sheet , less the TGA account and Overnight Reverse REPO agreements.
Net Liquidity = Fed Balance Sheet - ( TGA + Reverse REPO)
This is an overlay that can be added to stock or other charts (like SPY ) to see how the market may appear correlated to Net Liquidity - injection of liquidity into the markets.
This was hypothesized by Max Anderson, this is just a script realizing that posting.
New updates include a resolution feature, and an option to offset backwards by 2 days per original intent.
Relative Andean ScalpingThis is an experimental signal providing script for scalper that uses 2 of open source indicators.
First one provides the signals for us called Andean Oscillator by @alexgrover . We use it to create long signals when bull line crosses over signal line while being above the bear line. And reverse is true for shorts where bear line crosses over signal line while being above bull line.
Second one is used for filtering out low volatility areas thanks to great idea by @HeWhoMustNotBeNamed called Relative Bandwidth Filter . We use it to filter out signals and create signals only when the Relative Bandwith Line below middle line.
The default values for both indicators changed a bit, especially used linreg values to create relatively better signals. These can be changed in settings. Please be aware that i did not do extensive testing with this indicator in different market conditions so it should be used with caution.
Timed AlertTradingView doesn't offer a way easily set timed alerts. This script solves that problem and also allows you to set variables in the script similar to other alerts.
The variables can be found here .
Manual Stop Loss / Risk Management PanelHere is a panel where you enter the desired stop-loss price, the amount you would like to risk and it spits out what you should trade to only lose that amount if the stop-loss is hit.