anexas

Oscillator Moving Average (OsMA)

This code for Oscillator of Moving Averages (OsMA) is based on MACD 4C indicator code published by vkno422. Many thanks to vkno422. I have borrowed the concept of 4 colours which I find very useful.

For those who are not familiar with OsMA, it is histogram of difference between MACD (oscillator) and its MA (signal line). The zero line cross over of this indicator is used in many strategies.

This version includes MACD & its signal line together with OsMA histogram. I have programmed flexibility for switching OFF/ON individual indicator components as well as changing the periods for various moving averages.

I am dedicating this indicator to the TV trading community hoping that people will find it useful.
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?
//Indicator - Oscillator of Moving Averages.
//Histogram of difference between MACD (oscillator) and its MA (signal line)
//Version 2.0 Created on 14 July 2016 by - Shailesh Saxena
//code based on MACD 4C indicator code published by vkno422
study(shorttitle = "OsMA", title = "Oscillator Moving Average")

//User Inputs
fastMA = input(title="Fast MA Period", type = integer, defval = 12, minval = 3)
slowMA = input(title="Slow MA Period", type = integer, defval = 26, minval = 3)
smoothing = input(title="MACD MA Period", type = integer, defval = 9, minval = 3)
sLine = input(title="Show Signal Line", type=bool, defval=true)
MACD_visible = input(title="Show MACD", type = bool, defval = true)
OsMA_histogram = input(title="Show OsMA Histogram", type = bool, defval = true)

//MACD
[MACD,signalLine,_] = macd(close[0], fastMA, slowMA, smoothing)
show_MACD = MACD_visible ? MACD : na

MACDColor = MACD > 0 
    ? MACD > MACD[1] ? lime : green 
    : MACD < MACD[1] ? red : orange
plot(show_MACD, style = line, color = MACDColor, linewidth = 1)
plot(0, title = "Zero line", linewidth = 1, color = gray)

sl = sLine ? signalLine : na
plot(sl, color = yellow, linewidth = 1)

//OsMA
OsMA = OsMA_histogram ? MACD - signalLine : na

OsMAColor = OsMA > 0 
    ? OsMA > OsMA[1] ? aqua : teal 
    : OsMA < OsMA[1] ? fuchsia : purple
plot(OsMA, style = histogram, color = OsMAColor, linewidth = 2)
plot(0, title = "Zero line", linewidth = 1, color = gray)