RicardoSantos

[RS]Moving Average Cross System V0

moving average crossover with added functions:
if you want crossover with price set ma1 length to 1, or use as dual ma with both lengths, ability to turn ma's on and off leaving the crossover signals behind, ability to chose ma mode (sma, ema, rma, wma, vwma, swma and alma), ability to chose source (open, high, low, close, hl2, hlc3 or ohlc4).
Open-source Skript

Ganz im Spirit von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es besser verstehen und überprüfen können. Herzlichen Glückwunsch an den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Veröffentlichung unterliegt den Hausregeln. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie dieses Skript auf einem Chart verwenden?
study(title="[RS]Moving Average Cross System V0", shorttitle="[RS]MACS.V0", overlay=true)
matype = input("sma")
hidema = input(false)
sourcetype = input("close")
source = sourcetype == "open" ? open :
        sourcetype == "high" ? high :
        sourcetype == "low" ? low :
        sourcetype == "close" ? close :
        sourcetype == "hl2" ? hl2 :
        sourcetype == "hlc3" ? hlc3 :
        sourcetype == "ohlc4" ? ohlc4 : na

length1 = input(1)
length2 = input(10)

ma1 = matype == "sma" ? sma(source, length1) :
        matype == "ema" ? ema(source, length1) : 
        matype == "rma" ? rma(source, length1) :
        matype == "wma" ? wma(source, length1) :
        matype == "vwma" ? vwma(source, length1) :
        matype == "swma" ? sma(swma(source), length1) :
        matype == "alma" ? alma(source, length1, 0.85, 0) : na
ma2 = matype == "sma" ? sma(source, length2) :
        matype == "ema" ? ema(source, length2) : 
        matype == "rma" ? rma(source, length2) :
        matype == "wma" ? wma(source, length2) :
        matype == "vwma" ? vwma(source, length2) :
        matype == "swma" ? sma(swma(source), length2) :
        matype == "alma" ? alma(source, length1, 0.85, 0) : na

signal = cross(ma1, ma2) ? ma2 : na
signalcolor = source > ma2 ? green : maroon
plot(hidema ? na : ma1, color=gray, linewidth=1)
plot(hidema ? na : ma2, color=black, linewidth=1)
plot(signal, style=cross, color=signalcolor, linewidth=4)