Function
Scripting Tutorial 8 - Triple Many Moving Averages RibbonsThis script is for a triple moving average indicator 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.
This script is meant as an educational script with well-formatted styling, and references for specific functions.
Number of digits before and after the decimal point - FunctionFunction - Number of digits before and after the decimal point
Detect the number of digits in integers and floats, before the decimal and after it.
It also works for negative numbers.
There are some rounding issues, but the currently maximum supported number can have safely up to 3 digits after the decimal point.
Symbol Name Prefix Function()Symbol Name Prefix Function()
Function to detect the Symbol name prefix on the current chart.
The prefix is returned as string.
Function - Number of Digits in integerA improvement to previous script:
This uses a algorithmic approach for calculating the digits in a integer.
Function call bugThis is a code to showcase a function call bug in PineScript.
Problem description:
When a function is called from inside of if-then scope, this function may return an invalid result.
Code description:
Two identical code pieces are used to perform simple calculation. The only difference is that one piece has a part of its code wrapped into a function.
Expected result:
All green and red crosses should appear on the same candles. These crosses are calculated by identical code.
Actual result:
Some red crosses appear on the candles they should not appear on.
[e2] Color Gradient Function20 step red/green gradient function
The color gradient function allow colorize any source in 5% steps.
Define the source, minimum and maximum value (constant or , for example, bb (or any other channel)).
Function : Stochastic Oscillator Here is the Stochastic Oscillator function.
Now you can easily use length with mutable variables !!
Function : Relative Strength Index The relative strength index function is defined.
Now you can easily use length with mutable variables !!
Smart labelling - Candlestick FunctionOftentimes a single look at the candlestick configuration happens to be enough to understand what is going on. The chandlestick function is an experiment in smart labelling that produces candles for various time frames, not only for the fixed 1m, 3m , 5m, 15m, etc. ones, and helps in decision-making when eye-balling the chart. This function generates up to 12 last candlesticks , which is generally more than enough.
Mind that since this is an experiment, the function does not cover all possible combinations. In some time frames the produced candles overlap. This is a todo item for those who are unterested. For instance, the current version covers the following TFs:
Chart - TF in the script
1m - 1-20,24,30,32
3m - 1-10
5m - 1-4,6,9,12,18,36
15m - 1-4,6,12
Tested chart TFs: 1m, 3m ,5m,15m. Tested securities: BTCUSD , EURUSD
Function StochRSI Stochastic Relative Strength Index developed by Tushar Chande and Stanley Kroll.
This script has been written to eliminate the period variable.(Integer)
Thus, it can be used comfortably in adaptive period scripts ! (For example : Adaptive Moving Average , KAMA , FAMA .. etc. )
All efforts goes to ChaosTrader () ,
RicardoSantos () ,
Hpotter for barcolor codes (iff) ()
I hope it will help your new ideas . Best regards ! Noldo .
[RS]Function - Geometric Line Drawingsfunctions using the new line functions in V4 to draw multiple geometric shapes.
[RS]Function - Normaly Distributed Pseudo Random GeneratorEXPERIMENTAL:
Function to generate a normally distributed pseudo random value.
if you find that something doesn't add up, please leave a message bellow.
Multi-Instantaneous Frequency MeasurementI compiled all of Ehlers' IFM methods into one script - all written as functional blocks so you can simply add them to your own scripts.
Bonus! I also dropped in the Super Smoother, which is a much more efficient and low lag averaging method. I used it to clean the data before feeding it into other indicators.
Function for Least Squares Moving AverageThank you to alexgrover for putting me wide to this, after putting up with long conversations and stupid questions. Follow him and behold: www.tradingview.com
What is this?
This is simply the function for a Least Squares Moving Average. You can render this on the chart by using the linreg() function in Pine.
Personally I like to use the slope of the LSMA to help determine what direction to take a trade in, but I'm sure there are other, more exotic ways of using it and, if you know how to get your fingers dirty with Pine, you can create more exotic versions of it by modifying the function provided.
Want to learn?
If you'd like the opportunity to learn Pine but you have difficulty finding resources to guide you, take a look at this rudimentary list: docs.google.com
The list will be updated in the future as more people share the resources that have helped, or continue to help, them. Follow me on Twitter to keep up-to-date with the growing list of resources.
Suggestions or Questions?
Don't even kinda hesitate to forward them to me. My (metaphorical) door is always open.
Godmode 4.0.1 [Correlator]First off, a huge thank you to the following people:
@LEGION:
@LazyBear: www.tradingview.com
@xSilas: www.tradingview.com
@Ni6HTH4awK: www.tradingview.com
@sco77m4r7and:
@SNOW_CITY: www.tradingview.com
@oh92: www.tradingview.com
@alexgrover: www.tradingview.com
@cI8DH: www.tradingview.com
@DonovanWall: www.tradingview.com
This is my second iteration of Godmode. This time I allowed the possibility to correlate two benchmarks against one another, thereby giving you twice the signals (once there's a strong correlation between the two, inverse or otherwise). That aside, there are no changes to this indicator that the first iteration doesn't have:
There are still more iterations planned, but if you guys have any ideas or wishes regarding what direction I go, then please let me know.
Want to Learn?
If you'd like the opportunity to learn Pine but you have difficulty finding resources to guide you, take a look at this rudimentary list: docs.google.com
The list will be updated in the future as more people share the resources that have helped, or continue to help, them. Follow me on Twitter to keep up-to-date with the growing list of resources as well as any other scripts I publish.
Suggestions or Questions?
Don't even kinda hesitate to forward them to me. My (metaphorical) door is always open.
Godmode 4.0.0 [Oscillator]First off, a huge thank you to the following people:
LEGION:
LazyBear: www.tradingview.com
xSilas: www.tradingview.com
Ni6HTH4awK: www.tradingview.com
sco77m4r7and:
SNOW_CITY: www.tradingview.com
oh92: www.tradingview.com
alexgrover: www.tradingview.com
cI8DH: www.tradingview.com
DonovanWall: www.tradingview.com
Since I've been on TradingView I've become somewhat enthralled by Godmode and the collective work that goes in to it, so I decided to publish my own iteration, building off the ideas already present. (This is a great way to get familiar with Pine by the way, just in case there are any beginners reading this)
Changes
The first change I made was to allow the user to select whatever tickerid they wanted as a benchmark. If trading XBTUSD on BitMEX for example, the indicator will react to exchange-specific activity, which means it will respond to all the little whipsaws, whipsaws that can be especially present on a futures exchange. By typing CRYPTOCAP:BTC or CRYPTOCAP:TOTAL we endeavor to remove noise. It can also signal earlier. Less noise and less lag. Another idea would be to choose a benchmark that has a strong inverse relationship with the asset you're trading: try CRYPTOCAP:USDT as the benchmark against BTC to see what I mean.
I also added the ability to smooth the plot, yet again removing noise but adding considerable lag.
The linear regression of the wave-trend is calculated in place of the EMA. This is plotted as columns with the midline (50) as the base. This is just calculating the slope of the wave-trend and can signal a weakening trend before a reversal takes place.
Using cI8DH's True RSI script () as inspiration, I added a function for calculating the True TSI in an attempt to remove any bullish bias. Funnily enough, when I tried to do the same with the RSI I had some problems. I'll try to resolve this in the coming weeks.
Made slight changes to the aesthetics. Tried to bring the two main plots alive by making their bold, opaque colors stand off the subtle tones in the background.
To Do List
1. I would like to sort out the issue with the True RSI.
2. When the plots are smoothed, there's an issue with the green 'Caution!' dots appearing in the lower half of the indicator.
3. I'd like to adjust the code so that if the 'Benchmark' box is empty, that it will automatically register the current tickerid as the 'Benchmark'.
If anyone has any suggestions on other fixes or how to apply the fixes mentioned by me, please don't hesitate to reach out to me here or through other media platforms.
Want to Learn?
If you'd like the opportunity to learn Pine but you have difficulty finding resources to guide you, take a look at this rudimentary list: docs.google.com
The list will be updated in the future as more people share the resources that have helped, or continue to help, them. Follow me on Twitter to keep up-to-date with the growing list of resources.
Suggestions or Questions?
Don't even kinda hesitate to forward them to me. My (metaphorical) door is always open.
BITMEX:XBTUSD
CRYPTOCAP:BTC
CRYPTOCAP:TOTAL
CRYPTOCAP:USDT.D
[RS]Function - RGB Color (low resolution)Function to handle rgb color selection, it has low resolution due to pinescript limitations.
included examples with manual background color selection via inputs and automatic color of a rsi plot based on its value.
let your rainbow dreams come true!! :D