/// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © amico5
// # ========================================================================= #
// # script overview
// # ========================================================================= #
// # ========================================================================= #
// 1. simple test case for alerts.
// 2. two alerts: long only basic, long only extended
// 3. further buy, if there is alert on index, fut.
// 4. all alert cond, must be monitored to buy.
// 5. watch not to buy multiple times on the same subscript.
// 6. backtesting needed.
// 7. test on sandbox broker needed.
// 8. test 3 commodities.
// # ========================================================================= #
// # ========================================================================= #
// # script structure
// # ========================================================================= #
// # ========================================================================= #
// 1. overview
// 2. structure
// 3. main script version number (should b ver' 4. after tested, will b moved to ver' 5)
// 4. main script's: study / inducator (must have only one for all the script)
// 5. sub indicators numbers
// 6. sub indicators title
// 7. input variables
// 8. CALCULATIONS
// 9. plots Entry
// 10. trade definition (for the specific indicator)
// 11. compounding trade definitions (for the indicators, so far)
// 12. alerts Conditions (for the specific indicator)
// 13. compounding alerts Conditions (for the comulative, so far)
// # ========================================================================= #
// # ========================================================================= #
// # main script version number
// # ========================================================================= #
//@version=4
// # ========================================================================= #
// # main script's: study / inducator (must have only one for all the script)
// # ========================================================================= #
// indicator('one_indicator_UCS_Stochastic Momentum Index', shorttitle='oneindicator_UCS_SMI', overlay=false)
study ('one_indicator_UCS_Stochastic Momentum Index', shorttitle='oneindicator_UCS_SMI', overlay=false)
// # ========================================================================= #
// # sub indicators numbers
// # ========================================================================= #
// first indicator
// # ========================================================================= #
// input variables
// # ========================================================================= #
one_a = input(5, 'Percent K Length')
one_b = input(3, 'Percent D Length')
// # ========================================================================= #
// Range Calculation
// # ========================================================================= #
one_ll = lowest(low, one_a)
one_hh = highest(high, one_a)
one_diff = one_hh - one_ll
one_rdiff = close - (one_hh + one_ll) / 2
// # ========================================================================= #
// Nested Moving Average for smoother curves
// # ========================================================================= #
one_avgrel = ema(ema(one_rdiff, one_b), one_b)
one_avgdiff = ema(ema(one_diff, one_b), one_b)
// # ========================================================================= #
// SMI calculations
// # ========================================================================= #
one_SMI = one_avgdiff != 0 ? one_avgrel / (one_avgdiff / 2) * 100 : 0
one_SMIsignal = ema(one_SMI, one_b)
// # ========================================================================= #
// ob, os, zeroline calc
// # ========================================================================= #
one_ob = 40
one_os = -40
one_zeroline = 0
// # ========================================================================= #
// All PLOTS
// # ========================================================================= #
plot(one_SMI, title='Stochastic Momentum Index')
plot(one_SMIsignal, color=color.new(#FF0000, 0), title='SMI Signal Line')
one_ob_plot = plot(40, color=color.new(#FFCDD2, 0), title='one_Over_Bought_plot')
one_os_plot = plot(-40, color=color.new(#008000, 0), title='one_Over_Sold_plot')
one_zeroline_plot = plot(0, color=color.new(#0094ff, 0), title='one_Zero_Line_plot')
// # ========================================================================= #
// trade definition (for the specific indicator)
// # ========================================================================= #
// one_Buy = crossover (one_SMI, one_os)
// one_Sell = crossunder(one_SMI, one_ob)
one_Buy_5 = one_SMI > one_os
one_Sell_5 = one_SMI < one_ob
one_Buy_7_maybe = one_SMI > one_SMIsignal
one_Sell_7_maybe = one_SMI < one_SMIsignal
one_SMI_stat_less_zero = one_SMI < one_zeroline // buy
one_SMI_stat_above_zero = one_SMI > one_zeroline // sell
// second option //
//
// one_Buy = if one_SMI > -40
// close
// one_Sell = if one_SMI < 40
// close
// with other option than above / less //
// one_sell_test = crossunder(one_SMI, one_SMIsignal)
// one_buy_test = crossover(one_SMI, one_SMIsignal)
// # ========================================================================= #
// compounding trade definitions (for the indicators, so far)
// # ========================================================================= #
// compoundAlertBuy = one_Buy_5 and one_Buy_7_maybe
// compoundAlertSell = one_Sell_5 and one_Sell_7_maybe
// with only zero
one_compoundAlertBuyExtraZero = one_Buy_5 and one_Buy_7_maybe and one_SMI_stat_less_zero
one_compoundAlertSellExtraZero = one_Sell_5 and one_Sell_7_maybe and one_SMI_stat_above_zero
// # ========================================================================= #
// alerts Conditions (for the specific indicator)
// # ========================================================================= #
// should be only alerting one time //
// alertcondition(one_Buy, title='one_Buy Signal', message='one_Buy')
// alertcondition(one_Sell, title='not_one_Sell_Signal', message='not_one_Sell')
// alertcondition (one_Sell_5, title= "one_sell_5", message ="one_sell_5")
// alertcondition (one_Buy_5, title= "one_buy_5", message ="one_buy_5")
// alertcondition (one_Sell_7_maybe, title= "one_Sell_7_maybe", message ="one_Sell_7_maybe")
// alertcondition (one_Buy_7_maybe, title= "one_Buy_7_maybe", message ="one_Buy_7_maybe")
// # ========================================================================= #
// compound alerts condition
// # ========================================================================= #
// alertcondition (compoundAlertBuy, title= "compoundAlertBuy", message ="ocompoundAlertBuy")
// with extra zero
alertcondition (one_compoundAlertBuyExtraZero, title= "one_compoundAlertBuyExtraZero", message ="one_compoundAlertBuyExtraZero")
alertcondition (one_compoundAlertSellExtraZero, title= "one_compoundAlertSellExtraZero", message ="one_compoundAlertSellExtraZero")
///////////////////////////////////////////////////////////////////////////
// --second indicator-- //
// ---- //
// //
// //
// - - //
// //
// //
// ---- //
// # ========================================================================= #
// # indicator number
// # ========================================================================= #
// 2nd indicator
// # ========================================================================= #
// # indicator title
// # ========================================================================= #
// Overbought oversold
//
two_n = input(5, title="Length")
two_Barcolor=input(true,title="Barcolor")
two_ys1 = (high + low + close * 2) / 4
two_rk3 = ema(two_ys1, two_n)
two_rk4 = stdev(two_ys1, two_n)
two_rk5 = (two_ys1 - two_rk3) * 100 / two_rk4
two_rk6 = ema(two_rk5, two_n)
two_up = ema(two_rk6, two_n)
two_down = ema(two_up, two_n)
two_Oo = iff(two_up < two_down, two_up, two_down)
two_Hh = two_Oo
two_Ll = iff(two_up < two_down, two_down, two_up)
two_Cc = two_Ll
two_b_color = iff(two_Oo[1] < two_Oo and two_Cc < two_Cc[1], #FFFF00, iff(two_up > two_down, #008000, #FF0000))
barcolor(two_Barcolor ? two_b_color : na)
hline(0)
plot(two_Oo, style=plot.style_histogram, color=two_b_color)
plot(two_Ll, style=plot.style_histogram, color=two_b_color)
plot(two_up, color=two_b_color,title="Up")
plot(two_down, color=two_b_color,title="Down")
// # ========================================================================= #
// trade definition (for the specific indicator)
// # ========================================================================= #
// Buy = crossover(up, down)
// Sell = crossunder(up, down)
two_Buy = two_up > two_down
two_Sell = two_up < two_down
// # ========================================================================= #
// Compound Trade Definition (for the specific indicator)
// # ========================================================================= #
two_compoundAlertBuy = one_Buy_5 and one_Buy_7_maybe and one_SMI_stat_less_zero and two_Buy
two_compoundAlertSell = one_Sell_5 and one_Sell_7_maybe and one_SMI_stat_above_zero and two_Sell
//
plotshape(two_Buy, title="two_Buy", color=#008000, style=shape.triangleup, location=location.bottom, text="Buy",size=size.tiny)
plotshape(two_Sell, title="two_Sell", color=#FF0000, style=shape.triangledown, location=location.top, text="Sell",size=size.tiny)
//
// # ========================================================================= #
// alerts condition
// # ========================================================================= #
// alertcondition(two_Buy, title="two_Buy Signal", message="two_Buy")
// alertcondition(two_Sell, title="two_Sell Signal", message="two_Sell")
// # ========================================================================= #
// compound alerts condition
// # ========================================================================= #
alertcondition (two_compoundAlertBuy, title= "two_compoundAlertBuy", message ="two_ocompoundAlertBuy")
alertcondition (two_compoundAlertSell, title= "two_compoundAlertSell", message ="wo_compoundAlertSell")
// 3rd indicator //
///////////////////////////////////////////////////////////////////////////
three_n1 = input(10, "three_Channel Length")
three_n2 = input(21, "three_Average Length")
three_obLevel1 = input(60, "three_Over Bought Level 1")
three_obLevel2 = input(53, "three_Over Bought Level 2")
three_osLevel1 = input(-60, "three_Over Sold Level 1")
three_osLevel2 = input(-53, "three_Over Sold Level 2")
three_ap = hlc3
three_esa = ema(three_ap, three_n1)
three_d = ema(abs(three_ap - three_esa), three_n1)
three_ci = (three_ap - three_esa) / (0.015 * three_d)
three_tci = ema(three_ci, three_n2)
three_wt1 = three_tci
three_wt2 = sma(three_wt1,4)
plot(0, color=#7b8da6)
three_p55 = plot(three_obLevel1, color=#ff2c55)
three_p5 = plot(three_osLevel1, color=#99cc33)
three_p555 = plot(three_obLevel2, color=#f49f0a, style=3)
three_p7 = plot(three_osLevel2, color= #ba9588, style=3)
three_shortrig = plot(three_wt1, color=#6b5d52, title="three_shortrig")
three_longsig = plot(three_wt2, color= #f5cff2, style=3, title = "three_longsig")
three_p77 = plot(three_wt1-three_wt2, color= #ffd680, style= 3, transp=80)
// # ========================================================================= #
// buy, sell Trade Definition
// # ========================================================================= #
three_Buy = three_wt1 > three_wt2
three_Sell = three_wt1 < three_wt2
// # ========================================================================= #
// Compound Trade Definition
// # ========================================================================= #
three_compoundAlertBuy = one_Buy_5 and one_Buy_7_maybe and two_Buy and three_Buy
three_compoundAlertSell = one_Sell_5 and one_Sell_7_maybe and two_Sell and three_Sell
// # ========================================================================= #
// compound alerts condition
// # ========================================================================= #
alertcondition (three_compoundAlertBuy, title= "three_compoundAlertBuy", message ="three_ocompoundAlertBuy")
//////////////////////////////////////////////////////////////
// 4th indicator
// Getting inputs
four_fast_length = input(title="four_Fast Length", type=input.integer, defval=8)
four_slow_length = input(title="four_Slow Length", type=input.integer, defval=21)
four_First_R = input(title="four_First R", type=input.integer, defval = 8)
four_Second_S = input(title="four_Second S", type=input.integer, defval=5)
four_src = input(title="four_Source", type=input.source, defval=close)
four_signal_length = input(title="four_Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
four_sma_signal = input(title="four_Simple MA(Signal Line)", type=input.bool, defval=false)
// Plot colors
four_col_grow_above = #26A69A
four_col_grow_below = #FFCDD2
four_col_fall_above = #B2DFDB
four_col_fall_below = #EF5350
four_col_macd = #0094ff
four_col_signal = #00ff00
four_col_mirror_macd = #ff0000
// Calculating
four_fast_ma = ema(four_src, four_fast_length)
four_slow_ma = ema(four_src, four_slow_length)
four_macd = four_fast_ma - four_slow_ma
/////
four_MTM = four_macd - four_macd[1]
four_ABSMTM = abs(four_MTM)
four_EMA_MTM = ema(four_MTM, four_First_R)
four_EMA_ABSMTM = ema(four_ABSMTM, four_First_R)
four_EMA2_MTM = ema(four_EMA_MTM, four_Second_S)
four_EMA2_ABSMTM = ema(four_EMA_ABSMTM, four_Second_S)
four_TSI = 100.0*four_EMA2_MTM/four_EMA2_ABSMTM
four_Mirror_TSI = -100.0*four_EMA2_MTM/four_EMA2_ABSMTM
four_signal = four_sma_signal ? sma(four_TSI, four_signal_length) : ema(four_TSI, four_signal_length)
plotshape(crossover(four_TSI,four_Mirror_TSI), color = color.green, style = shape.cross, location = location.top)
plotshape(crossover(four_Mirror_TSI,four_TSI), color = color.red, style = shape.cross, location = location.top)
// 7. trade definition (for the specific indicator)
// 8. compounding trade definitions (for the indicators, so far)
// 9. alerts Conditions (for the specific indicator)
// 10. compounding alerts Conditions (for the comulative, so far)
hline(0)
plot(four_TSI, title="four_TSI_MACD", color=four_col_macd, transp=0)
plot(four_signal, title="four_Signal", color=four_col_signal, transp=0)
plot(four_Mirror_TSI, title="four_TSI_Mirror", color=four_col_mirror_macd)
///////////
//5th indicator
// The author of this indicator is Veronique Valcu. The z-score (z) for a data
// item x measures the distance (in standard deviations StdDev) and direction
// of the item from its mean (U):
// z = (x-StdDev) / U
// A value of zero indicates that the data item x is equal to the mean U, while
// positive or negative values show that the data item is above (x>U) or below
// (x Values of +2 and -2 show that the data item is two standard deviations
// above or below the chosen mean, respectively, and over 95.5% of all data
// items are contained within these two horizontal references (see Figure 1).
// We substitute x with the closing price C, the mean U with simple moving
// average (SMA) of n periods (n), and StdDev with the standard deviation of
// closing prices for n periods, the above formula becomes:
// Z_score = (C - SMA(n)) / StdDev(C,n)
// The z-score indicator is not new, but its use can be seen as a supplement to
// Bollinger bands. It offers a simple way to assess the position of the price
// vis-a-vis its resistance and support levels expressed by the Bollinger Bands.
// In addition, crossings of z-score averages may signal the start or the end of
// a tradable trend. Traders may take a step further and look for stronger signals
// by identifying common crossing points of z-score, its average, and average of average.
////////////////////////////////////////////////////////////
//study(title="Z-Score", shorttitle="Z-Score")
five_Period = input(20, minval=1)
hline(0, color=#d575b6)
five_xStdDev = stdev(close, five_Period)
five_xMA = sma(close, five_Period)
five_nRes = (close - five_xMA) / five_xStdDev
plot(five_nRes, color=#f2e2ce, title="five_Z-Score")
// 7. trade definition (for the specific indicator)
// 8. compounding trade definitions (for the indicators, so far)
// 9. alerts Conditions (for the specific indicator)
// 10. compounding alerts Conditions (for the comulative, so far)
//////////////
// 6th indicator
// argotic tsi
// r - Length of first EMA smoothing of 1 day momentum 4
// s - Length of second EMA smoothing of 1 day smoothing 8
// u- Length of third EMA smoothing of 1 day momentum 6
// Length of EMA signal line 3
// Source of Ergotic TSI Close
//
// This is one of the techniques described by William Blau in his book "Momentum,
// Direction and Divergence" (1995). If you like to learn more, we advise you to
// read this book. His book focuses on three key aspects of trading: momentum,
// direction and divergence. Blau, who was an electrical engineer before becoming
// a trader, thoroughly examines the relationship between price and momentum in
// step-by-step examples. From this grounding, he then looks at the deficiencies
// in other oscillators and introduces some innovative techniques, including a
// fresh twist on Stochastics. On directional issues, he analyzes the intricacies
// of ADX and offers a unique approach to help define trending and non-trending periods.
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
////////////////////////////////////////////////////////////
//study(title="Ergotic TSI Strategy")
// r = input(4, minval=1)
// s = input(8, minval=1)
// u = input(6, minval=1)
// SmthLen = input(3, minval=1)
// hline(0, color=blue, linestyle=line)
// xPrice = close
// xPrice1 = xPrice - xPrice[1]
// xPrice2 = abs(xPrice - xPrice[1])
// xSMA_R = ema(ema(ema(xPrice1,r), s),u)
// xSMA_aR = ema(ema(ema(xPrice2, r), s),u)
// Val1 = 100 * xSMA_R
// Val2 = xSMA_aR
// xTSI = iff (Val2 != 0, Val1 / Val2, 0)
// xEMA_TSI = ema(xTSI, SmthLen)
// pos = iff(xTSI > xEMA_TSI, 1,
// iff(xTSI < xEMA_TSI, -1, nz(pos[1], 0)))
// barcolor(pos == -1 ? red: pos == 1 ? green : blue )
// plot(xTSI, color=green, title="Ergotic TSI")
// plot(xEMA_TSI, color=red, title="SigLin")
// // 7th indicator
// // lrs
// // Simple linear regression slope - Good way see if the trend is accelarating or decelarating
// // study(title="UCSGEARS - Linear Regression Slope", shorttitle="UCS-LRS", overlay=false)
// src = close
// //Input
// clen = input (defval = 50, minval = 1, title = "Curve Length")
// slen = input(defval=5, minval=1, title="Slope Length")
// glen = input(defval=13, minval=1, title="Signal Length")
// //Linear Regression Curve
// lrc = linreg(src, clen, 0)
// //Linear Regression Slope
// lrs = (lrc-lrc[1])/1
// //Smooth Linear Regression Slope
// slrs = ema(lrs, slen)
// //Signal Linear Regression Slope
// alrs = sma(slrs, glen)
// //loalrs = sma(slrs, (glen*5))
// uacce = lrs > alrs and lrs > 0
// dacce = lrs < alrs and lrs < 0
// scolor = uacce ? green : dacce ? red : blue
// plot(0, title = "Zero Line", color = gray)
// plot(slrs, color = scolor, title = "Linear Regression Slope", style = histogram, linewidth = 4)
// plot(alrs, color = gray, title = "Average Slope")
Show all 547 lines