mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 05:28:05 +00:00
Decay
This commit is contained in:
@@ -82,7 +82,8 @@ public class Tulip_Test
|
||||
|
||||
ATR_Series QL = new(bars, period, false);
|
||||
Tulip.Indicators.atr.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--)
|
||||
//Tulip ATR doesn't use warm-up SMA, compensating with 200 warming bars
|
||||
for (int i = QL.Length - 1; i > 200+skip; i--)
|
||||
{
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period + 1];
|
||||
@@ -112,19 +113,21 @@ public class Tulip_Test
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
/*
|
||||
[Fact]
|
||||
public void CCI() {
|
||||
double[][] arrin = { inopen, inhigh, inlow, inclose, involume };
|
||||
double[][] arrin = { inhigh, inlow, inclose };
|
||||
double[][] arrout = { outdata };
|
||||
CCI_Series QL = new(bars, period, useNaN: false);
|
||||
Tulip.Indicators.cci.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period-1];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
double TU_item = outdata[i - period + 1];
|
||||
Assert.Equal(QL_item,TU_item);
|
||||
//Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
[Fact]
|
||||
public void CMO() {
|
||||
double[][] arrin = { inclose };
|
||||
@@ -138,12 +141,24 @@ public class Tulip_Test
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void DECAY() {
|
||||
double[][] arrin = { inclose };
|
||||
double[][] arrout = { outdata };
|
||||
DECAY_Series QL = new(bars.Close, period, useNaN: false);
|
||||
Tulip.Indicators.decay.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip + 200; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void DEMA() {
|
||||
double[][] arrin = { inclose };
|
||||
double[][] arrout = { outdata };
|
||||
DEMA_Series QL = new(bars.Close, period, useNaN: false, useSMA: false);
|
||||
Tulip.Indicators.dema.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip*2; i--) {
|
||||
for (int i = QL.Length - 1; i > skip+200; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i-(period+period-2)];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
@@ -162,6 +177,18 @@ public class Tulip_Test
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void EDECAY() {
|
||||
double[][] arrin = { inclose };
|
||||
double[][] arrout = { outdata };
|
||||
DECAY_Series QL = new(bars.Close, period, exponential: true, useNaN: false);
|
||||
Tulip.Indicators.edecay.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip + 200; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void EMA()
|
||||
{
|
||||
double[][] arrin = { inclose };
|
||||
@@ -218,14 +245,15 @@ public class Tulip_Test
|
||||
|
||||
[Fact]
|
||||
public void HMA() {
|
||||
int p = 10;
|
||||
double[][] arrin = { inclose };
|
||||
double[][] arrout = { outdata };
|
||||
HMA_Series QL = new(bars.Close, period, false);
|
||||
Tulip.Indicators.hma.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--) {
|
||||
HMA_Series QL = new(bars.Close, p, false);
|
||||
Tulip.Indicators.hma.Run(inputs: arrin, options: new double[] { p }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip+2; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period - 1];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
double TU_item = arrout[0][i - p - 1];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits-2), Math.Exp(-digits-2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +341,7 @@ public class Tulip_Test
|
||||
Tulip.Indicators.obv.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period];
|
||||
double TU_item = arrout[0][i] + arrin[1][0];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
@@ -424,9 +452,9 @@ public class Tulip_Test
|
||||
double[][] arrout = { outdata };
|
||||
TEMA_Series QL = new(bars.Close, period, false);
|
||||
Tulip.Indicators.tema.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--) {
|
||||
for (int i = QL.Length - 1; i > skip+200; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period + 1];
|
||||
double TU_item = arrout[0][i - (period-1)*3];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
}
|
||||
}
|
||||
@@ -448,10 +476,10 @@ public class Tulip_Test
|
||||
double[][] arrout = { outdata };
|
||||
TRIX_Series QL = new(bars.Close, period);
|
||||
Tulip.Indicators.trix.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > period*10; i--) {
|
||||
for (int i = QL.Length - 1; i > period+200; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - (period*3) + 2];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits+2), Math.Exp(-digits+2));
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
@@ -479,15 +507,16 @@ public class Tulip_Test
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void ZLEMA() {
|
||||
public void ZLEMA() {
|
||||
int p = 4;
|
||||
double[][] arrin = { inclose };
|
||||
double[][] arrout = { outdata };
|
||||
ZLEMA_Series QL = new(bars.Close, period, false);
|
||||
Tulip.Indicators.zlema.Run(inputs: arrin, options: new double[] { period }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip; i--) {
|
||||
ZLEMA_Series QL = new(bars.Close, p, false);
|
||||
Tulip.Indicators.zlema.Run(inputs: arrin, options: new double[] { p }, outputs: arrout);
|
||||
for (int i = QL.Length - 1; i > skip+20; i--) {
|
||||
double QL_item = QL[i].v;
|
||||
double TU_item = arrout[0][i - period + 1];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits), Math.Exp(-digits));
|
||||
double TU_item = outdata[i];
|
||||
Assert.InRange(TU_item! - QL_item, -Math.Exp(-digits-2), Math.Exp(-digits-2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user