Simple Ultimate Oscillator█ OVERVIEW
This indicator as an educational and showcase the usage of user-defined types (UDT) or objects for Ultimate Oscillator.
█ CREDITS
TradingView
█ FEATURES
1. Color of plot is based on contrast color of chart background.
2. Plot fill of overbought and oversold.
3. Support Multi Timeframe.
TYPE
Regression Channel Alternative MTF V2█ OVERVIEW
This indicator is a predecessor to Regression Channel Alternative MTF , which is coded based on latest update of type, object and method.
█ IMPORTANT NOTES
This indicator is NOT true Multi Timeframe (MTF) but considered as Alternative MTF which calculate 100 bars for Primary MTF, can be refer from provided line helper.
The timeframe scenarios are defined based on Position, Swing and Intraday Trader.
Suppported Timeframe : W, D, 60, 15, 5 and 1.
Channel drawn based on regression calculation.
Angle channel is NOT supported.
█ INSPIRATIONS
These timeframe scenarios are defined based on Harmonic Trading : Volume Three written by Scott M Carney.
By applying channel on each timeframe, MW or ABCD patterns can be easily identified manually.
This can also be applied on other chart patterns.
█ CREDITS
Scott M Carney, Harmonic Trading : Volume Three (Reaction vs. Reversal)
█ TIMEFRAME EXPLAINED
Higher / Distal : The (next) longer or larger comparative timeframe after primary pattern has been identified.
Primary / Clear : Timeframe that possess the clearest pattern structure.
Lower / Proximate : The (next) shorter timeframe after primary pattern has been identified.
Lowest : Check primary timeframe as main reference.
█ FEATURES
Color is determined by trend or timeframe.
Some color is depends on chart contrast color.
Color is determined by trend or timeframe.
█ EXAMPLE OF USAGE / EXPLAINATION
Zigzag Array ExperimentalThis is experimental script for zigzag which uses type, method and array. Not recommend for actual usage, for pine script study maybe useful.
In this experiment, I use type as coded below. It seems have limitation as specially when push as array. As Trading View recommendation, pushing float and int into array especially for type not guarantee to work. I agree with that. Preferred to push array as line or label especially for types.
// @type Used for point especially for array
// @field x int value for bar_index
// @field y float value for price
// @field sty label style
// @field col color for text label
// @field str high or low string
type point
int x = na
float y = na
string sty = na
color col = na
string str = na
I simulate the arrays as below.
var dirLine = array.new()
var dirLabel = array.new()
var dirPoint = array.new()
....
dirPoint.unshift(zigzag.createPoint(0))
dirLabel.unshift(zigzag.createLabel(fontSize, 0, true))
dirLine.unshift(zigzag.createLine(width, switchLine, 0, true))
Here are some results.
RSI Divergence Method█ OVERVIEW
This is a divergence indicator based on Relative Strength Index (RSI).
My attempt to make this indicator updated based on latest pine script features such as type, object and method.
█ FEATURES
1. Color of plot and label is based on contrast color of chart background. Able to customize color from style menu.
2. Big divergence (Regular Divergence) is based on lime / red color.
3. Small divergence (Hidden Divergence) is based on contrast color of chart background.
█ EXAMPLES / USAGES
[-_-] DictionaryThe script shows an example implementation of dictionary-like data type which can store key:value pairs (Python style). Both keys and values can have any of the following type:
• string
• integer
• float
• boolean
• color
You can add items of different types to the same dictionary (e.g. key = 12 and value = "value" stored in the same dictionary with key = "key" and value = 0.23).
Under the hood dictionary is a custom Object (see www.tradingview.com), that has two array fields (one for storing keys, another for storing values). Keys and values of different types are converted into a string representation when adding a new item to the dictionary. The value is then converted back to certain type (bool/color/etc.) from that string representation when being retrieved. Script also utilises the new Methods (see www.tradingview.com).
The following methods are implemented:
• init() -> initialises the array fields of dictionary (without this the script throws an error "Array methods can't be called when ID of array is na"
• set(key, value) -> add a new item to dictionary; if an item for given key already exists - change it to new value
• getS(key) -> get value of string type
• getI(key) -> get value of integer type
• getF(key) -> get value of float type
• getB(key) -> get value of boolean type
• getC(key) -> get value of color type
• remove(key) -> removes item from dictionary
• len() -> get length of dictionary (the number of keys)
I could not make just one "get" function that returns any type of value (color/string/etc.), so instead I created a get function for each value type. Example usage:
• you add a string item: dictionary.set(2, "string here")
• you add a float item: dictionary.set(3, 24.56)
• to retrieve first value (key=2) do this: dictionary.getS(2)
• to retrieve second value (key=3) do this: dictionary.getF(3)
Sort array alphabetically - educational🔶 OVERVIEW
• This educational script will sort an array of tickers alphabetically and place these values in an table , together with the according current price value next to each ticker .
🔶 SORT ALPHABETICALLY
🔹 I. We make a User Defined Type (UDT) obj , with:
· ticker - the string name of the ticker
· price - the current price (close)
• From this UDT we make an object obj.new() for each ticker
🔹 II. 2 array's are made:
• array of objects aObj , containing obj type obj.new() for every ticker
• array of strings sort , the ticker part of each object obj.new()
🔹 III. Now we make an object of each ticker with the createObject(sym ) function
object_1 = createObject("TICKER")
• the object object_1 consists off:
· ticker -> "TICKER"
· price -> current Daily close through request.security("TICKER") (non-repainting)
• object_1 will be added to the aObj array
• "TICKER" ( string ticker part of object ) will be added to the sort array
🔹 IV. The latter array is sorted alphabetically by using array.sort_indices()
EXAMPLE
originalArray = array.from("B", "A", "C")
indicesArray = // sorted indices
array.get(originalArray, 1) -> "A"
array.get(originalArray, 0) -> "B"
array.get(originalArray, 2) -> "C"
IMPORTANT
Alphabetically sorting is case sensitive , just like Java compareTo(String anotherString) !
• The comparison is based on the Unicode value of each character in the string, the lowest "Dec" values are sorted first in line.
• Comparing the "Dec" values at unicodelookup explains why default CAPITAL lettres will be sorted first,
• Default you would get this (A= 65, B= 66, a= 97, b= 98)
Aa
Ba
ab
bb
• Adding str.lower(string) in the toLowerCase() function will result to the following:
Aa
ab
Ba
bb
• (A= 65 is transformed to a= 97, ...)
• As a side note, should you write "AMZN" as "ÀMZN" this would be placed at the end, even after transforming to lower case the "Dec" values are higher (À= 192, à= 224).
• You can toggle "To Lower Case" to verify.
🔹 V. Values are placed in a table , using these sorted indices.
• With the usage of UDTs and objects , the current price has the same index in the aObj as their ticker ,
giving the advantage it is fairly easy to place every value correctly next to each other.
• The same can be done by make 2 separate arrays , 1 for the current price , the other for "TICKER" .
🔶 OTHER TECHNIQUES USED
• Alternative technique for adding comment
Instead of
// this is a comment
You can also do this:
_=" this is a comment "
• Alternate colour
· During a loop , alternate colour when i is even or odd , using the modulo operation (%) .
· This is the remainder when dividing.
EXAMPLE
· 3 % 2 = 1 -> 3 / 2 -> 1 * 2, 1 left (remainder)
· 4 % 2 = 0 -> 4 / 2 -> 2 * 2, 0 left (remainder)
· 5 % 2 = 1 -> 5 / 2 -> 2 * 2, 1 left (remainder)
for i = 0 to 10
even = i % 2 == 0
col = even ? thisColor : otherColor
• Adjust colour in script by using colour picker
Cheers!
How To Identify Argument Type Of Number Using OverloadsExample overload functions accept loading of _value for types float, int, or string, then positively identifies the actual argument type of that specific loaded _value.
How To Identify Type Of NumberExample function accepts loading of _value for types float, int, or string, then identifies whether the loaded _value is a string number, string, or number.
[CLX][#02] Registry (type-based)This script only provides a basic __setter and __getter registration function with a type-based limitation.
We don't want to blow the code with additional conditions. The suggestion was to get the basic functionality.
Benefits:
- Get/set/update global-like variables between functions
- No init needed. You can call a entry before you set it.
Get-Functions:
- f_reg_getInt(_key)
- f_reg_getFloat(_key)
- f_reg_getBool(_key)
- f_reg_getString(_key)
- f_reg_getColor(_key)
- f_reg_getLabel(_key)
- f_reg_getLine(_key)
Set-Functions:
- f_reg_setInt(_key, _value)
- f_reg_setFloat(_key, _value)
- f_reg_setBool(_key, _value)
- f_reg_setString(_key, _value)
- f_reg_setColor(_key, _value)
- f_reg_setLabel(_key, _value)
- f_reg_setLine(_key, _value)
Feel free to contribute for an extended version. :)
We hope you enjoy it! 🎉
CRYPTOLINX - jango_blockchained 😊👍
Disclaimer:
Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely.
The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script.