Kurbelklaus

KK_Intraday MAs

Hey guys,

today I was browsing through intraday Charts looking at some moving averages. Basically what I wanted to see was whether the currency pair was trading below or above the moving average of the day/week/month. For a better understanding: The daily MA on a 15 minute Forex Chart would be the 96 MA.

I encountered the problem that i always had to change the settings for my MAs when changing the Time Interval, so I coded this here up. It is pretty simple but maybe somebody else has the same problem and can put it to use.

The script has some settings as listed below:
  • Choice which MAs to plot, (Daily, Weekly, Monthly)
  • Choice which type of MA to use (Simple, Exponential, Weighted)
  • Neccesary Settings for the correct calculation (e.g. Number of trading hours per day). These settings depend on the instrument you are using and should always be checked before using this script.

There are a few things to Note when using this script:
  • This script works for intraday charts only.
  • The monthly MA doesn't work on any Time Interval smaller than 15 minutes. Can't do anything about it unfortunately.

This is my first published Script, use it with caution and let me know what you think about it!
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?
study(title="KK_Intraday MAs",overlay=true)
//inputs
PD = input(false, title="Plot Daily MA")
PW = input(true, title="Plot Weekly MA")
PM = input(true, title="Plot Monthly MA")
MAT = input(1,minval=1,maxval=3,title="1=SMA, 2=EMA, 3=WMA")
HPD = input(24, title="Number of trading hours per day")
DPW = input(5, title="Number of trading days per Week")
WPY = input(52, title="Number of Weeks per Year")

//SMA generation
Simple = MAT == 1 ? true : false
Exponential = MAT == 2 ? true : false
Weighted = MAT == 3 ? true : false
BPD=round(60*HPD/interval)
BPW=round(60*HPD*DPW/interval)
BPM=round(60*HPD*DPW*WPY/(12*interval))
daily = Simple ? sma(close, BPD) : Exponential ? ema(close, BPD): Weighted ? wma(close, BPD) : na
weekly = Simple ? sma(close, BPW) : Exponential ? ema(close, BPW): Weighted ? wma(close, BPW) : na 
monthly = Simple ? sma(close, BPM) : Exponential ? ema(close, BPM): Weighted ? wma(close, BPM) : na

//Plotting
plot(PD and isintraday ? daily : na, color = green, linewidth = 3, title="Daily")
plot(PW and isintraday ? weekly : na, color = blue, linewidth = 3, title="Weekly")
plot(PM and isintraday ? monthly: na, color= black, linewidth = 3, title="Monthly")