-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathTORobots.cpp
More file actions
685 lines (535 loc) · 21.9 KB
/
TORobots.cpp
File metadata and controls
685 lines (535 loc) · 21.9 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
#include "sierrachart.h"
SCDLLName("TO Robots DLL")
#pragma region COMMON FUNCTIONS
double CandleLength(SCBaseDataRef InData, int index)
{
return InData[SC_HIGH][index] - InData[SC_LOW][index];
}
double BodyLength(SCBaseDataRef InData, int index)
{
return fabs(InData[SC_OPEN][index] - InData[SC_LAST][index]);
}
double UpperWickLength(SCBaseDataRef InData, int index)
{
double upperBoundary = max(InData[SC_LAST][index], InData[SC_OPEN][index]);
double upperWickLength = InData[SC_HIGH][index] - upperBoundary;
return upperWickLength;
}
double LowerWickLength(SCBaseDataRef InData, int index)
{
double lowerBoundary = min(InData[SC_LAST][index], InData[SC_OPEN][index]);
double lowerWickLength = lowerBoundary - InData[SC_LOW][index];
return lowerWickLength;
}
bool IsGreen(SCBaseDataRef InData, int index)
{
return InData[SC_LAST][index] > InData[SC_OPEN][index];
}
bool IsRed(SCBaseDataRef InData, int index)
{
return InData[SC_LAST][index] < InData[SC_OPEN][index];
}
bool IsVolImbGreen(SCStudyInterfaceRef sc, int index)
{
SCBaseDataRef InData = sc.BaseData;
bool ret_flag = false;
if (IsGreen(InData, index)
&& IsGreen(InData, index - 1)
&& InData[SC_OPEN][index] > InData[SC_LAST][index - 1]
)
ret_flag = true;
return ret_flag;
}
bool IsVolImbRed(SCStudyInterfaceRef sc, int index)
{
SCBaseDataRef InData = sc.BaseData;
bool ret_flag = false;
if (IsRed(InData, index)
&& IsRed(InData, index - 1)
&& InData[SC_OPEN][index] < InData[SC_LAST][index - 1]
)
ret_flag = true;
return ret_flag;
}
void LogInfo(SCStudyInterfaceRef sc)
{
SCString& r_CurrentOnScreenMessage = sc.GetPersistentSCString(1);
sc.AddMessageToLog(r_CurrentOnScreenMessage, 0);
}
#pragma endregion
#pragma region ORDER MANIPULATION
int OrderPizza(SCStudyInterfaceRef sc, int iDirection, int MaxPos)
{
int& orderBar = sc.GetPersistentInt(2);
if (sc.Index == orderBar)
return -3;
int iR;
s_SCPositionData PositionData;
sc.GetTradePosition(PositionData);
//if (PositionData.PositionQuantity == 0)
{
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = 1;
NewOrder.OrderType = ordertype
NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED;
if (iDirection == 1)
iR = static_cast<int>(sc.BuyEntry(NewOrder));
else
iR = static_cast<int>(sc.SellEntry(NewOrder));
sc.AddMessageToLog("Submitted trade order", 0);
return -2;
}
if (iR > 0)//order was accepted
{
}
else//order error
{
if (sc.Index == sc.ArraySize - 1)
{
// log error
}
}
return 0;
}
#pragma endregion
#pragma region GOLDBUG
SCSFExport scsf_GoldBug(SCStudyInterfaceRef sc)
{
#pragma region INPUTS
SCString txt;
SCInputRef Input_Enabled = sc.Input[0];
SCInputRef Input_Simulation = sc.Input[1];
SCInputRef Input_TradeBuySell = sc.Input[2];
SCInputRef Input_TradeImbalance = sc.Input[3];
SCInputRef Input_TradeEngulfBB = sc.Input[4];
SCInputRef Input_TradeFVG = sc.Input[5];
SCInputRef Input_Aggressive = sc.Input[6];
SCInputRef Input_MaxPositions = sc.Input[7];
SCInputRef Input_MaxLoss = sc.Input[8];
SCInputRef Input_MaxProfit = sc.Input[8];
SCInputRef Input_IgnoreDoji = sc.Input[9];
SCInputRef Input_Trend = sc.Input[10];
SCInputRef Input_UseWaddah = sc.Input[11];
SCInputRef Input_UseMacd = sc.Input[12];
SCInputRef Input_UseSar = sc.Input[13];
SCInputRef Input_UseSuperTrend = sc.Input[14];
SCInputRef Input_UseAO = sc.Input[15];
SCInputRef Input_UseHMA = sc.Input[16];
SCInputRef Input_UseT3 = sc.Input[17];
SCInputRef Input_UseFisher = sc.Input[18];
SCInputRef Input_WaddahExploding = sc.Input[19];
SCInputRef Input_ADX = sc.Input[20];
SCInputRef Input_WaddahIntensity = sc.Input[21];
///////////////////////////////////////////////////////////////
SCSubgraphRef Subgraph_WaddahPos = sc.Subgraph[0];
SCSubgraphRef Subgraph_WaddahNeg = sc.Subgraph[1];
SCSubgraphRef Subgraph_Slow = sc.Subgraph[2];
SCSubgraphRef Subgraph_Fast = sc.Subgraph[3];
SCSubgraphRef Subgraph_BB = sc.Subgraph[4];
SCSubgraphRef Subgraph_ColorBar = sc.Subgraph[5];
SCSubgraphRef Subgraph_ColorUp = sc.Subgraph[6];
SCSubgraphRef Subgraph_ColorDown = sc.Subgraph[7];
SCSubgraphRef Subgraph_LindaMACD = sc.Subgraph[8];
SCSubgraphRef Subgraph_Parabolic = sc.Subgraph[9];
SCSubgraphRef Subgraph_AO = sc.Subgraph[10];
SCSubgraphRef Subgraph_Fisher = sc.Subgraph[11];
SCSubgraphRef Subgraph_ADX = sc.Subgraph[12];
SCSubgraphRef Subgraph_T3 = sc.Subgraph[13];
SCSubgraphRef Subgraph_HMA = sc.Subgraph[14];
SCSubgraphRef Subgraph_Calc = sc.Subgraph[15];
SCSubgraphRef Subgraph_MomentumHist = sc.Subgraph[16];
SCSubgraphRef Subgraph_MomentumHistUpColors = sc.Subgraph[17];
SCSubgraphRef Subgraph_MomentumHistDownColors = sc.Subgraph[18];
SCSubgraphRef Subgraph_SuperTrend = sc.Subgraph[19];
SCSubgraphRef Subgraph_HullATR = sc.Subgraph[20];
SCSubgraphRef Subgraph_KAMA = sc.Subgraph[21];
SCSubgraphRef Subgraph_Txt = sc.Subgraph[22];
SCFloatArrayRef Array_TrueRange = Subgraph_SuperTrend.Arrays[0];
SCFloatArrayRef Array_AvgTrueRange = Subgraph_SuperTrend.Arrays[1];
SCFloatArrayRef Array_UpperBandBasic = Subgraph_SuperTrend.Arrays[2];
SCFloatArrayRef Array_LowerBandBasic = Subgraph_SuperTrend.Arrays[3];
SCFloatArrayRef Array_UpperBand = Subgraph_SuperTrend.Arrays[4];
SCFloatArrayRef Array_LowerBand = Subgraph_SuperTrend.Arrays[5];
#pragma endregion
#pragma region DEFAULTS
if (sc.SetDefaults)
{
sc.GraphName = "GoldBug";
sc.GraphRegion = 0;
sc.AutoLoop = 1;
Input_Trend.Name = "Trade Directions";
Input_Trend.SetCustomInputStrings("Trade Both Directions;Only Longs;Only Shorts");
Input_Trend.SetCustomInputIndex(0);
Input_Trend.SetDescription("If the trend is up or down, you can specify ONLY trading that direction, avoiding a lot of sideways noise.");
Input_Enabled.Name = "Enabled";
Input_Enabled.SetYesNo(1);
Input_Enabled.SetDescription("This input enables the study and allows it to function. Otherwise, it does nothing.");
Input_Simulation.Name = "Send Orders To Trade Service";
Input_Simulation.SetYesNo(1);
Input_Simulation.SetDescription("Send real orders to your trading service");
Input_TradeBuySell.Name = "Standard Buy/Sell";
Input_TradeBuySell.SetYesNo(1);
Input_TradeBuySell.SetDescription("Trade standard buy/sell signals");
Input_TradeImbalance.Name = "Trade Volume Imbalances";
Input_TradeImbalance.SetYesNo(0);
Input_TradeImbalance.SetDescription("Trade candle gaps (volume imbalances)");
Input_TradeEngulfBB.Name = "Trade Engulfing Candle off Bollinger Bands";
Input_TradeEngulfBB.SetYesNo(0);
Input_TradeEngulfBB.SetDescription("Are we bouncing off a bollinger band, and have an engulfing candle?");
Input_TradeFVG.Name = "Trade Fair Value Gaps";
Input_TradeFVG.SetYesNo(0);
Input_TradeFVG.SetDescription("Open trade when fair value gap is formed");
Input_Aggressive.Name = "Aggressive Mode";
Input_Aggressive.SetYesNo(0);
Input_Aggressive.SetDescription("Trades on every same-colored-candle, then bails when opposite colored candle closes");
Input_MaxPositions.Name = "Maximum Positions";
Input_MaxPositions.SetInt(20);
Input_MaxPositions.SetDescription("Maximum number of simultaneous open positions allowed");
Input_MaxLoss.Name = "Max Loss";
Input_MaxLoss.SetInt(5000);
Input_MaxLoss.SetDescription("Maximum loss in dollars");
Input_MaxProfit.Name = "Max Profit";
Input_MaxProfit.SetInt(20000);
Input_MaxProfit.SetDescription("Maximum profit in dollars");
Input_IgnoreDoji.Name = "Ignore Dojis";
Input_IgnoreDoji.SetYesNo(1);
Input_IgnoreDoji.SetDescription("Don't trade when wicks are larger than candle body");
Input_WaddahIntensity.Name = "Waddah Intensity";
Input_WaddahIntensity.SetInt(150);
Input_UseWaddah.Name = "Use Waddah";
Input_UseWaddah.SetYesNo(1);
Input_UseMacd.Name = "Use MACD";
Input_UseMacd.SetYesNo(1);
Input_UseSar.Name = "Use Parabolic Sar";
Input_UseSar.SetYesNo(1);
Input_UseSuperTrend.Name = "Use Supertrend";
Input_UseSuperTrend.SetYesNo(1);
Input_UseAO.Name = "Use Awesome Oscillator";
Input_UseAO.SetYesNo(0);
Input_UseFisher.Name = "Use Fisher Transform";
Input_UseFisher.SetYesNo(1);
Input_UseHMA.Name = "Use Hull Moving Average";
Input_UseHMA.SetYesNo(1);
Input_WaddahExploding.Name = "Only when Waddah Exploding";
Input_WaddahExploding.SetYesNo(1);
Input_UseT3.Name = "Use T3";
Input_UseT3.SetYesNo(1);
Input_ADX.Name = "Minimum ADX";
Input_ADX.SetInt(11);
Subgraph_KAMA.Name = "KAMA";
Subgraph_LindaMACD.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_LindaMACD.Name = "Linda MACD";
Subgraph_LindaMACD.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Parabolic.Name = "Parabolic";
Subgraph_Parabolic.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_HMA.Name = "Hull Moving Average";
Subgraph_HMA.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Calc.Name = "RSI";
Subgraph_Calc.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_MomentumHist.Name = "Squeeze Relaxer 1";
Subgraph_MomentumHist.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_MomentumHistUpColors.Name = "Squeeze Relaxer 2";
Subgraph_MomentumHistUpColors.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_MomentumHistDownColors.Name = "Squeeze Relaxer 3";
Subgraph_MomentumHistDownColors.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_BB.Name = "Bollinger Bands";
Subgraph_BB.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_AO.Name = "Awesome Oscillator";
Subgraph_AO.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Fisher.Name = "Awesome Oscillator";
Subgraph_Fisher.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_ADX.Name = "ADX";
Subgraph_ADX.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_T3.Name = "T3";
Subgraph_T3.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Slow.Name = "SMA Slow";
Subgraph_Slow.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Fast.Name = "SMA Fast";
Subgraph_Fast.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_WaddahPos.Name = "Waddah Positive";
Subgraph_WaddahPos.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_WaddahNeg.Name = "Waddah Negative";
Subgraph_WaddahNeg.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_SuperTrend.Name = "SuperTrend";
Subgraph_SuperTrend.DrawStyle = DRAWSTYLE_IGNORE;
Subgraph_Txt.Name = "Text Output 1";
Subgraph_Txt.DrawStyle = DRAWSTYLE_CUSTOM_VALUE_AT_Y;
Subgraph_Txt.LineWidth = 10;
Subgraph_Txt.DrawZeros = false;
sc.SendOrdersToTradeService = false;
sc.AllowMultipleEntriesInSameDirection = true;
sc.MaximumPositionAllowed = 10000;
sc.SupportReversals = true;
sc.AllowOppositeEntryWithOpposingPositionOrOrders = true;
sc.SupportAttachedOrdersForTrading = true;
sc.UseGUIAttachedOrderSetting = false;
sc.CancelAllOrdersOnEntries = false;
sc.CancelAllOrdersOnReversals = true;
sc.AllowEntryWithWorkingOrders = true;
sc.CancelAllWorkingOrdersOnExit = true;
sc.AllowOnlyOneTradePerBar = true;
sc.MaintainTradeStatisticsAndTradesData = true;
return;
}
#pragma endregion
sc.SendOrdersToTradeService = Input_Simulation.GetYesNo();
sc.MaximumPositionAllowed = Input_MaxPositions.GetInt();
if (!Input_Enabled.GetYesNo())
return;
if (sc.IsFullRecalculation)
return;
if (sc.LastCallToFunction)
return;
if (Input_IgnoreDoji.GetYesNo() == SC_YES &&
BodyLength(sc.BaseData, sc.Index) < LowerWickLength(sc.BaseData, sc.Index) &&
BodyLength(sc.BaseData, sc.Index) < UpperWickLength(sc.BaseData, sc.Index))
return;
SCString sF;
SCString& r_Msg = sc.GetPersistentSCString(1);
int& currBar = sc.GetPersistentInt(1);
s_SCPositionData SCPositionData;
if (false && sc.GetTradePosition(SCPositionData))
{
double totalPNL = abs(SCPositionData.DailyProfitLoss) + abs(SCPositionData.OpenProfitLoss);
if (totalPNL > Input_MaxLoss.GetInt())
{
r_Msg = "You exceeded your max loss";
return;
}
if (totalPNL > Input_MaxProfit.GetInt())
{
r_Msg = "You achieved your profit target";
return;
}
sF.Format("GoldBug - Version 1.4 \nDaily PNL: %.02f, Open PNL: %.02f \n", SCPositionData.DailyProfitLoss, SCPositionData.OpenProfitLoss);
sF.Append(r_Msg);
sc.AddAndManageSingleTextUserDrawnDrawingForStudy(sc, true, 5, 90, Subgraph_Txt, true, sF, true, 1);
}
int i = sc.Index;
currBar = sc.Index;
int iPos = 0;
int& r_SqueezeUp = sc.GetPersistentInt(0);
int cl = sc.GetBarHasClosedStatus(i); // BHCS_BAR_HAS_NOT_CLOSED
SCBaseDataRef in = sc.BaseData;
double close = in[SC_OPEN][i];
SCFloatArrayRef Price = sc.BaseData[SC_HL_AVG];
SCFloatArrayRef Array_Value = Subgraph_Calc.Arrays[0];
#pragma region INDICATORS
bool BarCloseStatus = false;
bool sqRelaxUp;
bool bSuperUp, bSuperDown;
if (i < sc.ArraySize - 1)
BarCloseStatus = true;
int FVGMinTickSize = 1;
float L1 = sc.Low[i];
float H1 = sc.High[i];
float L3 = sc.Low[i - 2];
float H3 = sc.High[i - 2];
bool FVGUp = (H3 < L1) && (L1 - H3 >= FVGMinTickSize);
bool FVGDn = (L3 > H1) && (L3 - H1 >= FVGMinTickSize);
// SUPER TREND
int ATRMultiplier = 2;
int ATRPeriod = 11;
sc.TrueRange(sc.BaseDataIn, Array_TrueRange);
sc.HullMovingAverage(Array_TrueRange, Subgraph_HullATR, ATRPeriod);
Array_AvgTrueRange[sc.Index] = Subgraph_HullATR[sc.Index];
Array_UpperBandBasic[sc.Index] = sc.BaseDataIn[SC_HL][sc.Index] + ATRMultiplier * Array_AvgTrueRange[sc.Index];
Array_LowerBandBasic[sc.Index] = sc.BaseDataIn[SC_HL][sc.Index] - ATRMultiplier * Array_AvgTrueRange[sc.Index];
// Calculate Upper and Lower Bands
if (Array_UpperBandBasic[sc.Index] < Array_UpperBand[sc.Index - 1] || sc.Close[sc.Index - 1] > Array_UpperBand[sc.Index - 1])
Array_UpperBand[sc.Index] = Array_UpperBandBasic[sc.Index];
else
Array_UpperBand[sc.Index] = Array_UpperBand[sc.Index - 1];
if (Array_LowerBandBasic[sc.Index] > Array_LowerBand[sc.Index - 1] || sc.Close[sc.Index - 1] < Array_LowerBand[sc.Index - 1])
Array_LowerBand[sc.Index] = Array_LowerBandBasic[sc.Index - 1];
else
Array_LowerBand[sc.Index] = Array_LowerBand[sc.Index - 1];
if (sc.Index == 0)
Subgraph_SuperTrend[sc.Index] = Array_UpperBand[sc.Index];
if (Subgraph_SuperTrend[sc.Index - 1] == Array_UpperBand[sc.Index - 1] && sc.Close[sc.Index] < Array_UpperBand[sc.Index])
Subgraph_SuperTrend[sc.Index] = Array_UpperBand[sc.Index];
else if (Subgraph_SuperTrend[sc.Index - 1] == Array_UpperBand[sc.Index - 1] && sc.Close[sc.Index] > Array_UpperBand[sc.Index])
Subgraph_SuperTrend[sc.Index] = Array_LowerBand[sc.Index];
else if (Subgraph_SuperTrend[sc.Index - 1] == Array_LowerBand[sc.Index - 1] && sc.Close[sc.Index] > Array_LowerBand[sc.Index])
Subgraph_SuperTrend[sc.Index] = Array_LowerBand[sc.Index];
else if (Subgraph_SuperTrend[sc.Index - 1] == Array_LowerBand[sc.Index - 1] && sc.Close[sc.Index] < Array_LowerBand[sc.Index])
Subgraph_SuperTrend[sc.Index] = Array_UpperBand[sc.Index];
else
Subgraph_SuperTrend[sc.Index] = Subgraph_SuperTrend[sc.Index - 1];
if (Subgraph_SuperTrend[sc.Index] == Array_UpperBand[sc.Index])
bSuperDown = true;
else
bSuperUp = true;
// SQUEEZE RELAXER
sc.DataStartIndex = 20;
sc.ExponentialMovAvg(sc.Close, Subgraph_MomentumHistUpColors, 20); // Note: EMA returns close when index is < HistogramLenSecondData.GetInt()
sc.MovingAverage(sc.Close, Subgraph_MomentumHistUpColors, MOVAVGTYPE_EXPONENTIAL, 20);
float hlh = sc.GetHighest(sc.High, 20);
float lll = sc.GetLowest(sc.Low, 20);
Subgraph_MomentumHistDownColors[sc.Index] = sc.Open[sc.Index] - ((hlh + lll) / 2.0f + Subgraph_MomentumHistUpColors[sc.Index]) / 2.0f;
sc.LinearRegressionIndicator(Subgraph_MomentumHistDownColors, Subgraph_MomentumHist, 20);
sc.MovingAverage(sc.Close, Subgraph_MomentumHistUpColors, MOVAVGTYPE_LINEARREGRESSION, 20);
if ((Subgraph_MomentumHist[i] <= 0) && (Subgraph_MomentumHist[i] > Subgraph_MomentumHist[i - 1]))
{
if (r_SqueezeUp == 0) {
r_SqueezeUp = 1;
}
}
else if ((Subgraph_MomentumHist[i] >= 0) && (Subgraph_MomentumHist[i] < Subgraph_MomentumHist[i - 1]))
{
if (r_SqueezeUp == 1) {
r_SqueezeUp = 0;
}
}
// FISHER TRANSFORM
float Highest = sc.GetHighest(Price, 10);
float Lowest = sc.GetLowest(Price, 10);
float Range = Highest - Lowest;
if (Range == 0)
Array_Value[i] = 0;
else
Array_Value[i] = .66f * ((Price[i] - Lowest) / Range - 0.5f) + 0.67f * Array_Value[i - 1];
float TruncValue = Array_Value[i];
if (TruncValue > .99f)
TruncValue = .999f;
else if (TruncValue < -.99f)
TruncValue = -.999f;
float fish = .5f * (log((1 + TruncValue) / (1 - TruncValue)) + Subgraph_Fisher[i - 1]);
sc.AdaptiveMovAvg(sc.BaseDataIn[SC_LAST], Subgraph_KAMA, 9, 2, 109);
float kama = Subgraph_KAMA[i];
sc.T3MovingAverage(sc.BaseDataIn[SC_LAST], Subgraph_T3, 0.84, 10);
float t3 = Subgraph_T3[i];
sc.ADX(sc.BaseDataIn, Subgraph_ADX, i, 14, 14);
float adx = Subgraph_ADX[i];
sc.AwesomeOscillator(sc.BaseDataIn[SC_LAST], Subgraph_AO, 0, 0);
float ao = Subgraph_AO[i];
sc.HullMovingAverage(sc.BaseDataIn[SC_LAST], Subgraph_HMA, 10);
float hma = Subgraph_HMA[i];
float phma = Subgraph_HMA[i - 1];
sc.MovingAverage(sc.BaseDataIn[SC_LAST], Subgraph_Fast, MOVAVGTYPE_EXPONENTIAL, 20);
float a1 = Subgraph_Fast[i];
float b1 = Subgraph_Fast[i - 1];
sc.MovingAverage(sc.BaseDataIn[SC_LAST], Subgraph_Slow, MOVAVGTYPE_EXPONENTIAL, 40);
float a2 = Subgraph_Slow[i];
float b2 = Subgraph_Slow[i - 1];
sc.BollingerBands(sc.BaseDataIn[SC_LAST], Subgraph_BB, 20, 2, MOVAVGTYPE_SIMPLE);
float UpperBand = Subgraph_BB.Arrays[0][i];
float LowerBand = Subgraph_BB.Arrays[1][i];
float e1 = UpperBand - LowerBand;
float t1 = ((a1 - a2) - (b1 - b2)) * Input_WaddahIntensity.GetInt();
sc.MACD(sc.BaseDataIn[SC_LAST], Subgraph_LindaMACD, 3, 9, 16, MOVAVGTYPE_SIMPLE);
float linda = Subgraph_LindaMACD.Arrays[3][i];
sc.Parabolic(sc.BaseDataIn, sc.BaseDateTimeIn, Subgraph_Parabolic, i, 0.02f, 0.02f, 0.2f, 0, SC_HIGH, SC_LOW);
float SAR = Subgraph_Parabolic[i];
sc.RSI(sc.BaseDataIn[SC_LAST], Subgraph_Calc, MOVAVGTYPE_SIMPLE, 14);
float rsi = Subgraph_Calc[i];
float prsi = Subgraph_Calc[i - 1];
float pprsi = Subgraph_Calc[i - 2];
if (!sc.ChartTradeModeEnabled)
{
r_Msg = "Chart Trade Mode is not Enabled";
LogInfo(sc);
return;
}
if (sc.TradingIsLocked)
{
r_Msg = "Trading is locked, fix it before continuing";
LogInfo(sc);
return;
}
//Subgraph_Txt[i] = t1;
#pragma endregion
#pragma region BUY SELL
bool bShowUp = true;
bool bShowDown = true;
if (
(Input_UseMacd.GetYesNo() == SC_YES && linda < 0) ||
(Input_UseSar.GetYesNo() == SC_YES && SAR > close) ||
(Input_UseFisher.GetYesNo() == SC_YES && fish < 0) ||
(Input_UseT3.GetYesNo() == SC_YES && t3 > close) ||
(Input_UseWaddah.GetYesNo() == SC_YES && t1 <= 0) ||
(Input_UseAO.GetYesNo() == SC_YES && ao < 0) ||
(adx < Input_ADX.GetInt()) ||
(Input_UseHMA.GetYesNo() == SC_YES && hma > close) ||
(Input_UseSuperTrend.GetYesNo() == SC_YES && bSuperDown) ||
(Input_Trend.GetIndex() == 1) ||
(Input_WaddahExploding.GetYesNo() == SC_YES && abs(t1) < e1)
)
bShowUp = false;
if (
(Input_UseMacd.GetYesNo() == SC_YES && linda > 0) ||
(Input_UseSar.GetYesNo() == SC_YES && SAR < close) ||
(Input_UseFisher.GetYesNo() == SC_YES && fish > 0) ||
(Input_UseT3.GetYesNo() == SC_YES && t3 < close) ||
(Input_UseWaddah.GetYesNo() == SC_YES && t1 > 0) ||
(Input_UseAO.GetYesNo() == SC_YES && ao > 0) ||
(adx < Input_ADX.GetInt()) ||
(Input_UseHMA.GetYesNo() == SC_YES && hma < close) ||
(Input_UseSuperTrend.GetYesNo() == SC_YES && bSuperUp) ||
(Input_Trend.GetIndex() == 2) ||
(Input_WaddahExploding.GetYesNo() == SC_YES && abs(t1) < e1)
)
bShowDown = false;
if (BarCloseStatus && bShowUp)
{
if (Input_TradeBuySell.GetYesNo() == SC_YES)
iPos = OrderPizza(sc, 1, Input_MaxPositions.GetInt());
txt.Format("Standard BUY Signal at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
//if (sc.IsNewBar(i))
sc.AlertWithMessage(199, "Standard BUY Signal");
}
if (BarCloseStatus && bShowDown)
{
if (Input_TradeBuySell.GetYesNo() == SC_YES)
iPos = OrderPizza(sc, -1, Input_MaxPositions.GetInt());
txt.Format("Standard SELL Signal at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
//if (sc.IsNewBar(i))
sc.AlertWithMessage(200, "Standard SELL Signal");
}
/*
if (BarCloseStatus && IsVolImbGreen(sc, sc.CurrentIndex) && Input_Trend.GetIndex() != 2)
{
if (Input_TradeImbalance.GetYesNo() == SC_YES)
iPos = OrderPizza(sc, 1, Input_MaxPositions.GetInt());
txt.Format("Volume Imbalance BUY at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
if (sc.IsNewBar(i))
sc.AlertWithMessage(197, "Volume Imbalance BUY");
}
if (BarCloseStatus && IsVolImbRed(sc, sc.CurrentIndex) && Input_Trend.GetIndex() != 1)
{
if (Input_TradeImbalance.GetYesNo() == SC_YES)
iPos = OrderPizza(sc, -1, Input_MaxPositions.GetInt());
txt.Format("Volume Imbalance SELL at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
if (sc.IsNewBar(i))
sc.AlertWithMessage(198, "Volume Imbalance SELL");
}
if (BarCloseStatus && FVGUp && Input_Trend.GetIndex() != 2 && Input_TradeFVG.GetYesNo() == SC_YES)
{
iPos = OrderPizza(sc, 1, Input_MaxPositions.GetInt());
txt.Format("Fair Value Gap BUY at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
if (sc.IsNewBar(i))
sc.AlertWithMessage(197, "Fair Value Gap BUY");
}
if (BarCloseStatus && FVGDn && Input_Trend.GetIndex() != 1 && Input_TradeFVG.GetYesNo() == SC_YES)
{
iPos = OrderPizza(sc, -1, Input_MaxPositions.GetInt());
txt.Format("Fair Value Gap SELL at %.2f", sc.Low[sc.Index]);
r_Msg = txt;
LogInfo(sc);
if (sc.IsNewBar(i))
sc.AlertWithMessage(198, "Fair Value Gap SELL");
}
*/
#pragma endregion
}
#pragma endregion