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).
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟
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)