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)