Professional Documents
Culture Documents
// Awesome Oscillator
AO() =>
sma(hl2, 5) - sma(hl2, 34)
// Stochastic RSI
StochRSI() =>
rsi1 = rsi(close, 14)
K = sma(stoch(rsi1, rsi1, rsi1, 14), 3)
D = sma(K, 3)
[K, D]
// Ultimate Oscillator
tl() => close[1] < low ? close[1]: low
uo(ShortLen, MiddlLen, LongLen) =>
Value1 = sum(tr, ShortLen)
Value2 = sum(tr, MiddlLen)
Value3 = sum(tr, LongLen)
Value4 = sum(close - tl(), ShortLen)
Value5 = sum(close - tl(), MiddlLen)
Value6 = sum(close - tl(), LongLen)
float UO = na
if Value1 != 0 and Value2 != 0 and Value3 != 0
var0 = LongLen / ShortLen
var1 = LongLen / MiddlLen
Value7 = (Value4 / Value1) * (var0)
Value8 = (Value5 / Value2) * (var1)
Value9 = (Value6 / Value3)
UO := (Value7 + Value8 + Value9) / (var0 + var1 + 1)
UO
// Ichimoku Cloud
donchian(len) => avg(lowest(len), highest(len))
ichimoku_cloud() =>
conversionLine = donchian(9)
baseLine = donchian(26)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(52)
[conversionLine, baseLine, leadLine1, leadLine2]
HullMA9 = hma(close, 9)
// Stochastic
lengthStoch = 14
smoothKStoch = 3
smoothDStoch = 3
kStoch = sma(stoch(close, high, low, lengthStoch), smoothKStoch)
dStoch = sma(kStoch, smoothDStoch)
// Momentum
Mom = mom(close, 10)
// Moving Average Convergence/Divergence, MACD
[macdMACD, signalMACD, _] = macd(close, 12, 26, 9)
// Stochastic RSI
[Stoch_RSI_K, Stoch_RSI_D] = StochRSI()
// Williams Percent Range
WR = wpr(14)
if not na(SMA10)
ratingMA := ratingMA + calcRatingMA(SMA10, close)
ratingMAC := ratingMAC + 1
if not na(SMA20)
ratingMA := ratingMA + calcRatingMA(SMA20, close)
ratingMAC := ratingMAC + 1
if not na(SMA30)
ratingMA := ratingMA + calcRatingMA(SMA30, close)
ratingMAC := ratingMAC + 1
if not na(SMA50)
ratingMA := ratingMA + calcRatingMA(SMA50, close)
ratingMAC := ratingMAC + 1
if not na(SMA100)
ratingMA := ratingMA + calcRatingMA(SMA100, close)
ratingMAC := ratingMAC + 1
if not na(SMA200)
ratingMA := ratingMA + calcRatingMA(SMA200, close)
ratingMAC := ratingMAC + 1
if not na(EMA10)
ratingMA := ratingMA + calcRatingMA(EMA10, close)
ratingMAC := ratingMAC + 1
if not na(EMA20)
ratingMA := ratingMA + calcRatingMA(EMA20, close)
ratingMAC := ratingMAC + 1
if not na(EMA30)
ratingMA := ratingMA + calcRatingMA(EMA30, close)
ratingMAC := ratingMAC + 1
if not na(EMA50)
ratingMA := ratingMA + calcRatingMA(EMA50, close)
ratingMAC := ratingMAC + 1
if not na(EMA100)
ratingMA := ratingMA + calcRatingMA(EMA100, close)
ratingMAC := ratingMAC + 1
if not na(EMA200)
ratingMA := ratingMA + calcRatingMA(EMA200, close)
ratingMAC := ratingMAC + 1
if not na(HullMA9)
ratingHullMA9 = calcRatingMA(HullMA9, close)
ratingMA := ratingMA + ratingHullMA9
ratingMAC := ratingMAC + 1
if not na(VWMA)
ratingVWMA = calcRatingMA(VWMA, close)
ratingMA := ratingMA + ratingVWMA
ratingMAC := ratingMAC + 1
float ratingIC = na
if not (na(IC_Lead1) or na(IC_Lead2) or na(close) or na(close[1]) or
na(IC_BLine) or na(IC_CLine))
ratingIC := calcRating(
IC_Lead1 > IC_Lead2 and close > IC_Lead1 and close < IC_BLine and close[1]
< IC_CLine and close > IC_CLine,
IC_Lead2 > IC_Lead1 and close < IC_Lead2 and close > IC_BLine and close[1]
> IC_CLine and close < IC_CLine)
if not na(ratingIC)
ratingMA := ratingMA + ratingIC
ratingMAC := ratingMAC + 1
float ratingOther = 0
float ratingOtherC = 0
ratingRSI = RSI
if not(na(ratingRSI) or na(ratingRSI[1]))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + calcRating(ratingRSI < 30 and ratingRSI[1] <
ratingRSI, ratingRSI > 70 and ratingRSI[1] > ratingRSI)
ratingCCI = CCI
if not(na(ratingCCI) or na(ratingCCI[1]))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + calcRating(ratingCCI < -100 and ratingCCI >
ratingCCI[1], ratingCCI > 100 and ratingCCI < ratingCCI[1])
if not(na(ao) or na(ao[1]))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + calcRating(crossover(ao,0) or (ao > 0 and
ao[1] > 0 and ao > ao[1] and ao[2] > ao[1]), crossunder(ao,0) or (ao < 0 and ao[1]
< 0 and ao < ao[1] and ao[2] < ao[1]))
if not(na(Mom) or na(Mom[1]))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + calcRating(Mom > Mom[1], Mom < Mom[1])
if not(na(macdMACD) or na(signalMACD))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + calcRating(macdMACD > signalMACD, macdMACD <
signalMACD)
float ratingStoch_RSI = na
if not(na(DownTrend) or na(UpTrend) or na(Stoch_RSI_K) or na(Stoch_RSI_D) or
na(Stoch_RSI_K[1]) or na(Stoch_RSI_D[1]))
ratingStoch_RSI := calcRating(
DownTrend and Stoch_RSI_K < 20 and Stoch_RSI_D < 20 and Stoch_RSI_K >
Stoch_RSI_D and Stoch_RSI_K[1] < Stoch_RSI_D[1],
UpTrend and Stoch_RSI_K > 80 and Stoch_RSI_D > 80 and Stoch_RSI_K <
Stoch_RSI_D and Stoch_RSI_K[1] > Stoch_RSI_D[1])
if not na(ratingStoch_RSI)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingStoch_RSI
float ratingWR = na
if not(na(WR) or na(WR[1]))
ratingWR := calcRating(WR < -80 and WR > WR[1], WR > -20 and WR < WR[1])
if not na(ratingWR)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingWR
float ratingBBPower = na
if not(na(UpTrend) or na(DownTrend) or na(BearPower) or na(BearPower[1]) or
na(BullPower) or na(BullPower[1]))
ratingBBPower := calcRating(
UpTrend and BearPower < 0 and BearPower > BearPower[1],
DownTrend and BullPower > 0 and BullPower < BullPower[1])
if not na(ratingBBPower)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingBBPower
float ratingUO = na
if not(na(UO))
ratingUO := calcRating(UO > 70, UO < 30)
if not na(ratingUO)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingUO
float ratingTotal = 0
float ratingTotalC = 0
if not na(ratingMA)
ratingTotal := ratingTotal + ratingMA
ratingTotalC := ratingTotalC + 1
if not na(ratingOther)
ratingTotal := ratingTotal + ratingOther
ratingTotalC := ratingTotalC + 1
ratingTotal := ratingTotalC > 0 ? ratingTotal / ratingTotalC : na