JayRogers

Multi Time Frame MA Duplicates

Description:
  • One stop shop for multiple MA duplicates over different resolutions.
  • A veritable banquet of MA's to choose from.
  • Set up you MA variables, and then plot up to 4 duplicates all using different time frames.
Commentaire: New revision of this script:
Supprimer des scripts favoris Ajouter aux scripts favoris
//@version=2

study(title="Multi Time Frame MA Duplicates", shorttitle="MTF MA Duplicates", overlay=true)

// Revision:    1
// Author:      JayRogers
//
// Description:
//  - One stop shop for multiple MA duplicates over different resolutions.
//  - A veritable banquet of MA's to choose from.
//  - Set up you MA variables, and then plot up to 4 duplicates all using different time frames.

// - INPUTS START
maType  = input(defval="EMA", title="Choose MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, LSMA ( case sensitive )", type=string)
maSrc   = input(defval=open, title="MA Source", type=source)
maLen   = input(defval=200, title="MA Period", minval=1)
lsma    = input(defval=0, title="Offset for Least Squares MA", minval=1)
res1    = input(defval="15", title="MA Duplicate 1 Resolution", type=resolution)
res2    = input(defval="30", title="MA Duplicate 2 Resolution", type=resolution)
res3    = input(defval="60", title="MA Duplicate 3 Resolution", type=resolution)
res4    = input(defval="120", title="MA Duplicate 4 Resolution", type=resolution)
// - INPUTS END

// - FUNCTIONS
// Returns chosen MA input calculation, default to SMA if blank or typo.
variant(type, src, len, lsma) =>
    v1 = sma(src, len)                                                  // Simple
    v2 = ema(src, len)                                                  // Exponential
    v3 = wma(src, len)                                                  // Weighted
    v4 = vwma(src, len)                                                 // Volume Weighted
    v5 = na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len    // Smoothed
    v6 = 2 * v2 - ema(v2, len)                                          // Double Exponential
    v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len)               // Triple Exponential
    v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))   // Hull
    v9 = linreg(src, len, lsma)                                         // Least Squares
    type=="EMA"?v2 : type=="WMA"?v3 : type=="VWMA"?v4 : type=="SMMA"?v5 : type=="DEMA"?v6 : type=="TEMA"?v7 : type=="HullMA"?v8 : type=="LSMA"?v9 : v1
// Return selected resolution series, or use current
reso(exp, use, res) => use ? security(tickerid, res, exp) : exp
// - FUNCTIONS END

// - SERIES VARIABLES
// Basis and deviation
ma1 = reso(variant(maType, maSrc, maLen, lsma), true, res1)
ma2 = reso(variant(maType, maSrc, maLen, lsma), true, res2)
ma3 = reso(variant(maType, maSrc, maLen, lsma), true, res3)
ma4 = reso(variant(maType, maSrc, maLen, lsma), true, res4)
// - SERIES VARIABLES END

// - PLOTTING
// Basis
maPlot1 = plot(ma1, title="MA 1", color=#00FF99, linewidth=1, transp=40)
maPlot2 = plot(ma2, title="MA 2", color=#00FFAA, linewidth=2, transp=40)
maPlot3 = plot(ma3, title="MA 3", color=#00FFBB, linewidth=3, transp=40)
maPlot4 = plot(ma4, title="MA 4", color=#00FFCC, linewidth=4, transp=40)
// - PLOTTING END
Shrinks the screen like a pan cake if the MA is way down below.
Répondre
Accueil Filtre d'actions Filtre Forex Filtre Crypto Calendrier économique Comment ça marche Caractéristiques du graphique Prix Règles de conduite Modérateurs Solutions site web & courtier Widgets Solutions de cartographie Obtenir de l'aide Demande de fonctionnalité Blog & News Questions Fréquentes Wiki Twitter
Profil Paramètres du Profil Compte et Facturation TradingView Coins Mes tickets au support Obtenir de l'aide Idées Publiées Suiveurs Suivi Messages privés dialogue en ligne Se Déconnecter