Skip to content

Commit ecc0f41

Browse files
committed
Add default value for *MAType parameters
1 parent 5fdf2e1 commit ecc0f41

10 files changed

Lines changed: 49 additions & 42 deletions

File tree

src/TALib.NETCore/TAFunc/TA_Apo.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
using System;
2+
13
namespace TALib
24
{
35
public static partial class Core
46
{
57
public static RetCode Apo(double[] inReal, int startIdx, int endIdx, double[] outReal, out int outBegIdx, out int outNbElement,
6-
MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
8+
MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
79
{
810
outBegIdx = outNbElement = 0;
911

@@ -25,7 +27,7 @@ public static RetCode Apo(double[] inReal, int startIdx, int endIdx, double[] ou
2527
}
2628

2729
public static RetCode Apo(decimal[] inReal, int startIdx, int endIdx, decimal[] outReal, out int outBegIdx, out int outNbElement,
28-
MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
30+
MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
2931
{
3032
outBegIdx = outNbElement = 0;
3133

@@ -46,14 +48,14 @@ public static RetCode Apo(decimal[] inReal, int startIdx, int endIdx, decimal[]
4648
optInMAType, tempBuffer, false);
4749
}
4850

49-
public static int ApoLookback(MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
51+
public static int ApoLookback(MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
5052
{
5153
if (optInFastPeriod < 2 || optInFastPeriod > 100000 || optInSlowPeriod < 2 || optInSlowPeriod > 100000)
5254
{
5355
return -1;
5456
}
5557

56-
return MaLookback(optInMAType, optInSlowPeriod <= optInFastPeriod ? optInFastPeriod : optInSlowPeriod);
58+
return MaLookback(optInMAType, Math.Max(optInSlowPeriod, optInFastPeriod));
5759
}
5860
}
5961
}

src/TALib.NETCore/TAFunc/TA_Bbands.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TALib
55
public static partial class Core
66
{
77
public static RetCode Bbands(double[] inReal, int startIdx, int endIdx, double[] outRealUpperBand, double[] outRealMiddleBand,
8-
double[] outRealLowerBand, out int outBegIdx, out int outNbElement, MAType optInMAType, int optInTimePeriod = 5,
8+
double[] outRealLowerBand, out int outBegIdx, out int outNbElement, MAType optInMAType = MAType.Sma, int optInTimePeriod = 5,
99
double optInNbDevUp = 2.0, double optInNbDevDn = 2.0)
1010
{
1111
outBegIdx = outNbElement = 0;
@@ -135,7 +135,7 @@ public static RetCode Bbands(double[] inReal, int startIdx, int endIdx, double[]
135135
}
136136

137137
public static RetCode Bbands(decimal[] inReal, int startIdx, int endIdx, decimal[] outRealUpperBand, decimal[] outRealMiddleBand,
138-
decimal[] outRealLowerBand, out int outBegIdx, out int outNbElement, MAType optInMAType, int optInTimePeriod = 5,
138+
decimal[] outRealLowerBand, out int outBegIdx, out int outNbElement, MAType optInMAType = MAType.Sma, int optInTimePeriod = 5,
139139
decimal optInNbDevUp = 2m, decimal optInNbDevDn = 2m)
140140
{
141141
outBegIdx = outNbElement = 0;
@@ -264,7 +264,7 @@ public static RetCode Bbands(decimal[] inReal, int startIdx, int endIdx, decimal
264264
return RetCode.Success;
265265
}
266266

267-
public static int BbandsLookback(MAType optInMAType, int optInTimePeriod = 5)
267+
public static int BbandsLookback(MAType optInMAType = MAType.Sma, int optInTimePeriod = 5)
268268
{
269269
if (optInTimePeriod < 2 || optInTimePeriod > 100000)
270270
{

src/TALib.NETCore/TAFunc/TA_Ma.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace TALib
33
public static partial class Core
44
{
55
public static RetCode Ma(double[] inReal, int startIdx, int endIdx, double[] outReal, out int outBegIdx, out int outNbElement,
6-
MAType optInMAType, int optInTimePeriod = 30)
6+
MAType optInMAType = MAType.Sma, int optInTimePeriod = 30)
77
{
88
outBegIdx = outNbElement = 0;
99

@@ -58,7 +58,7 @@ public static RetCode Ma(double[] inReal, int startIdx, int endIdx, double[] out
5858
}
5959

6060
public static RetCode Ma(decimal[] inReal, int startIdx, int endIdx, decimal[] outReal, out int outBegIdx, out int outNbElement,
61-
MAType optInMAType, int optInTimePeriod = 30)
61+
MAType optInMAType = MAType.Sma, int optInTimePeriod = 30)
6262
{
6363
outBegIdx = outNbElement = 0;
6464

@@ -112,7 +112,7 @@ public static RetCode Ma(decimal[] inReal, int startIdx, int endIdx, decimal[] o
112112
}
113113
}
114114

115-
public static int MaLookback(MAType optInMAType, int optInTimePeriod = 30)
115+
public static int MaLookback(MAType optInMAType = MAType.Sma, int optInTimePeriod = 30)
116116
{
117117
if (optInTimePeriod < 1 || optInTimePeriod > 100000)
118118
{

src/TALib.NETCore/TAFunc/TA_MacdExt.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ namespace TALib
55
public static partial class Core
66
{
77
public static RetCode MacdExt(double[] inReal, int startIdx, int endIdx, double[] outMacd, double[] outMacdSignal,
8-
double[] outMacdHist, out int outBegIdx, out int outNbElement, MAType optInFastMAType, MAType optInSlowMAType,
9-
MAType optInSignalMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26, int optInSignalPeriod = 9)
8+
double[] outMacdHist, out int outBegIdx, out int outNbElement, MAType optInFastMAType = MAType.Sma,
9+
MAType optInSlowMAType = MAType.Sma, MAType optInSignalMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26,
10+
int optInSignalPeriod = 9)
1011
{
1112
outBegIdx = outNbElement = 0;
1213

@@ -96,8 +97,9 @@ public static RetCode MacdExt(double[] inReal, int startIdx, int endIdx, double[
9697
}
9798

9899
public static RetCode MacdExt(decimal[] inReal, int startIdx, int endIdx, decimal[] outMacd, decimal[] outMacdSignal,
99-
decimal[] outMacdHist, out int outBegIdx, out int outNbElement, MAType optInFastMAType, MAType optInSlowMAType,
100-
MAType optInSignalMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26, int optInSignalPeriod = 9)
100+
decimal[] outMacdHist, out int outBegIdx, out int outNbElement, MAType optInFastMAType = MAType.Sma,
101+
MAType optInSlowMAType = MAType.Sma, MAType optInSignalMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26,
102+
int optInSignalPeriod = 9)
101103
{
102104
outBegIdx = outNbElement = 0;
103105

@@ -186,8 +188,8 @@ public static RetCode MacdExt(decimal[] inReal, int startIdx, int endIdx, decima
186188
return RetCode.Success;
187189
}
188190

189-
public static int MacdExtLookback(MAType optInFastMAType, MAType optInSlowMAType, MAType optInSignalMAType,
190-
int optInFastPeriod = 12, int optInSlowPeriod = 26, int optInSignalPeriod = 9)
191+
public static int MacdExtLookback(MAType optInFastMAType = MAType.Sma, MAType optInSlowMAType = MAType.Sma,
192+
MAType optInSignalMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26, int optInSignalPeriod = 9)
191193
{
192194
if (optInFastPeriod < 2 || optInFastPeriod > 100000 || optInSlowPeriod < 2 || optInSlowPeriod > 100000 ||
193195
optInSignalPeriod < 1 || optInSignalPeriod > 100000)

src/TALib.NETCore/TAFunc/TA_MacdFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public static RetCode MacdFix(decimal[] inReal, int startIdx, int endIdx, decima
4242
optInSignalPeriod);
4343
}
4444

45-
public static int MacdFixLookback(int optInSignalPeriod) => EmaLookback(26) + EmaLookback(optInSignalPeriod);
45+
public static int MacdFixLookback(int optInSignalPeriod = 9) => EmaLookback(26) + EmaLookback(optInSignalPeriod);
4646
}
4747
}

src/TALib.NETCore/TAFunc/TA_Mavp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace TALib
33
public static partial class Core
44
{
55
public static RetCode Mavp(double[] inReal, double[] inPeriods, int startIdx, int endIdx, double[] outReal, out int outBegIdx,
6-
out int outNbElement, MAType optInMAType, int optInMinPeriod = 2, int optInMaxPeriod = 30)
6+
out int outNbElement, MAType optInMAType = MAType.Sma, int optInMinPeriod = 2, int optInMaxPeriod = 30)
77
{
88
outBegIdx = outNbElement = 0;
99

@@ -83,7 +83,7 @@ public static RetCode Mavp(double[] inReal, double[] inPeriods, int startIdx, in
8383
}
8484

8585
public static RetCode Mavp(decimal[] inReal, decimal[] inPeriods, int startIdx, int endIdx, decimal[] outReal, out int outBegIdx,
86-
out int outNbElement, MAType optInMAType, int optInMinPeriod = 2, int optInMaxPeriod = 30)
86+
out int outNbElement, MAType optInMAType = MAType.Sma, int optInMinPeriod = 2, int optInMaxPeriod = 30)
8787
{
8888
outBegIdx = outNbElement = 0;
8989

@@ -162,7 +162,7 @@ public static RetCode Mavp(decimal[] inReal, decimal[] inPeriods, int startIdx,
162162
return RetCode.Success;
163163
}
164164

165-
public static int MavpLookback(MAType optInMAType, int optInMaxPeriod = 30)
165+
public static int MavpLookback(MAType optInMAType = MAType.Sma, int optInMaxPeriod = 30)
166166
{
167167
if (optInMaxPeriod < 2 || optInMaxPeriod > 100000)
168168
{

src/TALib.NETCore/TAFunc/TA_Ppo.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
using System;
2+
13
namespace TALib
24
{
35
public static partial class Core
46
{
57
public static RetCode Ppo(double[] inReal, int startIdx, int endIdx, double[] outReal, out int outBegIdx, out int outNbElement,
6-
MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
8+
MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
79
{
810
outBegIdx = outNbElement = 0;
911

@@ -20,12 +22,12 @@ public static RetCode Ppo(double[] inReal, int startIdx, int endIdx, double[] ou
2022

2123
var tempBuffer = new double[endIdx - startIdx + 1];
2224

23-
return TA_INT_PO(inReal, startIdx, endIdx, tempBuffer, out outBegIdx, out outNbElement, optInFastPeriod, optInSlowPeriod,
24-
optInMAType, outReal, true);
25+
return TA_INT_PO(inReal, startIdx, endIdx, outReal, out outBegIdx, out outNbElement, optInFastPeriod, optInSlowPeriod,
26+
optInMAType, tempBuffer, true);
2527
}
2628

2729
public static RetCode Ppo(decimal[] inReal, int startIdx, int endIdx, decimal[] outReal, out int outBegIdx, out int outNbElement,
28-
MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
30+
MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
2931
{
3032
outBegIdx = outNbElement = 0;
3133

@@ -42,18 +44,18 @@ public static RetCode Ppo(decimal[] inReal, int startIdx, int endIdx, decimal[]
4244

4345
var tempBuffer = new decimal[endIdx - startIdx + 1];
4446

45-
return TA_INT_PO(inReal, startIdx, endIdx, tempBuffer, out outBegIdx, out outNbElement, optInFastPeriod, optInSlowPeriod,
46-
optInMAType, outReal, true);
47+
return TA_INT_PO(inReal, startIdx, endIdx, outReal, out outBegIdx, out outNbElement, optInFastPeriod, optInSlowPeriod,
48+
optInMAType, tempBuffer, true);
4749
}
4850

49-
public static int PpoLookback(MAType optInMAType, int optInFastPeriod = 12, int optInSlowPeriod = 26)
51+
public static int PpoLookback(MAType optInMAType = MAType.Sma, int optInFastPeriod = 12, int optInSlowPeriod = 26)
5052
{
5153
if (optInFastPeriod < 2 || optInFastPeriod > 100000 || optInSlowPeriod < 2 || optInSlowPeriod > 100000)
5254
{
5355
return -1;
5456
}
5557

56-
return MaLookback(optInMAType, optInSlowPeriod <= optInFastPeriod ? optInFastPeriod : optInSlowPeriod);
58+
return MaLookback(optInMAType, Math.Max(optInSlowPeriod, optInFastPeriod));
5759
}
5860
}
5961
}

src/TALib.NETCore/TAFunc/TA_Stoch.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace TALib
55
public static partial class Core
66
{
77
public static RetCode Stoch(double[] inHigh, double[] inLow, double[] inClose, int startIdx, int endIdx, double[] outSlowK,
8-
double[] outSlowD, out int outBegIdx, out int outNbElement, MAType optInSlowKMAType, MAType optInSlowDMAType,
9-
int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
8+
double[] outSlowD, out int outBegIdx, out int outNbElement, MAType optInSlowKMAType = MAType.Sma,
9+
MAType optInSlowDMAType = MAType.Sma, int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
1010
{
1111
outBegIdx = outNbElement = 0;
1212

@@ -135,8 +135,8 @@ public static RetCode Stoch(double[] inHigh, double[] inLow, double[] inClose, i
135135
}
136136

137137
public static RetCode Stoch(decimal[] inHigh, decimal[] inLow, decimal[] inClose, int startIdx, int endIdx, decimal[] outSlowK,
138-
decimal[] outSlowD, out int outBegIdx, out int outNbElement, MAType optInSlowKMAType, MAType optInSlowDMAType,
139-
int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
138+
decimal[] outSlowD, out int outBegIdx, out int outNbElement, MAType optInSlowKMAType = MAType.Sma,
139+
MAType optInSlowDMAType = MAType.Sma, int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
140140
{
141141
outBegIdx = outNbElement = 0;
142142

@@ -264,8 +264,8 @@ public static RetCode Stoch(decimal[] inHigh, decimal[] inLow, decimal[] inClose
264264
return RetCode.Success;
265265
}
266266

267-
public static int StochLookback(MAType optInSlowKMAType, MAType optInSlowDmaType, int optInFastKPeriod = 5,
268-
int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
267+
public static int StochLookback(MAType optInSlowKMAType = MAType.Sma, MAType optInSlowDMAType = MAType.Sma,
268+
int optInFastKPeriod = 5, int optInSlowKPeriod = 3, int optInSlowDPeriod = 3)
269269
{
270270
if (optInFastKPeriod < 1 || optInFastKPeriod > 100000 || optInSlowKPeriod < 1 || optInSlowKPeriod > 100000 ||
271271
optInSlowDPeriod < 1 || optInSlowDPeriod > 100000)
@@ -275,7 +275,7 @@ public static int StochLookback(MAType optInSlowKMAType, MAType optInSlowDmaType
275275

276276
int retValue = optInFastKPeriod - 1;
277277
retValue += MaLookback(optInSlowKMAType, optInSlowKPeriod);
278-
retValue += MaLookback(optInSlowDmaType, optInSlowDPeriod);
278+
retValue += MaLookback(optInSlowDMAType, optInSlowDPeriod);
279279

280280
return retValue;
281281
}

src/TALib.NETCore/TAFunc/TA_StochF.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TALib
55
public static partial class Core
66
{
77
public static RetCode StochF(double[] inHigh, double[] inLow, double[] inClose, int startIdx, int endIdx, double[] outFastK,
8-
double[] outFastD, out int outBegIdx, out int outNbElement, MAType optInFastDMAType, int optInFastKPeriod = 5,
8+
double[] outFastD, out int outBegIdx, out int outNbElement, MAType optInFastDMAType = MAType.Sma, int optInFastKPeriod = 5,
99
int optInFastDPeriod = 3)
1010
{
1111
outBegIdx = outNbElement = 0;
@@ -126,7 +126,7 @@ public static RetCode StochF(double[] inHigh, double[] inLow, double[] inClose,
126126
}
127127

128128
public static RetCode StochF(decimal[] inHigh, decimal[] inLow, decimal[] inClose, int startIdx, int endIdx, decimal[] outFastK,
129-
decimal[] outFastD, out int outBegIdx, out int outNbElement, MAType optInFastDMAType, int optInFastKPeriod = 5,
129+
decimal[] outFastD, out int outBegIdx, out int outNbElement, MAType optInFastDMAType = MAType.Sma, int optInFastKPeriod = 5,
130130
int optInFastDPeriod = 3)
131131
{
132132
outBegIdx = outNbElement = 0;
@@ -246,7 +246,7 @@ public static RetCode StochF(decimal[] inHigh, decimal[] inLow, decimal[] inClos
246246
return RetCode.Success;
247247
}
248248

249-
public static int StochFLookback(MAType optInFastDMAType, int optInFastKPeriod = 5, int optInFastDPeriod = 3)
249+
public static int StochFLookback(MAType optInFastDMAType = MAType.Sma, int optInFastKPeriod = 5, int optInFastDPeriod = 3)
250250
{
251251
if (optInFastKPeriod < 1 || optInFastKPeriod > 100000 || optInFastDPeriod < 1 || optInFastDPeriod > 100000)
252252
{

src/TALib.NETCore/TAFunc/TA_StochRsi.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ namespace TALib
33
public static partial class Core
44
{
55
public static RetCode StochRsi(double[] inReal, int startIdx, int endIdx, double[] outFastK, double[] outFastD, out int outBegIdx,
6-
out int outNbElement, MAType optInFastDMAType, int optInTimePeriod = 14, int optInFastKPeriod = 5, int optInFastDPeriod = 3)
6+
out int outNbElement, MAType optInFastDMAType = MAType.Sma, int optInTimePeriod = 14, int optInFastKPeriod = 5,
7+
int optInFastDPeriod = 3)
78
{
89
outBegIdx = outNbElement = 0;
910

@@ -50,8 +51,8 @@ public static RetCode StochRsi(double[] inReal, int startIdx, int endIdx, double
5051
}
5152

5253
public static RetCode StochRsi(decimal[] inReal, int startIdx, int endIdx, decimal[] outFastK, decimal[] outFastD,
53-
out int outBegIdx, out int outNbElement, MAType optInFastDMAType, int optInTimePeriod = 14, int optInFastKPeriod = 5,
54-
int optInFastDPeriod = 3)
54+
out int outBegIdx, out int outNbElement, MAType optInFastDMAType = MAType.Sma, int optInTimePeriod = 14,
55+
int optInFastKPeriod = 5, int optInFastDPeriod = 3)
5556
{
5657
outBegIdx = outNbElement = 0;
5758

@@ -97,7 +98,7 @@ public static RetCode StochRsi(decimal[] inReal, int startIdx, int endIdx, decim
9798
return RetCode.Success;
9899
}
99100

100-
public static int StochRsiLookback(MAType optInFastDMAType, int optInTimePeriod = 14, int optInFastKPeriod = 5,
101+
public static int StochRsiLookback(MAType optInFastDMAType = MAType.Sma, int optInTimePeriod = 14, int optInFastKPeriod = 5,
101102
int optInFastDPeriod = 3)
102103
{
103104
if (optInTimePeriod < 2 || optInTimePeriod > 100000 || optInFastKPeriod < 1 || optInFastKPeriod > 100000 ||

0 commit comments

Comments
 (0)