-
Notifications
You must be signed in to change notification settings - Fork 2
/
TA.pd
executable file
·3925 lines (3485 loc) · 180 KB
/
TA.pd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use strict;
use warnings;
our $VERSION = '0.010';
pp_setversion($VERSION);
pp_addpm({At=>'Top'},<<'END');
=head1 NAME
PDL::Finance::TA - Technical Analysis Library (http://ta-lib.org) bindings for PDL
=head1 SYNOPSIS
use PDL;
use PDL::Finance::TA;
# first load market data you want to analyze
my $open = ... ; # 1D piddle
my $high = ... ; # 1D piddle
my $low = ... ; # 1D piddle
my $close = ... ; # 1D piddle
my $volume = ... ; # 1D piddle
my $period = 20;
my $moving_average = ta_sma($close, $period);
my $money_flow_index = ta_mfi($high, $low, $close, $volume, $period);
# both $moving_average and $money_flow_index are 1D piddles
=head1 DESCRIPTION
TA-Lib library - L<http://ta-lib.org> - is a multi-platform tool for market analysis. TA-Lib is widely used by trading
software developers requiring to perform technical analysis of financial market data.
This module provides an L<PDL> interface for TA-Lib library. It combines rich TA-Lib functionality with excellent
L<PDL> performance of handling huge data.
If you are not a L<PDL> user you might be interested in L<Finance::TA|Finance::TA> module which provides approximately
the same set of functions working with common perl data structures (which is fine if you are not about to process large
data sets and if you generally do not worry about performace).
=head1 FUNCTION INDEX
=head2 Group: Overlap Studies
L<ta_bbands|/ta_bbands> (Bollinger Bands), L<ta_dema|/ta_dema> (Double Exponential Moving Average), L<ta_ema|/ta_ema> (Exponential Moving Average), L<ta_ht_trendline|/ta_ht_trendline> (Hilbert Transform - Instantaneous Trendline), L<ta_kama|/ta_kama> (Kaufman Adaptive Moving Average), L<ta_ma|/ta_ma> (Moving average), L<ta_mama|/ta_mama> (MESA Adaptive Moving Average), L<ta_mavp|/ta_mavp> (Moving average with variable period), L<ta_midpoint|/ta_midpoint> (MidPoint over period), L<ta_midprice|/ta_midprice> (Midpoint Price over period), L<ta_sar|/ta_sar> (Parabolic SAR), L<ta_sarext|/ta_sarext> (Parabolic SAR - Extended), L<ta_sma|/ta_sma> (Simple Moving Average), L<ta_t3|/ta_t3> (Triple Exponential Moving Average (T3)), L<ta_tema|/ta_tema> (Triple Exponential Moving Average), L<ta_trima|/ta_trima> (Triangular Moving Average), L<ta_wma|/ta_wma> (Weighted Moving Average)
=head2 Group: Volatility Indicators
L<ta_atr|/ta_atr> (Average True Range), L<ta_natr|/ta_natr> (Normalized Average True Range), L<ta_trange|/ta_trange> (True Range)
=head2 Group: Momentum Indicators
L<ta_adx|/ta_adx> (Average Directional Movement Index), L<ta_adxr|/ta_adxr> (Average Directional Movement Index Rating), L<ta_apo|/ta_apo> (Absolute Price Oscillator), L<ta_aroon|/ta_aroon> (Aroon), L<ta_aroonosc|/ta_aroonosc> (Aroon Oscillator), L<ta_bop|/ta_bop> (Balance Of Power), L<ta_cci|/ta_cci> (Commodity Channel Index), L<ta_cmo|/ta_cmo> (Chande Momentum Oscillator), L<ta_dx|/ta_dx> (Directional Movement Index), L<ta_macd|/ta_macd> (Moving Average Convergence/Divergence), L<ta_macdext|/ta_macdext> (MACD with controllable MA type), L<ta_macdfix|/ta_macdfix> (Moving Average Convergence/Divergence Fix 12/26), L<ta_mfi|/ta_mfi> (Money Flow Index), L<ta_minus_di|/ta_minus_di> (Minus Directional Indicator), L<ta_minus_dm|/ta_minus_dm> (Minus Directional Movement), L<ta_mom|/ta_mom> (Momentum), L<ta_plus_di|/ta_plus_di> (Plus Directional Indicator), L<ta_plus_dm|/ta_plus_dm> (Plus Directional Movement), L<ta_ppo|/ta_ppo> (Percentage Price Oscillator), L<ta_roc|/ta_roc> (Rate of change : ((price/prevPrice)-1)*100), L<ta_rocp|/ta_rocp> (Rate of change Percentage: (price-prevPrice)/prevPrice), L<ta_rocr|/ta_rocr> (Rate of change ratio: (price/prevPrice)), L<ta_rocr100|/ta_rocr100> (Rate of change ratio 100 scale: (price/prevPrice)*100), L<ta_rsi|/ta_rsi> (Relative Strength Index), L<ta_stoch|/ta_stoch> (Stochastic), L<ta_stochf|/ta_stochf> (Stochastic Fast), L<ta_stochrsi|/ta_stochrsi> (Stochastic Relative Strength Index), L<ta_trix|/ta_trix> (1-day Rate-Of-Change (ROC) of a Triple Smooth EMA), L<ta_ultosc|/ta_ultosc> (Ultimate Oscillator), L<ta_willr|/ta_willr> (Williams' %R)
=head2 Group: Cycle Indicators
L<ta_ht_dcperiod|/ta_ht_dcperiod> (Hilbert Transform - Dominant Cycle Period), L<ta_ht_dcphase|/ta_ht_dcphase> (Hilbert Transform - Dominant Cycle Phase), L<ta_ht_phasor|/ta_ht_phasor> (Hilbert Transform - Phasor Components), L<ta_ht_sine|/ta_ht_sine> (Hilbert Transform - SineWave), L<ta_ht_trendmode|/ta_ht_trendmode> (Hilbert Transform - Trend vs Cycle Mode)
=head2 Group: Volume Indicators
L<ta_ad|/ta_ad> (Chaikin A/D Line), L<ta_adosc|/ta_adosc> (Chaikin A/D Oscillator), L<ta_obv|/ta_obv> (On Balance Volume)
=head2 Group: Pattern Recognition
L<ta_cdl2crows|/ta_cdl2crows> (Two Crows), L<ta_cdl3blackcrows|/ta_cdl3blackcrows> (Three Black Crows), L<ta_cdl3inside|/ta_cdl3inside> (Three Inside Up/Down), L<ta_cdl3linestrike|/ta_cdl3linestrike> (Three-Line Strike ), L<ta_cdl3outside|/ta_cdl3outside> (Three Outside Up/Down), L<ta_cdl3starsinsouth|/ta_cdl3starsinsouth> (Three Stars In The South), L<ta_cdl3whitesoldiers|/ta_cdl3whitesoldiers> (Three Advancing White Soldiers), L<ta_cdlabandonedbaby|/ta_cdlabandonedbaby> (Abandoned Baby), L<ta_cdladvanceblock|/ta_cdladvanceblock> (Advance Block), L<ta_cdlbelthold|/ta_cdlbelthold> (Belt-hold), L<ta_cdlbreakaway|/ta_cdlbreakaway> (Breakaway), L<ta_cdlclosingmarubozu|/ta_cdlclosingmarubozu> (Closing Marubozu), L<ta_cdlconcealbabyswall|/ta_cdlconcealbabyswall> (Concealing Baby Swallow), L<ta_cdlcounterattack|/ta_cdlcounterattack> (Counterattack), L<ta_cdldarkcloudcover|/ta_cdldarkcloudcover> (Dark Cloud Cover), L<ta_cdldoji|/ta_cdldoji> (Doji), L<ta_cdldojistar|/ta_cdldojistar> (Doji Star), L<ta_cdldragonflydoji|/ta_cdldragonflydoji> (Dragonfly Doji), L<ta_cdlengulfing|/ta_cdlengulfing> (Engulfing Pattern), L<ta_cdleveningdojistar|/ta_cdleveningdojistar> (Evening Doji Star), L<ta_cdleveningstar|/ta_cdleveningstar> (Evening Star), L<ta_cdlgapsidesidewhite|/ta_cdlgapsidesidewhite> (Up/Down-gap side-by-side white lines), L<ta_cdlgravestonedoji|/ta_cdlgravestonedoji> (Gravestone Doji), L<ta_cdlhammer|/ta_cdlhammer> (Hammer), L<ta_cdlhangingman|/ta_cdlhangingman> (Hanging Man), L<ta_cdlharami|/ta_cdlharami> (Harami Pattern), L<ta_cdlharamicross|/ta_cdlharamicross> (Harami Cross Pattern), L<ta_cdlhighwave|/ta_cdlhighwave> (High-Wave Candle), L<ta_cdlhikkake|/ta_cdlhikkake> (Hikkake Pattern), L<ta_cdlhikkakemod|/ta_cdlhikkakemod> (Modified Hikkake Pattern), L<ta_cdlhomingpigeon|/ta_cdlhomingpigeon> (Homing Pigeon), L<ta_cdlidentical3crows|/ta_cdlidentical3crows> (Identical Three Crows), L<ta_cdlinneck|/ta_cdlinneck> (In-Neck Pattern), L<ta_cdlinvertedhammer|/ta_cdlinvertedhammer> (Inverted Hammer), L<ta_cdlkicking|/ta_cdlkicking> (Kicking), L<ta_cdlkickingbylength|/ta_cdlkickingbylength> (Kicking - bull/bear determined by the longer marubozu), L<ta_cdlladderbottom|/ta_cdlladderbottom> (Ladder Bottom), L<ta_cdllongleggeddoji|/ta_cdllongleggeddoji> (Long Legged Doji), L<ta_cdllongline|/ta_cdllongline> (Long Line Candle), L<ta_cdlmarubozu|/ta_cdlmarubozu> (Marubozu), L<ta_cdlmatchinglow|/ta_cdlmatchinglow> (Matching Low), L<ta_cdlmathold|/ta_cdlmathold> (Mat Hold), L<ta_cdlmorningdojistar|/ta_cdlmorningdojistar> (Morning Doji Star), L<ta_cdlmorningstar|/ta_cdlmorningstar> (Morning Star), L<ta_cdlonneck|/ta_cdlonneck> (On-Neck Pattern), L<ta_cdlpiercing|/ta_cdlpiercing> (Piercing Pattern), L<ta_cdlrickshawman|/ta_cdlrickshawman> (Rickshaw Man), L<ta_cdlrisefall3methods|/ta_cdlrisefall3methods> (Rising/Falling Three Methods), L<ta_cdlseparatinglines|/ta_cdlseparatinglines> (Separating Lines), L<ta_cdlshootingstar|/ta_cdlshootingstar> (Shooting Star), L<ta_cdlshortline|/ta_cdlshortline> (Short Line Candle), L<ta_cdlspinningtop|/ta_cdlspinningtop> (Spinning Top), L<ta_cdlstalledpattern|/ta_cdlstalledpattern> (Stalled Pattern), L<ta_cdlsticksandwich|/ta_cdlsticksandwich> (Stick Sandwich), L<ta_cdltakuri|/ta_cdltakuri> (Takuri (Dragonfly Doji with very long lower shadow)), L<ta_cdltasukigap|/ta_cdltasukigap> (Tasuki Gap), L<ta_cdlthrusting|/ta_cdlthrusting> (Thrusting Pattern), L<ta_cdltristar|/ta_cdltristar> (Tristar Pattern), L<ta_cdlunique3river|/ta_cdlunique3river> (Unique 3 River), L<ta_cdlupsidegap2crows|/ta_cdlupsidegap2crows> (Upside Gap Two Crows), L<ta_cdlxsidegap3methods|/ta_cdlxsidegap3methods> (Upside/Downside Gap Three Methods)
=head2 Group: Statistic Functions
L<ta_beta|/ta_beta> (Beta), L<ta_correl|/ta_correl> (Pearson's Correlation Coefficient (r)), L<ta_linearreg|/ta_linearreg> (Linear Regression), L<ta_linearreg_angle|/ta_linearreg_angle> (Linear Regression Angle), L<ta_linearreg_intercept|/ta_linearreg_intercept> (Linear Regression Intercept), L<ta_linearreg_slope|/ta_linearreg_slope> (Linear Regression Slope), L<ta_stddev|/ta_stddev> (Standard Deviation), L<ta_tsf|/ta_tsf> (Time Series Forecast), L<ta_var|/ta_var> (Variance)
=head2 Group: Price Transform
L<ta_avgprice|/ta_avgprice> (Average Price), L<ta_medprice|/ta_medprice> (Median Price), L<ta_typprice|/ta_typprice> (Typical Price), L<ta_wclprice|/ta_wclprice> (Weighted Close Price)
=head1 HANDLING BAD VALUES
Most of the available functions may return BAD values, for example:
use PDL;
use PDL::Finance::TA;
my $PD = pdl([0, 1, 2, 3, 4, 5]);
my $MA = ta_ma($PD, 3, 1);
print $MA; # prints: [BAD BAD 1 2 3 4]
All available functions handles BAD values in input piddles (BAD values at the beginning are skipped), for example:
use PDL;
use PDL::Finance::TA;
my $PD = pdl([0, 1, 2, 3, 4, 5]);
my $MA1 = ta_ma($PD, 3, 1);
say $MA1; # prints: [BAD BAD 1 2 3 4]
my $MA2 = ta_ma($MA1, 3, 1);
say $MA2; # prints: [BAD BAD BAD BAD 2 3]
=cut
END
pp_addpm({At=>'Bot'},<<'END');
=head1 LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=cut
END
pp_addhdr << 'MARKER';
#include <ta_libc.h>
/* Remove #define's for close and open symbols from XSUB.h */
#undef close
#undef open
MARKER
sub _finalize { # XXX-TODO this is not nice
my $type = shift;
my $mov = "";
my $for = "";
my $bad = "";
my $non = "";
for my $name (@_) {
$mov .= "Move(\$P($name)+first, \$P($name)+first+begidx, nbelem, $type);\n";
$for .= "for(i=0;i<first+begidx;i++) \$SETBAD(\$$name(n=>i));\n
for(i=first+begidx+nbelem;i<first+count;i++) \$SETBAD(\$$name(n=>i));\n";
$bad .= "\$PDLSTATESETBAD($name);\n";
$non .= "for(i=0;i<first+count;i++) \$SETBAD(\$$name(n=>i));\n";
}
return <<"END";
if (rc!=0) {
/* ta-lib function failed - returning all BADs or should we rather die? */
$non
$bad
}
else if (nbelem<=0 || count<=0) {
/* empty output - returning all BADs */
$non
$bad
}
else {
if (begidx>0 && begidx+nbelem <= count) {
$mov
}
if (first>0 || begidx>0) {
$bad
$for
}
}
END
}
pp_add_boot(<<EOB);
TA_Initialize();
EOB
pp_def('ta_bbands',
# TA_RetCode TA_BBANDS( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,double optInNbDevUp,double optInNbDevDn,ta_matype optInMAType, int *outBegIdx, int *outNBElement, double outRealUpperBand[], double outRealMiddleBand[], double outRealLowerBand[] );
Pars => 'double inpdl(n); int InTimePeriod(); double InNbDevUp(); double InNbDevDn(); int InMAType(); double [o]outpdlUpperBand(n); double [o]outpdlMiddleBand(n); double [o]outpdlLowerBand(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_BBANDS(0, count-1, $P(inpdl)+first, $InTimePeriod(), $InNbDevUp(), $InNbDevDn(), $InMAType(), &begidx, &nbelem, $P(outpdlUpperBand)+first, $P(outpdlMiddleBand)+first, $P(outpdlLowerBand)+first);
} . _finalize('double', qw/outpdlUpperBand outpdlMiddleBand outpdlLowerBand/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_BBANDS(0, count-1, $P(inpdl), $InTimePeriod(), $InNbDevUp(), $InNbDevDn(), $InMAType(), &begidx, &nbelem, $P(outpdlUpperBand), $P(outpdlMiddleBand), $P(outpdlLowerBand));
} . _finalize('double', qw/outpdlUpperBand outpdlMiddleBand outpdlLowerBand/),
Doc => <<'END',
Bollinger Bands
($outpdlUpperBand, $outpdlMiddleBand, $outpdlLowerBand) = ta_bbands($inpdl, $InTimePeriod, $InNbDevUp, $InNbDevDn, $InMAType);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 5
# valid range: min=2 max=100000
# $InNbDevUp [Deviation multiplier for upper band] - real number
# default: 2
# valid range: min=-3e+037 max=3e+037
# $InNbDevDn [Deviation multiplier for lower band] - real number
# default: 2
# valid range: min=-3e+037 max=3e+037
# $InMAType [Type of Moving Average] - integer
# default: 0
# valid values: 0=SMA 1=EMA 2=WMA 3=DEMA 4=TEMA 5=TRIMA 6=KAMA 7=MAMA 8=T3
# returns: $outpdlUpperBand - 1D piddle
# returns: $outpdlMiddleBand - 1D piddle
# returns: $outpdlLowerBand - 1D piddle
END
);
pp_def('ta_dema',
# TA_RetCode TA_DEMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_DEMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_DEMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Double Exponential Moving Average
$outpdl = ta_dema($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_ema',
# TA_RetCode TA_EMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_EMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_EMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Exponential Moving Average
$outpdl = ta_ema($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_ht_trendline',
# TA_RetCode TA_HT_TRENDLINE( int startIdx, int endIdx, const double inReal[], int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_HT_TRENDLINE(0, count-1, $P(inpdl)+first, &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_HT_TRENDLINE(0, count-1, $P(inpdl), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Hilbert Transform - Instantaneous Trendline
$outpdl = ta_ht_trendline($inpdl);
# $inpdl - 1D piddle with input data
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_kama',
# TA_RetCode TA_KAMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_KAMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_KAMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Kaufman Adaptive Moving Average
$outpdl = ta_kama($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_ma',
# TA_RetCode TA_MA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,ta_matype optInMAType, int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); int InMAType(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_MA(0, count-1, $P(inpdl)+first, $InTimePeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_MA(0, count-1, $P(inpdl), $InTimePeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Moving average
$outpdl = ta_ma($inpdl, $InTimePeriod, $InMAType);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=1 max=100000
# $InMAType [Type of Moving Average] - integer
# default: 0
# valid values: 0=SMA 1=EMA 2=WMA 3=DEMA 4=TEMA 5=TRIMA 6=KAMA 7=MAMA 8=T3
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_mama',
# TA_RetCode TA_MA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,ta_matype optInMAType, int *outBegIdx, int *outNBElement, double outReal[] );MA
Pars => 'double inpdl(n); double InFastLimit(); double InSlowLimit(); double [o]outMAMA(n); double [o]outFAMA(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_MAMA(0, count-1, $P(inpdl)+first, $InFastLimit(), $InSlowLimit(), &begidx, &nbelem, $P(outMAMA)+first, $P(outFAMA)+first);
} . _finalize('double', qw/outMAMA outFAMA/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_MAMA(0, count-1, $P(inpdl), $InFastLimit(), $InSlowLimit(), &begidx, &nbelem, $P(outMAMA), $P(outFAMA));
} . _finalize('double', qw/outMAMA outFAMA/),
Doc => <<'END',
MESA Adaptive Moving Average
($outMAMA, $outFAMA) = ta_mama($inpdl, $InFastLimit, $InSlowLimit);
# $inpdl - 1D piddle with input data
# $InFastLimit [Upper limit use in the adaptive algorithm] - real number
# default: 0.5
# valid range: min=0.01 max=0.99
# $InSlowLimit [Lower limit use in the adaptive algorithm] - real number
# default: 0.05
# valid range: min=0.01 max=0.99
# returns: $outMAMA - 1D piddle
# returns: $outFAMA - 1D piddle
END
);
pp_def('ta_mavp',
# TA_RetCode TA_MA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,ta_matype optInMAType, int *outBegIdx, int *outNBElement, double outReal[] );VP
Pars => 'double inpdl(n); double inPeriods(n); int InMinPeriod(); int InMaxPeriod(); int InMAType(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_MAVP(0, count-1, $P(inpdl)+first, $P(inPeriods), $InMinPeriod(), $InMaxPeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_MAVP(0, count-1, $P(inpdl), $P(inPeriods), $InMinPeriod(), $InMaxPeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Moving average with variable period
$outpdl = ta_mavp($inpdl, $inPeriods, $InMinPeriod, $InMaxPeriod, $InMAType);
# $inpdl - 1D piddle with input data
# $inPeriods - 1D piddle
# $InMinPeriod [Value less than minimum will be changed to Minimum period] - integer
# default: 2
# valid range: min=2 max=100000
# $InMaxPeriod [Value higher than maximum will be changed to Maximum period] - integer
# default: 30
# valid range: min=2 max=100000
# $InMAType [Type of Moving Average] - integer
# default: 0
# valid values: 0=SMA 1=EMA 2=WMA 3=DEMA 4=TEMA 5=TRIMA 6=KAMA 7=MAMA 8=T3
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_midpoint',
# TA_RetCode TA_MIDPOINT( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_MIDPOINT(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_MIDPOINT(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
MidPoint over period
$outpdl = ta_midpoint($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_midprice',
# TA_RetCode TA_MIDPRICE( int startIdx, int endIdx, const double inHigh[], const double inLow[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_MIDPRICE(0, count-1, $P(high)+first, $P(low)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_MIDPRICE(0, count-1, $P(high), $P(low), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Midpoint Price over period
$outpdl = ta_midprice($high, $low, $InTimePeriod);
# $high, $low - 1D piddles, both have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_sar',
# TA_RetCode TA_SAR( int startIdx, int endIdx, const double inHigh[], const double inLow[], double optInAcceleration,double optInMaximum,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); double InAcceleration(); double InMaximum(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_SAR(0, count-1, $P(high)+first, $P(low)+first, $InAcceleration(), $InMaximum(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_SAR(0, count-1, $P(high), $P(low), $InAcceleration(), $InMaximum(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Parabolic SAR
$outpdl = ta_sar($high, $low, $InAcceleration, $InMaximum);
# $high, $low - 1D piddles, both have to be the same size
# $InAcceleration [Acceleration Factor used up to the Maximum value] - real number
# default: 0.02
# valid range: min=0 max=3e+037
# $InMaximum [Acceleration Factor Maximum value] - real number
# default: 0.2
# valid range: min=0 max=3e+037
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_sarext',
# TA_RetCode TA_SAR( int startIdx, int endIdx, const double inHigh[], const double inLow[], double optInAcceleration,double optInMaximum,int *outBegIdx, int *outNBElement, double outReal[] );EXT
Pars => 'double high(n); double low(n); double InStartValue(); double InOffsetOnReverse(); double InAccelerationInitLong(); double InAccelerationLong(); double InAccelerationMaxLong(); double InAccelerationInitShort(); double InAccelerationShort(); double InAccelerationMaxShort(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_SAREXT(0, count-1, $P(high)+first, $P(low)+first, $InStartValue(), $InOffsetOnReverse(), $InAccelerationInitLong(), $InAccelerationLong(), $InAccelerationMaxLong(), $InAccelerationInitShort(), $InAccelerationShort(), $InAccelerationMaxShort(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_SAREXT(0, count-1, $P(high), $P(low), $InStartValue(), $InOffsetOnReverse(), $InAccelerationInitLong(), $InAccelerationLong(), $InAccelerationMaxLong(), $InAccelerationInitShort(), $InAccelerationShort(), $InAccelerationMaxShort(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Parabolic SAR - Extended
$outpdl = ta_sarext($high, $low, $InStartValue, $InOffsetOnReverse, $InAccelerationInitLong, $InAccelerationLong, $InAccelerationMaxLong, $InAccelerationInitShort, $InAccelerationShort, $InAccelerationMaxShort);
# $high, $low - 1D piddles, both have to be the same size
# $InStartValue [Start value and direction. 0 for Auto, >0 for Long, <0 for Short] - real number
# default: 0
# valid range: min=-3e+037 max=3e+037
# $InOffsetOnReverse [Percent offset added/removed to initial stop on short/long reversal] - real number
# default: 0
# valid range: min=0 max=3e+037
# $InAccelerationInitLong [Acceleration Factor initial value for the Long direction] - real number
# default: 0.02
# valid range: min=0 max=3e+037
# $InAccelerationLong [Acceleration Factor for the Long direction] - real number
# default: 0.02
# valid range: min=0 max=3e+037
# $InAccelerationMaxLong [Acceleration Factor maximum value for the Long direction] - real number
# default: 0.2
# valid range: min=0 max=3e+037
# $InAccelerationInitShort [Acceleration Factor initial value for the Short direction] - real number
# default: 0.02
# valid range: min=0 max=3e+037
# $InAccelerationShort [Acceleration Factor for the Short direction] - real number
# default: 0.02
# valid range: min=0 max=3e+037
# $InAccelerationMaxShort [Acceleration Factor maximum value for the Short direction] - real number
# default: 0.2
# valid range: min=0 max=3e+037
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_sma',
# TA_RetCode TA_SMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
for(i=0;i<count;i++) warn("XXX isbad[%d]=%d", i, $ISBAD($inpdl(n=>i)));
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
warn("XXX first=%d count=%d", first, count);
if (count>0) rc=TA_SMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first+first);
warn("XXX rc=%d begidx=%d nbelem=%d", rc, begidx, nbelem);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_SMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Simple Moving Average
$outpdl = ta_sma($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_t3',
# TA_RetCode TA_T3( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,double optInVFactor,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double InVFactor(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_T3(0, count-1, $P(inpdl)+first, $InTimePeriod(), $InVFactor(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_T3(0, count-1, $P(inpdl), $InTimePeriod(), $InVFactor(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Triple Exponential Moving Average (T3)
$outpdl = ta_t3($inpdl, $InTimePeriod, $InVFactor);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 5
# valid range: min=2 max=100000
# $InVFactor [Volume Factor] - real number
# default: 0.7
# valid range: min=0 max=1
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_tema',
# TA_RetCode TA_TEMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_TEMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_TEMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Triple Exponential Moving Average
$outpdl = ta_tema($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_trima',
# TA_RetCode TA_TRIMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_TRIMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_TRIMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Triangular Moving Average
$outpdl = ta_trima($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_wma',
# TA_RetCode TA_WMA( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_WMA(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_WMA(0, count-1, $P(inpdl), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Weighted Moving Average
$outpdl = ta_wma($inpdl, $InTimePeriod);
# $inpdl - 1D piddle with input data
# $InTimePeriod [Number of period] - integer
# default: 30
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_atr',
# TA_RetCode TA_ATR( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); double close(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_ATR(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_ATR(0, count-1, $P(high), $P(low), $P(close), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Average True Range
$outpdl = ta_atr($high, $low, $close, $InTimePeriod);
# $high, $low, $close - 1D piddles, all have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=1 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_natr',
# TA_RetCode TA_NATR( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); double close(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_NATR(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_NATR(0, count-1, $P(high), $P(low), $P(close), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Normalized Average True Range
$outpdl = ta_natr($high, $low, $close, $InTimePeriod);
# $high, $low, $close - 1D piddles, all have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=1 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_trange',
# TA_RetCode TA_TRANGE( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); double close(n); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_TRANGE(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_TRANGE(0, count-1, $P(high), $P(low), $P(close), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
True Range
$outpdl = ta_trange($high, $low, $close);
# $high, $low, $close - 1D piddles, all have to be the same size
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_adx',
# TA_RetCode TA_AD( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], const double inVolume[], int *outBegIdx, int *outNBElement, double outReal[] );X
Pars => 'double high(n); double low(n); double close(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_ADX(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_ADX(0, count-1, $P(high), $P(low), $P(close), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Average Directional Movement Index
$outpdl = ta_adx($high, $low, $close, $InTimePeriod);
# $high, $low, $close - 1D piddles, all have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_adxr',
# TA_RetCode TA_AD( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], const double inVolume[], int *outBegIdx, int *outNBElement, double outReal[] );XR
Pars => 'double high(n); double low(n); double close(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_ADXR(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_ADXR(0, count-1, $P(high), $P(low), $P(close), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Average Directional Movement Index Rating
$outpdl = ta_adxr($high, $low, $close, $InTimePeriod);
# $high, $low, $close - 1D piddles, all have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_apo',
# TA_RetCode TA_APO( int startIdx, int endIdx, const double inReal[], int optInFastPeriod,int optInSlowPeriod,ta_matype optInMAType, int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InFastPeriod(); int InSlowPeriod(); int InMAType(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_APO(0, count-1, $P(inpdl)+first, $InFastPeriod(), $InSlowPeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_APO(0, count-1, $P(inpdl), $InFastPeriod(), $InSlowPeriod(), $InMAType(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Absolute Price Oscillator
$outpdl = ta_apo($inpdl, $InFastPeriod, $InSlowPeriod, $InMAType);
# $inpdl - 1D piddle with input data
# $InFastPeriod [Number of period for the fast MA] - integer
# default: 12
# valid range: min=2 max=100000
# $InSlowPeriod [Number of period for the slow MA] - integer
# default: 26
# valid range: min=2 max=100000
# $InMAType [Type of Moving Average] - integer
# default: 0
# valid values: 0=SMA 1=EMA 2=WMA 3=DEMA 4=TEMA 5=TRIMA 6=KAMA 7=MAMA 8=T3
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_aroon',
# TA_RetCode TA_AROON( int startIdx, int endIdx, const double inHigh[], const double inLow[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outAroonDown[], double outAroonUp[] );
Pars => 'double high(n); double low(n); int InTimePeriod(); double [o]outAroonDown(n); double [o]outAroonUp(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_AROON(0, count-1, $P(high)+first, $P(low)+first, $InTimePeriod(), &begidx, &nbelem, $P(outAroonDown)+first, $P(outAroonUp)+first);
} . _finalize('double', qw/outAroonDown outAroonUp/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_AROON(0, count-1, $P(high), $P(low), $InTimePeriod(), &begidx, &nbelem, $P(outAroonDown), $P(outAroonUp));
} . _finalize('double', qw/outAroonDown outAroonUp/),
Doc => <<'END',
Aroon
($outAroonDown, $outAroonUp) = ta_aroon($high, $low, $InTimePeriod);
# $high, $low - 1D piddles, both have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outAroonDown - 1D piddle
# returns: $outAroonUp - 1D piddle
END
);
pp_def('ta_aroonosc',
# TA_RetCode TA_AROON( int startIdx, int endIdx, const double inHigh[], const double inLow[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outAroonDown[], double outAroonUp[] );OSC
Pars => 'double high(n); double low(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_AROONOSC(0, count-1, $P(high)+first, $P(low)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_AROONOSC(0, count-1, $P(high), $P(low), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Aroon Oscillator
$outpdl = ta_aroonosc($high, $low, $InTimePeriod);
# $high, $low - 1D piddles, both have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_bop',
# TA_RetCode TA_BOP( int startIdx, int endIdx, const double inOpen[], const double inHigh[], const double inLow[], const double inClose[], int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double open(n); double high(n); double low(n); double close(n); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_BOP(0, count-1, $P(open)+first, $P(high)+first, $P(low)+first, $P(close)+first, &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_BOP(0, count-1, $P(open), $P(high), $P(low), $P(close), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Balance Of Power
$outpdl = ta_bop($open, $high, $low, $close);
# $open, $high, $low, $close - 1D piddles, all have to be the same size
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_cci',
# TA_RetCode TA_CCI( int startIdx, int endIdx, const double inHigh[], const double inLow[], const double inClose[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double high(n); double low(n); double close(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($high(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_CCI(0, count-1, $P(high)+first, $P(low)+first, $P(close)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);
} . _finalize('double', qw/outpdl/),
Code => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
if (count>0) rc=TA_CCI(0, count-1, $P(high), $P(low), $P(close), $InTimePeriod(), &begidx, &nbelem, $P(outpdl));
} . _finalize('double', qw/outpdl/),
Doc => <<'END',
Commodity Channel Index
$outpdl = ta_cci($high, $low, $close, $InTimePeriod);
# $high, $low, $close - 1D piddles, all have to be the same size
# $InTimePeriod [Number of period] - integer
# default: 14
# valid range: min=2 max=100000
# returns: $outpdl - 1D piddle
END
);
pp_def('ta_cmo',
# TA_RetCode TA_CMO( int startIdx, int endIdx, const double inReal[], int optInTimePeriod,int *outBegIdx, int *outNBElement, double outReal[] );
Pars => 'double inpdl(n); int InTimePeriod(); double [o]outpdl(n);',
GenericTypes => ['D'],
HandleBad => 1,
BadCode => q{
TA_RetCode rc=0;
int begidx, nbelem, i, first=0, count=$SIZE(n);
while($ISBAD($inpdl(n=>first)) && count>0) { first++; count--; }
if (count>0) rc=TA_CMO(0, count-1, $P(inpdl)+first, $InTimePeriod(), &begidx, &nbelem, $P(outpdl)+first);