generated from EA31337/Strategy-Oscillator_Cross
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stg_Oscillator_Cross_Shift.mqh
828 lines (815 loc) · 55.8 KB
/
Stg_Oscillator_Cross_Shift.mqh
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
/**
* @file
* Implements Oscillator Cross Shift strategy.
*/
// Enums.
enum ENUM_STG_OSCILLATOR_CROSS_SHIFT_TYPE {
STG_OSCILLATOR_CROSS_SHIFT_TYPE_0_NONE = 0, // (None)
STG_OSCILLATOR_SHIFT_TYPE_AC, // AC: Accelerator/Decelerator
STG_OSCILLATOR_SHIFT_TYPE_AD, // AD: Accumulation/Distribution
STG_OSCILLATOR_SHIFT_TYPE_AO, // AO: Awesome
STG_OSCILLATOR_SHIFT_TYPE_ATR, // ATR
STG_OSCILLATOR_SHIFT_TYPE_BEARS, // Bears Power
STG_OSCILLATOR_SHIFT_TYPE_BULLS, // Bulls Power
STG_OSCILLATOR_SHIFT_TYPE_BWMFI, // BWMFI
STG_OSCILLATOR_SHIFT_TYPE_CCI, // CCI
STG_OSCILLATOR_SHIFT_TYPE_CHO, // CHO: Chaikin
STG_OSCILLATOR_SHIFT_TYPE_CHV, // CHV: Chaikin Volatility
STG_OSCILLATOR_SHIFT_TYPE_DEMARKER, // DeMarker
STG_OSCILLATOR_SHIFT_TYPE_MFI, // MFI
STG_OSCILLATOR_SHIFT_TYPE_MOM, // MOM: Momentum
STG_OSCILLATOR_SHIFT_TYPE_OBV, // OBV: On Balance Volume
STG_OSCILLATOR_SHIFT_TYPE_PVT, // PVT: Price and Volume Trend
STG_OSCILLATOR_SHIFT_TYPE_ROC, // ROC: Rate of Change
STG_OSCILLATOR_SHIFT_TYPE_RSI, // RSI
STG_OSCILLATOR_SHIFT_TYPE_STDDEV, // StdDev: Standard Deviation
STG_OSCILLATOR_SHIFT_TYPE_STOCH, // Stochastic
STG_OSCILLATOR_SHIFT_TYPE_TRIX, // TRIX: Triple Exponential Average
STG_OSCILLATOR_SHIFT_TYPE_UO, // UO: Ultimate Oscillator
STG_OSCILLATOR_SHIFT_TYPE_WAD, // WAD: Larry Williams' Accumulation/Distribution
STG_OSCILLATOR_SHIFT_TYPE_WPR, // WPR
STG_OSCILLATOR_SHIFT_TYPE_VOL, // VOL: Volumes
// STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADX, // ADX
// STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADXW, // ADXW
// STG_OSCILLATOR_CROSS_SHIFT_TYPE_MACD, // MACD
// STG_OSCILLATOR_CROSS_SHIFT_TYPE_RVI, // RVI: Relative Vigor Index
};
// User input params.
INPUT_GROUP("Oscillator Cross Shift strategy: main strategy params");
INPUT ENUM_STG_OSCILLATOR_CROSS_SHIFT_TYPE Oscillator_Cross_Shift_Type =
STG_OSCILLATOR_SHIFT_TYPE_AD; // Oscillator type
INPUT_GROUP("Oscillator Cross Shift strategy: strategy params");
INPUT float Oscillator_Cross_Shift_LotSize = 0; // Lot size
INPUT int Oscillator_Cross_Shift_SignalOpenMethod = 6; // Signal open method
INPUT float Oscillator_Cross_Shift_SignalOpenLevel = 5.0f; // Signal open level
INPUT int Oscillator_Cross_Shift_SignalOpenFilterMethod = 32; // Signal open filter method
INPUT int Oscillator_Cross_Shift_SignalOpenFilterTime = 3; // Signal open filter time (0-31)
INPUT int Oscillator_Cross_Shift_SignalOpenBoostMethod = 0; // Signal open boost method
INPUT int Oscillator_Cross_Shift_SignalCloseMethod = 0; // Signal close method
INPUT int Oscillator_Cross_Shift_SignalCloseFilter = 32; // Signal close filter (-127-127)
INPUT float Oscillator_Cross_Shift_SignalCloseLevel = 5.0f; // Signal close level
INPUT int Oscillator_Cross_Shift_PriceStopMethod = 0; // Price limit method
INPUT float Oscillator_Cross_Shift_PriceStopLevel = 2; // Price limit level
INPUT int Oscillator_Cross_Shift_TickFilterMethod = 32; // Tick filter method (0-255)
INPUT float Oscillator_Cross_Shift_MaxSpread = 4.0; // Max spread to trade (in pips)
INPUT short Oscillator_Cross_Shift_Shift = 0; // Shift
INPUT float Oscillator_Cross_Shift_OrderCloseLoss = 80; // Order close loss
INPUT float Oscillator_Cross_Shift_OrderCloseProfit = 80; // Order close profit
INPUT int Oscillator_Cross_Shift_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0)
INPUT_GROUP("Oscillator strategy: AC oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_AC_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_AC_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_AC_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: AD oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_AD_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_AD_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_AD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: ATR oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_ATR_Period = 13; // Period
INPUT int Oscillator_Cross_Shift_Indi_ATR_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_ATR_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_ATR_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Awesome oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_Awesome_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_Awesome_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_Awesome_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: BearsPower oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_BearsPower_Period = 30; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_BearsPower_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_BearsPower_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_BearsPower_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_BearsPower_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: BullsPower oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_BullsPower_Period = 30; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_BullsPower_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_BullsPower_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_BullsPower_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_BullsPower_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: BWMFI oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_BWMFI_Shift = 1; // Shift
INPUT int Oscillator_Cross_Shift_Indi_BWMFI_Shift2 = 1; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_BWMFI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: CCI oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_CCI_Period = 20; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_CCI_Applied_Price = PRICE_TYPICAL; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_CCI_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_CCI_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_CCI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Chaikin oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_CHO_InpFastMA = 10; // Fast EMA period
INPUT int Oscillator_Cross_Shift_Indi_CHO_InpSlowMA = 30; // Slow MA period
INPUT ENUM_MA_METHOD Oscillator_Cross_Shift_Indi_CHO_InpSmoothMethod = MODE_SMMA; // MA method
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Shift_Indi_CHO_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Shift_Indi_CHO_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_CHO_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_CHO_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Chaikin Volatility oscillator params");
INPUT unsigned int Oscillator_Cross_Shift_Indi_CHV_Smooth_Period; // Smooth period
INPUT unsigned int Oscillator_Cross_Shift_Indi_CHV_Period; // Period
INPUT ENUM_CHV_SMOOTH_METHOD Oscillator_Cross_Shift_Indi_CHV_Smooth_Method; // Smooth method
INPUT int Oscillator_Cross_Shift_Indi_CHV_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_CHV_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_CHV_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: DeMarker indicator params");
INPUT int Oscillator_Cross_Shift_Indi_DeMarker_Period = 23; // Period
INPUT int Oscillator_Cross_Shift_Indi_DeMarker_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_DeMarker_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_DeMarker_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: MFI oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_MFI_MA_Period = 22; // MA Period
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Shift_Indi_MFI_Applied_Volume = (ENUM_APPLIED_VOLUME)0; // Applied volume.
INPUT int Oscillator_Cross_Shift_Indi_MFI_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_MFI_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_MFI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Momentum oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_Momentum_Period = 12; // Averaging period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_Momentum_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_Momentum_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_Momentum_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_Momentum_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: OBV oscillator params");
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_OBV_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_OBV_Shift = 1; // Shift
INPUT int Oscillator_Cross_Shift_Indi_OBV_Shift2 = 1; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_OBV_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: PVT oscillator params");
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Shift_Indi_PVT_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Shift_Indi_PVT_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_PVT_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_PVT_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: ROC oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_ROC_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_ROC_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_ROC_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_ROC_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_ROC_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: RSI oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_RSI_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_RSI_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_RSI_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_RSI_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_RSI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: StdDev oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_StdDev_MA_Period = 24; // Period
INPUT int Oscillator_Cross_Shift_Indi_StdDev_MA_Shift = 0; // MA Shift
INPUT ENUM_MA_METHOD Oscillator_Cross_Shift_Indi_StdDev_MA_Method = (ENUM_MA_METHOD)3; // MA Method
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_StdDev_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_StdDev_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_StdDev_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_StdDev_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Stochastic oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_Stochastic_KPeriod = 8; // K line period
INPUT int Oscillator_Cross_Shift_Indi_Stochastic_DPeriod = 12; // D line period
INPUT int Oscillator_Cross_Shift_Indi_Stochastic_Slowing = 12; // Slowing
INPUT ENUM_MA_METHOD Oscillator_Cross_Shift_Indi_Stochastic_MA_Method = MODE_EMA; // Moving Average method
INPUT ENUM_STO_PRICE Oscillator_Cross_Shift_Indi_Stochastic_Price_Field = 0; // Price (0 - Low/High or 1 - Close/Close)
INPUT int Oscillator_Cross_Shift_Indi_Stochastic_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_Stochastic_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_Stochastic_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: TRIX oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_TRIX_InpPeriodEMA = 14; // EMA period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_TRIX_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_TRIX_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_TRIX_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_TRIX_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Ultimate oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_UO_InpFastPeriod = 7; // Fast ATR period
INPUT int Oscillator_Cross_Shift_Indi_UO_InpMiddlePeriod = 14; // Middle ATR period
INPUT int Oscillator_Cross_Shift_Indi_UO_InpSlowPeriod = 28; // Slow ATR period
INPUT int Oscillator_Cross_Shift_Indi_UO_InpFastK = 4; // Fast K
INPUT int Oscillator_Cross_Shift_Indi_UO_InpMiddleK = 2; // Middle K
INPUT int Oscillator_Cross_Shift_Indi_UO_InpSlowK = 1; // Slow K
INPUT int Oscillator_Cross_Shift_Indi_UO_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_UO_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_UO_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Williams' Accumulation/Distribution oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_WAD_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_WAD_Shift2 = 0; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_WAD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: WPR oscillator params");
INPUT int Oscillator_Cross_Shift_Indi_WPR_Period = 18; // Period
INPUT int Oscillator_Cross_Shift_Indi_WPR_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_WPR_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_WPR_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: Volumes oscillator params");
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Shift_Indi_VOL_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Shift_Indi_VOL_Shift = 0; // Shift
INPUT int Oscillator_Cross_Shift_Indi_VOL_Shift2 = 10; // Shift 2
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_VOL_SourceType = IDATA_BUILTIN; // Source type
/* @todo
INPUT_GROUP("Oscillator Cross Shift strategy: ADX indicator params");
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Shift_Indi_ADX_Fast_Line = LINE_PLUSDI; // Fast line
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Shift_Indi_ADX_Slow_Line = LINE_MINUSDI; // Slow line to cross_shift
INPUT int Oscillator_Cross_Shift_Indi_ADX_Period = 16; // Averaging period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_ADX_AppliedPrice = PRICE_TYPICAL; // Applied price
INPUT int Oscillator_Cross_Shift_Indi_ADX_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_ADX_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Shift strategy: ADXW indicator params");
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Shift_Indi_ADXW_Fast_Line = LINE_PLUSDI; // Fast line
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Shift_Indi_ADXW_Slow_Line = LINE_MINUSDI; // Slow line to cross_shift
INPUT int Oscillator_Cross_Shift_Indi_ADXW_Period = 16; // Averaging period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_ADXW_AppliedPrice = PRICE_TYPICAL; // Applied price
INPUT int Oscillator_Cross_Shift_Indi_ADXW_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_ADXW_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: MACD indicator params");
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Shift_Indi_MACD_Fast_Line = LINE_SIGNAL; // Fast line
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Shift_Indi_MACD_Slow_Line = LINE_MAIN; // Slow line
INPUT int Oscillator_Cross_Shift_Indi_MACD_Period_Fast = 6; // Period Fast
INPUT int Oscillator_Cross_Shift_Indi_MACD_Period_Slow = 34; // Period Slow
INPUT int Oscillator_Cross_Shift_Indi_MACD_Period_Signal = 10; // Period Signal
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Shift_Indi_MACD_Applied_Price = PRICE_OPEN; // Applied Price
INPUT int Oscillator_Cross_Shift_Indi_MACD_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_MACD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator strategy: RVI indicator params");
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Shift_Indi_RVI_Fast_Line = LINE_SIGNAL; // Fast line
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Shift_Indi_RVI_Slow_Line = LINE_MAIN; // Slow line
INPUT unsigned int Oscillator_Cross_Shift_Indi_RVI_Period = 12; // Averaging
period INPUT int Oscillator_Cross_Shift_Indi_RVI_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Shift_Indi_RVI_SourceType = IDATA_BUILTIN; // Source type
*/
// Structs.
// Defines struct with default user strategy values.
struct Stg_Oscillator_Cross_Shift_Params_Defaults : StgParams {
uint shift1, shift2;
Stg_Oscillator_Cross_Shift_Params_Defaults()
: StgParams(::Oscillator_Cross_Shift_SignalOpenMethod, ::Oscillator_Cross_Shift_SignalOpenFilterMethod,
::Oscillator_Cross_Shift_SignalOpenLevel, ::Oscillator_Cross_Shift_SignalOpenBoostMethod,
::Oscillator_Cross_Shift_SignalCloseMethod, ::Oscillator_Cross_Shift_SignalCloseFilter,
::Oscillator_Cross_Shift_SignalCloseLevel, ::Oscillator_Cross_Shift_PriceStopMethod,
::Oscillator_Cross_Shift_PriceStopLevel, ::Oscillator_Cross_Shift_TickFilterMethod,
::Oscillator_Cross_Shift_MaxSpread, ::Oscillator_Cross_Shift_Shift),
shift1(0),
shift2(0) {
Set(STRAT_PARAM_LS, ::Oscillator_Cross_Shift_LotSize);
Set(STRAT_PARAM_OCL, ::Oscillator_Cross_Shift_OrderCloseLoss);
Set(STRAT_PARAM_OCP, ::Oscillator_Cross_Shift_OrderCloseProfit);
Set(STRAT_PARAM_OCT, ::Oscillator_Cross_Shift_OrderCloseTime);
Set(STRAT_PARAM_SOFT, ::Oscillator_Cross_Shift_SignalOpenFilterTime);
}
// Getters.
uint GetShift1() { return shift1; }
uint GetShift2() { return shift2; }
// Setters.
void SetShift1(uint _value) { shift1 = _value; }
void SetShift2(uint _value) { shift2 = _value; }
};
class Stg_Oscillator_Cross_Shift : public Strategy {
protected:
Stg_Oscillator_Cross_Shift_Params_Defaults ssparams;
public:
Stg_Oscillator_Cross_Shift(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "")
: Strategy(_sparams, _tparams, _cparams, _name) {}
static Stg_Oscillator_Cross_Shift *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) {
// Initialize strategy initial values.
Stg_Oscillator_Cross_Shift_Params_Defaults stg_oscillator_cross_shift_defaults;
StgParams _stg_params(stg_oscillator_cross_shift_defaults);
// Initialize Strategy instance.
ChartParams _cparams(_tf, _Symbol);
TradeParams _tparams;
Stg_Oscillator_Cross_Shift *_strat =
new Stg_Oscillator_Cross_Shift(_stg_params, _tparams, _cparams, "Oscillator Cross Shift");
_strat.ssparams = stg_oscillator_cross_shift_defaults;
return _strat;
}
/**
* Validate oscillator's entry.
*/
bool IsValidEntry(IndicatorBase *_indi, int _shift = 0) {
bool _result = true;
switch (::Oscillator_Cross_Shift_Type) {
case STG_OSCILLATOR_SHIFT_TYPE_AC:
_result &= dynamic_cast<Indi_AC *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_AC *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_AD:
_result &= dynamic_cast<Indi_AD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_AD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_AO:
_result &= dynamic_cast<Indi_AO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_AO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_ATR:
_result &= dynamic_cast<Indi_ATR *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_ATR *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_BEARS:
_result &= dynamic_cast<Indi_BearsPower *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_BearsPower *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_BULLS:
_result &= dynamic_cast<Indi_BullsPower *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_BullsPower *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_BWMFI:
_result &= dynamic_cast<Indi_BWMFI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_BWMFI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_CCI:
_result &= dynamic_cast<Indi_CCI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_CCI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_CHO:
_result &= dynamic_cast<Indi_CHO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_CHO *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_CHV:
_result &= dynamic_cast<Indi_CHV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_CHV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_DEMARKER:
_result &= dynamic_cast<Indi_DeMarker *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_DeMarker *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_MFI:
_result &= dynamic_cast<Indi_MFI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_MFI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_MOM:
_result &= dynamic_cast<Indi_Momentum *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_Momentum *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_OBV:
_result &= dynamic_cast<Indi_OBV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_OBV *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_PVT:
_result &= dynamic_cast<Indi_PriceVolumeTrend *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_PriceVolumeTrend *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_ROC:
_result &= dynamic_cast<Indi_RateOfChange *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RateOfChange *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_RSI:
_result &= dynamic_cast<Indi_RSI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RSI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_STDDEV:
_result &= dynamic_cast<Indi_StdDev *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_StdDev *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_STOCH:
_result &= dynamic_cast<Indi_Stochastic *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_Stochastic *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_TRIX:
_result &= dynamic_cast<Indi_TRIX *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_TRIX *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_UO:
_result &= dynamic_cast<Indi_UltimateOscillator *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_UltimateOscillator *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_WPR:
_result &= dynamic_cast<Indi_WPR *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_WPR *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_WAD:
_result &= dynamic_cast<Indi_WilliamsAD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_WilliamsAD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_SHIFT_TYPE_VOL:
_result &= dynamic_cast<Indi_Volumes *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_Volumes *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
/* @todo
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADX:
_result &= dynamic_cast<Indi_ADX *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_ADX *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADXW:
_result &= dynamic_cast<Indi_ADXW *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_ADXW *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_MACD:
_result &= dynamic_cast<Indi_MACD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_MACD *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_RVI:
_result &= dynamic_cast<Indi_RVI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) &&
dynamic_cast<Indi_RVI *>(_indi).GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
break;
*/
default:
break;
}
return _result;
}
/**
* Event on strategy's init.
*/
void OnInit() {
// Initialize indicators.
switch (Oscillator_Cross_Shift_Type) {
case STG_OSCILLATOR_SHIFT_TYPE_AC: // AC
{
IndiACParams _indi_params(::Oscillator_Cross_Shift_Indi_AC_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Cross_Shift_Indi_AC_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_AC_Shift2);
SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Cross_Shift_Indi_AC_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_AC_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_AC_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_AD: // AD
{
IndiADParams _indi_params(::Oscillator_Cross_Shift_Indi_AD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Cross_Shift_Indi_AD_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_AD_Shift2);
SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Cross_Shift_Indi_AD_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_AD_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_AD_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_AO: // AO
{
IndiAOParams _indi_params(::Oscillator_Cross_Shift_Indi_Awesome_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Cross_Shift_Indi_Awesome_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_Awesome_Shift2);
SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Cross_Shift_Indi_Awesome_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_Awesome_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_Awesome_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_ATR: // ATR
{
IndiATRParams _indi_params(::Oscillator_Cross_Shift_Indi_ATR_Period, ::Oscillator_Cross_Shift_Indi_ATR_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Cross_Shift_Indi_ATR_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_ATR_Shift2);
SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Cross_Shift_Indi_ATR_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_ATR_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_ATR_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_BEARS: // Bears
{
IndiBearsPowerParams _indi_params(::Oscillator_Cross_Shift_Indi_BearsPower_Period,
::Oscillator_Cross_Shift_Indi_BearsPower_Applied_Price,
::Oscillator_Cross_Shift_Indi_BearsPower_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Cross_Shift_Indi_BearsPower_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_BearsPower_Shift2);
SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Cross_Shift_Indi_BearsPower_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_BearsPower_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_BearsPower_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_BULLS: // Bulls
{
IndiBullsPowerParams _indi_params(::Oscillator_Cross_Shift_Indi_BullsPower_Period,
::Oscillator_Cross_Shift_Indi_BullsPower_Applied_Price,
::Oscillator_Cross_Shift_Indi_BullsPower_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Cross_Shift_Indi_BullsPower_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_BullsPower_Shift2);
SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Cross_Shift_Indi_BullsPower_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_BullsPower_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_BullsPower_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_BWMFI: // BWMFI
{
IndiBWIndiMFIParams _indi_params(::Oscillator_Cross_Shift_Indi_BWMFI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Cross_Shift_Indi_BWMFI_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_BWMFI_Shift2);
SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Cross_Shift_Indi_BWMFI_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_BWMFI_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_BWMFI_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_CCI: // CCI
{
IndiCCIParams _indi_params(::Oscillator_Cross_Shift_Indi_CCI_Period,
::Oscillator_Cross_Shift_Indi_CCI_Applied_Price,
::Oscillator_Cross_Shift_Indi_CCI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Cross_Shift_Indi_CCI_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_CCI_Shift2);
SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Cross_Shift_Indi_CCI_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_CCI_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_CCI_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_CHO: // Chaikin (CHO)
{
IndiCHOParams _indi_params(
::Oscillator_Cross_Shift_Indi_CHO_InpFastMA, ::Oscillator_Cross_Shift_Indi_CHO_InpSlowMA,
::Oscillator_Cross_Shift_Indi_CHO_InpSmoothMethod, ::Oscillator_Cross_Shift_Indi_CHO_InpVolumeType,
::Oscillator_Cross_Shift_Indi_CHO_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Cross_Shift_Indi_CHO_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_CHO_Shift2);
SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Cross_Shift_Indi_CHO_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_CHO_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_CHO_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_CHV: // Chaikin Volatility (CHV)
{
IndiCHVParams _indi_params(
::Oscillator_Cross_Shift_Indi_CHV_Smooth_Period, ::Oscillator_Cross_Shift_Indi_CHV_Period,
::Oscillator_Cross_Shift_Indi_CHV_Smooth_Method, ::Oscillator_Cross_Shift_Indi_CHV_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Cross_Shift_Indi_CHV_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_CHV_Shift2);
SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Cross_Shift_Indi_CHV_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_CHV_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_CHV_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_DEMARKER: // DeMarker
{
IndiDeMarkerParams _indi_params(::Oscillator_Cross_Shift_Indi_DeMarker_Period,
::Oscillator_Cross_Shift_Indi_DeMarker_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Cross_Shift_Indi_DeMarker_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_DeMarker_Shift2);
SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Cross_Shift_Indi_DeMarker_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_DeMarker_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_DeMarker_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_MFI: // MFI
{
IndiMFIParams _indi_params(::Oscillator_Cross_Shift_Indi_MFI_MA_Period,
::Oscillator_Cross_Shift_Indi_MFI_Applied_Volume,
::Oscillator_Cross_Shift_Indi_MFI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Cross_Shift_Indi_MFI_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_MFI_Shift2);
SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Cross_Shift_Indi_MFI_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_MFI_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_MFI_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_MOM: // MOM
{
IndiMomentumParams _indi_params(::Oscillator_Cross_Shift_Indi_Momentum_Period,
::Oscillator_Cross_Shift_Indi_Momentum_Applied_Price,
::Oscillator_Cross_Shift_Indi_Momentum_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Cross_Shift_Indi_Momentum_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_Momentum_Shift2);
SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Cross_Shift_Indi_Momentum_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_Momentum_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_Momentum_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_OBV: // OBV
{
IndiOBVParams _indi_params(::Oscillator_Cross_Shift_Indi_OBV_Applied_Price,
::Oscillator_Cross_Shift_Indi_OBV_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Cross_Shift_Indi_OBV_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_OBV_Shift2);
SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Cross_Shift_Indi_OBV_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_OBV_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_OBV_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_PVT: // PVT
{
IndiPriceVolumeTrendParams _indi_params(::Oscillator_Cross_Shift_Indi_PVT_InpVolumeType,
::Oscillator_Cross_Shift_Indi_PVT_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Cross_Shift_Indi_PVT_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_PVT_Shift2);
SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Cross_Shift_Indi_PVT_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_PVT_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_PVT_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_ROC: // ROC
{
IndiRateOfChangeParams _indi_params(::Oscillator_Cross_Shift_Indi_ROC_Period,
::Oscillator_Cross_Shift_Indi_ROC_Applied_Price,
::Oscillator_Cross_Shift_Indi_ROC_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Cross_Shift_Indi_ROC_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_ROC_Shift2);
SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Cross_Shift_Indi_ROC_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_ROC_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_ROC_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_RSI: // RSI
{
IndiRSIParams _indi_params(::Oscillator_Cross_Shift_Indi_RSI_Period,
::Oscillator_Cross_Shift_Indi_RSI_Applied_Price,
::Oscillator_Cross_Shift_Indi_RSI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Cross_Shift_Indi_RSI_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_RSI_Shift2);
SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Cross_Shift_Indi_RSI_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_RSI_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_RSI_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_STDDEV: // StdDev
{
IndiStdDevParams _indi_params(
::Oscillator_Cross_Shift_Indi_StdDev_MA_Period, ::Oscillator_Cross_Shift_Indi_StdDev_MA_Shift,
::Oscillator_Cross_Shift_Indi_StdDev_MA_Method, ::Oscillator_Cross_Shift_Indi_StdDev_Applied_Price,
::Oscillator_Cross_Shift_Indi_StdDev_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Cross_Shift_Indi_StdDev_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_StdDev_Shift2);
SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Cross_Shift_Indi_StdDev_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_StdDev_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_StdDev_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_STOCH: // Stochastic
{
IndiStochParams _indi_params(
::Oscillator_Cross_Shift_Indi_Stochastic_KPeriod, ::Oscillator_Cross_Shift_Indi_Stochastic_DPeriod,
::Oscillator_Cross_Shift_Indi_Stochastic_Slowing, ::Oscillator_Cross_Shift_Indi_Stochastic_MA_Method,
::Oscillator_Cross_Shift_Indi_Stochastic_Price_Field, ::Oscillator_Cross_Shift_Indi_Stochastic_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Cross_Shift_Indi_Stochastic_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_Stochastic_Shift2);
SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Cross_Shift_Indi_Stochastic_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_Stochastic_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_Stochastic_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_TRIX: // TRIX
{
IndiTRIXParams _indi_params(::Oscillator_Cross_Shift_Indi_TRIX_InpPeriodEMA,
::Oscillator_Cross_Shift_Indi_TRIX_Applied_Price,
::Oscillator_Cross_Shift_Indi_TRIX_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Cross_Shift_Indi_TRIX_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_TRIX_Shift2);
SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Cross_Shift_Indi_TRIX_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_TRIX_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_TRIX_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_UO: // UO
{
IndiUltimateOscillatorParams _indi_params(
::Oscillator_Cross_Shift_Indi_UO_InpFastPeriod, ::Oscillator_Cross_Shift_Indi_UO_InpMiddlePeriod,
::Oscillator_Cross_Shift_Indi_UO_InpSlowPeriod, ::Oscillator_Cross_Shift_Indi_UO_InpFastK,
::Oscillator_Cross_Shift_Indi_UO_InpMiddleK, ::Oscillator_Cross_Shift_Indi_UO_InpSlowK,
::Oscillator_Cross_Shift_Indi_UO_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Cross_Shift_Indi_UO_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_UO_Shift2);
SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Cross_Shift_Indi_UO_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_UO_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_UO_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_WAD: // Williams' AD
{
IndiWilliamsADParams _indi_params(::Oscillator_Cross_Shift_Indi_WAD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Cross_Shift_Indi_WAD_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_WAD_Shift2);
SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Cross_Shift_Indi_WAD_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_WAD_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_WAD_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_WPR: // WPR
{
IndiWPRParams _indi_params(::Oscillator_Cross_Shift_Indi_WPR_Period, ::Oscillator_Cross_Shift_Indi_WPR_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Cross_Shift_Indi_WPR_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_WPR_Shift2);
SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Cross_Shift_Indi_WPR_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_WPR_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_WPR_Shift2);
break;
}
case STG_OSCILLATOR_SHIFT_TYPE_VOL: // Volumes
{
IndiVolumesParams _indi_params(::Oscillator_Cross_Shift_Indi_VOL_InpVolumeType,
::Oscillator_Cross_Shift_Indi_VOL_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Cross_Shift_Indi_VOL_SourceType), ::Oscillator_Cross_Shift_Type);
_indi_params.SetShift(::Oscillator_Cross_Shift_Indi_VOL_Shift2);
SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Cross_Shift_Indi_VOL_SourceType), ::Oscillator_Cross_Shift_Type + 1);
ssparams.SetShift1(Oscillator_Cross_Shift_Indi_VOL_Shift);
ssparams.SetShift2(Oscillator_Cross_Shift_Indi_VOL_Shift2);
break;
}
/* @todo: Convert multi into single mode.
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADX: // ADX
{
IndiADXParams _adx_params(::Oscillator_Cross_Shift_Indi_ADX_Period,
::Oscillator_Cross_Shift_Indi_ADX_AppliedPrice,
::Oscillator_Cross_Shift_Indi_ADX_Shift);
_adx_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ADX(_adx_params, ::Oscillator_Cross_Shift_Indi_ADX_SourceType), ::Oscillator_Cross_Shift_Type);
// sparams.SetLineFast(0); // @todo: Fix Strategy to allow custom params stored in sparam.
ssparams.SetLineFast((uint)Oscillator_Cross_Shift_Indi_ADX_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Shift_Indi_ADX_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_ADXW: // ADXW
{
IndiADXWParams _adxw_params(::Oscillator_Cross_Shift_Indi_ADXW_Period,
::Oscillator_Cross_Shift_Indi_ADXW_AppliedPrice,
::Oscillator_Cross_Shift_Indi_ADXW_Shift);
_adxw_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ADXW(_adxw_params, ::Oscillator_Cross_Shift_Indi_ADXW_SourceType), ::Oscillator_Cross_Shift_Type);
// sparams.SetLineFast(0); // @todo: Fix Strategy to allow custom params stored in sparam.
ssparams.SetLineFast((uint)Oscillator_Cross_Shift_Indi_ADXW_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Shift_Indi_ADXW_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_MACD: // MACD
{
IndiMACDParams _indi_params(::Oscillator_Cross_Shift_Indi_MACD_Period_Fast,
::Oscillator_Cross_Shift_Indi_MACD_Period_Slow,
::Oscillator_Cross_Shift_Indi_MACD_Period_Signal,
::Oscillator_Cross_Shift_Indi_MACD_Applied_Price,
::Oscillator_Cross_Shift_Indi_MACD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_MACD(_indi_params, ::Oscillator_Cross_Shift_Indi_MACD_SourceType), ::Oscillator_Cross_Shift_Type);
ssparams.SetLineFast((uint)Oscillator_Cross_Shift_Indi_MACD_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Shift_Indi_MACD_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_RVI: // RVI
{
IndiRVIParams _indi_params(::Oscillator_Cross_Shift_Indi_RVI_Period,
::Oscillator_Cross_Shift_Indi_RVI_Shift);
_indi_params.SetDataSourceType(::Oscillator_Cross_Shift_Indi_RVI_SourceType);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RVI(_indi_params), ::Oscillator_Cross_Shift_Type);
ssparams.SetLineFast((uint)Oscillator_Cross_Shift_Indi_RVI_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Shift_Indi_RVI_Slow_Line);
break;
}
*/
case STG_OSCILLATOR_CROSS_SHIFT_TYPE_0_NONE: // (None)
default:
break;
}
}
/**
* Check strategy's opening signal.
*/
bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method, float _level = 0.0f, int _shift = 0) {
IndicatorData *_indi1 = GetIndicator(::Oscillator_Cross_Shift_Type);
IndicatorData *_indi2 = GetIndicator(::Oscillator_Cross_Shift_Type + 1);
// uint _ishift1 = _indi1.GetParams().GetShift(); // @todo: Convert into Get().
// uint _ishift2 = _indi2.GetParams().GetShift(); // @todo: Convert into Get().
uint _ishift1 = ssparams.GetShift1();
uint _ishift2 = ssparams.GetShift2();
bool _result = Oscillator_Cross_Shift_Type != STG_OSCILLATOR_CROSS_SHIFT_TYPE_0_NONE &&
IsValidEntry(_indi1, _ishift1) && IsValidEntry(_indi2, _ishift2);
if (!_result) {
// Returns false when indicator data is not valid.
return false;
}
double _value1 = _indi1[_ishift1][0];
double _value2 = _indi2[_ishift2][0];
switch (_cmd) {
case ORDER_TYPE_BUY:
// Buy signal.
_result &= _indi1.IsIncreasing(1, 0, _ishift1);
_result &= _indi1[_ishift1][0] > _indi2[_ishift2][0];
_result &= _indi1[_ishift1 + 1][0] < _indi2[_ishift2 + 1][0];
_result &= Math::ChangeInPct(_indi1[_ishift1 + 1][0], _indi1[_ishift1][0], true) > _level;
if (_result && _method != 0) {
if (METHOD(_method, 0)) _result &= _indi1[_ishift1][0] < _indi1[_ishift1 + 3][0];
if (METHOD(_method, 1)) _result &= _indi2[_ishift2][0] < _indi2[_ishift2 + 3][0];
if (METHOD(_method, 2))
_result &= fmax4(_indi1[_ishift1][0], _indi1[_ishift1 + 1][0], _indi1[_ishift1 + 2][0],
_indi1[_ishift1 + 3][0]) == _indi1[_ishift1][0];
if (METHOD(_method, 3))
_result &= fmax4(_indi2[_ishift2][0], _indi2[_ishift2 + 1][0], _indi2[_ishift2 + 2][0],
_indi2[_ishift2 + 3][0]) == _indi2[_ishift2][0];
}
break;
case ORDER_TYPE_SELL:
// Sell signal.
_result &= _indi1.IsDecreasing(1, 0, _ishift1);
_result &= _indi1[_ishift1][0] < _indi2[_ishift2][0];
_result &= _indi1[_ishift1 + 1][0] > _indi2[_ishift2 + 1][0];
_result &= Math::ChangeInPct(_indi1[_ishift1 + 1][0], _indi1[_ishift1][0], true) < _level;
if (_result && _method != 0) {
if (METHOD(_method, 0)) _result &= _indi1[_ishift1][0] > _indi1[_ishift1 + 3][0];
if (METHOD(_method, 1)) _result &= _indi2[_ishift2][0] > _indi2[_ishift2 + 3][0];
if (METHOD(_method, 2))
_result &= fmin4(_indi1[_ishift1][0], _indi1[_ishift1 + 1][0], _indi1[_ishift1 + 2][0],
_indi1[_ishift1 + 3][0]) == _indi1[_ishift1][0];
if (METHOD(_method, 3))
_result &= fmin4(_indi2[_ishift2][0], _indi2[_ishift2 + 1][0], _indi2[_ishift2 + 2][0],
_indi2[_ishift2 + 3][0]) == _indi2[_ishift2][0];
}
break;
}
return _result;
}
};