Repository navigation
Expand file tree
/
Copy pathAditrady Megatron.cpp
More file actions
3228 lines (2965 loc) · 158 KB
/
Copy pathAditrady Megatron.cpp
File metadata and controls
3228 lines (2965 loc) · 158 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ============================================================================
// ADITRADYMEGATRON - Sierra Chart ACSIL port
//
// Ported from the NinjaTrader 8 NinjaScript indicator ADITRADYMEGATRON.cs,
// which itself unified: OptimusNinja / OptimusNinjaSignals, GodTrades21,
// God Trades for Sierra Chart, PredatorBollinger, ADITRADYSOLIDSNAKE and
// EngulfingBarsBB into one confluence / gap-engine / pattern indicator.
//
// This file is self contained: every moving average, oscillator and pattern
// test is implemented directly against Sierra's base OHLCV arrays, so no
// other custom study or "Study/Price Overlay" reference is required.
//
// BUILD: Add this .cpp to a Custom Studies DLL project (Sierra Chart's
// ACS_Source template, built with the bundled Visual Studio Build Tools /
// full Visual Studio), build the DLL, then load it in Sierra via
// Analysis > Studies > (your DLL) > ADITRADYMEGATRON.
//
// NOTE ON FIDELITY: A handful of NinjaTrader built-ins (FisherTransform,
// ADX, RSI, ATR, Parabolic SAR, KAMA, T3, HMA) are internal/black-box in
// NinjaTrader. They are reimplemented here from their standard published
// formulas (Wilder ADX/ATR/RSI, Wells Wilder Parabolic SAR, Ehlers Fisher
// Transform, Tillson T3, Hull MA, Kaufman KAMA), which is what those
// indicators are defined to compute. Everything else (confluence rules,
// gap engine, OBR, Bollinger Gap, FC continuation, spiderweb, SMI +
// divergence, Wave state, Vodka Shot, adaptive thresholds, all candle
// patterns) is a direct line-by-line port of the original logic.
//
// ALERT SOUNDS: the original exposed ~28 individual per-signal .wav file
// inputs (mostly duplicating "bullish"/"bearish"/generic sounds under the
// hood). That is collapsed here into three sound inputs (Bullish / Bearish
// / Neutral); every individual "Alert On/Off" checkbox is preserved.
// ============================================================================
#include "sierrachart.h"
#include <vector>
#include <deque>
#include <map>
#include <string>
#include <utility>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
SCDLLName("Aditrady_Megatron")
// ---------------------------------------------------------------------------
// Small color helper
// ---------------------------------------------------------------------------
#ifndef ADM_RGB
#define ADM_RGB(r,g,b) RGB((r),(g),(b))
#endif
// Scales a color's brightness (shade 0..255 => 0..100%), mirroring the original's ScaleBrush.
static inline COLORREF ADM_ScaleColor(COLORREF c, int shade)
{
double f = shade / 255.0;
int r = (int)(GetRValue(c) * f + 0.5);
int g = (int)(GetGValue(c) * f + 0.5);
int b = (int)(GetBValue(c) * f + 0.5);
return ADM_RGB(r, g, b);
}
// ---------------------------------------------------------------------------
// Subgraph indices (mirrors the original plot layout 1:1)
// ---------------------------------------------------------------------------
enum ADMSubgraph
{
SG_BUY = 0, SG_SELL, SG_KAMA, SG_BBU, SG_BBM, SG_BBL, SG_BARCOLOR,
SG_LOWTOUCH, SG_UPTOUCH, SG_MIDCLOSE,
SG_CONFLUENCE, SG_BIGARROW, SG_SQUEEZE, SG_PATTERN,
SG_VOLIMB, SG_GAPTOUCH, SG_INVALIDTOUCH,
SG_CONT, SG_BGAP, SG_OBR,
SG_ACTIVEGAPS, SG_VALIDGAPS, SG_PENDING, SG_WEBCOUNT, SG_WEBWARN, SG_NEARGAP,
SG_ENTRY, SG_STOP, SG_TARGET,
SG_DIR, SG_CODE, SG_MLONG, SG_MSHORT,
SG_SMI, SG_SMIAVG, SG_SMISTATE, SG_SMIDIV,
SG_WAVE, SG_VODKA, SG_VOLRATIO,
SG_COUNT
};
// ---------------------------------------------------------------------------
// Enums (mirrors the NinjaScript enums)
// ---------------------------------------------------------------------------
enum ADMFilterRules { ADM_Sierra = 0, ADM_NinjaLegacy = 1 };
enum ADMBarColorMode { ADM_BC_None = 0, ADM_BC_Waddah = 1, ADM_BC_Linda = 2, ADM_BC_Supertrend = 3 };
enum ADMSuperTrendAtr { ADM_ST_Hull = 0, ADM_ST_Wilder = 1 };
enum ADMEarlyTouch { ADM_ET_StopImmediately = 0, ADM_ET_IgnoreUntilValid = 1 };
enum ADMValidTouch { ADM_VT_StopOnly = 0, ADM_VT_StopAndContinuation = 1 };
enum ADMConfirmMode { ADM_CM_TouchOnly = 0, ADM_CM_CloseBeyondLine = 1, ADM_CM_CloseBeyondZone = 2 };
enum ADMLinePriceMode { ADM_LP_Midpoint = 0, ADM_LP_PrevCloseEdge = 1, ADM_LP_CurrentOpenEdge = 2 };
enum ADMTargetMode { ADM_TM_None = 0, ADM_TM_OppositeBand = 1, ADM_TM_FixedTicks = 2 };
enum ADMBollingerLocation { ADM_BL_Close = 0, ADM_BL_WickExtreme = 1, ADM_BL_HLC3 = 2, ADM_BL_BodyMid = 3 };
enum ADMObrLocationMode { ADM_OL_NearBand = 0, ADM_OL_PierceOrPrev = 1 };
enum ADMObrMarkerStyle { ADM_OM_Diamond = 0, ADM_OM_Arrow = 1, ADM_OM_None = 2 };
enum ADMGapLineExtension { ADM_GLE_Projected = 0, ADM_GLE_ToCurrentBar = 1 };
enum ADMBgLocationMode { ADM_BG_Proximity = 0, ADM_BG_SierraPierce = 1 };
enum ADMBrightnessMode { ADM_BM_Fixed = 0, ADM_BM_AutoScale = 1 };
enum ADMDashCorner { ADM_DC_TopRight = 0, ADM_DC_TopLeft = 1, ADM_DC_BottomRight = 2, ADM_DC_BottomLeft = 3 };
enum ADMAlertSignal
{
AS_Buy, AS_Sell, AS_BigBuy, AS_BigSell, AS_SqueezeUp, AS_SqueezeDown,
AS_VolImbBuy, AS_VolImbSell, AS_GapTouchBull, AS_GapTouchBear,
AS_FcLong, AS_FcShort, AS_BgLong, AS_BgShort, AS_ObrLong, AS_ObrShort,
AS_Tramp, AS_ThreeOutside, AS_Tweezer, AS_WickPat, AS_Stairs, AS_RevSquare,
AS_KamaBounce, AS_VodkaBuy, AS_VodkaSell, AS_SmiDivBull, AS_SmiDivBear, AS_Spiderweb
};
// ---------------------------------------------------------------------------
// Generic numeric helpers
// ---------------------------------------------------------------------------
static inline bool ADM_IsZero(double x) { return fabs(x) < 1e-12; }
static inline double ADM_Ema(double prev, double price, int period, bool& init)
{
double k = 2.0 / (period + 1.0);
if (!init) { init = true; return price; }
return k * price + (1.0 - k) * prev;
}
// Self-contained recursive EMA line (own seeding flag, no cross-talk between lines)
struct EmaState
{
double value;
bool init;
EmaState() : value(0), init(false) {}
double Push(double price, int period)
{
value = ADM_Ema(value, price, period, init);
return value;
}
void Reset() { value = 0; init = false; }
};
// Wilder-style recursive smoothing: v += (x - v) / period, seeded with x on first use.
// This is the exact recurrence for Wilder's ATR, and a standard (widely used) way to
// smooth ADX's internal DM/TR/DX lines without needing a bootstrap window.
struct WilderState
{
double value;
bool init;
WilderState() : value(0), init(false) {}
double Push(double x, int period)
{
if (!init) { init = true; value = x; }
else value = value + (x - value) / period;
return value;
}
void Reset() { value = 0; init = false; }
};
// Rolling SMA using a deque + running sum (O(1) amortized)
static inline double ADM_RollingSma(std::deque<double>& win, double& sum, double value, int period)
{
win.push_back(value);
sum += value;
if ((int)win.size() > period)
{
sum -= win.front();
win.pop_front();
}
return win.empty() ? 0.0 : sum / (double)win.size();
}
// Linear regression endpoint at bar `idx` over the trailing `period` bars (matches
// NinjaTrader's LinReg last-bar value); uses fewer points during warmup, like NT does.
template <typename Getter>
static double ADM_LinRegAt(Getter get, int idx, int period)
{
int n = (idx + 1 < period) ? (idx + 1) : period;
if (n <= 0) return get(idx);
double sx = 0, sy = 0, sxy = 0, sxx = 0;
for (int i = 0; i < n; i++)
{
double x = (double)i;
double y = get(idx - n + 1 + i);
sx += x; sy += y; sxy += x * y; sxx += x * x;
}
double denom = (n * sxx - sx * sx);
double slope = ADM_IsZero(denom) ? 0.0 : (n * sxy - sx * sy) / denom;
double intercept = (sy - slope * sx) / n;
return intercept + slope * (n - 1);
}
// Simple moving average of `get(idx-period+1..idx)`, shrinking the window during warmup.
template <typename Getter>
static double ADM_SmaAt(Getter get, int idx, int period)
{
int n = (idx + 1 < period) ? (idx + 1) : period;
if (n <= 0) return get(idx);
double sum = 0;
for (int i = 0; i < n; i++) sum += get(idx - i);
return sum / n;
}
// Weighted moving average (most recent bar gets the highest weight).
template <typename Getter>
static double ADM_WmaAt(Getter get, int idx, int period)
{
int n = (idx + 1 < period) ? (idx + 1) : period;
if (n <= 0) return get(idx);
double wsum = 0, sum = 0;
for (int i = 0; i < n; i++) { int w = n - i; wsum += w * get(idx - i); sum += w; }
return sum > 0 ? wsum / sum : get(idx);
}
template <typename Getter>
static double ADM_MaxAt(Getter get, int idx, int period)
{
int n = (idx + 1 < period) ? (idx + 1) : period;
double m = get(idx);
for (int i = 1; i < n; i++) { double v = get(idx - i); if (v > m) m = v; }
return m;
}
template <typename Getter>
static double ADM_MinAt(Getter get, int idx, int period)
{
int n = (idx + 1 < period) ? (idx + 1) : period;
double m = get(idx);
for (int i = 1; i < n; i++) { double v = get(idx - i); if (v < m) m = v; }
return m;
}
// Hull Moving Average of an arbitrary source: WMA(2*WMA(src,period/2) - WMA(src,period), sqrt(period))
template <typename Getter>
static double ADM_HmaAt(Getter get, int idx, int period)
{
int half = (std::max)(1, period / 2);
int sq = (std::max)(1, (int)(sqrt((double)period) + 0.5));
auto raw = [&](int i) -> double {
double w1 = ADM_WmaAt(get, i, half);
double w2 = ADM_WmaAt(get, i, period);
return 2.0 * w1 - w2;
};
return ADM_WmaAt(raw, idx, sq);
}
// ---------------------------------------------------------------------------
// Nested value types
// ---------------------------------------------------------------------------
struct SmiPivot
{
int Bar;
double Value;
bool IsHigh;
};
struct GapInfo
{
int Direction;
int CreationBar;
double PreviousClose;
double CurrentOpen;
double ZoneLow;
double ZoneHigh;
double LinePrice;
bool IsValid;
bool Touched;
bool InvalidTooEarly;
bool Drawn;
int LineId;
int ZoneId;
};
struct PendingContinuation
{
int GapIndexInHistory; // index into g_GapHistory (stable storage, see below)
int TouchBar;
};
struct SuperTrendState
{
double Ub, Lb, St;
int Dir;
bool Init;
bool SierraLag;
double pLbBasic;
SuperTrendState() : Ub(0), Lb(0), St(0), Dir(1), Init(false), SierraLag(false), pLbBasic(0) {}
void Update(double close, double prevClose, double basePrice, double atr, double mult)
{
double ubBasic = basePrice + mult * atr;
double lbBasic = basePrice - mult * atr;
if (!Init)
{
Ub = ubBasic;
Lb = lbBasic;
Dir = close >= basePrice ? 1 : -1;
St = Dir > 0 ? Lb : Ub;
pLbBasic = lbBasic;
Init = true;
return;
}
double pUb = Ub;
double pLb = Lb;
Ub = (ubBasic < pUb || prevClose > pUb) ? ubBasic : pUb;
double lbSource = SierraLag ? pLbBasic : lbBasic;
Lb = (lbBasic > pLb || prevClose < pLb) ? lbSource : pLb;
pLbBasic = lbBasic;
if (Dir > 0) { if (close < Lb) Dir = -1; }
else { if (close > Ub) Dir = 1; }
St = Dir > 0 ? Lb : Ub;
}
};
// ---------------------------------------------------------------------------
// Persistent engine state (one instance per chart/study, via GetPersistentPointer)
// ---------------------------------------------------------------------------
struct AdmState
{
// ---- shadow series (mirrors every Series<T> in the original 1:1) ----
std::vector<double> lindaLine, aoLine, fisherValue, sqzRaw;
std::vector<double> sumDmPlus, sumDmMinus, diPlusIdx, diMinusIdx, adxIdx, adxvmaLine, adxvmaTrend;
std::vector<double> tsiLine;
std::vector<double> rsiUpS, rsiDnS, rsiCut;
std::vector<double> vdkMacd, wadAbsS, volAtrS, lindaAbsS;
std::vector<char> brightGreenS, brightRedS, upVodkaS, downVodkaS;
std::vector<int> waveS;
std::vector<double> smiNum1, smiDen1, smiNum2, smiDen2, smiLine, smiAvgLine;
// scalar EMA/SMA/etc. state (only [0]/[1] ever referenced upstream)
EmaState ema20, ema40;
double sarValue; int sarTrend; double sarEp, sarAf;
double kamaPrev; bool kamaInit;
WilderState rsiGainW, rsiLossW; // classic (NinjaLegacy) Wilder RSI
std::vector<double> rsiStdV; // classic RSI value per bar
double fishRaw, fishNt; bool fishInit; // classic (NinjaLegacy) Ehlers Fisher Transform on Close
EmaState t3Ema1[6], t3Ema2[6];
EmaState sqEma;
EmaState tsiNum1, tsiNum2, tsiDen1, tsiDen2, tsiSignal;
EmaState vdkEmaFast, vdkEmaSlow, vdkSignal;
std::vector<double> vdkWma1V, vdkWma2V; // vdkWma3 (=WMA(vdkWma2V,w3)) computed on demand
double wadAbsAvgSum; std::deque<double> wadAbsAvgWin;
double lindaAbsAvgSum; std::deque<double> lindaAbsAvgWin;
double linWadAbsAvgSum; std::deque<double> linWadAbsAvgWin;
double volAtrAvgSum; std::deque<double> volAtrAvgWin;
WilderState volAtr, lizAtr, stWilderAtr, smiAtr, adxVolatility;
// classic Wilder ADX (separate from the ADXVMA port, which has its own diPlusIdx/diMinusIdx above)
WilderState adxTR, adxDmPlus, adxDmMinus, adxDx;
// SuperTrend
SuperTrendState stMain, stLiz;
// gap engine
std::vector<GapInfo> gapHistory; // stable storage so pending continuations can reference by index
std::vector<int> activeGapIdx; // indices into gapHistory currently active
std::vector<PendingContinuation> pendingContinuations;
// SMI pivots
std::vector<SmiPivot> smiPricePivots, smiOscPivots;
std::string lastBullDivKey, lastBearDivKey;
// stacking
std::map<int,double> stackUp, stackDn;
// misc per-bar state
bool sqRelaxUp;
bool bigArrowUp;
std::string prevEvil;
int warmupBars;
int drawCounter;
int nextLineId;
bool spiderWarnPrev;
int wavePrev;
double volRatio;
bool vodkaBuyRaw, vodkaSellRaw;
// per-bar cache
bool cGreen, cRed, cDoji;
double cBody, cPBody;
double bbU, bbM, bbL, bbU1, bbL1;
double cT1, cLinda, cSar, cKama;
double cWadAvg, cLindaAvg, cLinWadAvg;
double cAo, cAo1, cAdx, cHma, cHma1, cT3, cFishNt, cFishNt1;
double cRsi0, cRsi1, cRsi2, cSqHist, cSqHist1, cTsi, cTsiSig;
double cSmi, cSmiPrev, cSmiAvg;
};
// Resets all engine state to its bar-0 condition (mirrors the original's
// SeedFirstBar / field initializers). Called both when constructing the
// state and whenever the chart does a full recalculation from bar 0.
static void ADM_ResetState(AdmState& s)
{
s.lindaLine.clear(); s.aoLine.clear(); s.fisherValue.clear(); s.sqzRaw.clear();
s.sumDmPlus.clear(); s.sumDmMinus.clear(); s.diPlusIdx.clear(); s.diMinusIdx.clear();
s.adxIdx.clear(); s.adxvmaLine.clear(); s.adxvmaTrend.clear();
s.tsiLine.clear();
s.rsiUpS.clear(); s.rsiDnS.clear(); s.rsiCut.clear();
s.vdkMacd.clear(); s.wadAbsS.clear(); s.volAtrS.clear(); s.lindaAbsS.clear();
s.brightGreenS.clear(); s.brightRedS.clear(); s.upVodkaS.clear(); s.downVodkaS.clear();
s.waveS.clear();
s.smiNum1.clear(); s.smiDen1.clear(); s.smiNum2.clear(); s.smiDen2.clear();
s.smiLine.clear(); s.smiAvgLine.clear();
s.ema20.Reset(); s.ema40.Reset();
s.sarValue = 0; s.sarTrend = 1; s.sarEp = 0; s.sarAf = 0;
s.kamaPrev = 0; s.kamaInit = false;
s.rsiGainW.Reset(); s.rsiLossW.Reset(); s.rsiStdV.clear();
s.fishRaw = 0; s.fishNt = 0; s.fishInit = false;
for (int i = 0; i < 6; i++) { s.t3Ema1[i].Reset(); s.t3Ema2[i].Reset(); }
s.sqEma.Reset();
s.tsiNum1.Reset(); s.tsiNum2.Reset(); s.tsiDen1.Reset(); s.tsiDen2.Reset(); s.tsiSignal.Reset();
s.vdkEmaFast.Reset(); s.vdkEmaSlow.Reset(); s.vdkSignal.Reset();
s.vdkWma1V.clear(); s.vdkWma2V.clear();
s.wadAbsAvgSum = s.lindaAbsAvgSum = s.linWadAbsAvgSum = s.volAtrAvgSum = 0;
s.wadAbsAvgWin.clear(); s.lindaAbsAvgWin.clear(); s.linWadAbsAvgWin.clear(); s.volAtrAvgWin.clear();
s.volAtr.Reset(); s.lizAtr.Reset(); s.stWilderAtr.Reset(); s.smiAtr.Reset(); s.adxVolatility.Reset();
s.adxTR.Reset(); s.adxDmPlus.Reset(); s.adxDmMinus.Reset(); s.adxDx.Reset();
s.stMain = SuperTrendState();
s.stLiz = SuperTrendState();
s.gapHistory.clear(); s.activeGapIdx.clear(); s.pendingContinuations.clear();
s.smiPricePivots.clear(); s.smiOscPivots.clear();
s.lastBullDivKey.clear(); s.lastBearDivKey.clear();
s.stackUp.clear(); s.stackDn.clear();
s.sqRelaxUp = false;
s.bigArrowUp = false;
s.prevEvil.clear();
s.warmupBars = 45;
s.drawCounter = 0;
s.nextLineId = 100000;
s.spiderWarnPrev = false;
s.wavePrev = -1;
s.volRatio = 1.0;
s.vodkaBuyRaw = s.vodkaSellRaw = false;
}
struct AdmStateInit
{
static AdmState* Create()
{
AdmState* s = new AdmState();
ADM_ResetState(*s);
return s;
}
};
// ---------------------------------------------------------------------------
// Dashboard / drawing helpers
// ---------------------------------------------------------------------------
static void ADM_DeleteDrawing(SCStudyInterfaceRef sc, int lineId)
{
sc.DeleteACSChartDrawing(sc.ChartNumber, TOOL_DELETE_CHARTDRAWING, lineId);
}
static void ADM_DrawText(SCStudyInterfaceRef sc, int lineId, int barIndex, double price,
const SCString& text, COLORREF color, int fontSize, bool bold, bool addAlways = false)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_TEXT;
tool.LineNumber = lineId;
tool.BeginDateTime = sc.BaseDateTimeIn[barIndex];
tool.BeginValue = (float)price;
tool.Color = RGB(255,255,255);
tool.FontSize = 9;
tool.FontBold = bold ? 1 : 0;
tool.FontFace = "Arial";
tool.Text = text;
tool.TextAlignment = DT_CENTER | DT_VCENTER;
tool.AddMethod = addAlways ? UTAM_ADD_ALWAYS : UTAM_ADD_OR_ADJUST;
tool.AddAsUserDrawnDrawing = 0;
sc.UseTool(tool);
}
static void ADM_DrawLine(SCStudyInterfaceRef sc, int lineId, int startBar, double startPrice,
int endBar, double endPrice, COLORREF color, int lineStyle, int width, bool extendRight)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_LINE;
tool.LineNumber = lineId;
tool.BeginDateTime = sc.BaseDateTimeIn[startBar];
tool.BeginValue = (float)startPrice;
tool.EndDateTime = sc.BaseDateTimeIn[endBar];
tool.EndValue = (float)endPrice;
tool.Color = RGB(255,255,255);
tool.LineStyle = (SubgraphLineStyles)lineStyle;
tool.LineWidth = width;
tool.ExtendRight = extendRight ? 1 : 0;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.AddAsUserDrawnDrawing = 0;
sc.UseTool(tool);
}
static void ADM_DrawRect(SCStudyInterfaceRef sc, int lineId, int startBar, double top,
int endBar, double bottom, COLORREF fillColor, int transparency)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.LineNumber = lineId;
tool.BeginDateTime = sc.BaseDateTimeIn[startBar];
tool.BeginValue = (float)top;
tool.EndDateTime = sc.BaseDateTimeIn[endBar];
tool.EndValue = (float)bottom;
tool.Color = fillColor;
tool.SecondaryColor = fillColor;
tool.TransparencyLevel = transparency;
tool.LineWidth = 1;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.AddAsUserDrawnDrawing = 0;
sc.UseTool(tool);
}
static void ADM_DrawTextFixed(SCStudyInterfaceRef sc, int lineId, int anchorBar,
float relativeY, const SCString& text, COLORREF color, int fontSize, bool bold, int alignment)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_TEXT;
tool.LineNumber = lineId;
tool.BeginDateTime = sc.BaseDateTimeIn[anchorBar];
tool.UseRelativeVerticalValues = 1;
tool.BeginValue = relativeY;
tool.Color = color;
tool.FontSize = 9;
tool.FontBold = bold ? 1 : 0;
tool.FontFace = "Arial";
tool.Text = text;
tool.TextAlignment = alignment;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.AddAsUserDrawnDrawing = 0;
sc.UseTool(tool);
}
static void ADM_DrawRectFixed(SCStudyInterfaceRef sc, int lineId, int anchorBar,
float relTop, float relBottom, COLORREF fillColor, int transparency)
{
s_UseTool tool;
tool.Clear();
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
tool.LineNumber = lineId;
tool.BeginDateTime = sc.BaseDateTimeIn[anchorBar];
tool.EndDateTime = sc.BaseDateTimeIn[anchorBar];
tool.UseRelativeVerticalValues = 1;
tool.BeginValue = relTop;
tool.EndValue = relBottom;
tool.Color = fillColor;
tool.SecondaryColor = fillColor;
tool.TransparencyLevel = transparency;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.AddAsUserDrawnDrawing = 0;
sc.UseTool(tool);
}
// ---------------------------------------------------------------------------
// Input indices - named so SetDefaults and the runtime read stay in lock-step
// ---------------------------------------------------------------------------
enum ADMInput
{
// 01. Confluence Filters
IN_FilterRules, IN_SierraExactMode, IN_UseWaddah, IN_UseLindaMacd, IN_UsePsar,
IN_UseSupertrend, IN_UseAO, IN_UseHma, IN_UseT3, IN_UseFisher, IN_UseSqueezeMomentum,
IN_MinAdx, IN_UseAdxvma, IN_UseLizardSuperTrend, IN_UseMultiTsi, IN_UseSmi,
IN_RequireCandleDirection, IN_IgnoreDojis,
// 02. Filter Parameters
IN_WaddahIntensity, IN_LindaFast, IN_LindaSlow, IN_LindaSignal,
IN_PsarAcceleration, IN_PsarMax, IN_PsarStep, IN_AdxPeriod, IN_HmaPeriod,
IN_T3Period, IN_T3TCount, IN_T3VFactor, IN_StPeriod, IN_StMultiplier, IN_StAtrType,
IN_SqueezePeriod, IN_SqueezeUsesOpen, IN_AdxvmaPeriod, IN_TsiSmooth1, IN_TsiSmooth2,
IN_TsiSignalPeriod, IN_LizStAtrPeriod, IN_LizStMultiplier,
IN_SmiPeriodK, IN_SmiSmooth1, IN_SmiSmooth2, IN_SmiSignalPeriod, IN_SmiOverbought,
IN_SmiOversold, IN_SmiMidline, IN_SmiRequireSlope, IN_SmiDivergenceLookback,
// 03. Signals / patterns display
IN_ShowBuySell, IN_ShowBigArrow, IN_ShowSqueezeStars, IN_ShowVolumeImbalanceArrows,
IN_ShowTrampoline, IN_TrampolineRsiHigh, IN_TrampolineRsiLow, IN_TrampolineToleranceTicks,
IN_ShowThreeOutside, IN_ShowTweezers, IN_TweezerToleranceTicks, IN_ShowWickPattern,
IN_ShowStairs, IN_ShowReversalSquare, IN_ShowShavedCandles, IN_ShavedToleranceTicks,
IN_ShowBbEngulfShading,
// 04. SMI divergence
IN_EnableSmiDivergence, IN_SmiIncludeHiddenDivergence, IN_ShowSmiDivergenceLines,
// 05. KAMA
IN_ShowKama, IN_KamaFast, IN_KamaPeriod, IN_KamaSlow, IN_ShowKamaBounceMarkers, IN_KamaLineWidth,
// 06. Evil Times
IN_ShowEvilTimes, IN_EvilTimesChartOffsetHours,
// 07. Signal layout
IN_StackSignals, IN_StackStepTicks, IN_TextSize, IN_ShowSignalLabels,
// 08. Bar color
IN_BarColor, IN_WaddahBarOffset, IN_WaddahBrightnessMode, IN_WaddahBarGain,
IN_WaddahAutoLength, IN_WaddahAutoFullMultiple, IN_LindaBrightnessMode,
IN_LindaBarIntensity, IN_LindaAutoLength, IN_LindaAutoFullMultiple, IN_LindaBarOffset,
// 09. Bollinger
IN_BbPeriod, IN_BbStdDev, IN_ShowBollingerBands, IN_BbLineWidth,
IN_ShowBollingerMiddle, IN_BbMidWidth,
// 10. Gap engine
IN_MinGapSizeTicks, IN_MinBarsBeforeValid, IN_MinBodyTicks, IN_MaxGapBarRangeTicks,
IN_MaxActiveGaps, IN_EarlyTouch, IN_ValidTouch, IN_LinePriceMode, IN_ShowGapLine,
IN_ShowGapZone, IN_ShowTouchMarker, IN_UseTouchedLineColor, IN_GapLineWidth,
IN_GapWidthBySize, IN_GapMinWidth, IN_GapMaxWidth, IN_GapMaxWidthAtTicks,
IN_GapZoneOpacity, IN_GapLineExtension, IN_GapProjectionBars,
// 11. FC continuation
IN_EnableContinuation, IN_UseBbMidFilterFc, IN_FcLocationSource, IN_FcLongBelowMidPct,
IN_FcShortAboveMidPct, IN_ConfirmMode, IN_ConfirmBarsAfterTouch,
IN_RequireSignalCandleDirection, IN_RequireCorrectApproach, IN_ShowContinuationMarkers,
// 12. OBR
IN_EnableObr, IN_PaintObrBars, IN_ObrMarkerStyle, IN_UseBbMidFilterObr,
IN_ObrLocationMode, IN_AllowObrOutsideBand, IN_BearObrTolTicks, IN_BullObrTolTicks,
IN_ObrPierceTicks, IN_ObrRequireLargerBody, IN_ObrMinBarSizeTicks, IN_ObrShowEntryLine,
IN_ObrEntryLineBars, IN_ObrShowZones, IN_ObrZoneBars, IN_ObrZoneOpacity,
// 13. Bollinger Gap
IN_EnableBollingerGap, IN_BgLocationMode, IN_BgProximityTicks, IN_ShowBgMarkers,
// 14. Spiderweb
IN_EnableSpiderweb, IN_ShowSpiderwebText, IN_SpiderwebDistanceTicks,
IN_SpiderwebLineCount, IN_SpiderwebFontSize,
// 15. Time filter / targets
IN_UseSignalTimeFilter, IN_SignalStartTime, IN_SignalEndTime,
IN_SuggestedStopOffsetTicks, IN_TargetMode, IN_FixedTargetTicks,
// 16. Vodka Shot
IN_EnableVodka, IN_VodkaRequireWave, IN_VodkaVolumeScale, IN_VodkaVolumeLength,
IN_VodkaCooldownBars, IN_VodkaTrendLength, IN_VodkaMacdFast, IN_VodkaMacdSlow,
IN_VodkaMacdSignal, IN_VodkaGlyphSize,
// 17. Wave
IN_WaveLookback, IN_WaveIgnoreDojis, IN_WaveDojiMaxTicks, IN_WaveFilterFc,
IN_WaveFilterBg, IN_WaveFilterObr,
// 18. Adaptive thresholds
IN_AdaptiveThresholds, IN_AdaptAtrLength, IN_AdaptAverageLength, IN_AdaptMinRatio,
IN_AdaptMaxRatio, IN_AdaptAdxFloor, IN_AdaptGapFilters, IN_AdaptBandDistances, IN_AdaptSpiderweb,
// 19. Alerts
IN_EnableAlerts, IN_PlaySounds,
IN_AlertBuy, IN_AlertSell, IN_AlertBigBuy, IN_AlertBigSell, IN_AlertSqueezeUp, IN_AlertSqueezeDown,
IN_AlertVolImbBuy, IN_AlertVolImbSell, IN_AlertGapTouchBull, IN_AlertGapTouchBear,
IN_AlertFcLong, IN_AlertFcShort, IN_AlertBgLong, IN_AlertBgShort, IN_AlertObrLong, IN_AlertObrShort,
IN_AlertTramp, IN_AlertThreeOutside, IN_AlertTweezer, IN_AlertWickPat, IN_AlertStairs,
IN_AlertRevSquare, IN_AlertKamaBounce, IN_AlertVodkaBuy, IN_AlertVodkaSell,
IN_AlertSmiDivBull, IN_AlertSmiDivBear, IN_AlertSpiderweb,
IN_SoundBullish, IN_SoundBearish, IN_SoundNeutral,
// 20. Offsets
IN_BuyTriangleOffsetTicks, IN_SellTriangleOffsetTicks, IN_BigArrowUpOffsetTicks,
IN_BigArrowDownOffsetTicks, IN_SqueezeStarUpOffsetTicks, IN_SqueezeStarDownOffsetTicks,
IN_VolImbUpOffsetTicks, IN_VolImbDownOffsetTicks, IN_FcMarkerOffsetTicks,
IN_BgMarkerOffsetTicks, IN_ObrMarkerOffsetTicks, IN_ObrArrowOffsetTicks,
IN_SignalLabelOffsetTicks, IN_PatternLabelOffsetTicks, IN_TrampolineOffsetTicks,
IN_ReversalSquareOffsetTicks, IN_EvilTimesOffsetTicks, IN_VodkaUpOffsetTicks, IN_VodkaDownOffsetTicks,
// 21. Colors
IN_WaddahUpColor, IN_WaddahDownColor, IN_BuyColor, IN_SellColor, IN_StarColor, IN_VolImbColor,
IN_GapBullLineColor, IN_GapBearLineColor, IN_GapTouchedColor, IN_GapInvalidColor,
IN_GapBullZoneColor, IN_GapBearZoneColor, IN_TouchMarkerColor,
IN_BgLongColor, IN_BgShortColor, IN_FcLongColor, IN_FcShortColor,
IN_ObrBullColor, IN_ObrBearColor, IN_ObrLightZoneColor, IN_ObrShadowZoneColor,
IN_SpiderwebColor, IN_PatternTextColor, IN_PatternBullBackColor, IN_PatternBearBackColor,
IN_TrampTextColor, IN_TrampBackColor, IN_BbEngulfGreenColor, IN_BbEngulfRedColor,
IN_ShavedGreenColor, IN_ShavedRedColor, IN_KamaColor, IN_BbUpperColor, IN_BbLowerColor, IN_BbMidColor,
IN_SmiBullDivColor, IN_SmiBearDivColor, IN_SmiHiddenBullDivColor, IN_SmiHiddenBearDivColor,
IN_EvilTimesColor, IN_VodkaUpColor, IN_VodkaDownColor,
// 22. Dashboard
IN_ShowDashboard, IN_DashboardCorner, IN_DashboardFontSize, IN_DashboardOpacity,
IN_COUNT
};
// ---------------------------------------------------------------------------
// Main study function
// ---------------------------------------------------------------------------
SCSFExport scsf_ADITRADYMEGATRON(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "Aditrady Megatron";
sc.StudyDescription =
"Unified confluence signals, candle patterns, gap engine (Volume Imbalance / "
"FC continuation / Bollinger Gap / Outside Bar Reversal), spiderweb warning, "
"SMI + divergence, Wave state, Vodka Shot, KAMA and Bollinger Bands, with a "
"compact on-chart dashboard. Ported from the ADITRADYMEGATRON NinjaScript indicator.";
sc.AutoLoop = 1;
sc.GraphRegion = 0;
sc.FreeDLL = 0;
sc.ScaleRangeType = SCALE_SAMEASREGION;
sc.CalculationPrecedence = LOW_PREC_LEVEL;
// ---- Subgraphs (matches the original plot layout) ----
sc.Subgraph[SG_BUY].Name = "Buy Triangle";
sc.Subgraph[SG_BUY].DrawStyle = DRAWSTYLE_IGNORE; // drawn as a glyph, see DrawSignalGlyph()
sc.Subgraph[SG_BUY].DrawZeros = false;
sc.Subgraph[SG_SELL].Name = "Sell Triangle";
sc.Subgraph[SG_SELL].DrawStyle = DRAWSTYLE_IGNORE;
sc.Subgraph[SG_SELL].DrawZeros = false;
sc.Subgraph[SG_KAMA].Name = "KAMA";
sc.Subgraph[SG_KAMA].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[SG_KAMA].PrimaryColor = ADM_RGB(184, 134, 11);
sc.Subgraph[SG_KAMA].LineWidth = 2;
sc.Subgraph[SG_BBU].Name = "Bollinger Upper";
sc.Subgraph[SG_BBU].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[SG_BBU].PrimaryColor = ADM_RGB(30, 144, 255);
sc.Subgraph[SG_BBM].Name = "Bollinger Middle";
sc.Subgraph[SG_BBM].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[SG_BBM].PrimaryColor = ADM_RGB(218, 165, 32);
sc.Subgraph[SG_BBL].Name = "Bollinger Lower";
sc.Subgraph[SG_BBL].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[SG_BBL].PrimaryColor = ADM_RGB(30, 144, 255);
sc.Subgraph[SG_BARCOLOR].Name = "Bar Color";
sc.Subgraph[SG_BARCOLOR].DrawStyle = DRAWSTYLE_IGNORE; // set to DRAWSTYLE_COLOR_BAR at runtime when a bar-color mode is active
const char* hiddenNames[] = {
"Lower Touch","Upper Touch","Middle Close","Confluence","Big Arrow","Squeeze Star",
"Pattern Code","Volume Imbalance","Gap Touched","Invalid Gap Touched","Continuation",
"Bollinger Gap","Outside Bar Reversal","Active Gaps","Valid Gaps","Pending Continuations",
"Spiderweb Count","Spiderweb Warning","Nearest Gap Price","Suggested Entry",
"Suggested Stop","Suggested Target","Signal Direction","Signal Code","Master Long",
"Master Short","SMI","SMI Signal","SMI State","SMI Divergence","Wave State",
"Vodka Signal","Volatility Ratio"
};
for (int i = SG_LOWTOUCH; i < SG_COUNT; i++)
{
sc.Subgraph[i].Name = hiddenNames[i - SG_LOWTOUCH];
sc.Subgraph[i].DrawStyle = DRAWSTYLE_IGNORE;
sc.Subgraph[i].DrawZeros = false;
}
// ================= INPUTS =================
// ---- 01. Confluence Filters ----
sc.Input[IN_FilterRules].Name = "01 - Filter Rules";
sc.Input[IN_FilterRules].SetCustomInputStrings("Sierra;NinjaLegacy");
sc.Input[IN_FilterRules].SetCustomInputIndex(0);
sc.Input[IN_SierraExactMode].Name = "01 - Sierra Exact Mode";
sc.Input[IN_SierraExactMode].SetYesNo(false);
sc.Input[IN_UseWaddah].Name = "01 - Filter: Waddah Explosion";
sc.Input[IN_UseWaddah].SetYesNo(true);
sc.Input[IN_UseLindaMacd].Name = "01 - Filter: Linda MACD";
sc.Input[IN_UseLindaMacd].SetYesNo(true);
sc.Input[IN_UsePsar].Name = "01 - Filter: Parabolic SAR";
sc.Input[IN_UsePsar].SetYesNo(true);
sc.Input[IN_UseSupertrend].Name = "01 - Filter: SuperTrend";
sc.Input[IN_UseSupertrend].SetYesNo(false);
sc.Input[IN_UseAO].Name = "01 - Filter: Awesome Oscillator";
sc.Input[IN_UseAO].SetYesNo(false);
sc.Input[IN_UseHma].Name = "01 - Filter: Hull Moving Avg";
sc.Input[IN_UseHma].SetYesNo(true);
sc.Input[IN_UseT3].Name = "01 - Filter: T3";
sc.Input[IN_UseT3].SetYesNo(false);
sc.Input[IN_UseFisher].Name = "01 - Filter: Fisher Transform";
sc.Input[IN_UseFisher].SetYesNo(true);
sc.Input[IN_UseSqueezeMomentum].Name = "01 - Filter: Squeeze Momentum";
sc.Input[IN_UseSqueezeMomentum].SetYesNo(false);
sc.Input[IN_MinAdx].Name = "01 - Minimum ADX";
sc.Input[IN_MinAdx].SetInt(11); sc.Input[IN_MinAdx].SetIntLimits(0, 100);
sc.Input[IN_UseAdxvma].Name = "01 - Filter: ADXVMA Trend";
sc.Input[IN_UseAdxvma].SetYesNo(false);
sc.Input[IN_UseLizardSuperTrend].Name = "01 - Filter: Median SuperTrend (Lizard)";
sc.Input[IN_UseLizardSuperTrend].SetYesNo(false);
sc.Input[IN_UseMultiTsi].Name = "01 - Filter: Multi TSI";
sc.Input[IN_UseMultiTsi].SetYesNo(false);
sc.Input[IN_UseSmi].Name = "01 - Filter: SMI";
sc.Input[IN_UseSmi].SetYesNo(false);
sc.Input[IN_RequireCandleDirection].Name = "01 - Require Candle Direction";
sc.Input[IN_RequireCandleDirection].SetYesNo(false);
sc.Input[IN_IgnoreDojis].Name = "01 - Ignore Dojis";
sc.Input[IN_IgnoreDojis].SetYesNo(true);
// ---- 02. Filter Parameters ----
sc.Input[IN_WaddahIntensity].Name = "02 - Waddah Intensity";
sc.Input[IN_WaddahIntensity].SetInt(150); sc.Input[IN_WaddahIntensity].SetIntLimits(1, 100000);
sc.Input[IN_LindaFast].Name = "02 - Linda MACD Fast";
sc.Input[IN_LindaFast].SetInt(3); sc.Input[IN_LindaFast].SetIntLimits(1, 1000);
sc.Input[IN_LindaSlow].Name = "02 - Linda MACD Slow";
sc.Input[IN_LindaSlow].SetInt(9); sc.Input[IN_LindaSlow].SetIntLimits(1, 1000);
sc.Input[IN_LindaSignal].Name = "02 - Linda MACD Signal";
sc.Input[IN_LindaSignal].SetInt(16); sc.Input[IN_LindaSignal].SetIntLimits(1, 1000);
sc.Input[IN_PsarAcceleration].Name = "02 - PSAR Acceleration";
sc.Input[IN_PsarAcceleration].SetFloat(0.02f); sc.Input[IN_PsarAcceleration].SetFloatLimits(0.001f, 1.0f);
sc.Input[IN_PsarMax].Name = "02 - PSAR Max";
sc.Input[IN_PsarMax].SetFloat(0.2f); sc.Input[IN_PsarMax].SetFloatLimits(0.001f, 1.0f);
sc.Input[IN_PsarStep].Name = "02 - PSAR Step";
sc.Input[IN_PsarStep].SetFloat(0.02f); sc.Input[IN_PsarStep].SetFloatLimits(0.001f, 1.0f);
sc.Input[IN_AdxPeriod].Name = "02 - ADX Period";
sc.Input[IN_AdxPeriod].SetInt(14); sc.Input[IN_AdxPeriod].SetIntLimits(1, 500);
sc.Input[IN_HmaPeriod].Name = "02 - HMA Period";
sc.Input[IN_HmaPeriod].SetInt(10); sc.Input[IN_HmaPeriod].SetIntLimits(2, 500);
sc.Input[IN_T3Period].Name = "02 - T3 Period";
sc.Input[IN_T3Period].SetInt(10); sc.Input[IN_T3Period].SetIntLimits(1, 500);
sc.Input[IN_T3TCount].Name = "02 - T3 Stage Count";
sc.Input[IN_T3TCount].SetInt(3); sc.Input[IN_T3TCount].SetIntLimits(1, 6);
sc.Input[IN_T3VFactor].Name = "02 - T3 V Factor";
sc.Input[IN_T3VFactor].SetFloat(0.84f); sc.Input[IN_T3VFactor].SetFloatLimits(0.0f, 1.0f);
sc.Input[IN_StPeriod].Name = "02 - SuperTrend Period";
sc.Input[IN_StPeriod].SetInt(11); sc.Input[IN_StPeriod].SetIntLimits(1, 500);
sc.Input[IN_StMultiplier].Name = "02 - SuperTrend Multiplier";
sc.Input[IN_StMultiplier].SetFloat(2.0f); sc.Input[IN_StMultiplier].SetFloatLimits(0.1f, 20.0f);
sc.Input[IN_StAtrType].Name = "02 - SuperTrend ATR Type";
sc.Input[IN_StAtrType].SetCustomInputStrings("Hull;Wilder");
sc.Input[IN_StAtrType].SetCustomInputIndex(0);
sc.Input[IN_SqueezePeriod].Name = "02 - Squeeze Period";
sc.Input[IN_SqueezePeriod].SetInt(20); sc.Input[IN_SqueezePeriod].SetIntLimits(2, 500);
sc.Input[IN_SqueezeUsesOpen].Name = "02 - Squeeze Uses Open";
sc.Input[IN_SqueezeUsesOpen].SetYesNo(true);
sc.Input[IN_AdxvmaPeriod].Name = "02 - ADXVMA Period";
sc.Input[IN_AdxvmaPeriod].SetInt(8); sc.Input[IN_AdxvmaPeriod].SetIntLimits(1, 200);
sc.Input[IN_TsiSmooth1].Name = "02 - TSI Smooth 1";
sc.Input[IN_TsiSmooth1].SetInt(20); sc.Input[IN_TsiSmooth1].SetIntLimits(1, 200);
sc.Input[IN_TsiSmooth2].Name = "02 - TSI Smooth 2";
sc.Input[IN_TsiSmooth2].SetInt(9); sc.Input[IN_TsiSmooth2].SetIntLimits(1, 200);
sc.Input[IN_TsiSignalPeriod].Name = "02 - TSI Signal Period";
sc.Input[IN_TsiSignalPeriod].SetInt(5); sc.Input[IN_TsiSignalPeriod].SetIntLimits(1, 200);
sc.Input[IN_LizStAtrPeriod].Name = "02 - Lizard SuperTrend ATR Period";
sc.Input[IN_LizStAtrPeriod].SetInt(15); sc.Input[IN_LizStAtrPeriod].SetIntLimits(1, 500);
sc.Input[IN_LizStMultiplier].Name = "02 - Lizard SuperTrend Multiplier";
sc.Input[IN_LizStMultiplier].SetFloat(2.5f); sc.Input[IN_LizStMultiplier].SetFloatLimits(0.1f, 20.0f);
sc.Input[IN_SmiPeriodK].Name = "02 - SMI Period K";
sc.Input[IN_SmiPeriodK].SetInt(8); sc.Input[IN_SmiPeriodK].SetIntLimits(1, 200);
sc.Input[IN_SmiSmooth1].Name = "02 - SMI Smooth 1";
sc.Input[IN_SmiSmooth1].SetInt(3); sc.Input[IN_SmiSmooth1].SetIntLimits(1, 200);
sc.Input[IN_SmiSmooth2].Name = "02 - SMI Smooth 2";
sc.Input[IN_SmiSmooth2].SetInt(5); sc.Input[IN_SmiSmooth2].SetIntLimits(1, 200);
sc.Input[IN_SmiSignalPeriod].Name = "02 - SMI Signal Period";
sc.Input[IN_SmiSignalPeriod].SetInt(7); sc.Input[IN_SmiSignalPeriod].SetIntLimits(1, 200);
sc.Input[IN_SmiOverbought].Name = "02 - SMI Overbought";
sc.Input[IN_SmiOverbought].SetFloat(50.0f);
sc.Input[IN_SmiOversold].Name = "02 - SMI Oversold";
sc.Input[IN_SmiOversold].SetFloat(-50.0f);
sc.Input[IN_SmiMidline].Name = "02 - SMI Midline";
sc.Input[IN_SmiMidline].SetFloat(0.0f);
sc.Input[IN_SmiRequireSlope].Name = "02 - SMI Require Slope";
sc.Input[IN_SmiRequireSlope].SetYesNo(true);
sc.Input[IN_SmiDivergenceLookback].Name = "02 - SMI Divergence Lookback";
sc.Input[IN_SmiDivergenceLookback].SetInt(10); sc.Input[IN_SmiDivergenceLookback].SetIntLimits(2, 200);
// ---- 03. Signals / Patterns Display ----
sc.Input[IN_ShowBuySell].Name = "03 - Show Buy/Sell Triangles";
sc.Input[IN_ShowBuySell].SetYesNo(true);
sc.Input[IN_ShowBigArrow].Name = "03 - Show Big Arrow (MACD/PSAR)";
sc.Input[IN_ShowBigArrow].SetYesNo(true);
sc.Input[IN_ShowSqueezeStars].Name = "03 - Show Squeeze Stars";
sc.Input[IN_ShowSqueezeStars].SetYesNo(true);
sc.Input[IN_ShowVolumeImbalanceArrows].Name = "03 - Show Volume Imbalance Arrows";
sc.Input[IN_ShowVolumeImbalanceArrows].SetYesNo(true);
sc.Input[IN_ShowTrampoline].Name = "03 - Show Trampoline";
sc.Input[IN_ShowTrampoline].SetYesNo(true);
sc.Input[IN_TrampolineRsiHigh].Name = "03 - Trampoline RSI High";
sc.Input[IN_TrampolineRsiHigh].SetInt(80); sc.Input[IN_TrampolineRsiHigh].SetIntLimits(50, 100);
sc.Input[IN_TrampolineRsiLow].Name = "03 - Trampoline RSI Low";
sc.Input[IN_TrampolineRsiLow].SetInt(20); sc.Input[IN_TrampolineRsiLow].SetIntLimits(0, 50);
sc.Input[IN_TrampolineToleranceTicks].Name = "03 - Trampoline Tolerance Ticks";
sc.Input[IN_TrampolineToleranceTicks].SetInt(1); sc.Input[IN_TrampolineToleranceTicks].SetIntLimits(0, 100);
sc.Input[IN_ShowThreeOutside].Name = "03 - Show Three Outside";
sc.Input[IN_ShowThreeOutside].SetYesNo(true);
sc.Input[IN_ShowTweezers].Name = "03 - Show Tweezers";
sc.Input[IN_ShowTweezers].SetYesNo(true);
sc.Input[IN_TweezerToleranceTicks].Name = "03 - Tweezer Tolerance Ticks";
sc.Input[IN_TweezerToleranceTicks].SetInt(3); sc.Input[IN_TweezerToleranceTicks].SetIntLimits(0, 100);
sc.Input[IN_ShowWickPattern].Name = "03 - Show Wick Pattern";
sc.Input[IN_ShowWickPattern].SetYesNo(true);
sc.Input[IN_ShowStairs].Name = "03 - Show Stairs";
sc.Input[IN_ShowStairs].SetYesNo(false);
sc.Input[IN_ShowReversalSquare].Name = "03 - Show Reversal Square";
sc.Input[IN_ShowReversalSquare].SetYesNo(false);
sc.Input[IN_ShowShavedCandles].Name = "03 - Show Shaved Candles";
sc.Input[IN_ShowShavedCandles].SetYesNo(true);
sc.Input[IN_ShavedToleranceTicks].Name = "03 - Shaved Tolerance Ticks";
sc.Input[IN_ShavedToleranceTicks].SetInt(0); sc.Input[IN_ShavedToleranceTicks].SetIntLimits(0, 100);
sc.Input[IN_ShowBbEngulfShading].Name = "03 - Show BB Engulf Shading";
sc.Input[IN_ShowBbEngulfShading].SetYesNo(true);
// ---- 04. SMI Divergence ----
sc.Input[IN_EnableSmiDivergence].Name = "04 - Enable SMI Divergence";
sc.Input[IN_EnableSmiDivergence].SetYesNo(false);
sc.Input[IN_SmiIncludeHiddenDivergence].Name = "04 - Include Hidden Divergence";
sc.Input[IN_SmiIncludeHiddenDivergence].SetYesNo(true);
sc.Input[IN_ShowSmiDivergenceLines].Name = "04 - Show SMI Divergence Lines";
sc.Input[IN_ShowSmiDivergenceLines].SetYesNo(true);
// ---- 05. KAMA ----
sc.Input[IN_ShowKama].Name = "05 - Show KAMA";
sc.Input[IN_ShowKama].SetYesNo(true);
sc.Input[IN_KamaFast].Name = "05 - KAMA Fast";
sc.Input[IN_KamaFast].SetInt(2); sc.Input[IN_KamaFast].SetIntLimits(1, 200);
sc.Input[IN_KamaPeriod].Name = "05 - KAMA Period";
sc.Input[IN_KamaPeriod].SetInt(9); sc.Input[IN_KamaPeriod].SetIntLimits(1, 500);
sc.Input[IN_KamaSlow].Name = "05 - KAMA Slow";
sc.Input[IN_KamaSlow].SetInt(109); sc.Input[IN_KamaSlow].SetIntLimits(1, 500);
sc.Input[IN_ShowKamaBounceMarkers].Name = "05 - Show KAMA Bounce Markers";
sc.Input[IN_ShowKamaBounceMarkers].SetYesNo(false);
sc.Input[IN_KamaLineWidth].Name = "05 - KAMA Line Width";
sc.Input[IN_KamaLineWidth].SetInt(2); sc.Input[IN_KamaLineWidth].SetIntLimits(1, 10);
// ---- 06. Evil Times ----
sc.Input[IN_ShowEvilTimes].Name = "06 - Show Evil Times Session Labels";
sc.Input[IN_ShowEvilTimes].SetYesNo(false);
sc.Input[IN_EvilTimesChartOffsetHours].Name = "06 - Evil Times Chart Offset Hours";
sc.Input[IN_EvilTimesChartOffsetHours].SetInt(0); sc.Input[IN_EvilTimesChartOffsetHours].SetIntLimits(-12, 12);
// ---- 07. Signal layout ----
sc.Input[IN_StackSignals].Name = "07 - Stack Overlapping Signals";
sc.Input[IN_StackSignals].SetYesNo(true);
sc.Input[IN_StackStepTicks].Name = "07 - Stack Step Ticks";
sc.Input[IN_StackStepTicks].SetInt(8); sc.Input[IN_StackStepTicks].SetIntLimits(1, 200);
sc.Input[IN_TextSize].Name = "07 - Label Text Size";
sc.Input[IN_TextSize].SetInt(9); sc.Input[IN_TextSize].SetIntLimits(6, 30);
sc.Input[IN_ShowSignalLabels].Name = "07 - Show Signal Labels (FC/BG/OBR)";
sc.Input[IN_ShowSignalLabels].SetYesNo(true);
// ---- 08. Bar Color ----
sc.Input[IN_BarColor].Name = "08 - Bar Color Mode";
sc.Input[IN_BarColor].SetCustomInputStrings("None;Waddah;LindaMACD;Supertrend");
sc.Input[IN_BarColor].SetCustomInputIndex(0);
sc.Input[IN_WaddahBarOffset].Name = "08 - Waddah Bar Offset";
sc.Input[IN_WaddahBarOffset].SetInt(80); sc.Input[IN_WaddahBarOffset].SetIntLimits(0, 255);
sc.Input[IN_WaddahBrightnessMode].Name = "08 - Waddah Brightness Mode";
sc.Input[IN_WaddahBrightnessMode].SetCustomInputStrings("Fixed;AutoScale");
sc.Input[IN_WaddahBrightnessMode].SetCustomInputIndex(0);
sc.Input[IN_WaddahBarGain].Name = "08 - Waddah Bar Gain";
sc.Input[IN_WaddahBarGain].SetFloat(1.0f);
sc.Input[IN_WaddahAutoLength].Name = "08 - Waddah Auto Length";
sc.Input[IN_WaddahAutoLength].SetInt(200); sc.Input[IN_WaddahAutoLength].SetIntLimits(2, 5000);
sc.Input[IN_WaddahAutoFullMultiple].Name = "08 - Waddah Auto Full Multiple";
sc.Input[IN_WaddahAutoFullMultiple].SetFloat(2.0f);
sc.Input[IN_LindaBrightnessMode].Name = "08 - Linda Brightness Mode";
sc.Input[IN_LindaBrightnessMode].SetCustomInputStrings("Fixed;AutoScale");
sc.Input[IN_LindaBrightnessMode].SetCustomInputIndex(0);
sc.Input[IN_LindaBarIntensity].Name = "08 - Linda Bar Intensity";
sc.Input[IN_LindaBarIntensity].SetInt(40); sc.Input[IN_LindaBarIntensity].SetIntLimits(0, 255);
sc.Input[IN_LindaAutoLength].Name = "08 - Linda Auto Length";
sc.Input[IN_LindaAutoLength].SetInt(200); sc.Input[IN_LindaAutoLength].SetIntLimits(2, 5000);
sc.Input[IN_LindaAutoFullMultiple].Name = "08 - Linda Auto Full Multiple";
sc.Input[IN_LindaAutoFullMultiple].SetFloat(2.0f);
sc.Input[IN_LindaBarOffset].Name = "08 - Linda Bar Offset";
sc.Input[IN_LindaBarOffset].SetInt(40); sc.Input[IN_LindaBarOffset].SetIntLimits(0, 255);
// ---- 09. Bollinger ----
sc.Input[IN_BbPeriod].Name = "09 - Bollinger Period";
sc.Input[IN_BbPeriod].SetInt(20); sc.Input[IN_BbPeriod].SetIntLimits(2, 500);
sc.Input[IN_BbStdDev].Name = "09 - Bollinger StdDev";
sc.Input[IN_BbStdDev].SetFloat(2.0f); sc.Input[IN_BbStdDev].SetFloatLimits(0.1f, 10.0f);
sc.Input[IN_ShowBollingerBands].Name = "09 - Show Bollinger Bands";
sc.Input[IN_ShowBollingerBands].SetYesNo(true);
sc.Input[IN_BbLineWidth].Name = "09 - Bollinger Band Line Width";
sc.Input[IN_BbLineWidth].SetInt(1); sc.Input[IN_BbLineWidth].SetIntLimits(1, 10);
sc.Input[IN_ShowBollingerMiddle].Name = "09 - Show Bollinger Middle";
sc.Input[IN_ShowBollingerMiddle].SetYesNo(true);
sc.Input[IN_BbMidWidth].Name = "09 - Bollinger Middle Width";
sc.Input[IN_BbMidWidth].SetInt(1); sc.Input[IN_BbMidWidth].SetIntLimits(1, 10);
// ---- 10. Gap Engine ----
sc.Input[IN_MinGapSizeTicks].Name = "10 - Min Gap Size Ticks";
sc.Input[IN_MinGapSizeTicks].SetInt(1); sc.Input[IN_MinGapSizeTicks].SetIntLimits(1, 1000);
sc.Input[IN_MinBarsBeforeValid].Name = "10 - Min Bars Before Valid";
sc.Input[IN_MinBarsBeforeValid].SetInt(3); sc.Input[IN_MinBarsBeforeValid].SetIntLimits(0, 500);
sc.Input[IN_MinBodyTicks].Name = "10 - Min Body Ticks";
sc.Input[IN_MinBodyTicks].SetInt(0); sc.Input[IN_MinBodyTicks].SetIntLimits(0, 1000);
sc.Input[IN_MaxGapBarRangeTicks].Name = "10 - Max Gap Bar Range Ticks (0=off)";
sc.Input[IN_MaxGapBarRangeTicks].SetInt(0); sc.Input[IN_MaxGapBarRangeTicks].SetIntLimits(0, 5000);
sc.Input[IN_MaxActiveGaps].Name = "10 - Max Active Gaps";
sc.Input[IN_MaxActiveGaps].SetInt(300); sc.Input[IN_MaxActiveGaps].SetIntLimits(1, 5000);
sc.Input[IN_EarlyTouch].Name = "10 - Early Touch Handling";
sc.Input[IN_EarlyTouch].SetCustomInputStrings("StopLineImmediately;IgnoreTouchesUntilValid");
sc.Input[IN_EarlyTouch].SetCustomInputIndex(0);
sc.Input[IN_ValidTouch].Name = "10 - Valid Touch Behavior";
sc.Input[IN_ValidTouch].SetCustomInputStrings("StopLineOnly;StopLineAndMarkContinuation");
sc.Input[IN_ValidTouch].SetCustomInputIndex(1);
sc.Input[IN_LinePriceMode].Name = "10 - Gap Line Price Mode";
sc.Input[IN_LinePriceMode].SetCustomInputStrings("Midpoint;PreviousCloseEdge;CurrentOpenEdge");
sc.Input[IN_LinePriceMode].SetCustomInputIndex(2);
sc.Input[IN_ShowGapLine].Name = "10 - Show Gap Line";
sc.Input[IN_ShowGapLine].SetYesNo(true);
sc.Input[IN_ShowGapZone].Name = "10 - Show Gap Zone";
sc.Input[IN_ShowGapZone].SetYesNo(false);
sc.Input[IN_ShowTouchMarker].Name = "10 - Show Touch Marker";
sc.Input[IN_ShowTouchMarker].SetYesNo(false);
sc.Input[IN_UseTouchedLineColor].Name = "10 - Use Touched Line Color";
sc.Input[IN_UseTouchedLineColor].SetYesNo(false);
sc.Input[IN_GapLineWidth].Name = "10 - Gap Line Width";
sc.Input[IN_GapLineWidth].SetInt(2); sc.Input[IN_GapLineWidth].SetIntLimits(1, 10);
sc.Input[IN_GapWidthBySize].Name = "10 - Gap Width Scales With Size";
sc.Input[IN_GapWidthBySize].SetYesNo(true);
sc.Input[IN_GapMinWidth].Name = "10 - Gap Min Width";
sc.Input[IN_GapMinWidth].SetInt(1); sc.Input[IN_GapMinWidth].SetIntLimits(1, 10);
sc.Input[IN_GapMaxWidth].Name = "10 - Gap Max Width";
sc.Input[IN_GapMaxWidth].SetInt(6); sc.Input[IN_GapMaxWidth].SetIntLimits(1, 20);
sc.Input[IN_GapMaxWidthAtTicks].Name = "10 - Gap Max Width At Ticks";
sc.Input[IN_GapMaxWidthAtTicks].SetInt(20); sc.Input[IN_GapMaxWidthAtTicks].SetIntLimits(1, 5000);
sc.Input[IN_GapZoneOpacity].Name = "10 - Gap Zone Opacity (0-100)";
sc.Input[IN_GapZoneOpacity].SetInt(12); sc.Input[IN_GapZoneOpacity].SetIntLimits(0, 100);
sc.Input[IN_GapLineExtension].Name = "10 - Gap Line Extension";
sc.Input[IN_GapLineExtension].SetCustomInputStrings("Projected;ToCurrentBar");
sc.Input[IN_GapLineExtension].SetCustomInputIndex(0);
sc.Input[IN_GapProjectionBars].Name = "10 - Gap Projection Bars";
sc.Input[IN_GapProjectionBars].SetInt(300); sc.Input[IN_GapProjectionBars].SetIntLimits(1, 5000);
// ---- 11. FC Continuation ----
sc.Input[IN_EnableContinuation].Name = "11 - Enable FC Continuation";
sc.Input[IN_EnableContinuation].SetYesNo(true);
sc.Input[IN_UseBbMidFilterFc].Name = "11 - FC: Use Bollinger Midpoint Filter";
sc.Input[IN_UseBbMidFilterFc].SetYesNo(true);
sc.Input[IN_FcLocationSource].Name = "11 - FC Location Source";
sc.Input[IN_FcLocationSource].SetCustomInputStrings("Close;WickExtreme;HLC3;BodyMidpoint");
sc.Input[IN_FcLocationSource].SetCustomInputIndex(1);
sc.Input[IN_FcLongBelowMidPct].Name = "11 - FC Long Below Mid Pct";
sc.Input[IN_FcLongBelowMidPct].SetFloat(50.0f); sc.Input[IN_FcLongBelowMidPct].SetFloatLimits(0.0f, 100.0f);
sc.Input[IN_FcShortAboveMidPct].Name = "11 - FC Short Above Mid Pct";