Implementation of the DPO indicator in FMZ

Author: Weighted deshunquant, Created: 2021-09-28 10:49:11, Updated: 2021-09-28 11:50:39

First, how to use the DPO indicator?

The first thing you need to know is the calculation formula for the DPO indicator:

1, MA = simple moving average of N days;

2, DPO = simple moving average of the closing price-MA ((N/2+1) day;

3, MADPO = the simple moving average of the DPO for M days;

So, N is 21, M is 6.

How to use the DPO indicator:

1, above the 0 axis, set up an overbought line, and once the DPO fluctuates to overbought, it means that the stock price is at a short-term high.

2, below the 0 axis, set an oversold line, which means that the stock price is at a short-term low once the DPO fluctuates to the oversold line.

3, if the DPO indicator is above the 0 axis, the representative is in a multi-head market. This is a buy signal if the DPO indicator crosses the 0 axis from the negative upwards.

4, if the DPO indicator is below the 0 axis, the representative is in the blank market. This is a sell signal if the DPO indicator crosses the 0 axis from the positive value downwards.


More

The Little DreamWhat's up? /* How to calculate: 1, the closing price of MA on day N plus the sum/N 2, DPO = closing price - (n / 2) + MA of day 1) 3, MADPO = moving average of DPO for M days N is 21, M is 6. */ // the indicator algorithm function DPO ((r, n) { var arrDpo is equal to [] for (var i = 0 ; i < r.length ; i++) { I'm going to have to go. for (var j = 0 ; j < i ; j++) { currRecords.push ((r[j]) I'm not sure. var ma = TA.MA ((currRecords, (_N ((n / 2, 0) + 1)) var dpo = NaN If (currRecords.length == 0 て!ma て ma.length == 0 て!ma [ma.length - 1]) { dpo = NaN } else { var close = r[i].Close dpo = close - ma[ma.length - 1] I'm not sure. arrDpo.push ((dpo)) I'm not sure. return arrDpo I'm not sure. function MADPO ((dpo, m) { return TA.MA ((dpo, m) I'm not sure. // Example of using indicators function main (() { var r = exchange.GetRecords ((() var dpo = DPO ((r, 21) Log ((_D(r[r.length - 1].Time), "dpo on last bar:", dpo[dpo.length - 1]) Log ((_D(r[r.length - 2].Time), "dpo on pre bar:", dpo[dpo.length - 2]) What do you think? var madpo = MADPO ((dpo, 6)), which is the Log ((_D(r[r.length - 1].Time), "madpo on last bar:", madpo [madpo.length - 1]) Log ((_D(r[r.length - 2].Time), "madpo on pre bar:", madpo [madpo.length - 2]) I'm not sure. What's up? I'll give you an idea, without guarantee, without verification.