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.
Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?
//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)