Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Moving average deviation rate
 Post subject: Moving average deviation rate Post rating: 0   New post Posted: Mon 15 Mar, 2021, 16:30 
User avatar

User rating: 0
Joined: Sat 27 Apr, 2013, 15:03
Posts: 1
Location: PolandPoland
Hello,
can anyone help me write an indicator based on this:

https://www.tradingview.com/script/25KCgL9H/

Simple moving average deviation rate and standard deviation.

The bollinger band is momentum value standard devition.
Bat the bollinger band is not normal distribution to close price.

Moving average deviation rate is normal distribution.

This indicator is draw Moving average deviation rate and fill area 2σ standard devition.
If it exceeds 2σ, it is a trading opportunity.


//@version=3
study("Moving average deviation rate", overlay=false)

//input
_maPeriod = input(21, title="Moving average period")

//deviation rate
_sma = sma(close, _maPeriod)
_rate = close / _sma * 100 - 100

//deviation rate std
_stdCenter = sma(_rate, _maPeriod * 2)
_std = stdev(_rate, _maPeriod * 2)
_plusDev = _stdCenter + _std * 2
_minusDev = _stdCenter - _std * 2

plot(_rate, color=red)
_plotCenter = plot(_stdCenter, color=green)
_plotPlus = plot(_plusDev, color=green)
_plotMinus = plot(_minusDev, color=green)
fill(_plotCenter, _plotPlus, color=green)
fill(_plotCenter, _plotMinus, color=green)

thank you in advance for your help !!


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com