Indicator example
Ulcer Index
Readonly source from tests/EasyLanguage/David_EasyLanguage, generated Pine Script v6, and an expiry-free example EX5.
Original EasyLanguage
{ Search Tag: WA-Ulcer Index }inputs:Price( Close ) [DisplayName = "Price", ToolTip ="Enter an EasyLanguage expression to use in the calculation of the Ulcer Index."],Length( 14 ) [DisplayName = "Length", ToolTip ="Enter the number of bars to be used in the calculation of the Ulcer Index."],SafeLevel( 5 ) [DisplayName = "SafeLevel", ToolTip ="Enter a value below which downward volatility is considered to be low."] ;variables:UlcerX( 0 ) ;UlcerX = UlcerIndex( Price, Length ) ;Plot1( UlcerX, !( "UlcerX" ) ) ;Plot2( SafeLevel, !( "SafeLevel" ) ) ;if AlertEnabled and UlcerX crosses over SafeLevel thenAlert( !( "Indicator crossing over Safe Level" ) ) ;{ ** Copyright © TradeStation Technologies, Inc. All Rights Reserved **** TradeStation reserves the right to modify or overwrite this analysis techniquewith each release. ** }
Generated Pine Script v6
//@version=6indicator("UlcerIndexIndicator", overlay=true)// dependencies:__el_ulcer_index(float source, int length) =>float peak = ta.highest(source, length)float drawdownPercent = peak == 0 ? 0 : 100 * (source - peak) / peakmath.sqrt(ta.sma(drawdownPercent * drawdownPercent, length))price = input.source(close, "price")length = input.float(14.0, "length")safelevel = input.float(5.0, "safelevel")var float ulcerx = 0float __el_plot1 = nacolor __el_plot1_color = color.bluefloat __el_plot2 = nacolor __el_plot2_color = color.blue__el_call1 = __el_ulcer_index(price, int(length))if bar_index >= 13ulcerx := __el_call1__el_plot1 := ulcerx__el_plot2 := safelevelif true and ta.crossover(ulcerx, safelevel)alert("Indicator crossing over Safe Level", alert.freq_once_per_bar)plot(__el_plot1, title="UlcerX", color=__el_plot1_color)plot(__el_plot2, title="SafeLevel", color=__el_plot2_color)
Compiled MetaTrader 5 example
The EX5 uses the original script filename stem and has no PineAnywhere expiration guard.