-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathQCAlgorithm.Indicators.cs
More file actions
4568 lines (4140 loc) · 277 KB
/
QCAlgorithm.Indicators.cs
File metadata and controls
4568 lines (4140 loc) · 277 KB
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
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using QuantConnect.Data;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using System;
using System.Collections.Generic;
using System.Linq;
using Python.Runtime;
using QuantConnect.Util;
using static QuantConnect.StringExtensions;
using QuantConnect.Data.Common;
using QuantConnect.Python;
namespace QuantConnect.Algorithm
{
public partial class QCAlgorithm
{
private readonly List<Func<IBaseData, decimal>> _quoteRequiredFields = new() {
Field.BidPrice,
Field.AskPrice,
Field.BidClose,
Field.BidOpen,
Field.BidLow,
Field.BidHigh,
Field.AskClose,
Field.AskOpen,
Field.AskLow,
Field.AskHigh,
};
private static readonly HashSet<string> _ignoredProperties = new HashSet<string>
{
"Consolidators",
"Current",
"Previous",
"Name",
"Samples",
"IsReady",
"Window",
"Item",
"WarmUpPeriod",
"Period"
};
/// <summary>
/// Gets whether or not WarmUpIndicator is allowed to warm up indicators
/// </summary>
[Obsolete("Please use Settings.AutomaticIndicatorWarmUp")]
public bool EnableAutomaticIndicatorWarmUp
{
get
{
return Settings.AutomaticIndicatorWarmUp;
}
set
{
Settings.AutomaticIndicatorWarmUp = value;
}
}
/// <summary>
/// Creates a new Acceleration Bands indicator.
/// </summary>
/// <param name="symbol">The symbol whose Acceleration Bands we want.</param>
/// <param name="period">The period of the three moving average (middle, upper and lower band).</param>
/// <param name="width">A coefficient specifying the distance between the middle band and upper or lower bands.</param>
/// <param name="movingAverageType">Type of the moving average.</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar.</param>
/// <returns></returns>
[DocumentationAttribute(Indicators)]
public AccelerationBands ABANDS(Symbol symbol, int period, decimal width = 4, MovingAverageType movingAverageType = MovingAverageType.Simple,
Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"ABANDS({period},{width})", resolution);
var accelerationBands = new AccelerationBands(name, period, width, movingAverageType);
InitializeIndicator(accelerationBands, resolution, selector, symbol);
return accelerationBands;
}
/// <summary>
/// Creates a new AccumulationDistribution indicator.
/// </summary>
/// <param name="symbol">The symbol whose AD we want</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The AccumulationDistribution indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AccumulationDistribution AD(Symbol symbol, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, "AD", resolution);
var accumulationDistribution = new AccumulationDistribution(name);
InitializeIndicator(accumulationDistribution, resolution, selector, symbol);
return accumulationDistribution;
}
/// <summary>
/// Creates a new AccumulationDistributionOscillator indicator.
/// </summary>
/// <param name="symbol">The symbol whose ADOSC we want</param>
/// <param name="fastPeriod">The fast moving average period</param>
/// <param name="slowPeriod">The slow moving average period</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The AccumulationDistributionOscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AccumulationDistributionOscillator ADOSC(Symbol symbol, int fastPeriod, int slowPeriod, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"ADOSC({fastPeriod},{slowPeriod})", resolution);
var accumulationDistributionOscillator = new AccumulationDistributionOscillator(name, fastPeriod, slowPeriod);
InitializeIndicator(accumulationDistributionOscillator, resolution, selector, symbol);
return accumulationDistributionOscillator;
}
/// <summary>
/// Creates a Alpha indicator for the given target symbol in relation with the reference used.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="target">The target symbol whose Alpha value we want</param>
/// <param name="reference">The reference symbol to compare with the target symbol</param>
/// <param name="alphaPeriod">The period of the Alpha indicator</param>
/// <param name="betaPeriod">The period of the Beta indicator</param>
/// <param name="resolution">The resolution</param>
/// <param name="riskFreeRate">The risk free rate</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Alpha indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public Alpha A(Symbol target, Symbol reference, int alphaPeriod = 1, int betaPeriod = 252, Resolution? resolution = null, decimal? riskFreeRate = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var baseBame = riskFreeRate.HasValue ? $"A({alphaPeriod},{betaPeriod},{riskFreeRate})" : $"A({alphaPeriod},{betaPeriod})";
var name = CreateIndicatorName(target, baseBame, resolution);
// If risk free rate is not specified, use the default risk free rate model
IRiskFreeInterestRateModel riskFreeRateModel = riskFreeRate.HasValue
? new ConstantRiskFreeRateInterestRateModel(riskFreeRate.Value)
: new FuncRiskFreeRateInterestRateModel((datetime) => RiskFreeInterestRateModel.GetInterestRate(datetime));
var alpha = new Alpha(name, target, reference, alphaPeriod, betaPeriod, riskFreeRateModel);
InitializeIndicator(alpha, resolution, selector, target, reference);
return alpha;
}
/// <summary>
/// Creates a new Average Range (AR) indicator.
/// </summary>
/// <param name="symbol">The symbol whose Average Range we want to calculate</param>
/// <param name="period">The period over which to compute the Average Range</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator. If null, defaults to the Value property of BaseData (x => x.Value).</param>
/// <returns>The Average Range indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AverageRange AR(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"AR({period})", resolution);
var averageRange = new AverageRange(name, period);
InitializeIndicator(averageRange, resolution, selector, symbol);
return averageRange;
}
/// <summary>
/// Creates a new ARIMA indicator.
/// </summary>
/// <param name="symbol">The symbol whose ARIMA indicator we want</param>
/// <param name="arOrder">AR order (p) -- defines the number of past values to consider in the AR component of the model.</param>
/// <param name="diffOrder">Difference order (d) -- defines how many times to difference the model before fitting parameters.</param>
/// <param name="maOrder">MA order (q) -- defines the number of past values to consider in the MA component of the model.</param>
/// <param name="period">Size of the rolling series to fit onto</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ARIMA indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AutoRegressiveIntegratedMovingAverage ARIMA(Symbol symbol, int arOrder, int diffOrder, int maOrder, int period,
Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
return ARIMA(symbol, arOrder, diffOrder, maOrder, period, true, resolution, selector);
}
/// <summary>
/// Creates a new ARIMA indicator.
/// </summary>
/// <param name="symbol">The symbol whose ARIMA indicator we want</param>
/// <param name="arOrder">AR order (p) -- defines the number of past values to consider in the AR component of the model.</param>
/// <param name="diffOrder">Difference order (d) -- defines how many times to difference the model before fitting parameters.</param>
/// <param name="maOrder">MA order (q) -- defines the number of past values to consider in the MA component of the model.</param>
/// <param name="period">Size of the rolling series to fit onto</param>
/// <param name="intercept">Whether or not to include the intercept term</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ARIMA indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AutoRegressiveIntegratedMovingAverage ARIMA(Symbol symbol, int arOrder, int diffOrder, int maOrder, int period, bool intercept,
Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"ARIMA({arOrder},{diffOrder},{maOrder},{period})", resolution);
var arimaIndicator = new AutoRegressiveIntegratedMovingAverage(name, arOrder, diffOrder, maOrder, period, intercept);
InitializeIndicator(arimaIndicator, resolution, selector, symbol);
return arimaIndicator;
}
/// <summary>
/// Creates a new Average Directional Index indicator.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose Average Directional Index we seek</param>
/// <param name="resolution">The resolution.</param>
/// <param name="period">The period over which to compute the Average Directional Index</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Average Directional Index indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public AverageDirectionalIndex ADX(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"ADX({period})", resolution);
var averageDirectionalIndex = new AverageDirectionalIndex(name, period);
InitializeIndicator(averageDirectionalIndex, resolution, selector, symbol);
return averageDirectionalIndex;
}
/// <summary>
/// Creates a new Awesome Oscillator from the specified periods.
/// </summary>
/// <param name="symbol">The symbol whose Awesome Oscillator we seek</param>
/// <param name="resolution">The resolution.</param>
/// <param name="fastPeriod">The period of the fast moving average associated with the AO</param>
/// <param name="slowPeriod">The period of the slow moving average associated with the AO</param>
/// <param name="type">The type of moving average used when computing the fast and slow term. Defaults to simple moving average.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
[DocumentationAttribute(Indicators)]
public AwesomeOscillator AO(Symbol symbol, int fastPeriod, int slowPeriod, MovingAverageType type, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"AO({fastPeriod},{slowPeriod},{type})", resolution);
var awesomeOscillator = new AwesomeOscillator(name, fastPeriod, slowPeriod, type);
InitializeIndicator(awesomeOscillator, resolution, selector, symbol);
return awesomeOscillator;
}
/// <summary>
/// Creates a new AverageDirectionalMovementIndexRating indicator.
/// </summary>
/// <param name="symbol">The symbol whose ADXR we want</param>
/// <param name="period">The period over which to compute the ADXR</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The AverageDirectionalMovementIndexRating indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AverageDirectionalMovementIndexRating ADXR(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"ADXR({period})", resolution);
var averageDirectionalMovementIndexRating = new AverageDirectionalMovementIndexRating(name, period);
InitializeIndicator(averageDirectionalMovementIndexRating, resolution, selector, symbol);
return averageDirectionalMovementIndexRating;
}
/// <summary>
/// Creates a new ArnaudLegouxMovingAverage indicator.
/// </summary>
/// <param name="symbol">The symbol whose ALMA we want</param>
/// <param name="period">int - the number of periods to calculate the ALMA</param>
/// <param name="sigma"> int - this parameter is responsible for the shape of the curve coefficients.
/// </param>
/// <param name="offset">
/// decimal - This parameter allows regulating the smoothness and high sensitivity of the
/// Moving Average. The range for this parameter is [0, 1].
/// </param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ArnaudLegouxMovingAverage indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public ArnaudLegouxMovingAverage ALMA(Symbol symbol, int period, int sigma = 6, decimal offset = 0.85m, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"ALMA({period},{sigma},{offset})", resolution);
var arnaudLegouxMovingAverage = new ArnaudLegouxMovingAverage(name, period, sigma, offset);
InitializeIndicator(arnaudLegouxMovingAverage, resolution, selector, symbol);
return arnaudLegouxMovingAverage;
}
/// <summary>
/// Creates a new AbsolutePriceOscillator indicator.
/// </summary>
/// <param name="symbol">The symbol whose APO we want</param>
/// <param name="fastPeriod">The fast moving average period</param>
/// <param name="slowPeriod">The slow moving average period</param>
/// <param name="movingAverageType">The type of moving average to use</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The AbsolutePriceOscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public AbsolutePriceOscillator APO(Symbol symbol, int fastPeriod, int slowPeriod, MovingAverageType movingAverageType, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"APO({fastPeriod},{slowPeriod})", resolution);
var absolutePriceOscillator = new AbsolutePriceOscillator(name, fastPeriod, slowPeriod, movingAverageType);
InitializeIndicator(absolutePriceOscillator, resolution, selector, symbol);
return absolutePriceOscillator;
}
/// <summary>
/// Creates a new AroonOscillator indicator which will compute the AroonUp and AroonDown (as well as the delta)
/// </summary>
/// <param name="symbol">The symbol whose Aroon we seek</param>
/// <param name="period">The look back period for computing number of periods since maximum and minimum</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>An AroonOscillator configured with the specified periods</returns>
[DocumentationAttribute(Indicators)]
public AroonOscillator AROON(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
return AROON(symbol, period, period, resolution, selector);
}
/// <summary>
/// Creates a new AroonOscillator indicator which will compute the AroonUp and AroonDown (as well as the delta)
/// </summary>
/// <param name="symbol">The symbol whose Aroon we seek</param>
/// <param name="upPeriod">The look back period for computing number of periods since maximum</param>
/// <param name="downPeriod">The look back period for computing number of periods since minimum</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>An AroonOscillator configured with the specified periods</returns>
[DocumentationAttribute(Indicators)]
public AroonOscillator AROON(Symbol symbol, int upPeriod, int downPeriod, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"AROON({upPeriod},{downPeriod})", resolution);
var aroonOscillator = new AroonOscillator(name, upPeriod, downPeriod);
InitializeIndicator(aroonOscillator, resolution, selector, symbol);
return aroonOscillator;
}
/// <summary>
/// Creates a new AverageTrueRange indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose ATR we want</param>
/// <param name="period">The smoothing period used to smooth the computed TrueRange values</param>
/// <param name="type">The type of smoothing to use</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>A new AverageTrueRange indicator with the specified smoothing type and period</returns>
[DocumentationAttribute(Indicators)]
public AverageTrueRange ATR(Symbol symbol, int period, MovingAverageType type = MovingAverageType.Simple, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"ATR({period})", resolution);
var averageTrueRange = new AverageTrueRange(name, period, type);
InitializeIndicator(averageTrueRange, resolution, selector, symbol);
return averageTrueRange;
}
/// <summary>
/// Creates an AugenPriceSpike indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose APS we want</param>
/// <param name="period">The period of the APS</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The AugenPriceSpike indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public AugenPriceSpike APS(Symbol symbol, int period = 3, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"APS({period})", resolution);
var augenPriceSpike = new AugenPriceSpike(name, period);
InitializeIndicator(augenPriceSpike, resolution, selector, symbol);
return augenPriceSpike;
}
/// <summary>
/// Creates a new BollingerBands indicator which will compute the MiddleBand, UpperBand, LowerBand, and StandardDeviation
/// </summary>
/// <param name="symbol">The symbol whose BollingerBands we seek</param>
/// <param name="period">The period of the standard deviation and moving average (middle band)</param>
/// <param name="k">The number of standard deviations specifying the distance between the middle band and upper or lower bands</param>
/// <param name="movingAverageType">The type of moving average to be used</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>A BollingerBands configured with the specified period</returns>
[DocumentationAttribute(Indicators)]
public BollingerBands BB(Symbol symbol, int period, decimal k, MovingAverageType movingAverageType = MovingAverageType.Simple,
Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"BB({period},{k})", resolution);
var bollingerBands = new BollingerBands(name, period, k, movingAverageType);
InitializeIndicator(bollingerBands, resolution, selector, symbol);
return bollingerBands;
}
/// <summary>
/// Creates a Beta indicator for the given target symbol in relation with the reference used.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="target">The target symbol whose Beta value we want</param>
/// <param name="reference">The reference symbol to compare with the target symbol</param>
/// <param name="period">The period of the Beta indicator</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Beta indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public Beta B(Symbol target, Symbol reference, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(QuantConnect.Symbol.None, $"B({period})", resolution);
var beta = new Beta(name, target, reference, period);
InitializeIndicator(beta, resolution, selector, target, reference);
return beta;
}
/// <summary>
/// Creates a new Balance Of Power indicator.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose Balance Of Power we seek</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Balance Of Power indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public BalanceOfPower BOP(Symbol symbol, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, "BOP", resolution);
var balanceOfPower = new BalanceOfPower(name);
InitializeIndicator(balanceOfPower, resolution, selector, symbol);
return balanceOfPower;
}
/// <summary>
/// Initializes a new instance of the <see cref="CoppockCurve"/> indicator
/// </summary>
/// <param name="symbol">The symbol whose Coppock Curve we want</param>
/// <param name="shortRocPeriod">The period for the short ROC</param>
/// <param name="longRocPeriod">The period for the long ROC</param>
/// <param name="lwmaPeriod">The period for the LWMA</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Coppock Curve indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public CoppockCurve CC(Symbol symbol, int shortRocPeriod = 11, int longRocPeriod = 14, int lwmaPeriod = 10, Resolution? resolution = null,
Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"CC({shortRocPeriod},{longRocPeriod},{lwmaPeriod})", resolution);
var coppockCurve = new CoppockCurve(name, shortRocPeriod, longRocPeriod, lwmaPeriod);
InitializeIndicator(coppockCurve, resolution, selector, symbol);
return coppockCurve;
}
/// <summary>
/// Creates a Correlation indicator for the given target symbol in relation with the reference used.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="target">The target symbol of this indicator</param>
/// <param name="reference">The reference symbol of this indicator</param>
/// <param name="period">The period of this indicator</param>
/// <param name="correlationType">Correlation type</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Correlation indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public Correlation C(Symbol target, Symbol reference, int period, CorrelationType correlationType = CorrelationType.Pearson, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(QuantConnect.Symbol.None, $"C({period})", resolution);
var correlation = new Correlation(name, target, reference, period, correlationType);
InitializeIndicator(correlation, resolution, selector, target, reference);
return correlation;
}
/// <summary>
/// Creates a Covariance indicator for the given target symbol in relation with the reference used.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="target">The target symbol whose Covariance value we want</param>
/// <param name="reference">The reference symbol to compare with the target symbol</param>
/// <param name="period">The period of the Covariance indicator</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Covariance indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public Covariance COV(Symbol target, Symbol reference, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(QuantConnect.Symbol.None, $"COV({period})", resolution);
var covariance = new Covariance(name, target, reference, period);
InitializeIndicator(covariance, resolution, selector, target, reference);
return covariance;
}
/// <summary>
/// Creates a new CommodityChannelIndex indicator. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose CCI we want</param>
/// <param name="period">The period over which to compute the CCI</param>
/// <param name="movingAverageType">The type of moving average to use in computing the typical price average</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The CommodityChannelIndex indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public CommodityChannelIndex CCI(Symbol symbol, int period, MovingAverageType movingAverageType = MovingAverageType.Simple, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CCI({period})", resolution);
var commodityChannelIndex = new CommodityChannelIndex(name, period, movingAverageType);
InitializeIndicator(commodityChannelIndex, resolution, selector, symbol);
return commodityChannelIndex;
}
/// <summary>
/// Creates a new ChoppinessIndex indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose CHOP we want</param>
/// <param name="period">The input window period used to calculate max high and min low</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>A new ChoppinessIndex indicator with the window period</returns>
[DocumentationAttribute(Indicators)]
public ChoppinessIndex CHOP(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CHOP({period})", resolution);
var indicator = new ChoppinessIndex(name, period);
InitializeIndicator(indicator, resolution, selector, symbol);
return indicator;
}
/// <summary>
/// Creates a new Chande Kroll Stop indicator which will compute the short and lower stop.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose Chande Kroll Stop we seek.</param>
/// <param name="atrPeriod">The period over which to compute the average true range.</param>
/// <param name="atrMult">The ATR multiplier to be used to compute stops distance.</param>
/// <param name="period">The period over which to compute the max of high stop and min of low stop.</param>
/// <param name="resolution">The resolution.</param>
/// <param name="movingAverageType">The type of smoothing used to smooth the true range values</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Chande Kroll Stop indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public ChandeKrollStop CKS(Symbol symbol, int atrPeriod, decimal atrMult, int period, MovingAverageType movingAverageType = MovingAverageType.Wilders, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CKS({atrPeriod},{atrMult},{period})", resolution);
var indicator = new ChandeKrollStop(name, atrPeriod, atrMult, period, movingAverageType);
InitializeIndicator(indicator, resolution, selector, symbol);
return indicator;
}
/// <summary>
/// Creates a new ChaikinMoneyFlow indicator.
/// </summary>
/// <param name="symbol">The symbol whose CMF we want</param>
/// <param name="period">The period over which to compute the CMF</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The ChaikinMoneyFlow indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public ChaikinMoneyFlow CMF(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CMF({period})", resolution);
var chaikinMoneyFlow = new ChaikinMoneyFlow(name, period);
InitializeIndicator(chaikinMoneyFlow, resolution, selector, symbol);
return chaikinMoneyFlow;
}
/// <summary>
/// Creates a new Chaikin Oscillator indicator.
/// </summary>
/// <param name="symbol">The symbol whose CO we want</param>
/// <param name="fastPeriod">The fast moving average period</param>
/// <param name="slowPeriod">The slow moving average period</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The Chaikin Oscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public ChaikinOscillator CO(Symbol symbol, int fastPeriod, int slowPeriod, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"CO({fastPeriod},{slowPeriod})", resolution);
var chaikinOscillator = new ChaikinOscillator(name, fastPeriod, slowPeriod);
InitializeIndicator(chaikinOscillator, resolution, selector, symbol);
return chaikinOscillator;
}
/// <summary>
/// Creates a new ChandeMomentumOscillator indicator.
/// </summary>
/// <param name="symbol">The symbol whose CMO we want</param>
/// <param name="period">The period over which to compute the CMO</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ChandeMomentumOscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public ChandeMomentumOscillator CMO(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"CMO({period})", resolution);
var chandeMomentumOscillator = new ChandeMomentumOscillator(name, period);
InitializeIndicator(chandeMomentumOscillator, resolution, selector, symbol);
return chandeMomentumOscillator;
}
/// <summary>
/// Creates a new Connors Relative Strength Index (CRSI) indicator, which combines the traditional Relative Strength Index (RSI),
/// Streak RSI (SRSI), and Percent Rank to provide a more robust measure of market strength.
/// This indicator oscillates based on momentum, streak behavior, and price change over the specified periods.
/// </summary>
/// <param name="symbol">The symbol whose CRSI is to be calculated.</param>
/// <param name="rsiPeriod">The period for the traditional RSI calculation.</param>
/// <param name="rsiPeriodStreak">The period for the Streak RSI calculation (SRSI).</param>
/// <param name="lookBackPeriod">The look-back period for calculating the Percent Rank.</param>
/// <param name="resolution">The resolution of the data (optional).</param>
/// <param name="selector">Function to select a value from the BaseData to input into the indicator. Defaults to using the 'Value' property of BaseData if null.</param>
/// <returns>The Connors Relative Strength Index (CRSI) for the specified symbol and periods.</returns>
[DocumentationAttribute(Indicators)]
public ConnorsRelativeStrengthIndex CRSI(Symbol symbol, int rsiPeriod, int rsiPeriodStreak, int lookBackPeriod, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"CRSI({rsiPeriod},{rsiPeriodStreak},{lookBackPeriod})", resolution);
var connorsRelativeStrengthIndex = new ConnorsRelativeStrengthIndex(name, rsiPeriod, rsiPeriodStreak, lookBackPeriod);
InitializeIndicator(connorsRelativeStrengthIndex, resolution, selector, symbol);
return connorsRelativeStrengthIndex;
}
///<summary>
/// Creates a new DeMarker Indicator (DEM), an oscillator-type indicator measuring changes in terms of an asset's
/// High and Low tradebar values.
///</summary>
/// <param name="symbol">The symbol whose DEM we seek.</param>
/// <param name="period">The period of the moving average implemented</param>
/// <param name="type">Specifies the type of moving average to be used</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The DeMarker indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public DeMarkerIndicator DEM(Symbol symbol, int period, MovingAverageType type, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"DEM({period},{type})", resolution);
var deMarkerIndicator = new DeMarkerIndicator(name, period, type);
InitializeIndicator(deMarkerIndicator, resolution, selector, symbol);
return deMarkerIndicator;
}
/// <summary>
/// Creates a new Donchian Channel indicator which will compute the Upper Band and Lower Band.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose Donchian Channel we seek.</param>
/// <param name="upperPeriod">The period over which to compute the upper Donchian Channel.</param>
/// <param name="lowerPeriod">The period over which to compute the lower Donchian Channel.</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The Donchian Channel indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public DonchianChannel DCH(Symbol symbol, int upperPeriod, int lowerPeriod, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"DCH({upperPeriod},{lowerPeriod})", resolution);
var donchianChannel = new DonchianChannel(name, upperPeriod, lowerPeriod);
InitializeIndicator(donchianChannel, resolution, selector, symbol);
return donchianChannel;
}
/// <summary>
/// Overload shorthand to create a new symmetric Donchian Channel indicator which
/// has the upper and lower channels set to the same period length.
/// </summary>
/// <param name="symbol">The symbol whose Donchian Channel we seek.</param>
/// <param name="period">The period over which to compute the Donchian Channel.</param>
/// <param name="resolution">The resolution.</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a IBaseDataBar</param>
/// <returns>The Donchian Channel indicator for the requested symbol.</returns>
[DocumentationAttribute(Indicators)]
public DonchianChannel DCH(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
return DCH(symbol, period, period, resolution, selector);
}
/// <summary>
/// Creates a new Delta indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The option symbol whose values we want as an indicator</param>
/// <param name="mirrorOption">The mirror option for parity calculation</param>
/// <param name="riskFreeRate">The risk free rate</param>
/// <param name="dividendYield">The dividend yield</param>
/// <param name="optionModel">The option pricing model used to estimate Delta</param>
/// <param name="ivModel">The option pricing model used to estimate IV</param>
/// <param name="resolution">The desired resolution of the data</param>
/// <returns>A new Delta indicator for the specified symbol</returns>
[DocumentationAttribute(Indicators)]
public Delta D(Symbol symbol, Symbol mirrorOption = null, decimal? riskFreeRate = null, decimal? dividendYield = null,
OptionPricingModelType? optionModel = null, OptionPricingModelType? ivModel = null, Resolution? resolution = null)
{
var name = InitializeOptionIndicator<Delta>(symbol, out var riskFreeRateModel, out var dividendYieldModel, riskFreeRate, dividendYield, optionModel, resolution);
var delta = new Delta(name, symbol, riskFreeRateModel, dividendYieldModel, mirrorOption, optionModel, ivModel);
InitializeOptionIndicator(delta, resolution, symbol, mirrorOption);
return delta;
}
/// <summary>
/// Creates a new Delta indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The option symbol whose values we want as an indicator</param>
/// <param name="mirrorOption">The mirror option for parity calculation</param>
/// <param name="riskFreeRate">The risk free rate</param>
/// <param name="dividendYield">The dividend yield</param>
/// <param name="optionModel">The option pricing model used to estimate Delta</param>
/// <param name="ivModel">The option pricing model used to estimate IV</param>
/// <param name="resolution">The desired resolution of the data</param>
/// <returns>A new Delta indicator for the specified symbol</returns>
[DocumentationAttribute(Indicators)]
public Delta Δ(Symbol symbol, Symbol mirrorOption = null, decimal? riskFreeRate = null, decimal? dividendYield = null, OptionPricingModelType optionModel = OptionPricingModelType.BlackScholes,
OptionPricingModelType? ivModel = null, Resolution? resolution = null)
{
return D(symbol, mirrorOption, riskFreeRate, dividendYield, optionModel, ivModel, resolution);
}
/// <summary>
/// Creates a new DoubleExponentialMovingAverage indicator.
/// </summary>
/// <param name="symbol">The symbol whose DEMA we want</param>
/// <param name="period">The period over which to compute the DEMA</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The DoubleExponentialMovingAverage indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public DoubleExponentialMovingAverage DEMA(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"DEMA({period})", resolution);
var doubleExponentialMovingAverage = new DoubleExponentialMovingAverage(name, period);
InitializeIndicator(doubleExponentialMovingAverage, resolution, selector, symbol);
return doubleExponentialMovingAverage;
}
/// <summary>
/// Creates a new DerivativeOscillator indicator.
/// </summary>
/// <param name="symbol">The symbol whose DO we want</param>
/// <param name="rsiPeriod">The period over which to compute the RSI</param>
/// <param name="smoothingRsiPeriod">The period over which to compute the smoothing RSI</param>
/// <param name="doubleSmoothingRsiPeriod">The period over which to compute the double smoothing RSI</param>
/// <param name="signalLinePeriod">The period over which to compute the signal line</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The DerivativeOscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public DerivativeOscillator DO(Symbol symbol, int rsiPeriod, int smoothingRsiPeriod, int doubleSmoothingRsiPeriod, int signalLinePeriod, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"DO({rsiPeriod},{smoothingRsiPeriod},{doubleSmoothingRsiPeriod},{signalLinePeriod})", resolution);
var derivativeOscillator = new DerivativeOscillator(name, rsiPeriod, smoothingRsiPeriod, doubleSmoothingRsiPeriod, signalLinePeriod);
InitializeIndicator(derivativeOscillator, resolution, selector, symbol);
return derivativeOscillator;
}
/// <summary>
/// Creates a new <see cref="DetrendedPriceOscillator"/> indicator.
/// </summary>
/// <param name="symbol">The symbol whose DPO we want</param>
/// <param name="period">The period over which to compute the DPO</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>A new registered DetrendedPriceOscillator indicator for the requested symbol over the specified period</returns>
[DocumentationAttribute(Indicators)]
public DetrendedPriceOscillator DPO(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"DPO({period})", resolution);
var detrendedPriceOscillator = new DetrendedPriceOscillator(name, period);
InitializeIndicator(detrendedPriceOscillator, resolution, selector, symbol);
return detrendedPriceOscillator;
}
/// <summary>
/// Creates an ExponentialMovingAverage indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose EMA we want</param>
/// <param name="period">The period of the EMA</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ExponentialMovingAverage for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public ExponentialMovingAverage EMA(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
return EMA(symbol, period, ExponentialMovingAverage.SmoothingFactorDefault(period), resolution, selector);
}
/// <summary>
/// Creates an ExponentialMovingAverage indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose EMA we want</param>
/// <param name="period">The period of the EMA</param>
/// <param name="smoothingFactor">The percentage of data from the previous value to be carried into the next value</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
/// <returns>The ExponentialMovingAverage for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public ExponentialMovingAverage EMA(Symbol symbol, int period, decimal smoothingFactor, Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
var name = CreateIndicatorName(symbol, $"EMA({period})", resolution);
var exponentialMovingAverage = new ExponentialMovingAverage(name, period, smoothingFactor);
InitializeIndicator(exponentialMovingAverage, resolution, selector, symbol);
return exponentialMovingAverage;
}
/// <summary>
/// Creates an EaseOfMovementValue indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose EMV we want</param>
/// <param name="period">The period of the EMV</param>
/// <param name="scale">The length of the outputed value</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The EaseOfMovementValue indicator for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public EaseOfMovementValue EMV(Symbol symbol, int period = 1, int scale = 10000, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"EMV({period}, {scale})", resolution);
var easeOfMovementValue = new EaseOfMovementValue(name, period, scale);
InitializeIndicator(easeOfMovementValue, resolution, selector, symbol);
return easeOfMovementValue;
}
/// <summary>
/// Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The symbol whose values we want as an indicator</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <param name="filter">Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter</param>
/// <param name="fieldName">The name of the field being selected</param>
/// <returns>A new FilteredIdentity indicator for the specified symbol and selector</returns>
[DocumentationAttribute(Indicators)]
public FilteredIdentity FilteredIdentity(Symbol symbol, Func<IBaseData, IBaseDataBar> selector = null, Func<IBaseData, bool> filter = null, string fieldName = null)
{
var resolution = GetSubscription(symbol).Resolution;
return FilteredIdentity(symbol, resolution, selector, filter, fieldName);
}
/// <summary>
/// Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The symbol whose values we want as an indicator</param>
/// <param name="resolution">The desired resolution of the data</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <param name="filter">Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter</param>
/// <param name="fieldName">The name of the field being selected</param>
/// <returns>A new FilteredIdentity indicator for the specified symbol and selector</returns>
[DocumentationAttribute(Indicators)]
public FilteredIdentity FilteredIdentity(Symbol symbol, Resolution resolution, Func<IBaseData, IBaseDataBar> selector = null, Func<IBaseData, bool> filter = null, string fieldName = null)
{
var name = CreateIndicatorName(symbol, fieldName ?? "close", resolution);
var filteredIdentity = new FilteredIdentity(name, filter);
RegisterIndicator<IBaseData>(symbol, filteredIdentity, resolution, selector);
return filteredIdentity;
}
/// <summary>
/// Creates a new FilteredIdentity indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The symbol whose values we want as an indicator</param>
/// <param name="resolution">The desired resolution of the data</param>
/// <param name="selector">Selects a value from the BaseData, if null defaults to the .Value property (x => x.Value)</param>
/// <param name="filter">Filters the IBaseData send into the indicator, if null defaults to true (x => true) which means no filter</param>
/// <param name="fieldName">The name of the field being selected</param>
/// <returns>A new FilteredIdentity indicator for the specified symbol and selector</returns>
[DocumentationAttribute(Indicators)]
public FilteredIdentity FilteredIdentity(Symbol symbol, TimeSpan resolution, Func<IBaseData, IBaseDataBar> selector = null, Func<IBaseData, bool> filter = null, string fieldName = null)
{
var name = Invariant($"{symbol}({fieldName ?? "close"}_{resolution})");
var filteredIdentity = new FilteredIdentity(name, filter);
RegisterIndicator<IBaseData>(symbol, filteredIdentity, ResolveConsolidator(symbol, resolution), selector);
return filteredIdentity;
}
/// <summary>
/// Creates a new ForceIndex indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose ForceIndex we want</param>
/// <param name="period">The smoothing period used to smooth the computed ForceIndex values</param>
/// <param name="type">The type of smoothing to use</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>A new ForceIndex indicator with the specified smoothing type and period</returns>
[DocumentationAttribute(Indicators)]
public ForceIndex FI(Symbol symbol, int period, MovingAverageType type = MovingAverageType.Exponential, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"FI({period})", resolution);
var indicator = new ForceIndex(name, period, type);
InitializeIndicator(indicator, resolution, selector, symbol);
return indicator;
}
/// <summary>
/// Creates an FisherTransform indicator for the symbol.
/// The indicator will be automatically updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose FisherTransform we want</param>
/// <param name="period">The period of the FisherTransform</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The FisherTransform for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public FisherTransform FISH(Symbol symbol, int period, Resolution? resolution = null, Func<IBaseData, TradeBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"FISH({period})", resolution);
var fisherTransform = new FisherTransform(name, period);
InitializeIndicator(fisherTransform, resolution, selector, symbol);
return fisherTransform;
}
/// <summary>
/// Creates an FractalAdaptiveMovingAverage (FRAMA) indicator for the symbol. The indicator will be automatically
/// updated on the given resolution.
/// </summary>
/// <param name="symbol">The symbol whose FRAMA we want</param>
/// <param name="period">The period of the FRAMA</param>
/// <param name="longPeriod">The long period of the FRAMA</param>
/// <param name="resolution">The resolution</param>
/// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar</param>
/// <returns>The FRAMA for the given parameters</returns>
[DocumentationAttribute(Indicators)]
public FractalAdaptiveMovingAverage FRAMA(Symbol symbol, int period, int longPeriod = 198, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
{
var name = CreateIndicatorName(symbol, $"FRAMA({period},{longPeriod})", resolution);
var fractalAdaptiveMovingAverage = new FractalAdaptiveMovingAverage(name, period, longPeriod);
InitializeIndicator(fractalAdaptiveMovingAverage, resolution, selector, symbol);
return fractalAdaptiveMovingAverage;
}
/// <summary>
/// Creates a new Gamma indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The option symbol whose values we want as an indicator</param>
/// <param name="mirrorOption">The mirror option for parity calculation</param>
/// <param name="riskFreeRate">The risk free rate</param>
/// <param name="dividendYield">The dividend yield</param>
/// <param name="optionModel">The option pricing model used to estimate Gamma</param>
/// <param name="ivModel">The option pricing model used to estimate IV</param>
/// <param name="resolution">The desired resolution of the data</param>
/// <returns>A new Gamma indicator for the specified symbol</returns>
[DocumentationAttribute(Indicators)]
public Gamma G(Symbol symbol, Symbol mirrorOption = null, decimal? riskFreeRate = null, decimal? dividendYield = null,
OptionPricingModelType? optionModel = null, OptionPricingModelType? ivModel = null, Resolution? resolution = null)
{
var name = InitializeOptionIndicator<Gamma>(symbol, out var riskFreeRateModel, out var dividendYieldModel, riskFreeRate, dividendYield, optionModel, resolution);
var gamma = new Gamma(name, symbol, riskFreeRateModel, dividendYieldModel, mirrorOption, optionModel, ivModel);
InitializeOptionIndicator(gamma, resolution, symbol, mirrorOption);
return gamma;
}
/// <summary>
/// Creates a new Gamma indicator for the symbol The indicator will be automatically
/// updated on the symbol's subscription resolution
/// </summary>
/// <param name="symbol">The option symbol whose values we want as an indicator</param>
/// <param name="mirrorOption">The mirror option for parity calculation</param>
/// <param name="riskFreeRate">The risk free rate</param>