generated from EA31337/Strategy-Oscillator_Cross_Shift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Stg_Oscillator_Cross_Timeframe.mqh
748 lines (736 loc) · 52.1 KB
/
Stg_Oscillator_Cross_Timeframe.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
/**
* @file
* Implements Oscillator Cross Timeframe strategy.
*/
// Enums.
enum ENUM_STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE {
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_0_NONE = 0, // (None)
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AC, // AC: Accelerator/Decelerator
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AD, // AD: Accumulation/Distribution
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AO, // AO: Awesome
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ATR, // ATR
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BEARS, // Bears Power
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BULLS, // Bulls Power
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BWMFI, // BWMFI
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CCI, // CCI
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CHO, // CHO: Chaikin
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CHV, // CHV: Chaikin Volatility
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_DEMARKER, // DeMarker
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MFI, // MFI
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MOM, // MOM: Momentum
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_OBV, // OBV: On Balance Volume
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_PVT, // PVT: Price and Volume Trend
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ROC, // ROC: Rate of Change
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_RSI, // RSI
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_STDDEV, // StdDev: Standard Deviation
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_STOCH, // Stochastic
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_TRIX, // TRIX: Triple Exponential Average
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_UO, // UO: Ultimate Oscillator
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_WAD, // WAD: Larry Williams' Accumulation/Distribution
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_WPR, // WPR
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_VOL, // VOL: Volumes
// STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ADX, // ADX
// STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ADXW, // ADXW
// STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MACD, // MACD
// STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_RVI, // RVI: Relative Vigor Index
};
// User input params.
INPUT_GROUP("Oscillator Cross Timeframe strategy: main strategy params");
INPUT ENUM_STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE Oscillator_Cross_Timeframe_Type =
STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_TRIX; // Oscillator type
INPUT ENUM_TIMEFRAMES Oscillator_Cross_Timeframe_Tf = PERIOD_H6; // Oscillator timeframe to cross
INPUT_GROUP("Oscillator Cross Timeframe strategy: strategy params");
INPUT float Oscillator_Cross_Timeframe_LotSize = 0; // Lot size
INPUT int Oscillator_Cross_Timeframe_SignalOpenMethod = 6; // Signal open method
INPUT float Oscillator_Cross_Timeframe_SignalOpenLevel = 5.0f; // Signal open level
INPUT int Oscillator_Cross_Timeframe_SignalOpenFilterMethod = 32; // Signal open filter method
INPUT int Oscillator_Cross_Timeframe_SignalOpenFilterTime = 3; // Signal open filter time (0-31)
INPUT int Oscillator_Cross_Timeframe_SignalOpenBoostMethod = 0; // Signal open boost method
INPUT int Oscillator_Cross_Timeframe_SignalCloseMethod = 0; // Signal close method
INPUT int Oscillator_Cross_Timeframe_SignalCloseFilter = 32; // Signal close filter (-127-127)
INPUT float Oscillator_Cross_Timeframe_SignalCloseLevel = 5.0f; // Signal close level
INPUT int Oscillator_Cross_Timeframe_PriceStopMethod = 0; // Price limit method
INPUT float Oscillator_Cross_Timeframe_PriceStopLevel = 2; // Price limit level
INPUT int Oscillator_Cross_Timeframe_TickFilterMethod = 32; // Tick filter method (0-255)
INPUT float Oscillator_Cross_Timeframe_MaxSpread = 4.0; // Max spread to trade (in pips)
INPUT short Oscillator_Cross_Timeframe_Shift = 0; // Shift
INPUT float Oscillator_Cross_Timeframe_OrderCloseLoss = 80; // Order close loss
INPUT float Oscillator_Cross_Timeframe_OrderCloseProfit = 80; // Order close profit
INPUT int Oscillator_Cross_Timeframe_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0)
INPUT_GROUP("Oscillator Cross Timeframe strategy: AC oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_AC_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_AC_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: AD oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_AD_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_AD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: ATR oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_ATR_Period = 13; // Period
INPUT int Oscillator_Cross_Timeframe_Indi_ATR_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_ATR_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Awesome oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_Awesome_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_Awesome_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: BearsPower oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_BearsPower_Period = 30; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_BearsPower_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_BearsPower_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_BearsPower_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: BullsPower oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_BullsPower_Period = 30; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_BullsPower_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_BullsPower_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_BullsPower_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: BWMFI oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_BWMFI_Shift = 1; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_BWMFI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: CCI oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_CCI_Period = 20; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_CCI_Applied_Price = PRICE_TYPICAL; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_CCI_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_CCI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Chaikin oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_CHO_InpFastMA = 10; // Fast EMA period
INPUT int Oscillator_Cross_Timeframe_Indi_CHO_InpSlowMA = 30; // Slow MA period
INPUT ENUM_MA_METHOD Oscillator_Cross_Timeframe_Indi_CHO_InpSmoothMethod = MODE_SMMA; // MA method
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Timeframe_Indi_CHO_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Timeframe_Indi_CHO_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_CHO_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Chaikin Volatility oscillator params");
INPUT unsigned int Oscillator_Cross_Timeframe_Indi_CHV_Smooth_Period; // Smooth period
INPUT unsigned int Oscillator_Cross_Timeframe_Indi_CHV_Period; // Period
INPUT ENUM_CHV_SMOOTH_METHOD Oscillator_Cross_Timeframe_Indi_CHV_Smooth_Method; // Smooth method
INPUT int Oscillator_Cross_Timeframe_Indi_CHV_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_CHV_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: DeMarker indicator params");
INPUT int Oscillator_Cross_Timeframe_Indi_DeMarker_Period = 23; // Period
INPUT int Oscillator_Cross_Timeframe_Indi_DeMarker_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_DeMarker_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: MFI oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_MFI_MA_Period = 22; // MA Period
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Timeframe_Indi_MFI_Applied_Volume =
(ENUM_APPLIED_VOLUME)0; // Applied volume.
INPUT int Oscillator_Cross_Timeframe_Indi_MFI_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_MFI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Momentum oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_Momentum_Period = 12; // Averaging period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_Momentum_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_Momentum_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_Momentum_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: OBV oscillator params");
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_OBV_Applied_Price = PRICE_CLOSE; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_OBV_Shift = 1; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_OBV_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: PVT oscillator params");
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Timeframe_Indi_PVT_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Timeframe_Indi_PVT_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_PVT_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: ROC oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_ROC_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_ROC_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_ROC_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_ROC_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: RSI oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_RSI_Period = 16; // Period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_RSI_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_RSI_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_RSI_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: StdDev oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_StdDev_MA_Period = 24; // Period
INPUT int Oscillator_Cross_Timeframe_Indi_StdDev_MA_Shift = 0; // MA Shift
INPUT ENUM_MA_METHOD Oscillator_Cross_Timeframe_Indi_StdDev_MA_Method = (ENUM_MA_METHOD)3; // MA Method
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_StdDev_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_StdDev_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_StdDev_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Stochastic oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_Stochastic_KPeriod = 8; // K line period
INPUT int Oscillator_Cross_Timeframe_Indi_Stochastic_DPeriod = 12; // D line period
INPUT int Oscillator_Cross_Timeframe_Indi_Stochastic_Slowing = 12; // Slowing
INPUT ENUM_MA_METHOD Oscillator_Cross_Timeframe_Indi_Stochastic_MA_Method = MODE_EMA; // Moving Average method
INPUT ENUM_STO_PRICE Oscillator_Cross_Timeframe_Indi_Stochastic_Price_Field =
0; // Price (0 - Low/High or 1 - Close/Close)
INPUT int Oscillator_Cross_Timeframe_Indi_Stochastic_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_Stochastic_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: TRIX oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_TRIX_InpPeriodEMA = 14; // EMA period
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_TRIX_Applied_Price = PRICE_WEIGHTED; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_TRIX_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_TRIX_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Ultimate oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpFastPeriod = 7; // Fast ATR period
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpMiddlePeriod = 14; // Middle ATR period
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpSlowPeriod = 28; // Slow ATR period
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpFastK = 4; // Fast K
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpMiddleK = 2; // Middle K
INPUT int Oscillator_Cross_Timeframe_Indi_UO_InpSlowK = 1; // Slow K
INPUT int Oscillator_Cross_Timeframe_Indi_UO_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_UO_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Williams' Accumulation/Distribution oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_WAD_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_WAD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: WPR oscillator params");
INPUT int Oscillator_Cross_Timeframe_Indi_WPR_Period = 18; // Period
INPUT int Oscillator_Cross_Timeframe_Indi_WPR_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_WPR_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: Volumes oscillator params");
INPUT ENUM_APPLIED_VOLUME Oscillator_Cross_Timeframe_Indi_VOL_InpVolumeType = VOLUME_TICK; // Volumes
INPUT int Oscillator_Cross_Timeframe_Indi_VOL_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_VOL_SourceType = IDATA_BUILTIN; // Source type
/* @todo
INPUT_GROUP("Oscillator Cross Timeframe strategy: ADX indicator params");
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Timeframe_Indi_ADX_Fast_Line = LINE_PLUSDI; // Fast line
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Timeframe_Indi_ADX_Slow_Line = LINE_MINUSDI; // Slow line to
cross_shift INPUT int Oscillator_Cross_Timeframe_Indi_ADX_Period = 16; // Averaging
period INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_ADX_AppliedPrice = PRICE_TYPICAL; // Applied price
INPUT int Oscillator_Cross_Timeframe_Indi_ADX_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_ADX_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: ADXW indicator params");
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Timeframe_Indi_ADXW_Fast_Line = LINE_PLUSDI; // Fast line
INPUT ENUM_INDI_ADX_LINE Oscillator_Cross_Timeframe_Indi_ADXW_Slow_Line = LINE_MINUSDI; // Slow line to
cross_shift INPUT int Oscillator_Cross_Timeframe_Indi_ADXW_Period = 16; // Averaging
period INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_ADXW_AppliedPrice = PRICE_TYPICAL; // Applied price
INPUT int Oscillator_Cross_Timeframe_Indi_ADXW_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_ADXW_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: MACD indicator params");
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Timeframe_Indi_MACD_Fast_Line = LINE_SIGNAL; // Fast line
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Timeframe_Indi_MACD_Slow_Line = LINE_MAIN; // Slow line
INPUT int Oscillator_Cross_Timeframe_Indi_MACD_Period_Fast = 6; // Period Fast
INPUT int Oscillator_Cross_Timeframe_Indi_MACD_Period_Slow = 34; // Period Slow
INPUT int Oscillator_Cross_Timeframe_Indi_MACD_Period_Signal = 10; // Period Signal
INPUT ENUM_APPLIED_PRICE Oscillator_Cross_Timeframe_Indi_MACD_Applied_Price = PRICE_OPEN; // Applied Price
INPUT int Oscillator_Cross_Timeframe_Indi_MACD_Shift = 0; // Shift
Shift INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_MACD_SourceType = IDATA_BUILTIN; // Source type
INPUT_GROUP("Oscillator Cross Timeframe strategy: RVI indicator params");
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Timeframe_Indi_RVI_Fast_Line = LINE_SIGNAL; // Fast line
INPUT ENUM_SIGNAL_LINE Oscillator_Cross_Timeframe_Indi_RVI_Slow_Line = LINE_MAIN; // Slow line
INPUT unsigned int Oscillator_Cross_Timeframe_Indi_RVI_Period = 12; // Averaging
period INPUT int Oscillator_Cross_Timeframe_Indi_RVI_Shift = 0; //
Shift INPUT ENUM_IDATA_SOURCE_TYPE Oscillator_Cross_Timeframe_Indi_RVI_SourceType = IDATA_BUILTIN; // Source type
*/
// Structs.
// Defines struct with default user strategy values.
struct Stg_Oscillator_Cross_Timeframe_Params_Defaults : StgParams {
Stg_Oscillator_Cross_Timeframe_Params_Defaults()
: StgParams(::Oscillator_Cross_Timeframe_SignalOpenMethod, ::Oscillator_Cross_Timeframe_SignalOpenFilterMethod,
::Oscillator_Cross_Timeframe_SignalOpenLevel, ::Oscillator_Cross_Timeframe_SignalOpenBoostMethod,
::Oscillator_Cross_Timeframe_SignalCloseMethod, ::Oscillator_Cross_Timeframe_SignalCloseFilter,
::Oscillator_Cross_Timeframe_SignalCloseLevel, ::Oscillator_Cross_Timeframe_PriceStopMethod,
::Oscillator_Cross_Timeframe_PriceStopLevel, ::Oscillator_Cross_Timeframe_TickFilterMethod,
::Oscillator_Cross_Timeframe_MaxSpread, ::Oscillator_Cross_Timeframe_Shift) {
Set(STRAT_PARAM_LS, ::Oscillator_Cross_Timeframe_LotSize);
Set(STRAT_PARAM_OCL, ::Oscillator_Cross_Timeframe_OrderCloseLoss);
Set(STRAT_PARAM_OCP, ::Oscillator_Cross_Timeframe_OrderCloseProfit);
Set(STRAT_PARAM_OCT, ::Oscillator_Cross_Timeframe_OrderCloseTime);
Set(STRAT_PARAM_SOFT, ::Oscillator_Cross_Timeframe_SignalOpenFilterTime);
}
};
class Stg_Oscillator_Cross_Timeframe : public Strategy {
public:
Stg_Oscillator_Cross_Timeframe(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "")
: Strategy(_sparams, _tparams, _cparams, _name) {}
static Stg_Oscillator_Cross_Timeframe *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) {
// Initialize strategy initial values.
Stg_Oscillator_Cross_Timeframe_Params_Defaults stg_oscillator_cross_timeframe_defaults;
StgParams _stg_params(stg_oscillator_cross_timeframe_defaults);
// Initialize Strategy instance.
ChartParams _cparams(_tf, _Symbol);
TradeParams _tparams;
Stg_Oscillator_Cross_Timeframe *_strat =
new Stg_Oscillator_Cross_Timeframe(_stg_params, _tparams, _cparams, "Oscillator Cross Timeframe");
return _strat;
}
/**
* Validate oscillator's entry.
*/
bool IsValidEntry(IndicatorBase *_indi, int _shift = 0) {
bool _result = true;
switch (::Oscillator_Cross_Timeframe_Type) {
case STG_OSCILLATOR_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_CROSS_TIMEFRAME_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_TIMEFRAME_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_TIMEFRAME_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_TIMEFRAME_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_TIMEFRAME_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_Timeframe_Type) {
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AC: // AC
{
IndiACParams _indi_params(::Oscillator_Cross_Timeframe_Indi_AC_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Cross_Timeframe_Indi_AC_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_AC(_indi_params, ::Oscillator_Cross_Timeframe_Indi_AC_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AD: // AD
{
IndiADParams _indi_params(::Oscillator_Cross_Timeframe_Indi_AD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Cross_Timeframe_Indi_AD_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_AD(_indi_params, ::Oscillator_Cross_Timeframe_Indi_AD_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_AO: // AO
{
IndiAOParams _indi_params(::Oscillator_Cross_Timeframe_Indi_Awesome_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Awesome_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_AO(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Awesome_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ATR: // ATR
{
IndiATRParams _indi_params(::Oscillator_Cross_Timeframe_Indi_ATR_Period,
::Oscillator_Cross_Timeframe_Indi_ATR_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Cross_Timeframe_Indi_ATR_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_ATR(_indi_params, ::Oscillator_Cross_Timeframe_Indi_ATR_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BEARS: // Bears
{
IndiBearsPowerParams _indi_params(::Oscillator_Cross_Timeframe_Indi_BearsPower_Period,
::Oscillator_Cross_Timeframe_Indi_BearsPower_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_BearsPower_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BearsPower_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_BearsPower(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BearsPower_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BULLS: // Bulls
{
IndiBullsPowerParams _indi_params(::Oscillator_Cross_Timeframe_Indi_BullsPower_Period,
::Oscillator_Cross_Timeframe_Indi_BullsPower_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_BullsPower_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BullsPower_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_BullsPower(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BullsPower_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_BWMFI: // BWMFI
{
IndiBWIndiMFIParams _indi_params(::Oscillator_Cross_Timeframe_Indi_BWMFI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BWMFI_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_BWMFI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_BWMFI_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CCI: // CCI
{
IndiCCIParams _indi_params(::Oscillator_Cross_Timeframe_Indi_CCI_Period,
::Oscillator_Cross_Timeframe_Indi_CCI_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_CCI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CCI_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_CCI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CCI_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CHO: // Chaikin (CHO)
{
IndiCHOParams _indi_params(
::Oscillator_Cross_Timeframe_Indi_CHO_InpFastMA, ::Oscillator_Cross_Timeframe_Indi_CHO_InpSlowMA,
::Oscillator_Cross_Timeframe_Indi_CHO_InpSmoothMethod, ::Oscillator_Cross_Timeframe_Indi_CHO_InpVolumeType,
::Oscillator_Cross_Timeframe_Indi_CHO_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CHO_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_CHO(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CHO_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_CHV: // Chaikin Volatility (CHV)
{
IndiCHVParams _indi_params(
::Oscillator_Cross_Timeframe_Indi_CHV_Smooth_Period, ::Oscillator_Cross_Timeframe_Indi_CHV_Period,
::Oscillator_Cross_Timeframe_Indi_CHV_Smooth_Method, ::Oscillator_Cross_Timeframe_Indi_CHV_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CHV_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_CHV(_indi_params, ::Oscillator_Cross_Timeframe_Indi_CHV_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_DEMARKER: // DeMarker
{
IndiDeMarkerParams _indi_params(::Oscillator_Cross_Timeframe_Indi_DeMarker_Period,
::Oscillator_Cross_Timeframe_Indi_DeMarker_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Cross_Timeframe_Indi_DeMarker_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_DeMarker(_indi_params, ::Oscillator_Cross_Timeframe_Indi_DeMarker_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MFI: // MFI
{
IndiMFIParams _indi_params(::Oscillator_Cross_Timeframe_Indi_MFI_MA_Period,
::Oscillator_Cross_Timeframe_Indi_MFI_Applied_Volume,
::Oscillator_Cross_Timeframe_Indi_MFI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_MFI_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_MFI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_MFI_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MOM: // MOM
{
IndiMomentumParams _indi_params(::Oscillator_Cross_Timeframe_Indi_Momentum_Period,
::Oscillator_Cross_Timeframe_Indi_Momentum_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_Momentum_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Momentum_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_Momentum(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Momentum_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_OBV: // OBV
{
IndiOBVParams _indi_params(::Oscillator_Cross_Timeframe_Indi_OBV_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_OBV_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Cross_Timeframe_Indi_OBV_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_OBV(_indi_params, ::Oscillator_Cross_Timeframe_Indi_OBV_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_PVT: // PVT
{
IndiPriceVolumeTrendParams _indi_params(::Oscillator_Cross_Timeframe_Indi_PVT_InpVolumeType,
::Oscillator_Cross_Timeframe_Indi_PVT_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Cross_Timeframe_Indi_PVT_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_PriceVolumeTrend(_indi_params, ::Oscillator_Cross_Timeframe_Indi_PVT_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ROC: // ROC
{
IndiRateOfChangeParams _indi_params(::Oscillator_Cross_Timeframe_Indi_ROC_Period,
::Oscillator_Cross_Timeframe_Indi_ROC_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_ROC_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Cross_Timeframe_Indi_ROC_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_RateOfChange(_indi_params, ::Oscillator_Cross_Timeframe_Indi_ROC_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_RSI: // RSI
{
IndiRSIParams _indi_params(::Oscillator_Cross_Timeframe_Indi_RSI_Period,
::Oscillator_Cross_Timeframe_Indi_RSI_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_RSI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_RSI_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_RSI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_RSI_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_STDDEV: // StdDev
{
IndiStdDevParams _indi_params(
::Oscillator_Cross_Timeframe_Indi_StdDev_MA_Period, ::Oscillator_Cross_Timeframe_Indi_StdDev_MA_Shift,
::Oscillator_Cross_Timeframe_Indi_StdDev_MA_Method, ::Oscillator_Cross_Timeframe_Indi_StdDev_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_StdDev_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Cross_Timeframe_Indi_StdDev_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_StdDev(_indi_params, ::Oscillator_Cross_Timeframe_Indi_StdDev_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_STOCH: // Stochastic
{
IndiStochParams _indi_params(::Oscillator_Cross_Timeframe_Indi_Stochastic_KPeriod,
::Oscillator_Cross_Timeframe_Indi_Stochastic_DPeriod,
::Oscillator_Cross_Timeframe_Indi_Stochastic_Slowing,
::Oscillator_Cross_Timeframe_Indi_Stochastic_MA_Method,
::Oscillator_Cross_Timeframe_Indi_Stochastic_Price_Field,
::Oscillator_Cross_Timeframe_Indi_Stochastic_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Stochastic_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_Stochastic(_indi_params, ::Oscillator_Cross_Timeframe_Indi_Stochastic_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_TRIX: // TRIX
{
IndiTRIXParams _indi_params(::Oscillator_Cross_Timeframe_Indi_TRIX_InpPeriodEMA,
::Oscillator_Cross_Timeframe_Indi_TRIX_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_TRIX_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Cross_Timeframe_Indi_TRIX_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_TRIX(_indi_params, ::Oscillator_Cross_Timeframe_Indi_TRIX_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_UO: // UO
{
IndiUltimateOscillatorParams _indi_params(
::Oscillator_Cross_Timeframe_Indi_UO_InpFastPeriod, ::Oscillator_Cross_Timeframe_Indi_UO_InpMiddlePeriod,
::Oscillator_Cross_Timeframe_Indi_UO_InpSlowPeriod, ::Oscillator_Cross_Timeframe_Indi_UO_InpFastK,
::Oscillator_Cross_Timeframe_Indi_UO_InpMiddleK, ::Oscillator_Cross_Timeframe_Indi_UO_InpSlowK,
::Oscillator_Cross_Timeframe_Indi_UO_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Cross_Timeframe_Indi_UO_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_UltimateOscillator(_indi_params, ::Oscillator_Cross_Timeframe_Indi_UO_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_WAD: // Williams' AD
{
IndiWilliamsADParams _indi_params(::Oscillator_Cross_Timeframe_Indi_WAD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Cross_Timeframe_Indi_WAD_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_WilliamsAD(_indi_params, ::Oscillator_Cross_Timeframe_Indi_WAD_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_WPR: // WPR
{
IndiWPRParams _indi_params(::Oscillator_Cross_Timeframe_Indi_WPR_Period,
::Oscillator_Cross_Timeframe_Indi_WPR_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Cross_Timeframe_Indi_WPR_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_WPR(_indi_params, ::Oscillator_Cross_Timeframe_Indi_WPR_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_VOL: // Volumes
{
IndiVolumesParams _indi_params(::Oscillator_Cross_Timeframe_Indi_VOL_InpVolumeType,
::Oscillator_Cross_Timeframe_Indi_VOL_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Cross_Timeframe_Indi_VOL_SourceType), ::Oscillator_Cross_Timeframe_Type);
_indi_params.SetTf(::Oscillator_Cross_Timeframe_Tf);
SetIndicator(new Indi_Volumes(_indi_params, ::Oscillator_Cross_Timeframe_Indi_VOL_SourceType), ::Oscillator_Cross_Timeframe_Type + 1);
break;
}
/* @todo: Convert multi into single mode.
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ADX: // ADX
{
IndiADXParams _adx_params(::Oscillator_Cross_Timeframe_Indi_ADX_Period,
::Oscillator_Cross_Timeframe_Indi_ADX_AppliedPrice,
::Oscillator_Cross_Timeframe_Indi_ADX_Shift);
_adx_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ADX(_adx_params, ::Oscillator_Cross_Timeframe_Indi_ADX_SourceType), ::Oscillator_Cross_Timeframe_Type);
// sparams.SetLineFast(0); // @todo: Fix Strategy to allow custom params stored in sparam.
ssparams.SetLineFast((uint)Oscillator_Cross_Timeframe_Indi_ADX_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Timeframe_Indi_ADX_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_ADXW: // ADXW
{
IndiADXWParams _adxw_params(::Oscillator_Cross_Timeframe_Indi_ADXW_Period,
::Oscillator_Cross_Timeframe_Indi_ADXW_AppliedPrice,
::Oscillator_Cross_Timeframe_Indi_ADXW_Shift);
_adxw_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_ADXW(_adxw_params, ::Oscillator_Cross_Timeframe_Indi_ADXW_SourceType), ::Oscillator_Cross_Timeframe_Type);
// sparams.SetLineFast(0); // @todo: Fix Strategy to allow custom params stored in sparam.
ssparams.SetLineFast((uint)Oscillator_Cross_Timeframe_Indi_ADXW_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Timeframe_Indi_ADXW_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_MACD: // MACD
{
IndiMACDParams _indi_params(::Oscillator_Cross_Timeframe_Indi_MACD_Period_Fast,
::Oscillator_Cross_Timeframe_Indi_MACD_Period_Slow,
::Oscillator_Cross_Timeframe_Indi_MACD_Period_Signal,
::Oscillator_Cross_Timeframe_Indi_MACD_Applied_Price,
::Oscillator_Cross_Timeframe_Indi_MACD_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_MACD(_indi_params, ::Oscillator_Cross_Timeframe_Indi_MACD_SourceType), ::Oscillator_Cross_Timeframe_Type);
ssparams.SetLineFast((uint)Oscillator_Cross_Timeframe_Indi_MACD_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Timeframe_Indi_MACD_Slow_Line);
break;
}
case STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_RVI: // RVI
{
IndiRVIParams _indi_params(::Oscillator_Cross_Timeframe_Indi_RVI_Period,
::Oscillator_Cross_Timeframe_Indi_RVI_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_RVI(_indi_params, ::Oscillator_Cross_Timeframe_Indi_RVI_SourceType), ::Oscillator_Cross_Timeframe_Type);
ssparams.SetLineFast((uint)Oscillator_Cross_Timeframe_Indi_RVI_Fast_Line);
ssparams.SetLineSlow((uint)Oscillator_Cross_Timeframe_Indi_RVI_Slow_Line);
break;
}
*/
case STG_OSCILLATOR_CROSS_TIMEFRAME_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_Timeframe_Type);
IndicatorData *_indi2 = GetIndicator(::Oscillator_Cross_Timeframe_Type + 1);
// uint _ishift = _indi1.GetParams().GetShift(); // @todo: Convert into Get().
// uint _ishift = _indi2.GetParams().GetShift(); // @todo: Convert into Get().
uint _ishift = _shift;
bool _result = Oscillator_Cross_Timeframe_Type != STG_OSCILLATOR_CROSS_TIMEFRAME_TYPE_0_NONE &&
IsValidEntry(_indi1, _ishift) && IsValidEntry(_indi2, _ishift);
if (!_result) {
// Returns false when indicator data is not valid.
return false;
}
double _value1 = _indi1[_ishift][0];
double _value2 = _indi2[_ishift][0];
switch (_cmd) {
case ORDER_TYPE_BUY:
// Buy signal.
_result &= _indi1.IsIncreasing(1, 0, _ishift);
_result &= _indi1[_ishift][0] > _indi2[_ishift][0];
_result &= _indi1[_ishift + 1][0] < _indi2[_ishift + 1][0];
_result &= Math::ChangeInPct(_indi1[_ishift + 1][0], _indi1[_ishift][0], true) > _level;
if (_result && _method != 0) {
if (METHOD(_method, 0)) _result &= _indi1[_ishift][0] < _indi1[_ishift + 3][0];
if (METHOD(_method, 1)) _result &= _indi2[_ishift][0] < _indi2[_ishift + 3][0];
if (METHOD(_method, 2))
_result &= fmax4(_indi1[_ishift][0], _indi1[_ishift + 1][0], _indi1[_ishift + 2][0],
_indi1[_ishift + 3][0]) == _indi1[_ishift][0];
if (METHOD(_method, 3))
_result &= fmax4(_indi2[_ishift][0], _indi2[_ishift + 1][0], _indi2[_ishift + 2][0],
_indi2[_ishift + 3][0]) == _indi2[_ishift][0];
}
break;
case ORDER_TYPE_SELL:
// Sell signal.
_result &= _indi1.IsDecreasing(1, 0, _ishift);
_result &= _indi1[_ishift][0] < _indi2[_ishift][0];
_result &= _indi1[_ishift + 1][0] > _indi2[_ishift + 1][0];
_result &= Math::ChangeInPct(_indi1[_ishift + 1][0], _indi1[_ishift][0], true) < _level;
if (_result && _method != 0) {
if (METHOD(_method, 0)) _result &= _indi1[_ishift][0] > _indi1[_ishift + 3][0];
if (METHOD(_method, 1)) _result &= _indi2[_ishift][0] > _indi2[_ishift + 3][0];
if (METHOD(_method, 2))
_result &= fmin4(_indi1[_ishift][0], _indi1[_ishift + 1][0], _indi1[_ishift + 2][0],
_indi1[_ishift + 3][0]) == _indi1[_ishift][0];
if (METHOD(_method, 3))
_result &= fmin4(_indi2[_ishift][0], _indi2[_ishift + 1][0], _indi2[_ishift + 2][0],
_indi2[_ishift + 3][0]) == _indi2[_ishift][0];
}
break;
}
return _result;
}
};