#property copyright "Copyright © 2009, THV team" #property link "http://cobraforex.com/" extern string Entry_and_exit_conditions = "----------------------------------------------------------------------"; extern string PriceCrossCoral = "000"; extern double CrossCoralPips = 3.0; extern string PriceCrossIchimoku = "100"; extern double MinCrossIchimokuPips = 5.0; extern double MaxCrossIchimokuPips = 28.0; extern string FastSlowTrixCross = "000"; extern string FastTrixDirection = "100"; extern string SlowTrixDirection = "100"; extern string FastTrixZeroLevel = "000"; extern string iMaxCross = "200"; extern bool TrixOverboughtOversold = FALSE; extern double TrixOverboughtLevel = 0.00009; extern double TrixOversoldLevel = -0.00009; extern int TrixTimeframe = 0; extern string MTFTrixDot1 = "000"; extern string MTFTrixDot2 = "000"; extern string MTFTrixDot3 = "000"; extern string MTFTrixDot4 = "000"; extern string MTFIchimokuDot1 = "000"; extern string MTFIchimokuDot2 = "000"; extern bool PrevCandleSameDirection = FALSE; extern double EntryCandleMaxATR = 0.0; extern double SRDistance = 0.0; extern double DailyPivotDistance = 0.0; extern int PriceTouchSRLevel = 1; extern bool PriceTouchDailyPivot = TRUE; extern double DailyPivotTouchPips = 0.0; extern bool MidPivots = TRUE; extern int PriceTouchPsychLevel = 0; extern double MinLevelDistance = 5.0; extern bool OppositeSignalExit = FALSE; extern int IndicatorsExitPriority = 2; extern int LevelsExitPriority = 0; extern bool TrailingStopDisablesExits = FALSE; extern bool FreshSignal = TRUE; extern double MaxSpread = 0.0; extern string Patterns = "----------------------------------------------------------------------"; extern int PinBar = 0; extern int EngulfingBar = 0; extern int DoubleTopBottom = 0; extern int InsideBar = 0; extern int TrixDivergence = 0; extern int Harmonics = 0; extern int TrendlineBreak = 0; extern int PreviousBars = 3; extern string Order_settings = "----------------------------------------------------------------------"; extern int BaseMagicNumber = 600000; extern string TradeComment = "THV"; extern bool ClassicSL = TRUE; extern bool HighLowSL = FALSE; extern int BarsBack = 3; extern double MinimumSLPips = 0.0; extern double StopLossPips = 0.0; extern double StopLossAtrMultiplier = 3.0; extern double VisibleSL = 0.0; extern double TakeProfitPips1 = 0.0; extern double TakeProfitPips2 = 0.0; extern double TakeProfitAtrMultiplier1 = 2.0; extern double TakeProfitAtrMultiplier2 = 4.0; extern double VisibleTP = 0.0; extern double BreakEvenPips = 0.0; extern double BreakEvenAtrMultiplier = 0.0; extern double LockPips = 0.0; extern double LockAtrMultiplier = 0.0; extern bool PSARTrailingStop = FALSE; extern bool ClassicTrailingStop = FALSE; extern double TrailingStopPips = 0.0; extern double TrailingStopAtrMultiplier = 0.0; extern double TrailingStopStartPips = 0.0; extern double TrailingStepPips = 0.0; extern double ADXMultiplier = 0.0; extern double Slippage = 4.0; extern bool CloseIfProfit = FALSE; extern bool Hedge = FALSE; extern bool ScreenShots = TRUE; extern color LongColour = Chartreuse; extern color ShortColour = OrangeRed; extern string Trading_hours_settings = "----------------------------------------------------------------------"; extern bool UseTradingHours = FALSE; extern string StartHour = "0700"; extern string EndHour = "2400"; extern bool NewsFilter = FALSE; extern int MinutesBeforeNews = 10; extern int MinutesAfterNews = 10; extern bool MondayOpen = FALSE; extern string MondayOpenHour = "0700"; extern bool DailyClose = FALSE; extern string DailyCloseHour = "2250"; extern bool DailyCloseInProfit = FALSE; extern bool FridayClose = FALSE; extern string FridayCloseHour = "2250"; extern string Money_management_settings = "----------------------------------------------------------------------"; extern double Lots = 0.2; extern double PartialClose1 = 50.0; extern double PartialClose2 = 50.0; extern double PartialClose3 = 0.0; extern int BreakEvenPartialClose = 0; extern int StartTrailingPartialClose = 0; extern double MinCloseDistance = 5.0; extern bool MoneyManagement = FALSE; extern double LeveragePercent = 1.0; extern bool Martingale = FALSE; extern double LotMultiplier = 1.3; extern int MaxProgression = 3; extern string ATR_settings = "----------------------------------------------------------------------"; extern double AtrPeriod = 14.0; extern string ADX_settings = "----------------------------------------------------------------------"; extern double ADXPeriod = 14.0; extern string PSAR_settings = "----------------------------------------------------------------------"; extern double Step = 0.02; extern double Maximum = 0.2; extern string Trix_settings = "----------------------------------------------------------------------"; extern int Trix_A_t3_period = 20; extern int Trix_B_t3_period_ac = 35; extern string Ichimoku_settings = "----------------------------------------------------------------------"; extern int Tenkan_sen = 2; extern int Kijun_sen = 3; extern int Senkou_span_b = 5; extern string MTF_TrixHisto_settings = "----------------------------------------------------------------------"; extern int MTF_A_t3_period = 20; extern int MTF_B_t3_period_ac = 35; extern int ePeriod1 = 15; extern int ePeriod1Type = 1; extern int ePeriod2 = 30; extern int ePeriod2Type = 1; extern int ePeriod3 = 5; extern int ePeriod3Type = 0; extern int ePeriod4 = 15; extern int ePeriod4Type = 0; extern string MTF_IchimokuHisto_settings = "----------------------------------------------------------------------"; extern int MaPeriod1 = 2; extern int MaPeriod2 = 3; extern int MaPeriod3 = 5; extern int Shortperiod = 5; extern int Longperiod = 15; extern string THV3_SDX_TzPivots_v4_settings = "----------------------------------------------------------------------"; extern int Local__HrsServerTZFromGMT = 0; extern int Destination__HrsNewTzfromGMT = 0; extern int Show_1Daily_2FibonacciPivots = 2; extern string iMax_settings = "----------------------------------------------------------------------"; extern int Ph2shiftRed = 1; extern string Psych_Levels_settings = "----------------------------------------------------------------------"; extern string PsychLevel1 = "00"; extern string PsychLevel2 = "50"; extern string FFCal_settings = "----------------------------------------------------------------------"; extern bool IncludeHigh = TRUE; extern bool IncludeMedium = TRUE; extern bool IncludeLow = FALSE; extern bool IncludeSpeaks = TRUE; double gda_988[40][40]; double gda_992[30][30]; double gda_996[99][29][29]; double gda_1000[29][29]; double gda_1004[9]; double gda_1008[9]; double gda_1012[9]; double gda_1016[9]; double gda_1020[9]; double gda_1024[9]; double gda_1028[19]; double gda_1032[9][9]; double gda_1036[19]; double gda_1040[19]; double gda_1044[19]; double gda_1048[9]; int gia_1052[40][40]; int gia_1056[30][30]; int gia_1060[3]; int gia_1064[22]; int gia_1068[9]; int gia_1072[9]; int gia_1076[9]; int g_magic_1080; int g_icustom_1084; int g_icustom_1088; int gi_1092; int gi_1096; int gi_1100; int gi_1104; int g_y_1108; int g_index_1112; int gi_1116; int gi_1120; int gi_1124; int gi_1128; int gi_1132; int g_pos_1136; int gi_1140; int g_pos_1144; int g_bool_1148; int gi_1152; bool gba_1156[9][39][9]; bool gba_1160[9][39][9]; bool gba_1164[9]; bool gba_1168[9]; bool gba_1172[9]; bool gba_unused_1176[9]; bool gba_1180[9][29][9]; string gsa_1184[9][9]; string gsa_1188[29][19]; string gsa_1192[9][39][100]; string gsa_1196[100]; string gsa_1200[9]; string gsa_1204[9][39][9]; string gsa_1208[9][39][9]; string gsa_1212[9][9]; string gsa_1216[9]; string gsa_1220[9]; string gsa_1224[] = {"", "S5", "MS5", "S4", "MS4", "S3", "MS3", "S2", "MS2", "S1", "MS1", "P", "MR1", "R1", "MR2", "R2", "MR3", "R3", "MR4", "R4", "MR5", "R5", ""}; string gsa_1228[] = {"", "M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1"}; int gia_1232[19]; int g_datetime_1236 = 0; int g_timeframe_1240 = 0; int init() { gia_1052[0][0] = (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.01) * 2 + (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.1); gi_1092 = 10 * (Digits == 3 || Digits == 5) + (Digits == 2 || Digits == 4); gda_992[0][0] = MarketInfo(Symbol(), MODE_STOPLEVEL) / gi_1092; if ((VisibleSL < gda_992[0][0] && VisibleSL > 0.0) || (VisibleTP < gda_992[0][0] && VisibleTP > 0.0)) MessageBox("The VisibleSL and VisibleTP should be at least " + DoubleToStr(gda_992[0][0], 1) + " pips"); if (!ClassicSL && !HighLowSL) { StopLossPips = 0; StopLossAtrMultiplier = 0; } if (ClassicSL || BarsBack <= WHOLE_ARRAY) HighLowSL = FALSE; if (StopLossPips == 0.0 && StopLossAtrMultiplier == 0.0) ClassicSL = FALSE; if (StopLossPips > 0.0 && StopLossAtrMultiplier > 0.0) StopLossPips = 0; if (BreakEvenPips > 0.0 && BreakEvenAtrMultiplier > 0.0) BreakEvenPips = 0; if (LockPips > 0.0 && LockAtrMultiplier > 0.0) LockPips = 0; if (TrailingStopPips > 0.0 && TrailingStopAtrMultiplier > 0.0) TrailingStopPips = 0; if (TrailingStopPips == 0.0 && TrailingStopAtrMultiplier == 0.0) ClassicTrailingStop = FALSE; if (TakeProfitAtrMultiplier1 > 0.0 && TakeProfitAtrMultiplier2 > 0.0) { TakeProfitPips1 = 0; TakeProfitPips2 = 0; } if (TakeProfitPips1 > 0.0 && TakeProfitPips2 > 0.0) { TakeProfitAtrMultiplier1 = 0; TakeProfitAtrMultiplier2 = 0; } if (TakeProfitPips2 < TakeProfitPips1 && TakeProfitPips2 > 0.0) { gda_992[0][1] = TakeProfitPips1; gda_992[0][2] = TakeProfitPips2; TakeProfitPips1 = gda_992[0][2]; TakeProfitPips2 = gda_992[0][1]; } if (TakeProfitPips1 == 0.0 && TakeProfitPips2 > 0.0) { TakeProfitPips1 = TakeProfitPips2; TakeProfitPips2 = 0; } if (TakeProfitAtrMultiplier2 < TakeProfitAtrMultiplier1 && TakeProfitAtrMultiplier2 > 0.0) { gda_992[0][1] = TakeProfitAtrMultiplier1; gda_992[0][2] = TakeProfitAtrMultiplier2; TakeProfitAtrMultiplier1 = gda_992[0][2]; TakeProfitAtrMultiplier2 = gda_992[0][1]; } if (TakeProfitAtrMultiplier1 == 0.0 && TakeProfitAtrMultiplier2 > 0.0) { TakeProfitAtrMultiplier1 = TakeProfitAtrMultiplier2; TakeProfitAtrMultiplier2 = 0; } gda_1004[5] = (TakeProfitPips1 > 0.0) + (TakeProfitPips2 > 0.0) + (TakeProfitAtrMultiplier1 > 0.0) + (TakeProfitAtrMultiplier2 > 0.0); if (Period() > PERIOD_D1) { SRDistance = 0; DailyPivotDistance = 0; PriceTouchSRLevel = 0; PriceTouchDailyPivot = FALSE; DailyPivotTouchPips = 0; MidPivots = FALSE; } Slippage *= gi_1092; gda_1004[0] = NormalizeDouble(VisibleTP * Point * gi_1092, Digits); gda_1004[1] = NormalizeDouble(TakeProfitPips1 * Point * gi_1092, Digits); gda_1004[2] = NormalizeDouble(TakeProfitPips2 * Point * gi_1092, Digits); gda_1008[0] = NormalizeDouble(VisibleSL * Point * gi_1092, Digits); gda_1008[1] = NormalizeDouble(StopLossPips * Point * gi_1092, Digits); gda_1008[3] = NormalizeDouble(MinimumSLPips * Point * gi_1092, Digits); gda_1020[1] = NormalizeDouble(BreakEvenPips * Point * gi_1092, Digits); gda_1024[1] = NormalizeDouble(LockPips * Point * gi_1092, Digits); gda_1012[1] = NormalizeDouble(TrailingStopPips * Point * gi_1092, Digits); gda_1012[2] = NormalizeDouble(TrailingStopStartPips * Point * gi_1092, Digits); gda_1016[1] = NormalizeDouble(TrailingStepPips * Point * gi_1092, Digits); gda_1028[1] = NormalizeDouble(MinLevelDistance * Point * gi_1092, Digits); gda_1028[2] = NormalizeDouble(MaxCrossIchimokuPips * Point * gi_1092, Digits); gda_1028[3] = NormalizeDouble(StrToInteger(PsychLevel1) * Point * gi_1092, Digits); gda_1028[4] = NormalizeDouble(StrToInteger(PsychLevel2) * Point * gi_1092, Digits); gda_1028[5] = NormalizeDouble(100.0 * Point * gi_1092, Digits); gda_1028[6] = NormalizeDouble((MinCrossIchimokuPips - (MinCrossIchimokuPips > 0.0) / gi_1092) * Point * gi_1092, Digits); gda_1028[7] = NormalizeDouble(Point * gi_1092, Digits); gda_1028[8] = NormalizeDouble(MinCloseDistance * Point * gi_1092, Digits); gda_1028[9] = NormalizeDouble((CrossCoralPips - (CrossCoralPips > 0.0) / gi_1092) * Point * gi_1092, Digits); gda_1028[10] = NormalizeDouble(SRDistance * Point * gi_1092, Digits); gda_1028[11] = NormalizeDouble(MaxSpread * Point * gi_1092, Digits); gda_1028[12] = NormalizeDouble(DailyPivotDistance * Point * gi_1092, Digits); gda_1028[13] = NormalizeDouble(DailyPivotTouchPips * Point * gi_1092, Digits); gia_1060[1] = LongColour; gia_1060[2] = ShortColour; gi_1096 = (Period() == PERIOD_M1) + (Period() == PERIOD_M5) * 2 + 3 * (Period() == PERIOD_M15) + (Period() == PERIOD_M30) < 2 + 5 * (Period() == PERIOD_H1) + 6 * (Period() == PERIOD_H4) + 7 * (Period() == PERIOD_D1) + (Period() == PERIOD_W1) < 3; g_magic_1080 = BaseMagicNumber + gi_1096; TradeComment = StringConcatenate(TradeComment, " ", StringSubstr(Symbol(), 0, 6), " ", gsa_1228[gi_1096]); gda_1000[0][20] = 7; gda_1000[1][20] = PinBar; gda_1000[2][20] = EngulfingBar; gda_1000[3][20] = DoubleTopBottom; gda_1000[4][20] = InsideBar; gda_1000[5][20] = TrixDivergence; gda_1000[6][20] = Harmonics; gda_1000[7][20] = TrendlineBreak; for (gi_1104 = 1; gi_1104 <= gda_1000[0][20]; gi_1104++) gda_1000[0][21] += (gda_1000[gi_1104][20] == 1.0 || gda_1000[gi_1104][20] == 3.0 || gda_1000[gi_1104][20] == 4.0); gda_1000[1][19] = 16; gda_1000[2][19] = 16; gda_1000[3][19] = 16; gda_1000[4][19] = 16; gda_1000[5][19] = 22; gda_1000[6][19] = 21; gda_1000[7][19] = 2; for (g_y_1108 = 1; g_y_1108 <= 2; g_y_1108++) { gsa_1192[0][g_y_1108 + 10][1] = "Pin bar"; gsa_1192[0][g_y_1108 + 10][2] = "Engulfing bar"; gsa_1192[0][g_y_1108 + 10][4] = "Inside bar"; gsa_1192[0][g_y_1108 + 10][5] = "Trix divergence"; gsa_1192[0][g_y_1108 + 10][6] = "Harmonic pattern"; gsa_1192[0][g_y_1108 + 10][7] = "Trendline break"; } gsa_1192[0][11][3] = "Double bottom"; gsa_1192[0][12][3] = "Double top"; gda_1044[1] = PartialClose1; gda_1044[2] = PartialClose2; gda_1044[3] = PartialClose3; if (gda_1044[1] >= 100.0) { gda_1044[1] = 100; gda_1044[2] = 0; gda_1044[3] = 0; } if (gda_1044[2] >= 100.0) { gda_1044[2] = 100; gda_1044[3] = 0; } if (gda_1044[3] >= 100.0) gda_1044[3] = 100; gda_1044[4] = 100; if (gda_1044[1] + gda_1044[2] > 100.0) { gda_1044[2] = 100 - gda_1044[1]; gda_1044[3] = 0; } if (gda_1044[2] + gda_1044[3] > 100.0) gda_1044[3] = 100 - gda_1044[2]; if (gda_1044[1] + gda_1044[3] > 100.0) { gda_1044[3] = 100 - gda_1044[1] - gda_1044[2]; gda_1044[3] = gda_1044[3] * (gda_1044[3] > 0.0); } if (gda_1044[2] > 0.0) gda_1044[2] = gda_1044[2] / ((100 - gda_1044[1]) / 100.0); if (gda_1044[3] > 0.0) gda_1044[3] = gda_1044[3] / ((100 - gda_1044[1] - gda_1044[2]) / 100.0); gsa_1184[1][1] = StringConcatenate(StringSubstr(StartHour, 0, 2), ":", StringSubstr(StartHour, 2, 2)); gsa_1184[1][2] = StringConcatenate(StringSubstr(EndHour, 0, 2), ":", StringSubstr(EndHour, 2, 2)); gsa_1184[1][3] = StringConcatenate(StringSubstr(FridayCloseHour, 0, 2), ":", StringSubstr(FridayCloseHour, 2, 2)); gsa_1184[1][4] = StringConcatenate(StringSubstr(DailyCloseHour, 0, 2), ":", StringSubstr(DailyCloseHour, 2, 2)); gsa_1184[1][5] = StringConcatenate(StringSubstr(MondayOpenHour, 0, 2), ":", StringSubstr(MondayOpenHour, 2, 2)); gsa_1188[1][1] = MTFTrixDot1; gsa_1188[2][1] = MTFTrixDot2; gsa_1188[3][1] = MTFTrixDot3; gsa_1188[4][1] = MTFTrixDot4; gsa_1188[5][1] = MTFIchimokuDot1; gsa_1188[6][1] = MTFIchimokuDot2; gsa_1188[7][1] = PriceCrossCoral; gsa_1188[8][1] = PriceCrossIchimoku; gsa_1188[9][1] = FastSlowTrixCross; gsa_1188[10][1] = FastTrixDirection; gsa_1188[11][1] = SlowTrixDirection; gsa_1188[12][1] = FastTrixZeroLevel; gsa_1188[13][1] = iMaxCross; for (gi_1104 = 1; gi_1104 <= 13; gi_1104++) for (g_y_1108 = 1; g_y_1108 <= 3; g_y_1108++) gia_1052[gi_1104][g_y_1108] = StrToInteger(StringSubstr(gsa_1188[gi_1104][1], g_y_1108 - 1, 1)); for (gi_1104 = 1; gi_1104 <= 13; gi_1104++) for (g_y_1108 = 1; g_y_1108 <= 2; g_y_1108++) for (g_index_1112 = 0; g_index_1112 <= 1; g_index_1112++) gba_1180[g_index_1112][gi_1104][g_y_1108] = gia_1052[gi_1104][g_y_1108 + 1] == g_index_1112 && gia_1052[gi_1104][1] == g_y_1108 || gia_1052[gi_1104][1] == 3; gba_1180[0][14][1] = TrixOverboughtOversold; gba_1180[0][15][1] = EntryCandleMaxATR > 0.0; gba_1180[1][16][1] = PrevCandleSameDirection; gba_1180[0][17][1] = MaxCrossIchimokuPips > 0.0 && gba_1180[0][8][1] || gba_1180[1][8][1]; gba_1180[0][18][1] = SRDistance > 0.0; gba_1180[0][19][1] = DailyPivotDistance > 0.0; gba_1180[0][20][2] = PriceTouchSRLevel > 0 || PriceTouchDailyPivot || PriceTouchPsychLevel > 0; gba_1180[0][22][2] = OppositeSignalExit; for (gi_1104 = 0; gi_1104 <= 4; gi_1104++) { for (g_y_1108 = 0; g_y_1108 <= 29; g_y_1108++) { for (g_index_1112 = 0; g_index_1112 <= 2; g_index_1112++) { gsa_1204[gi_1104][g_y_1108][g_index_1112] = StringConcatenate(Symbol(), g_magic_1080, "opc", gi_1104, g_y_1108, g_index_1112); gsa_1208[gi_1104][g_y_1108][g_index_1112] = StringConcatenate(Symbol(), g_magic_1080, "oex", gi_1104, g_y_1108, g_index_1112); } } } for (gi_1104 = 1; gi_1104 <= 8; gi_1104++) for (g_y_1108 = 1; g_y_1108 <= 2; g_y_1108++) gsa_1212[gi_1104][g_y_1108] = StringConcatenate(Symbol(), g_magic_1080, "oss", gi_1104, g_y_1108); for (gi_1104 = 0; gi_1104 <= 30; gi_1104++) { gsa_1196[gi_1104] = StringConcatenate("Comment", gi_1104); ObjectCreate(gsa_1196[gi_1104], OBJ_LABEL, 0, 0, 0); if (gi_1104 <= 8) { gsa_1216[gi_1104] = StringConcatenate(Symbol(), g_magic_1080, "osl", gi_1104); gsa_1220[gi_1104] = StringConcatenate(Symbol(), g_magic_1080, "otp", gi_1104); } gsa_1192[0][0][gi_1104] = ""; } gsa_1192[0][30][1] = "MTF trix dot 1"; gsa_1192[0][30][2] = "MTF trix dot 2"; gsa_1192[0][30][3] = "MTF trix dot 3"; gsa_1192[0][30][4] = "MTF trix dot 4"; gsa_1192[0][30][5] = "MTF ichimoku dot 1"; gsa_1192[0][30][6] = "MTF ichimoku dot 2"; gsa_1192[0][30][7] = "coral cross"; gsa_1192[0][30][8] = "ichimoku cross"; gsa_1192[0][30][9] = "fast slow trix cross"; gsa_1192[0][30][10] = "fast trix opposite direction"; gsa_1192[0][30][11] = "slow trix opposite direction"; gsa_1192[0][30][12] = "fast trix zero level cross"; gsa_1192[0][30][13] = "iMax cross"; gsa_1192[0][31][1] = " current profit is "; gsa_1192[0][31][2] = " current loss is "; gsa_1192[0][31][3] = "Long order"; gsa_1192[0][31][4] = "Short order"; gda_996[0][8][1] = gia_1052[5][1] > 0; gda_996[0][8][2] = gia_1052[6][1] > 0; gda_996[0][8][3] = gia_1052[8][1] > 0; gda_996[0][8][4] = gia_1052[7][1] > 0; gda_996[0][8][5] = gia_1052[9][1] > 0 || gia_1052[10][1] > 0 || gia_1052[11][1] > 0 || gia_1052[12][1] > 0; gda_996[0][8][6] = gia_1052[1][1] > 0; gda_996[0][8][7] = gia_1052[2][1] > 0; gda_996[0][8][8] = gia_1052[3][1] > 0; gda_996[0][8][9] = gia_1052[4][1] > 0; gda_996[0][8][10] = SRDistance > 0.0 || DailyPivotDistance > 0.0 || PriceTouchSRLevel > 0 || PriceTouchDailyPivot; gda_996[0][8][12] = gia_1052[13][1] > 0; gda_996[0][8][14] = gba_1180[0][14][1]; gia_1052[30][1] = (Show_1Daily_2FibonacciPivots == 2) + 5 * (Show_1Daily_2FibonacciPivots == 1); gia_1052[30][2] = 21 * (Show_1Daily_2FibonacciPivots == 2) + 17 * (Show_1Daily_2FibonacciPivots == 1); gba_1164[1] = 1; gba_1164[3] = 1; gba_1164[4] = 1; gsa_1184[0][0] = "2009.10.01"; gia_1232[8] = StrToTime(gsa_1184[0][0]); return (0); } int deinit() { return (0); } int start() { if (!IsDemo() && !IsTesting()) { Comment("This expert advisor does not work on real accounts"); return (0); } if (gia_1232[1] != Time[0]) { gia_1232[1] = Time[0]; gba_1168[3] = 0; gba_1168[4] = 0; gba_1172[1] = 1; gba_1172[2] = 1; GlobalVariableSet(gsa_1216[3], 0); GlobalVariableSet(gsa_1216[4], 0); if (gda_996[0][8][10] == 1.0) Pivots(); for (gi_1104 = 0; gi_1104 <= 3; gi_1104++) { if (gda_996[0][8][1] == 1.0) { gda_996[gi_1104][3][1] = iIchimoku(Symbol(), Longperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANA, gi_1104); gda_996[gi_1104][4][1] = iIchimoku(Symbol(), Longperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANB, gi_1104); } if (gda_996[0][8][2] == 1.0) { gda_996[gi_1104][3][2] = iIchimoku(Symbol(), Shortperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANA, gi_1104); gda_996[gi_1104][4][2] = iIchimoku(Symbol(), Shortperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANB, gi_1104); } if (gda_996[0][8][4] == 1.0) gda_996[gi_1104][0][4] = iCustom(Symbol(), 0, "THV3 Coral", 0, gi_1104); if (gda_996[0][8][5] == 1.0) { gda_996[gi_1104][6][5] = iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 6, gi_1104); gda_996[gi_1104][7][5] = iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 7, gi_1104); } if (gda_996[0][8][6] == 1.0) gda_996[gi_1104][0][6] = iCustom(Symbol(), ePeriod1, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod1Type, gi_1104); if (gda_996[0][8][7] == 1.0) gda_996[gi_1104][0][7] = iCustom(Symbol(), ePeriod2, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod2Type, gi_1104); if (gda_996[0][8][8] == 1.0) gda_996[gi_1104][0][8] = iCustom(Symbol(), ePeriod3, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod3Type, gi_1104); if (gda_996[0][8][9] == 1.0) gda_996[gi_1104][0][9] = iCustom(Symbol(), ePeriod4, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod4Type, gi_1104); if (gda_996[0][8][12] == 1.0) { gda_996[gi_1104][0][12] = iCustom(Symbol(), 0, "iMAX", Ph2shiftRed, 0, gi_1104); gda_996[gi_1104][1][12] = iCustom(Symbol(), 0, "iMAX", Ph2shiftRed, 1, gi_1104); } } for (gi_1104 = 0; gi_1104 <= 98; gi_1104++) { if (gda_996[0][8][3] == 1.0) { gda_996[gi_1104][3][3] = iIchimoku(Symbol(), 0, Tenkan_sen, Kijun_sen, Senkou_span_b, MODE_SENKOUSPANA, gi_1104); gda_996[gi_1104][4][3] = iIchimoku(Symbol(), 0, Tenkan_sen, Kijun_sen, Senkou_span_b, MODE_SENKOUSPANB, gi_1104); } gda_996[gi_1104][0][13] = iMA(Symbol(), 0, 7, 0, MODE_SMA, PRICE_CLOSE, gi_1104); } if (gda_1000[0][21] > 0.0) CheckPatterns(); for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { gba_1156[gi_1104][1][1] = gda_996[BarClose(ePeriod1)][0][6] > gda_996[BarClose(ePeriod1) + 1][0][6]; gba_1156[gi_1104][1][2] = gda_996[BarClose(ePeriod1)][0][6] < gda_996[BarClose(ePeriod1) + 1][0][6]; gba_1156[gi_1104][2][1] = gda_996[BarClose(ePeriod2)][0][7] > gda_996[BarClose(ePeriod2) + 1][0][7]; gba_1156[gi_1104][2][2] = gda_996[BarClose(ePeriod2)][0][7] < gda_996[BarClose(ePeriod2) + 1][0][7]; gba_1156[gi_1104][3][1] = gda_996[BarClose(ePeriod3)][0][8] > gda_996[BarClose(ePeriod3) + 1][0][8]; gba_1156[gi_1104][3][2] = gda_996[BarClose(ePeriod3)][0][8] < gda_996[BarClose(ePeriod3) + 1][0][8]; gba_1156[gi_1104][4][1] = gda_996[BarClose(ePeriod4)][0][9] > gda_996[BarClose(ePeriod4) + 1][0][9]; gba_1156[gi_1104][4][2] = gda_996[BarClose(ePeriod4)][0][9] < gda_996[BarClose(ePeriod4) + 1][0][9]; gba_1156[gi_1104][5][1] = Close[1] > MathMax(gda_996[BarClose(Longperiod)][3][1], gda_996[BarClose(Longperiod)][4][1]); gba_1156[gi_1104][5][2] = Close[1] < MathMin(gda_996[BarClose(Longperiod)][3][1], gda_996[BarClose(Longperiod)][4][1]); gba_1156[gi_1104][6][1] = Close[1] > MathMax(gda_996[BarClose(Shortperiod)][3][2], gda_996[BarClose(Shortperiod)][4][2]); gba_1156[gi_1104][6][2] = Close[1] < MathMin(gda_996[BarClose(Shortperiod)][3][2], gda_996[BarClose(Shortperiod)][4][2]); gba_1156[gi_1104][7][1] = High[gi_1104] > gda_996[gi_1104][0][4] + gda_1028[9]; gba_1156[gi_1104][7][2] = Low[gi_1104] < gda_996[gi_1104][0][4] - gda_1028[9]; gba_1156[gi_1104][8][1] = High[gi_1104] > MathMax(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]) + gda_1028[6]; gba_1156[gi_1104][8][2] = Low[gi_1104] < MathMin(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]) - gda_1028[6]; gba_1156[gi_1104][9][1] = gda_996[gi_1104][6][5] > gda_996[gi_1104][7][5]; gba_1156[gi_1104][9][2] = gda_996[gi_1104][6][5] < gda_996[gi_1104][7][5]; gba_1156[gi_1104][10][1] = gda_996[gi_1104][6][5] > gda_996[gi_1104 + 1][6][5]; gba_1156[gi_1104][10][2] = gda_996[gi_1104][6][5] < gda_996[gi_1104 + 1][6][5]; gba_1156[gi_1104][11][1] = gda_996[gi_1104][7][5] > gda_996[gi_1104 + 1][7][5]; gba_1156[gi_1104][11][2] = gda_996[gi_1104][7][5] < gda_996[gi_1104 + 1][7][5]; gba_1156[gi_1104][12][1] = gda_996[gi_1104][6][5] > 0.0; gba_1156[gi_1104][12][2] = gda_996[gi_1104][6][5] < 0.0; gba_1156[gi_1104][13][1] = gda_996[gi_1104][0][12] > gda_996[gi_1104][1][12]; gba_1156[gi_1104][13][2] = gda_996[gi_1104][0][12] < gda_996[gi_1104][1][12]; gba_1156[gi_1104][16][1] = Open[1] < Close[1]; gba_1156[gi_1104][16][2] = Open[1] > Close[1]; } for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { gba_1156[gi_1104][0][1] = 1; gba_1156[gi_1104][0][2] = 1; gba_1156[gi_1104][0][3] = 1; gba_1156[gi_1104][0][4] = 1; for (g_y_1108 = 1; g_y_1108 <= 16; g_y_1108++) { gi_1120 = g_y_1108 <= 6 || (g_y_1108 >= 14 && g_y_1108 <= 16) && gi_1104 == 2; gba_1156[gi_1104][g_y_1108][3] = gba_1156[gi_1104][g_y_1108][1] || !gba_1180[gi_1104 - 1][g_y_1108][1] || gi_1120 > 0; gba_1156[gi_1104][g_y_1108][1] = gba_1156[gi_1104][g_y_1108][1] || !gba_1180[1][g_y_1108][1]; gba_1156[gi_1104][0][1] = gba_1156[gi_1104][0][1] * gba_1156[gi_1104][g_y_1108][1]; gba_1156[gi_1104][0][3] = gba_1156[gi_1104][0][3] * gba_1156[gi_1104][g_y_1108][3]; gba_1156[gi_1104][g_y_1108][4] = gba_1156[gi_1104][g_y_1108][2] || !gba_1180[gi_1104 - 1][g_y_1108][1] || gi_1120 > 0; gba_1156[gi_1104][g_y_1108][2] = gba_1156[gi_1104][g_y_1108][2] || !gba_1180[1][g_y_1108][1]; gba_1156[gi_1104][0][2] = gba_1156[gi_1104][0][2] * gba_1156[gi_1104][g_y_1108][2]; gba_1156[gi_1104][0][4] = gba_1156[gi_1104][0][4] * gba_1156[gi_1104][g_y_1108][4]; } } gba_1160[1][1][1] = gda_996[BarClose(ePeriod1)][0][6] < gda_996[BarClose(ePeriod1) + 1][0][6]; gba_1160[1][1][2] = gda_996[BarClose(ePeriod1)][0][6] > gda_996[BarClose(ePeriod1) + 1][0][6]; gba_1160[1][2][1] = gda_996[BarClose(ePeriod2)][0][7] < gda_996[BarClose(ePeriod2) + 1][0][7]; gba_1160[1][2][2] = gda_996[BarClose(ePeriod2)][0][7] > gda_996[BarClose(ePeriod2) + 1][0][7]; gba_1160[1][3][1] = gda_996[BarClose(ePeriod3)][0][8] < gda_996[BarClose(ePeriod3) + 1][0][8]; gba_1160[1][3][2] = gda_996[BarClose(ePeriod3)][0][8] > gda_996[BarClose(ePeriod3) + 1][0][8]; gba_1160[1][4][1] = gda_996[BarClose(ePeriod4)][0][9] < gda_996[BarClose(ePeriod4) + 1][0][9]; gba_1160[1][4][2] = gda_996[BarClose(ePeriod4)][0][9] > gda_996[BarClose(ePeriod4) + 1][0][9]; gba_1160[1][5][1] = Close[1] < MathMin(gda_996[BarClose(Longperiod)][3][1], gda_996[BarClose(Longperiod)][4][1]); gba_1160[1][5][2] = Close[1] > MathMax(gda_996[BarClose(Longperiod)][3][1], gda_996[BarClose(Longperiod)][4][1]); gba_1160[1][6][1] = Close[1] < MathMin(gda_996[BarClose(Shortperiod)][3][2], gda_996[BarClose(Shortperiod)][4][2]); gba_1160[1][6][2] = Close[1] > MathMax(gda_996[BarClose(Shortperiod)][3][2], gda_996[BarClose(Shortperiod)][4][2]); gba_1160[1][7][1] = Close[1] < gda_996[0][0][4] - gda_1028[9]; gba_1160[1][7][2] = Close[1] > gda_996[0][0][4] + gda_1028[9]; gba_1160[1][8][1] = Close[1] < MathMin(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]) - gda_1028[6]; gba_1160[1][8][2] = Close[1] > MathMax(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]) + gda_1028[6]; gba_1160[1][9][1] = gda_996[1][6][5] < gda_996[1][7][5]; gba_1160[1][9][2] = gda_996[1][6][5] > gda_996[1][7][5]; gba_1160[1][10][1] = gda_996[1][6][5] < gda_996[2][6][5]; gba_1160[1][10][2] = gda_996[1][6][5] > gda_996[2][6][5]; gba_1160[1][11][1] = gda_996[1][7][5] < gda_996[2][7][5]; gba_1160[1][11][2] = gda_996[1][7][5] > gda_996[2][7][5]; gba_1160[1][12][1] = gda_996[1][6][5] < 0.0; gba_1160[1][12][2] = gda_996[1][6][5] > 0.0; gba_1160[1][13][1] = gda_996[1][0][12] < gda_996[1][1][12]; gba_1160[1][13][2] = gda_996[1][0][12] > gda_996[1][1][12]; for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { gba_1160[1][0][gi_1104] = 0; for (g_y_1108 = 1; g_y_1108 <= 13; g_y_1108++) { gba_1160[1][g_y_1108][gi_1104] = gba_1160[1][g_y_1108][gi_1104] && gba_1180[1][g_y_1108][2] && gba_1168[gi_1104]; gba_1160[1][0][gi_1104] = gba_1160[1][0][gi_1104] || gba_1160[1][g_y_1108][gi_1104]; } } gda_1032[1][1] = gda_1032[1][1] * (gda_996[1][gia_1064[1]][10] == gda_1032[1][1]); gda_1032[1][2] = gda_1032[1][2] * (gda_996[1][gia_1064[2]][10] == gda_1032[1][2]); } if (gda_996[0][8][1] == 1.0) { gda_996[0][3][1] = iIchimoku(Symbol(), Longperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANA, 0); gda_996[0][4][1] = iIchimoku(Symbol(), Longperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANB, 0); } if (gda_996[0][8][2] == 1.0) { gda_996[0][3][2] = iIchimoku(Symbol(), Shortperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANA, 0); gda_996[0][4][2] = iIchimoku(Symbol(), Shortperiod, MaPeriod1, MaPeriod2, MaPeriod3, MODE_SENKOUSPANB, 0); } if (gda_996[0][8][3] == 1.0) { gda_996[0][3][3] = iIchimoku(Symbol(), 0, Tenkan_sen, Kijun_sen, Senkou_span_b, MODE_SENKOUSPANA, 0); gda_996[0][4][3] = iIchimoku(Symbol(), 0, Tenkan_sen, Kijun_sen, Senkou_span_b, MODE_SENKOUSPANB, 0); } if (gda_996[0][8][4] == 1.0) gda_996[0][0][4] = iCustom(Symbol(), 0, "THV3 Coral", 0, 0); if (gda_996[0][8][5] == 1.0) { gda_996[0][6][5] = iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 6, 0); gda_996[0][7][5] = iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 7, 0); } if (gda_996[0][8][6] == 1.0) gda_996[0][0][6] = iCustom(Symbol(), ePeriod1, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod1Type, 0); if (gda_996[0][8][7] == 1.0) gda_996[0][0][7] = iCustom(Symbol(), ePeriod2, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod2Type, 0); if (gda_996[0][8][8] == 1.0) gda_996[0][0][8] = iCustom(Symbol(), ePeriod3, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod3Type, 0); if (gda_996[0][8][9] == 1.0) gda_996[0][0][9] = iCustom(Symbol(), ePeriod4, "THV3 Trix called", MTF_A_t3_period, MTF_B_t3_period_ac, 1, 7 - ePeriod4Type, 0); if (gda_996[0][8][12] == 1.0) { gda_996[0][0][12] = iCustom(Symbol(), 0, "iMAX", Ph2shiftRed, 0, 0); gda_996[0][1][12] = iCustom(Symbol(), 0, "iMAX", Ph2shiftRed, 1, 0); } if (gda_996[0][8][14] == 1.0) gda_996[0][6][14] = iCustom(Symbol(), TrixTimeframe, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 6, 0); if (gba_1180[0][17][1]) { gda_988[1][1] = 0; gda_988[1][2] = 0; for (gi_1104 = 0; gi_1104 <= 98 && gda_988[1][1] == 0.0 || gda_988[1][2] == 0.0; gi_1104++) { gda_992[0][1] = MathMax(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]); gda_992[0][2] = MathMin(gda_996[gi_1104][3][3], gda_996[gi_1104][4][3]); if (gda_988[1][1] == 0.0) gda_988[1][1] = (High[gi_1104] > gda_992[0][1] && Low[gi_1104 + 1] < MathMax(gda_996[gi_1104 + 1][3][3], gda_996[gi_1104 + 1][4][3])) * gda_992[0][1]; if (gda_988[1][2] == 0.0) gda_988[1][2] = (Low[gi_1104] < gda_992[0][2] && High[gi_1104 + 1] > MathMin(gda_996[gi_1104 + 1][3][3], gda_996[gi_1104 + 1][4][3])) * gda_992[0][2]; } } if (SRDistance > 0.0) { gia_1052[18][0] = 0; for (gi_1104 = gia_1052[30][1]; gi_1104 <= gia_1052[30][2] && gia_1052[18][0] == 0; gi_1104 += !MidPivots + 1) gia_1052[18][0] = gi_1104 != 11 && MathAbs(Bid - gda_996[1][gi_1104][10]) <= gda_1028[10]; } gba_1156[0][1][1] = gda_996[0][0][6] > gda_996[1][0][6]; gba_1156[0][1][2] = gda_996[0][0][6] < gda_996[1][0][6]; gba_1156[0][2][1] = gda_996[0][0][7] > gda_996[1][0][7]; gba_1156[0][2][2] = gda_996[0][0][7] < gda_996[1][0][7]; gba_1156[0][3][1] = gda_996[0][0][8] > gda_996[1][0][8]; gba_1156[0][3][2] = gda_996[0][0][8] < gda_996[1][0][8]; gba_1156[0][4][1] = gda_996[0][0][9] > gda_996[1][0][9]; gba_1156[0][4][2] = gda_996[0][0][9] < gda_996[1][0][9]; gba_1156[0][5][1] = Bid > MathMax(gda_996[0][3][1], gda_996[0][4][1]); gba_1156[0][5][2] = Bid < MathMin(gda_996[0][3][1], gda_996[0][4][1]); gba_1156[0][6][1] = Bid > MathMax(gda_996[0][3][2], gda_996[0][4][2]); gba_1156[0][6][2] = Bid < MathMin(gda_996[0][3][2], gda_996[0][4][2]); gba_1156[0][7][1] = Bid > gda_996[0][0][4] + gda_1028[9]; gba_1156[0][7][2] = Bid < gda_996[0][0][4] - gda_1028[9]; gba_1156[0][8][1] = Bid > MathMax(gda_996[0][3][3], gda_996[0][4][3]) + gda_1028[6]; gba_1156[0][8][2] = Bid < MathMin(gda_996[0][3][3], gda_996[0][4][3]) - gda_1028[6]; gba_1156[0][9][1] = gda_996[0][6][5] > gda_996[0][7][5]; gba_1156[0][9][2] = gda_996[0][6][5] < gda_996[0][7][5]; gba_1156[0][10][1] = gda_996[0][6][5] > gda_996[1][6][5]; gba_1156[0][10][2] = gda_996[0][6][5] < gda_996[1][6][5]; gba_1156[0][11][1] = gda_996[0][7][5] > gda_996[1][7][5]; gba_1156[0][11][2] = gda_996[0][7][5] < gda_996[1][7][5]; gba_1156[0][12][1] = gda_996[0][6][5] > 0.0; gba_1156[0][12][2] = gda_996[0][6][5] < 0.0; gba_1156[0][13][1] = gda_996[0][0][12] > gda_996[0][1][12]; gba_1156[0][13][2] = gda_996[0][0][12] < gda_996[0][1][12]; gba_1156[0][14][1] = gda_996[0][6][14] < TrixOverboughtLevel; gba_1156[0][14][2] = gda_996[0][6][14] > TrixOversoldLevel; gba_1156[0][15][1] = High[0] - Low[0] <= EntryCandleMaxATR * iATR(Symbol(), 0, AtrPeriod, 0); gba_1156[0][15][2] = gba_1156[0][15][1]; gba_1156[0][17][1] = Bid - gda_988[1][1] <= gda_1028[2]; gba_1156[0][17][2] = gda_988[1][2] - Bid <= gda_1028[2]; gba_1156[0][18][1] = gia_1052[18][0] == 0; gba_1156[0][18][2] = gia_1052[18][0] == 0; gba_1156[0][19][1] = MathAbs(Bid - gda_996[1][11][10]) >= gda_1028[12]; gba_1156[0][19][2] = gba_1156[0][19][1]; for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { gba_1156[0][0][gi_1104] = 1; for (g_y_1108 = 1; g_y_1108 <= 19; g_y_1108++) { gba_1156[0][g_y_1108][gi_1104] = gba_1156[0][g_y_1108][gi_1104] || !gba_1180[0][g_y_1108][1]; gba_1156[0][0][gi_1104] = gba_1156[0][0][gi_1104] * gba_1156[0][g_y_1108][gi_1104]; } } gba_1156[0][0][1] = gba_1156[0][0][1] * (gba_1156[1][0][1] && gda_1000[0][1] > 0.0 || gda_1000[0][21] == 0.0); gba_1156[0][0][1] = gba_1156[0][0][1] * (!gba_1156[1][0][3] || !gba_1156[2][0][3] || !FreshSignal); gba_1156[0][0][2] = gba_1156[0][0][2] * (gba_1156[1][0][2] && gda_1000[0][2] > 0.0 || gda_1000[0][21] == 0.0); gba_1156[0][0][2] = gba_1156[0][0][2] * (!gba_1156[1][0][4] || !gba_1156[2][0][4] || !FreshSignal); gba_1160[0][1][1] = gda_996[0][0][6] < gda_996[1][0][6]; gba_1160[0][1][2] = gda_996[0][0][6] > gda_996[1][0][6]; gba_1160[0][2][1] = gda_996[0][0][7] < gda_996[1][0][7]; gba_1160[0][2][2] = gda_996[0][0][7] > gda_996[1][0][7]; gba_1160[0][3][1] = gda_996[0][0][8] < gda_996[1][0][8]; gba_1160[0][3][2] = gda_996[0][0][8] > gda_996[1][0][8]; gba_1160[0][4][1] = gda_996[0][0][9] < gda_996[1][0][9]; gba_1160[0][4][2] = gda_996[0][0][9] > gda_996[1][0][9]; gba_1160[0][5][1] = Bid < MathMin(gda_996[0][3][1], gda_996[0][4][1]); gba_1160[0][5][2] = Bid > MathMax(gda_996[0][3][1], gda_996[0][4][1]); gba_1160[0][6][1] = Bid < MathMin(gda_996[0][3][2], gda_996[0][4][2]); gba_1160[0][6][2] = Bid > MathMax(gda_996[0][3][2], gda_996[0][4][2]); gba_1160[0][7][1] = Bid < gda_996[0][0][4] - gda_1028[9]; gba_1160[0][7][2] = Bid > gda_996[0][0][4] + gda_1028[9]; gba_1160[0][8][1] = Bid < MathMin(gda_996[0][3][3], gda_996[0][4][3]) - gda_1028[6]; gba_1160[0][8][2] = Bid > MathMax(gda_996[0][3][3], gda_996[0][4][3]) + gda_1028[6]; gba_1160[0][9][1] = gda_996[0][6][5] < gda_996[0][7][5]; gba_1160[0][9][2] = gda_996[0][6][5] > gda_996[0][7][5]; gba_1160[0][10][1] = gda_996[0][6][5] < gda_996[1][6][5]; gba_1160[0][10][2] = gda_996[0][6][5] > gda_996[1][6][5]; gba_1160[0][11][1] = gda_996[0][7][5] < gda_996[1][7][5]; gba_1160[0][11][2] = gda_996[0][7][5] > gda_996[1][7][5]; gba_1160[0][12][1] = gda_996[0][6][5] < 0.0; gba_1160[0][12][2] = gda_996[0][6][5] > 0.0; gba_1160[0][13][1] = gda_996[0][0][12] < gda_996[0][1][12]; gba_1160[0][13][2] = gda_996[0][0][12] > gda_996[0][1][12]; gba_1160[0][20][1] = gda_1032[0][1] > 0.0 && Bid >= gda_1032[0][1]; gba_1160[0][20][2] = gda_1032[0][2] > 0.0 && Bid <= gda_1032[0][2]; gba_1160[0][22][1] = gba_1156[0][0][2]; gba_1160[0][22][2] = gba_1156[0][0][1]; for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { gba_1160[0][0][gi_1104] = 0; gba_1160[0][30][gi_1104] = 0; for (g_y_1108 = 1; g_y_1108 <= 22; g_y_1108++) { gba_1160[0][g_y_1108][gi_1104] = gba_1160[1][g_y_1108][gi_1104] || (gba_1160[0][g_y_1108][gi_1104] && gba_1180[0][g_y_1108][2] && Time[0] > gia_1072[gi_1104] || g_y_1108 == 20); gba_1160[0][g_y_1108][gi_1104] = gba_1160[0][g_y_1108][gi_1104] * (g_y_1108 >= 20 || (GlobalVariableGet(gsa_1204[0][0][gi_1104]) >= IndicatorsExitPriority - 1 && GlobalVariableGet(gsa_1204[0][24][gi_1104]) == 0.0)); gba_1160[0][30][gi_1104] = gba_1160[0][30][gi_1104] || (gba_1160[0][g_y_1108][gi_1104] && g_y_1108 <= 13); gba_1160[0][0][gi_1104] = gba_1160[0][0][gi_1104] || gba_1160[0][g_y_1108][gi_1104]; } gba_1160[0][0][gi_1104] = gba_1160[0][0][gi_1104] * (GlobalVariableGet(gsa_1216[gi_1104 + 4]) == 0.0); } gba_1168[1] = 0; gba_1168[2] = 0; for (g_pos_1136 = OrdersTotal() - 1; g_pos_1136 >= 0; g_pos_1136--) { if (OrderSelect(g_pos_1136, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_1080) { gi_1100 = OrderType() + 1; gda_1048[1] = Bid; gda_1048[2] = Ask; gi_1152 = (gi_1100 == 1) - (gi_1100 == 2); gda_988[30][1] = iATR(Symbol(), 0, AtrPeriod, 0) * (ADXMultiplier * iADX(Symbol(), 0, ADXPeriod, PRICE_CLOSE, MODE_MAIN, 0) + (ADXMultiplier == 0.0)); if (OrderStopLoss() == 0.0 && OrderTakeProfit() == 0.0 && gda_1008[0] > 0.0 || gda_1004[0] > 0.0) { gda_992[0][1] = NormalizeDouble((gda_1008[0] > 0.0) * (OrderOpenPrice() - gi_1152 * gda_1008[0]), Digits); gda_992[0][2] = NormalizeDouble((gda_1004[0] > 0.0) * (OrderOpenPrice() + gi_1152 * gda_1004[0]), Digits); OrderModify(OrderTicket(), OrderOpenPrice(), gda_992[0][1], gda_992[0][2], 0, gia_1060[gi_1100]); } if (!gba_1164[3] || (!gba_1164[4] && DailyCloseInProfit || OrderProfit() + OrderSwap() < 0.0)) { OrderClose(OrderTicket(), OrderLots(), gda_1048[gi_1100], Slippage, gia_1060[gi_1100]); gsa_1192[0][13][gi_1100] = " at daily close hour"; if (!gba_1164[3]) gsa_1192[0][13][gi_1100] = " at Friday close hour"; } if (gda_1000[0][21] > 0.0) DrawPatterns(); if (gia_1068[gi_1100] != OrderTicket()) { gia_1068[gi_1100] = OrderTicket(); gsa_1192[0][13][gi_1100] = ""; } gba_1168[gi_1100] = 1; gba_1168[gi_1100 + 2] = 0; gba_1172[gi_1100] = 0; gsa_1200[gi_1100] = OrderComment(); gia_1072[gi_1100] = OrderOpenTime(); gia_1076[gi_1100] = TimeCurrent(); gda_1040[gi_1100] = NormalizeDouble(gi_1152 * (gda_1048[gi_1100] - OrderOpenPrice()) / (Point * gi_1092), 1); if (gsa_1192[0][14][gi_1100] == "") gsa_1192[0][14][gi_1100] = gsa_1192[0][10][gi_1100]; if (ClassicSL || HighLowSL) { gda_992[1][0] = gda_1008[1] + StopLossAtrMultiplier * gda_988[30][1]; if (OrderType() == OP_BUY && GlobalVariableGet(gsa_1216[1]) == 0.0) { if (ClassicSL) gda_992[1][1] = OrderOpenPrice(); if (HighLowSL) { gda_992[1][1] = Low[iLowest(Symbol(), 0, MODE_LOW, BarsBack, 1)]; if (OrderOpenPrice() - gda_992[1][1] + gda_992[1][0] < gda_1008[3]) { gda_992[1][1] = OrderOpenPrice(); gda_992[1][0] = gda_1008[3]; } } GlobalVariableSet(gsa_1216[1], NormalizeDouble(gda_992[1][1] - gda_992[1][0], Digits)); } if (OrderType() == OP_SELL && GlobalVariableGet(gsa_1216[2]) == 0.0) { if (ClassicSL) gda_992[1][2] = OrderOpenPrice(); if (HighLowSL) { gda_992[1][2] = High[iHighest(Symbol(), 0, MODE_HIGH, BarsBack, 1)]; if (gda_992[1][2] - OrderOpenPrice() + gda_992[1][0] < gda_1008[3]) { gda_992[1][2] = OrderOpenPrice(); gda_992[1][0] = gda_1008[3]; } } GlobalVariableSet(gsa_1216[2], NormalizeDouble(gda_992[1][2] + gda_992[1][0], Digits)); } } if (BreakEvenPips > 0.0 || BreakEvenAtrMultiplier > 0.0) { gda_1020[0] = gda_1020[1] + BreakEvenAtrMultiplier * gda_988[30][1]; gda_1024[0] = gda_1024[1] + LockAtrMultiplier * gda_988[30][1]; if (gi_1152 * (gda_1048[gi_1100] - OrderOpenPrice()) >= gda_1020[0] && gi_1152 * (OrderOpenPrice() - GlobalVariableGet(gsa_1216[gi_1100])) + gda_1024[0] > 0.0 || GlobalVariableGet(gsa_1216[gi_1100]) == 0.0) GlobalVariableSet(gsa_1216[gi_1100], NormalizeDouble(OrderOpenPrice() + gi_1152 * gda_1024[0], Digits)); } if (ClassicTrailingStop) { gda_1012[0] = gda_1012[1] + TrailingStopAtrMultiplier * gda_988[30][1]; if (OrderType() == OP_BUY && GlobalVariableGet(gsa_1204[0][0][1]) >= StartTrailingPartialClose) { GlobalVariableSet(gsa_1216[5], TrailingStopDisablesExits); if (Bid - OrderOpenPrice() >= gda_1012[0] && Bid - OrderOpenPrice() >= gda_1012[2] && GlobalVariableGet(gsa_1216[1]) <= Bid - gda_1012[0] - gda_1016[1]) GlobalVariableSet(gsa_1216[1], NormalizeDouble(Bid - gda_1012[0], Digits)); } if (OrderType() == OP_SELL && GlobalVariableGet(gsa_1204[0][0][2]) >= StartTrailingPartialClose) { GlobalVariableSet(gsa_1216[6], TrailingStopDisablesExits); if (OrderOpenPrice() - Ask >= gda_1012[0] && OrderOpenPrice() - Ask >= gda_1012[2] && GlobalVariableGet(gsa_1216[2]) >= Ask + gda_1012[0] + gda_1016[1] || GlobalVariableGet(gsa_1216[2]) == 0.0) GlobalVariableSet(gsa_1216[2], NormalizeDouble(Ask + gda_1012[0], Digits)); } } if (PSARTrailingStop) { if (OrderType() == OP_BUY && GlobalVariableGet(gsa_1204[0][0][1]) >= StartTrailingPartialClose && Low[0] >= iSAR(Symbol(), 0, Step, Maximum, 1) && GlobalVariableGet(gsa_1216[1]) < iSAR(Symbol(), 0, Step, Maximum, 1)) { GlobalVariableSet(gsa_1216[1], NormalizeDouble(iSAR(Symbol(), 0, Step, Maximum, 1) - gda_1028[7], Digits)); GlobalVariableSet(gsa_1216[5], TrailingStopDisablesExits); } if (OrderType() == OP_SELL && GlobalVariableGet(gsa_1204[0][0][2]) >= StartTrailingPartialClose && High[0] <= iSAR(Symbol(), 0, Step, Maximum, 1) && GlobalVariableGet(gsa_1216[2]) > iSAR(Symbol(), 0, Step, Maximum, 1) + Ask - Bid || GlobalVariableGet(gsa_1216[2]) == 0.0) { GlobalVariableSet(gsa_1216[2], NormalizeDouble(iSAR(Symbol(), 0, Step, Maximum, 1) + Ask - Bid + gda_1028[7], Digits)); GlobalVariableSet(gsa_1216[6], TrailingStopDisablesExits); } } if (GlobalVariableGet(gsa_1216[gi_1100]) > 0.0) { if (gi_1152 * (gda_1048[gi_1100] - GlobalVariableGet(gsa_1216[gi_1100])) <= 0.0) { OrderClose(OrderTicket(), OrderLots(), gda_1048[gi_1100], Slippage, gia_1060[gi_1100]); gsa_1192[0][13][gi_1100] = " by stop loss"; GlobalVariableSet(gsa_1216[gi_1100 + 2], 1); } } if (GlobalVariableGet(gsa_1204[0][27][gi_1100]) == OrderTicket() && !IsTradeContextBusy()) OrderClose(OrderTicket(), GlobalVariableGet(gsa_1204[0][28][gi_1100]), gda_1048[gi_1100], Slippage, gia_1060[gi_1100]); gba_1160[0][21][gi_1100] = CalcTP() > 0.0 && gi_1152 * (gda_1048[gi_1100] - GlobalVariableGet(gsa_1220[gi_1100])) >= 0.0; if (gba_1160[0][0][gi_1100] || gba_1160[0][21][gi_1100]) { if (OrderProfit() + OrderSwap() >= 0.0 || !CloseIfProfit) { if (gba_1160[0][20][gi_1100] + gba_1160[0][21][gi_1100] + gba_1160[0][22][gi_1100] + gba_1160[0][30][gi_1100] > 1) { if (gba_1160[0][22][gi_1100]) { gba_1160[0][20][gi_1100] = 0; gba_1160[0][21][gi_1100] = 0; gba_1160[0][30][gi_1100] = 0; } if (gba_1160[0][21][gi_1100]) { gba_1160[0][20][gi_1100] = 0; gba_1160[0][30][gi_1100] = 0; } if (gba_1160[0][20][gi_1100]) gba_1160[0][30][gi_1100] = 0; } gda_1036[5] = 0; gi_1124 = GlobalVariableGet(gsa_1204[0][0][gi_1100]) + 1.0; GlobalVariableSet(gsa_1204[0][0][gi_1100], gi_1124); gi_1120 = gba_1160[0][20][gi_1100] * 2 + gba_1160[0][21][gi_1100] + 3 * gba_1160[0][30][gi_1100]; GlobalVariableSet(gsa_1204[gi_1124][26][gi_1100], gi_1120); if (gba_1160[0][20][gi_1100]) { if (gda_1032[0][gi_1100] == gda_1032[1][gi_1100]) { gsa_1192[0][gi_1124][gi_1100] = StringConcatenate(gsa_1224[gia_1064[gi_1100]], " level touch"); gi_1120 = GlobalVariableGet(gsa_1208[1][1][gi_1100]) + 1.0; GlobalVariableSet(gsa_1208[1][1][gi_1100], gi_1120); gda_1032[1][gi_1100] = 0; } if (gda_1032[0][gi_1100] == gda_1032[2][gi_1100]) { gsa_1192[0][gi_1124][gi_1100] = "psych level touch"; gi_1120 = GlobalVariableGet(gsa_1208[1][2][gi_1100]) + 1.0; GlobalVariableSet(gsa_1208[1][2][gi_1100], gi_1120); gda_1032[2][gi_1100] = 0; } if (gda_1032[0][gi_1100] == gda_1032[3][gi_1100]) { gsa_1192[0][gi_1124][gi_1100] = "daily pivot level touch"; gi_1120 = GlobalVariableGet(gsa_1208[1][3][gi_1100]) + 1.0; GlobalVariableSet(gsa_1208[1][3][gi_1100], gi_1120); gda_1032[3][gi_1100] = 0; } } if (gba_1160[0][20][gi_1100] || gba_1160[0][21][gi_1100]) { gda_1032[0][gi_1100] = 0; GlobalVariableSet(gsa_1204[0][23][gi_1100], Bid); } if (gba_1160[0][21][gi_1100]) { gsa_1192[0][gi_1124][gi_1100] = "take profit"; gi_1120 = GlobalVariableGet(gsa_1204[0][25][gi_1100]) + 1.0; GlobalVariableSet(gsa_1204[0][25][gi_1100], gi_1120); GlobalVariableSet(gsa_1220[gi_1100], 0); } if (gba_1160[0][30][gi_1100]) { GlobalVariableSet(gsa_1204[0][24][gi_1100], 1); gsa_1192[0][gi_1124][gi_1100] = ""; for (gi_1104 = 1; gi_1104 <= 13; gi_1104++) { if (gba_1160[0][gi_1104][gi_1100]) { if (gsa_1192[0][gi_1124][gi_1100] != "") gsa_1192[0][gi_1124][gi_1100] = StringConcatenate(gsa_1192[0][gi_1124][gi_1100], ", ", gsa_1192[0][30][gi_1104]); if (gsa_1192[0][gi_1124][gi_1100] == "") gsa_1192[0][gi_1124][gi_1100] = gsa_1192[0][30][gi_1104]; } } } if (gda_1044[gi_1124] > 0.0) gda_1036[5] = MathMax(MarketInfo(Symbol(), MODE_MINLOT), NormalizeDouble(OrderLots() * gda_1044[gi_1124] / 100.0, gia_1052[0][0])); if (gba_1160[0][22][gi_1100]) { gda_1036[5] = OrderLots(); gsa_1192[0][13][gi_1100] = " by opposite signal"; gba_1168[5 - gi_1100] = 1; } if (gda_1036[5] > 0.0) { OrderClose(OrderTicket(), gda_1036[5], gda_1048[gi_1100], Slippage, gia_1060[gi_1100]); GlobalVariableSet(gsa_1204[0][27][gi_1100], OrderTicket()); GlobalVariableSet(gsa_1204[0][28][gi_1100], gda_1036[5]); } if (GlobalVariableGet(gsa_1204[0][0][gi_1100]) == BreakEvenPartialClose && gi_1152 * (gda_1048[gi_1100] - OrderOpenPrice()) > 0.0 && gi_1152 * (OrderOpenPrice() - GlobalVariableGet(gsa_1216[gi_1100])) > 0.0 || GlobalVariableGet(gsa_1216[gi_1100]) == 0.0) GlobalVariableSet(gsa_1216[gi_1100], OrderOpenPrice()); } } if (GlobalVariableGet(gsa_1204[0][0][gi_1100]) >= LevelsExitPriority - 1) { if (GlobalVariableGet(gsa_1208[1][1][gi_1100]) < PriceTouchSRLevel) { for (gi_1104 = gia_1052[30][1]; gi_1104 <= gia_1052[30][2]; gi_1104 += !MidPivots + 1) { g_y_1108 = (!MidPivots + 1) * (gi_1104 == !MidPivots + 12); g_index_1112 = gi_1104 - MidPivots - 1 - g_y_1108; g_index_1112 *= (g_index_1112 > 0); g_y_1108 = (MidPivots + 1) * (gi_1104 == 10 - MidPivots); gi_1116 = gi_1104 + MidPivots + 1 + g_y_1108; if (gi_1104 != 11) { if (OrderType() == OP_BUY && CalcL() > gda_996[1][g_index_1112][10] && CalcL() <= gda_996[1][gi_1104][10] && gda_1032[0][1] == 0.0) { gda_1032[1][1] = gda_996[1][gi_1104][10]; gia_1064[1] = gi_1104; } if (OrderType() == OP_SELL && CalcL() >= gda_996[1][gi_1104][10] && CalcL() < gda_996[1][gi_1116][10] || gi_1104 == 21 && gda_1032[0][2] == 0.0) { gda_1032[1][2] = gda_996[1][gi_1104][10]; gia_1064[2] = gi_1104; } } } } if (GlobalVariableGet(gsa_1208[1][3][gi_1100]) < PriceTouchDailyPivot) { if (OrderType() == OP_BUY && CalcL() <= gda_996[1][11][10] - gda_1028[13] && gda_1032[0][1] == 0.0) gda_1032[3][1] = gda_996[1][11][10] - gda_1028[13]; if (OrderType() == OP_SELL && CalcL() >= gda_996[1][11][10] + gda_1028[13] && gda_1032[0][2] == 0.0) gda_1032[3][2] = gda_996[1][11][10] + gda_1028[13]; } if (GlobalVariableGet(gsa_1208[1][2][gi_1100]) < PriceTouchPsychLevel) { if (OrderType() == OP_BUY && gda_1032[0][1] == 0.0) { gda_992[0][0] = MathMax(OrderOpenPrice() + gda_1028[1], Bid); gda_992[0][0] = MathMax(gda_992[0][0], GlobalVariableGet(gsa_1204[0][23][1]) + gda_1028[8]); gda_992[0][1] = NormalizeDouble(gda_992[0][0], Digits - (gi_1092 == 10) - 2); gda_992[0][2] = gda_992[0][1] + gda_1028[3]; gda_992[0][2] += (gda_992[0][2] < gda_992[0][0]) * gda_1028[5]; gda_992[0][3] = gda_992[0][1] + gda_1028[4]; gda_992[0][3] += (gda_992[0][3] < gda_992[0][0]) * gda_1028[5]; gda_1032[2][1] = MathMin(gda_992[0][2], gda_992[0][3]); } if (OrderType() == OP_SELL && gda_1032[0][2] == 0.0) { gda_992[0][0] = MathMin(OrderOpenPrice() - gda_1028[1], Bid); if (GlobalVariableGet(gsa_1204[0][23][2]) > 0.0) gda_992[0][0] = MathMin(gda_992[0][0], GlobalVariableGet(gsa_1204[0][23][2]) - gda_1028[8]); gda_992[0][1] = NormalizeDouble(gda_992[0][0], Digits - (gi_1092 == 10) - 2); gda_992[0][2] = gda_992[0][1] + gda_1028[3]; gda_992[0][2] = gda_992[0][2] - (gda_992[0][2] > gda_992[0][0]) * gda_1028[5]; gda_992[0][3] = gda_992[0][1] + gda_1028[4]; gda_992[0][3] = gda_992[0][3] - (gda_992[0][3] > gda_992[0][0]) * gda_1028[5]; gda_1032[2][2] = MathMax(gda_992[0][2], gda_992[0][3]); } } gda_1032[0][1] = MathMin(gda_1032[1][1], gda_1032[2][1]); if (gda_1032[0][1] == 0.0) gda_1032[0][1] = MathMax(gda_1032[1][1], gda_1032[2][1]); if (gda_1032[3][1] > 0.0 && gda_1032[0][1] > 0.0) gda_1032[0][1] = MathMin(gda_1032[0][1], gda_1032[3][1]); if (gda_1032[3][1] > 0.0 && gda_1032[0][1] == 0.0) gda_1032[0][1] = gda_1032[3][1]; gda_1032[0][2] = MathMax(gda_1032[1][2], gda_1032[2][2]); gda_1032[0][2] = MathMax(gda_1032[0][2], gda_1032[3][2]); } } } if (TradingHours()) { if (gba_1156[0][0][1] || gba_1168[3] && !gba_1168[2] || Hedge && !gba_1168[1] && gba_1172[1] && GlobalVariableGet(gsa_1216[4]) == 0.0 && gda_1028[11] >= (gda_1028[11] > 0.0) * (Ask - Bid)) OrderSend(Symbol(), OP_BUY, CalcLots(), Ask, Slippage, 0, 0, TradeComment, g_magic_1080, 0, gia_1060[1]); if (gba_1156[0][0][2] || gba_1168[4] && !gba_1168[1] || Hedge && !gba_1168[2] && gba_1172[2] && GlobalVariableGet(gsa_1216[3]) == 0.0 && gda_1028[11] >= (gda_1028[11] > 0.0) * (Ask - Bid)) OrderSend(Symbol(), OP_SELL, CalcLots(), Bid, Slippage, 0, 0, TradeComment, g_magic_1080, 0, gia_1060[2]); } for (gi_1104 = 0; gi_1104 <= 2; gi_1104++) { if (!gba_1168[gi_1104] && gi_1104 > 0) { gda_1032[0][gi_1104] = 0; gsa_1192[0][14][gi_1104] = ""; if (GlobalVariableGet(gsa_1216[gi_1104]) != 0.0) GlobalVariableSet(gsa_1216[gi_1104], 0); if (GlobalVariableGet(gsa_1216[gi_1104 + 4]) != 0.0) GlobalVariableSet(gsa_1216[gi_1104 + 4], 0); if (GlobalVariableGet(gsa_1220[gi_1104]) != 0.0) GlobalVariableSet(gsa_1220[gi_1104], 0); if (GlobalVariableGet(gsa_1220[gi_1104 + 6]) != 0.0) GlobalVariableSet(gsa_1220[gi_1104 + 6], 0); for (g_y_1108 = 0; g_y_1108 <= 29; g_y_1108++) { for (g_index_1112 = 0; g_index_1112 <= 4; g_index_1112++) { if (GlobalVariableGet(gsa_1204[g_index_1112][g_y_1108][gi_1104]) != 0.0) GlobalVariableSet(gsa_1204[g_index_1112][g_y_1108][gi_1104], 0); if (GlobalVariableGet(gsa_1208[g_index_1112][g_y_1108][gi_1104]) != 0.0) GlobalVariableSet(gsa_1208[g_index_1112][g_y_1108][gi_1104], 0); } } } } gsa_1192[0][0][1] = "The expert advisor has expired"; if (gia_1232[8] >= TimeCurrent()) gsa_1192[0][0][1] = StringConcatenate("Expert advisor expiration date: ", gsa_1184[0][0]); if (UseTradingHours) { gsa_1192[0][0][2] = StringConcatenate("Server time ", TimeToStr(TimeCurrent(), TIME_MINUTES)); gsa_1192[0][0][3] = StringConcatenate("Trading hours ", gsa_1184[1][1], " to ", gsa_1184[1][2]); gsa_1192[0][0][4] = "We are outside trading hours"; if (gba_1164[1]) gsa_1192[0][0][4] = "We are inside trading hours"; } if (NewsFilter) { gsa_1192[0][0][5] = "Trading is enabled as we are outside news period"; if (!gba_1164[2]) gsa_1192[0][0][5] = "Trading is disabled as we are inside news period"; if (g_icustom_1084 == 99999 && g_icustom_1088 == 99999) gsa_1192[0][0][5] = "Trading is enabled as no news data received from THV3 FFCal"; } for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { g_index_1112 = 10 * gi_1104; if (gba_1168[gi_1104]) { gsa_1192[0][0][g_index_1112 + 2] = ""; gsa_1192[0][0][g_index_1112 + 3] = ""; gsa_1192[0][0][g_index_1112 + 5] = ""; gsa_1192[0][0][g_index_1112 + 6] = ""; gsa_1192[0][0][g_index_1112 + 7] = ""; gsa_1192[0][0][g_index_1112 + 8] = ""; gsa_1192[0][0][g_index_1112 + 1] = gsa_1192[0][14][gi_1104]; if (GlobalVariableGet(gsa_1220[gi_1104]) > 0.0 && GlobalVariableGet(gsa_1204[0][25][gi_1104]) < 2.0) gsa_1192[0][0][g_index_1112 + 2] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " hidden take profit is ", DoubleToStr(GlobalVariableGet(gsa_1220[gi_1104]), Digits)); if (GlobalVariableGet(gsa_1216[gi_1104]) > 0.0) gsa_1192[0][0][g_index_1112 + 3] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " hidden stop loss is ", DoubleToStr(GlobalVariableGet(gsa_1216[gi_1104]), Digits)); gsa_1192[0][0][g_index_1112 + 4] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], gsa_1192[0][31][(gda_1040[gi_1104] >= 0.0) + (gda_1040[gi_1104] < 0.0) * 2], gda_1040[gi_1104], " pips"); gi_1120 = GlobalVariableGet(gsa_1204[1][26][gi_1104]); if (gi_1120 > 0) gsa_1192[0][0][g_index_1112 + 5] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " first exit by ", gsa_1192[0][1][gi_1104]); gi_1120 = GlobalVariableGet(gsa_1204[2][26][gi_1104]); if (gi_1120 > 0) gsa_1192[0][0][g_index_1112 + 6] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " second exit by ", gsa_1192[0][2][gi_1104]); gi_1120 = GlobalVariableGet(gsa_1204[3][26][gi_1104]); if (gi_1120 > 0) gsa_1192[0][0][g_index_1112 + 7] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " third exit by ", gsa_1192[0][3][gi_1104]); gi_1120 = GlobalVariableGet(gsa_1204[4][26][gi_1104]); if (gi_1120 > 0) gsa_1192[0][0][g_index_1112 + 8] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " fourth exit by ", gsa_1192[0][4][gi_1104]); } if (!gba_1168[gi_1104]) { gsa_1192[0][0][g_index_1112 + 4] = StringConcatenate(gsa_1192[0][31][gi_1104 + 2], " has been closed", gsa_1192[0][13][gi_1104]); if (TimeCurrent() > gia_1076[gi_1104] + 300) { for (g_y_1108 = g_index_1112 + 1; g_y_1108 <= g_index_1112 + 8; g_y_1108++) gsa_1192[0][0][g_y_1108] = ""; gsa_1192[0][13][gi_1104] = ""; } } } g_y_1108 = 12; for (gi_1104 = 1; gi_1104 <= 30; gi_1104++) { ObjectSetText(gsa_1196[gi_1104], gsa_1192[0][0][gi_1104], 9, "Verdana", White); ObjectSet(gsa_1196[gi_1104], OBJPROP_CORNER, 0); ObjectSet(gsa_1196[gi_1104], OBJPROP_XDISTANCE, 2); ObjectSet(gsa_1196[gi_1104], OBJPROP_YDISTANCE, g_y_1108); if (gsa_1192[0][0][gi_1104] != "") g_y_1108 += 14; } if (ScreenShots) { for (gi_1104 = 1; gi_1104 <= 2; gi_1104++) { if (gba_1168[gi_1104] && gsa_1200[gi_1104] == TradeComment && GlobalVariableGet(gsa_1212[1][gi_1104]) != gia_1068[gi_1104]) { WindowScreenShot(StringConcatenate(gsa_1228[gi_1096], Symbol(), gia_1068[gi_1104], "Open.gif"), 800, 600, -1, -1, -1); GlobalVariableSet(gsa_1212[1][gi_1104], gia_1068[gi_1104]); GlobalVariableSet(gsa_1212[2][gi_1104], gia_1068[gi_1104]); } if ((gba_1168[gi_1104] && gsa_1200[gi_1104] != TradeComment && GlobalVariableGet(gsa_1212[2][gi_1104]) != gia_1068[gi_1104]) || (!gba_1168[gi_1104] && GlobalVariableGet(gsa_1212[2][gi_1104]) == gia_1068[gi_1104] && GlobalVariableGet(gsa_1212[2][gi_1104]) != 0.0)) { WindowScreenShot(StringConcatenate(gsa_1228[gi_1096], Symbol(), GlobalVariableGet(gsa_1212[2][gi_1104]), "Close.gif"), 800, 600, -1, -1, -1); GlobalVariableSet(gsa_1212[2][gi_1104], gba_1168[gi_1104] * gia_1068[gi_1104]); } } } return (0); } int BarClose(int a_timeframe_0) { g_pos_1144 = iTime(Symbol(), 0, 0) <= iTime(Symbol(), a_timeframe_0, 0); return (g_pos_1144); } bool TradingHours() { if (TimeCurrent() > gia_1232[4] && NewsFilter) { g_icustom_1084 = iCustom(Symbol(), 0, "THV3 FFCal", IncludeHigh, IncludeMedium, IncludeLow, IncludeSpeaks, 1, 1, 1, 1); g_icustom_1088 = iCustom(Symbol(), 0, "THV3 FFCal", IncludeHigh, IncludeMedium, IncludeLow, IncludeSpeaks, 1, 1, 1, 0); if (g_icustom_1084 != 99999 || g_icustom_1088 != 99999) { gia_1232[2] = iTime(Symbol(), PERIOD_M1, 0) - 60 * (g_icustom_1088 - MinutesAfterNews); gia_1232[3] = iTime(Symbol(), PERIOD_M1, 0) + 60 * (g_icustom_1084 - MinutesBeforeNews); gia_1232[4] = iTime(Symbol(), PERIOD_M1, 0) + 60 * (g_icustom_1084 + MinutesAfterNews); } } gba_1164[2] = TimeCurrent() > gia_1232[2] && TimeCurrent() < gia_1232[3] || TimeCurrent() > gia_1232[4]; if (UseTradingHours) { gia_1232[10] = StrToTime(gsa_1184[1][1]); gia_1232[11] = StrToTime(gsa_1184[1][2]); gia_1232[10] = gia_1232[10] - 86400 * (gia_1232[11] < gia_1232[10] && TimeCurrent() < gia_1232[11]); gia_1232[11] += 86400 * (gia_1232[11] < gia_1232[10] && TimeCurrent() >= gia_1232[11]); gba_1164[1] = TimeCurrent() >= gia_1232[10] && TimeCurrent() < gia_1232[11]; } gba_1164[3] = !(FridayClose && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(gsa_1184[1][3])); gba_1164[4] = !(DailyClose && TimeCurrent() >= StrToTime(gsa_1184[1][4])); gba_1164[5] = !(MondayOpen && (DayOfWeek() == 1 && TimeCurrent() < StrToTime(gsa_1184[1][5])) || DayOfWeek() == 0); gi_1140 = TimeCurrent() <= gia_1232[8] && gba_1164[1] && gba_1164[2] && gba_1164[3] && gba_1164[5]; return (gi_1140); } double CalcLots() { gda_1036[0] = Lots; if (MoneyManagement) { gda_1036[0] = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), MathMax(MarketInfo(Symbol(), MODE_MINLOT), NormalizeDouble(AccountEquity() * LeveragePercent / (100000 * (MarketInfo(Symbol(), MODE_LOTSIZE) == 100000.0) + 10000 * (MarketInfo(Symbol(), MODE_LOTSIZE) == 10000.0)), gia_1052[0][0]))); } if (Martingale && !gba_1168[1] && !gba_1168[2]) { gi_1140 = 0; for (g_pos_1144 = OrdersHistoryTotal() - 1; g_pos_1144 >= 0; g_pos_1144--) { if (OrderSelect(g_pos_1144, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_1080) { gi_1140 += (OrderProfit() < 0.0 && TradeComment == StringSubstr(OrderComment(), 0, StringLen(TradeComment))); if (OrderProfit() >= 0.0) break; } } gi_1140 = MathMin(gi_1140, MaxProgression); gda_1036[0] = MathMin(NormalizeDouble(gda_1036[0] * MathPow(LotMultiplier, gi_1140), gia_1052[0][0]), MarketInfo(Symbol(), MODE_MAXLOT)); } return (gda_1036[0]); } double CalcTP() { if (gda_1004[5] > 0.0) { if (GlobalVariableGet(gsa_1220[gi_1100 + 6]) == 0.0) { gda_992[0][1] = gda_1004[1] + TakeProfitAtrMultiplier1 * gda_988[30][1]; gda_992[0][2] = 0; if (gda_1004[1] > 0.0 && gda_1004[2] > 0.0) { gda_992[0][1] = gda_1004[1]; gda_992[0][2] = gda_1004[2]; } if (TakeProfitAtrMultiplier1 > 0.0 && TakeProfitAtrMultiplier2 > 0.0) { gda_992[0][1] = TakeProfitAtrMultiplier1 * gda_988[30][1]; gda_992[0][2] = TakeProfitAtrMultiplier2 * gda_988[30][1]; } if (gda_1004[1] > 0.0 && TakeProfitAtrMultiplier1 > 0.0) { gda_992[0][3] = gda_1004[1]; gda_992[0][4] = TakeProfitAtrMultiplier1 * gda_988[30][1]; gda_992[0][1] = MathMin(gda_992[0][3], gda_992[0][4]); gda_992[0][2] = MathMax(gda_992[0][3], gda_992[0][4]); } GlobalVariableSet(gsa_1220[gi_1100 + 2], gda_992[0][1]); GlobalVariableSet(gsa_1220[gi_1100 + 4], gda_992[0][2]); GlobalVariableSet(gsa_1220[gi_1100 + 6], 1); } if (GlobalVariableGet(gsa_1220[gi_1100]) == 0.0 && GlobalVariableGet(gsa_1204[0][25][gi_1100]) < gda_1004[5]) { g_pos_1144 = GlobalVariableGet(gsa_1204[0][25][gi_1100]) == 0.0; g_bool_1148 = GlobalVariableGet(gsa_1204[0][25][gi_1100]) == 1.0; gda_992[0][0] = ((gi_1100 == 1) - (gi_1100 == 2)) * (g_pos_1144 * GlobalVariableGet(gsa_1220[gi_1100 + 2]) + g_bool_1148 * GlobalVariableGet(gsa_1220[gi_1100 + 4])); GlobalVariableSet(gsa_1220[gi_1100], NormalizeDouble(OrderOpenPrice() + gda_992[0][0], Digits)); } } return (GlobalVariableGet(gsa_1220[gi_1100])); } double CalcL() { if (gi_1100 == 1) { gda_992[10][gi_1100] = MathMax(OrderOpenPrice() + gda_1028[1], Bid); gda_992[10][gi_1100] = MathMax(gda_992[10][gi_1100], GlobalVariableGet(gsa_1204[0][23][gi_1100]) + gda_1028[8]); } if (gi_1100 == 2) { gda_992[10][gi_1100] = MathMin(OrderOpenPrice() - gda_1028[1], Bid); if (GlobalVariableGet(gsa_1204[0][23][gi_1100]) > 0.0) gda_992[10][gi_1100] = MathMin(gda_992[10][gi_1100], GlobalVariableGet(gsa_1204[0][23][gi_1100]) - gda_1028[8]); } return (gda_992[10][gi_1100]); } void DrawPatterns() { if (GlobalVariableGet(gsa_1204[0][26][gi_1100]) != OrderTicket() && OrderComment() == TradeComment) { GlobalVariableSet(gsa_1204[0][26][gi_1100], OrderTicket()); for (gi_1104 = 1; gi_1104 <= gda_1000[0][20]; gi_1104++) { gsa_1192[0][0][0] = StringConcatenate(gda_1000[gi_1104][gi_1100 + 6], gi_1104, gi_1100); if (gda_1000[gi_1104][gi_1100] > 0.0 && ObjectFind(gsa_1192[0][0][0]) == -1) { if (gi_1104 == 3 && gda_1000[gi_1104][gi_1100 + 4] == gda_1000[gi_1104][gi_1100 + 8]) gda_1000[gi_1104][gi_1100 + 4] += gi_1152 * gda_1028[7]; ObjectCreate(gsa_1192[0][0][0], gda_1000[gi_1104][19], 0, gda_1000[gi_1104][gi_1100 + 2], gda_1000[gi_1104][gi_1100 + 4], gda_1000[gi_1104][gi_1100 + 6], gda_1000[gi_1104][gi_1100 + 8]); ObjectSet(gsa_1192[0][0][0], OBJPROP_COLOR, gia_1060[gi_1100]); if (gi_1104 == 5) ObjectSet(gsa_1192[0][0][0], OBJPROP_ARROWCODE, gi_1100 + 240); if (gi_1104 == 6) ObjectSetText(gsa_1192[0][0][0], "H", 10, "Verdana"); if (gi_1104 == 7) ObjectSet(gsa_1192[0][0][0], OBJPROP_RAY, FALSE); } } } } void CheckPatterns() { for (gi_1104 = 0; gi_1104 <= gda_1000[0][20]; gi_1104++) for (g_y_1108 = 0; g_y_1108 <= 18; g_y_1108++) gda_1000[gi_1104][g_y_1108] = 0; if (PinBar > 0) { gda_992[0][0] = 0.66; gda_992[0][1] = 0.6; for (gi_1104 = 1; gi_1104 <= PreviousBars; gi_1104++) { if (High[gi_1104] - Low[gi_1104] >= gda_992[0][1] * iATR(Symbol(), 0, 14, 1)) { if (gda_1000[1][1] == 0.0) { if (MathMin(Open[gi_1104], Close[gi_1104]) - Low[gi_1104] >= (High[gi_1104] - Low[gi_1104]) * gda_992[0][0] && gda_996[gi_1104][0][13] < gda_996[gi_1104 + 1][0][13] && Low[gi_1104] <= Low[gi_1104 + 1] && Low[iLowest(Symbol(), 0, MODE_LOW, gi_1104, 1)] >= Low[gi_1104]) { gda_1000[1][1] = 1; gda_1000[1][3] = Time[gi_1104 + 1]; gda_1000[1][5] = Low[gi_1104]; gda_1000[1][7] = Time[gi_1104 - 1]; gda_1000[1][9] = High[gi_1104]; } } if (gda_1000[1][2] == 0.0) { if (High[gi_1104] - MathMax(Open[gi_1104], Close[gi_1104]) >= (High[gi_1104] - Low[gi_1104]) * gda_992[0][0] && gda_996[gi_1104][0][13] > gda_996[gi_1104 + 1][0][13] && High[gi_1104] >= High[gi_1104 + 1] && High[iHighest(Symbol(), 0, MODE_HIGH, gi_1104, 1)] <= High[gi_1104]) { gda_1000[1][2] = 1; gda_1000[1][4] = Time[gi_1104 + 1]; gda_1000[1][6] = Low[gi_1104]; gda_1000[1][8] = Time[gi_1104 - 1]; gda_1000[1][10] = High[gi_1104]; } } } } } if (EngulfingBar > 0) { gda_992[0][0] = 0.3; for (gi_1104 = 1; gi_1104 <= PreviousBars; gi_1104++) { if (MathAbs(Open[gi_1104 + 1] - (Close[gi_1104 + 1])) >= gda_992[0][0] * iATR(Symbol(), 0, 14, 1)) { if (gda_1000[2][1] == 0.0) { if (gda_996[gi_1104 + 1][0][13] < gda_996[gi_1104 + 2][0][13] && Open[gi_1104] < Close[gi_1104] && Open[gi_1104 + 1] > Close[gi_1104 + 1] && Close[gi_1104] > Open[gi_1104 + 1] && Close[gi_1104 + 1] < Close[gi_1104 + 2] && Close[gi_1104 + 1] < Close[gi_1104 + 3] && Low[iLowest(Symbol(), 0, MODE_LOW, gi_1104, 1)] >= Low[gi_1104]) { gda_1000[2][1] = 1; gda_1000[2][3] = Time[gi_1104 + 1]; gda_1000[2][5] = Low[gi_1104]; gda_1000[2][7] = Time[gi_1104 - 1]; gda_1000[2][9] = High[gi_1104]; } } if (gda_1000[2][2] == 0.0) { if (gda_996[gi_1104 + 1][0][13] > gda_996[gi_1104 + 2][0][13] && Open[gi_1104] > Close[gi_1104] && Open[gi_1104 + 1] < Close[gi_1104 + 1] && Close[gi_1104] < Open[gi_1104 + 1] && Close[gi_1104 + 1] > Close[gi_1104 + 2] && Close[gi_1104 + 1] > Close[gi_1104 + 3] && High[iHighest(Symbol(), 0, MODE_HIGH, gi_1104, 1)] <= High[gi_1104]) { gda_1000[2][2] = 1; gda_1000[2][4] = Time[gi_1104 + 1]; gda_1000[2][6] = Low[gi_1104]; gda_1000[2][8] = Time[gi_1104 - 1]; gda_1000[2][10] = High[gi_1104]; } } } } } if (DoubleTopBottom > 0) { gda_992[0][0] = 0.2; gda_992[0][1] = 2; for (gi_1104 = 1; gi_1104 <= PreviousBars; gi_1104++) { for (gi_1116 = 1; gi_1116 <= 8; gi_1116++) { gda_992[1][gi_1116] = 0; gia_1056[1][gi_1116] = 0; gda_992[2][gi_1116] = 0; gia_1056[2][gi_1116] = 0; } for (g_y_1108 = gi_1104 + 1; g_y_1108 <= gi_1104 + 30; g_y_1108++) { if (Low[iLowest(Symbol(), 0, MODE_LOW, gi_1104, 1)] >= Low[gi_1104] && gda_1000[3][1] == 0.0) { gda_992[1][1] = High[iHighest(Symbol(), 0, MODE_HIGH, g_y_1108 - gi_1104 + 1, gi_1104)]; gia_1056[1][1] += (Low[gi_1104] < Low[g_y_1108] && g_y_1108 <= gi_1104 + 3); if (g_y_1108 > gi_1104 + 3 && Low[g_y_1108] < Low[iLowest(Symbol(), 0, MODE_LOW, g_y_1108 - gi_1104 - 3, gi_1104 + 3)]) { gia_1056[1][2] = (MathAbs(Low[gi_1104] - Low[g_y_1108]) <= (gda_992[1][1] - MathMin(Low[gi_1104], Low[g_y_1108])) * gda_992[0][0] && gda_992[1][1] - MathMin(Low[gi_1104], Low[g_y_1108]) >= gda_992[0][1] * iATR(Symbol(), 0, 14, 1)) * g_y_1108; gda_992[1][2] = gda_992[1][1]; } if (Low[g_y_1108] > gda_992[1][2] && gia_1056[1][1] == 3 && gia_1056[1][2] > 0) { gda_1000[3][1] = 1; gda_1000[3][3] = Time[gi_1104]; gda_1000[3][5] = Low[gi_1104]; gda_1000[3][7] = Time[gia_1056[1][2]]; gda_1000[3][9] = Low[gia_1056[1][2]]; } } if (High[iHighest(Symbol(), 0, MODE_HIGH, gi_1104, 1)] <= High[gi_1104] && gda_1000[3][2] == 0.0) { gda_992[2][1] = Low[iLowest(Symbol(), 0, MODE_LOW, g_y_1108 - gi_1104 + 1, gi_1104)]; gia_1056[2][1] += (High[gi_1104] > High[g_y_1108] && g_y_1108 <= gi_1104 + 3); if (g_y_1108 > gi_1104 + 3 && High[g_y_1108] > High[iHighest(Symbol(), 0, MODE_HIGH, g_y_1108 - gi_1104 - 3, gi_1104 + 3)]) { gia_1056[2][2] = (MathAbs(High[gi_1104] - High[g_y_1108]) <= (MathMax(High[gi_1104], High[g_y_1108]) - gda_992[2][1]) * gda_992[0][0] && MathMax(High[gi_1104], High[g_y_1108]) - gda_992[2][1] >= gda_992[0][1] * iATR(Symbol(), 0, 14, 1)) * g_y_1108; gda_992[2][2] = gda_992[2][1]; } if (High[g_y_1108] < gda_992[2][2] && gia_1056[2][1] == 3 && gia_1056[2][2] > 0) { gda_1000[3][2] = 1; gda_1000[3][4] = Time[gi_1104]; gda_1000[3][6] = High[gi_1104]; gda_1000[3][8] = Time[gia_1056[2][2]]; gda_1000[3][10] = High[gia_1056[2][2]]; } } } } } if (InsideBar > 0 && PreviousBars > 1) { for (gi_1104 = 1; gi_1104 <= PreviousBars - 1; gi_1104++) { if (High[gi_1104 + 2] >= High[gi_1104 + 1] && Low[gi_1104 + 2] <= Low[gi_1104 + 1] && High[gi_1104 + 2] - (Low[gi_1104 + 2]) > High[gi_1104 + 1] - (Low[gi_1104 + 1])) { if (gda_1000[4][1] == 0.0) { if (Close[gi_1104] > High[gi_1104 + 1]) { gda_1000[4][1] = 1; gda_1000[4][3] = Time[gi_1104]; gda_1000[4][5] = Low[gi_1104 + 1]; gda_1000[4][7] = Time[gi_1104 + 2]; gda_1000[4][9] = High[gi_1104 + 1]; } } if (gda_1000[4][2] == 0.0) { if (Close[gi_1104] < Low[gi_1104 + 1]) { gda_1000[4][2] = 1; gda_1000[4][4] = Time[gi_1104]; gda_1000[4][6] = Low[gi_1104 + 1]; gda_1000[4][8] = Time[gi_1104 + 2]; gda_1000[4][10] = High[gi_1104 + 1]; } } } } } if (TrixDivergence > 0) { for (gi_1104 = 1; gi_1104 <= PreviousBars + 1; gi_1104++) { if (gda_1000[5][1] == 0.0) { if (iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 4, gi_1104) != EMPTY_VALUE) { gda_1000[5][1] = 1; gda_1000[5][3] = Time[gi_1104]; gda_1000[5][5] = Low[gi_1104]; gda_1000[5][7] = Time[gi_1104]; gda_1000[5][9] = 0; } } if (gda_1000[5][2] == 0.0) { if (iCustom(Symbol(), 0, "THV3 Trix called", Trix_A_t3_period, Trix_B_t3_period_ac, 1, 5, gi_1104) != EMPTY_VALUE) { gda_1000[5][2] = 1; gda_1000[5][4] = Time[gi_1104]; gda_1000[5][6] = High[gi_1104] + 5.0 * gda_1028[7]; gda_1000[5][8] = Time[gi_1104]; gda_1000[5][10] = 0; } } } } if (Harmonics > 0) { for (gi_1104 = 1; gi_1104 <= PreviousBars; gi_1104++) { if (gda_1000[6][1] == 0.0) { if (iCustom(Symbol(), 0, "Gartley", 6, gi_1104) > 0.0) { gda_1000[6][1] = 1; gda_1000[6][3] = Time[gi_1104]; gda_1000[6][5] = Low[gi_1104]; gda_1000[6][7] = Time[gi_1104]; gda_1000[6][9] = 0; } } if (gda_1000[6][2] == 0.0) { if (iCustom(Symbol(), 0, "Gartley", 7, gi_1104) > 0.0) { gda_1000[6][2] = 1; gda_1000[6][4] = Time[gi_1104]; gda_1000[6][6] = High[gi_1104] + 5.0 * gda_1028[7]; gda_1000[6][8] = Time[gi_1104]; gda_1000[6][10] = 0; } } } } if (TrendlineBreak > 0) { if (ObjectFind("Trendline") == -1) { ObjectCreate("Trendline", OBJ_TREND, 0, 0, 0, 0, 0); ObjectSet("Trendline", OBJPROP_TIMEFRAMES, EMPTY); } for (gi_1104 = 1; gi_1104 <= PreviousBars; gi_1104++) { if (gda_1000[7][1] == 0.0) { for (g_y_1108 = 6; g_y_1108 <= 40; g_y_1108++) { if (High[g_y_1108] > High[g_y_1108 - 1] && High[g_y_1108] > High[g_y_1108 + 1] || (High[g_y_1108] == High[g_y_1108 + 1] && High[g_y_1108 + 1] > High[g_y_1108 + 2])) { for (g_index_1112 = 3; g_index_1112 <= g_y_1108 - 3; g_index_1112++) { ObjectSet("Trendline", OBJPROP_TIME1, Time[g_y_1108]); ObjectSet("Trendline", OBJPROP_TIME2, Time[g_index_1112]); ObjectSet("Trendline", OBJPROP_PRICE1, High[g_y_1108]); ObjectSet("Trendline", OBJPROP_PRICE2, High[g_index_1112]); if (Close[gi_1104] > ObjectGetValueByShift("Trendline", gi_1104)) { gi_1128 = 0; for (gi_1116 = g_index_1112 + 1; gi_1116 <= g_y_1108 - 1; gi_1116++) gi_1128 += (High[gi_1116] > ObjectGetValueByShift("Trendline", gi_1116)); if (gi_1128 == 0) { gi_1132 = 0; for (gi_1120 = 2; gi_1120 <= g_index_1112 - 1; gi_1120++) gi_1132 += (High[gi_1120] > ObjectGetValueByShift("Trendline", gi_1120)); if (gi_1132 == 0) { gda_1000[7][1] = 1; gda_1000[7][3] = Time[g_y_1108]; gda_1000[7][5] = High[g_y_1108]; gda_1000[7][7] = Time[1]; gda_1000[7][9] = ObjectGetValueByShift("Trendline", 1); } } } } } } } if (gda_1000[7][2] == 0.0) { for (g_y_1108 = 6; g_y_1108 <= 40; g_y_1108++) { if (Low[g_y_1108] < Low[g_y_1108 - 1] && Low[g_y_1108] < Low[g_y_1108 + 1] || (Low[g_y_1108] == Low[g_y_1108 + 1] && Low[g_y_1108 + 1] < Low[g_y_1108 + 2])) { for (g_index_1112 = 3; g_index_1112 <= g_y_1108 - 3; g_index_1112++) { ObjectSet("Trendline", OBJPROP_TIME1, Time[g_y_1108]); ObjectSet("Trendline", OBJPROP_TIME2, Time[g_index_1112]); ObjectSet("Trendline", OBJPROP_PRICE1, Low[g_y_1108]); ObjectSet("Trendline", OBJPROP_PRICE2, Low[g_index_1112]); if (Close[gi_1104] < ObjectGetValueByShift("Trendline", gi_1104)) { gi_1128 = 0; for (gi_1116 = g_index_1112 + 1; gi_1116 <= g_y_1108 - 1; gi_1116++) gi_1128 += (Low[gi_1116] < ObjectGetValueByShift("Trendline", gi_1116)); if (gi_1128 == 0) { gi_1132 = 0; for (gi_1120 = 2; gi_1120 <= g_index_1112 - 1; gi_1120++) gi_1132 += (Low[gi_1120] < ObjectGetValueByShift("Trendline", gi_1120)); if (gi_1132 == 0) { gda_1000[7][2] = 1; gda_1000[7][4] = Time[g_y_1108]; gda_1000[7][6] = Low[g_y_1108]; gda_1000[7][8] = Time[1]; gda_1000[7][10] = ObjectGetValueByShift("Trendline", 1); } } } } } } } } } for (g_y_1108 = 1; g_y_1108 <= 2; g_y_1108++) { gi_1120 = 0; gda_1000[0][g_y_1108] = 0; gsa_1192[0][10][g_y_1108] = ""; for (gi_1104 = 1; gi_1104 <= gda_1000[0][20]; gi_1104++) { gi_1124 = gda_1000[gi_1104][g_y_1108] == 1.0 && gda_1000[gi_1104][20] == 1.0 || gda_1000[gi_1104][20] == 3.0 || gda_1000[gi_1104][20] == 4.0; gda_1000[0][g_y_1108] += gi_1124; gi_1120 += ((gda_1000[gi_1104][g_y_1108] == 0.0 && gda_1000[gi_1104][20] == 4.0) || (gda_1000[gi_1104][(g_y_1108 == 1) + 1] == 1.0 && gda_1000[gi_1104][20] == 2.0 || gda_1000[gi_1104][20] == 3.0)); if (gi_1124 > 0) { if (gsa_1192[0][10][g_y_1108] != "") gsa_1192[0][10][g_y_1108] = StringConcatenate(gsa_1192[0][10][g_y_1108], ", ", gsa_1192[0][g_y_1108 + 10][gi_1104]); if (gsa_1192[0][10][g_y_1108] == "") gsa_1192[0][10][g_y_1108] = gsa_1192[0][g_y_1108 + 10][gi_1104]; } } gda_1000[0][g_y_1108] = gda_1000[0][g_y_1108] * (gi_1120 == 0); if (gda_1000[0][g_y_1108] == 1.0) gsa_1192[0][10][g_y_1108] = StringConcatenate(gsa_1192[0][31][g_y_1108 + 2], " pattern: ", gsa_1192[0][10][g_y_1108]); if (gda_1000[0][g_y_1108] > 1.0) gsa_1192[0][10][g_y_1108] = StringConcatenate(gsa_1192[0][31][g_y_1108 + 2], " patterns: ", gsa_1192[0][10][g_y_1108]); } } void Pivots() { datetime lt_unused_0; datetime lt_unused_4; int li_unused_8; int li_unused_12; double ld_16; double ld_24; double ld_unused_32; double ld_40; double l_open_48; double ld_56; double l_close_64; int li_72; int li_76; int li_80; double ld_84; double ld_92; double ld_100; double ld_108; double ld_116; double ld_124; double ld_132; double ld_140; double ld_148; double ld_156; double ld_164; double ld_172; double ld_180; int li_188; int li_192; int li_196; int li_200; int l_day_of_week_204; int li_208; int li_220; int li_228; int li_232; if (Period() <= PERIOD_D1) { lt_unused_0 = 0; lt_unused_4 = 0; li_unused_8 = 0; li_unused_12 = 0; ld_16 = 0; ld_24 = 0; ld_unused_32 = 0; ld_40 = 0; l_open_48 = 0; ld_56 = 0; l_close_64 = 0; li_72 = 0; li_76 = 0; li_80 = 0; g_timeframe_1240 = Period(); g_datetime_1236 = TimeCurrent(); li_188 = Local__HrsServerTZFromGMT - Destination__HrsNewTzfromGMT; li_192 = 3600 * li_188; li_196 = 1440; li_200 = li_196 / Period(); l_day_of_week_204 = TimeDayOfWeek(Time[0] - li_192); li_208 = -1; li_72 = 0; li_76 = 0; li_80 = 0; switch (l_day_of_week_204) { case 6: case 0: li_208 = 5; break; case 1: break; default: li_208 = l_day_of_week_204 - 1; } for (int li_216 = 1; li_216 <= li_200 + 1; li_216++) { li_220 = Time[li_216] - li_192; if (TimeDayOfWeek(li_220) != l_day_of_week_204) { li_72 = li_216 - 1; break; } } for (int l_count_224 = 0; l_count_224 <= li_200 * 2 + 1; l_count_224++) { li_228 = Time[li_216 + l_count_224] - li_192; if (TimeDayOfWeek(li_228) == li_208) { li_80 = li_216 + l_count_224; break; } } for (l_count_224 = 1; l_count_224 <= li_200; l_count_224++) { li_232 = Time[li_80 + l_count_224] - li_192; if (TimeDayOfWeek(li_232) != li_208) { li_76 = li_80 + l_count_224 - 1; break; } } lt_unused_0 = Time[li_72]; lt_unused_4 = Time[li_76]; ld_40 = -99999; ld_56 = 99999; for (int li_236 = li_76; li_236 >= li_80; li_236--) { if (l_open_48 == 0.0) l_open_48 = Open[li_236]; ld_40 = MathMax(High[li_236], ld_40); ld_56 = MathMin(Low[li_236], ld_56); l_close_64 = Close[li_236]; } ld_unused_32 = Open[li_72]; ld_16 = -99999; ld_24 = 99999; for (gi_1140 = li_72; gi_1140 >= 0; gi_1140--) { ld_16 = MathMax(ld_16, High[gi_1140]); ld_24 = MathMin(ld_24, Low[gi_1140]); } ld_100 = ld_16 - ld_24; ld_92 = ld_40 - ld_56; ld_84 = (ld_40 + ld_56 + l_close_64) / 3.0; if (Show_1Daily_2FibonacciPivots == 1) { ld_108 = 2.0 * ld_84 - ld_56; ld_116 = ld_84 + (ld_40 - ld_56); ld_124 = 2.0 * ld_84 + (ld_40 - 2.0 * ld_56); ld_148 = 2.0 * ld_84 - ld_40; ld_156 = ld_84 - (ld_40 - ld_56); ld_164 = 2.0 * ld_84 - (2.0 * ld_40 - ld_56); } if (Show_1Daily_2FibonacciPivots == 2) { ld_108 = ld_84 + ld_92 / 2.0; ld_116 = ld_84 + 0.618 * ld_92; ld_124 = ld_84 + ld_92; ld_132 = ld_84 + 1.618 * ld_92; ld_140 = ld_84 + 2.618 * ld_92; ld_148 = ld_84 - ld_92 / 2.0; ld_156 = ld_84 - 0.618 * ld_92; ld_164 = ld_84 - ld_92; ld_172 = ld_84 - 1.618 * ld_92; ld_180 = ld_84 - 2.618 * ld_92; } gda_996[1][1][10] = NormalizeDouble(ld_180, Digits); gda_996[1][2][10] = NormalizeDouble((ld_172 + ld_180) / 2.0, Digits); gda_996[1][3][10] = NormalizeDouble(ld_172, Digits); gda_996[1][4][10] = (ld_172 > 0.0) * NormalizeDouble((ld_164 + ld_172) / 2.0, Digits); gda_996[1][5][10] = NormalizeDouble(ld_164, Digits); gda_996[1][6][10] = NormalizeDouble((ld_156 + ld_164) / 2.0, Digits); gda_996[1][7][10] = NormalizeDouble(ld_156, Digits); gda_996[1][8][10] = NormalizeDouble((ld_148 + ld_156) / 2.0, Digits); gda_996[1][9][10] = NormalizeDouble(ld_148, Digits); gda_996[1][10][10] = NormalizeDouble((ld_84 + ld_148) / 2.0, Digits); gda_996[1][11][10] = NormalizeDouble(ld_84, Digits); gda_996[1][12][10] = NormalizeDouble((ld_84 + ld_108) / 2.0, Digits); gda_996[1][13][10] = NormalizeDouble(ld_108, Digits); gda_996[1][14][10] = NormalizeDouble((ld_108 + ld_116) / 2.0, Digits); gda_996[1][15][10] = NormalizeDouble(ld_116, Digits); gda_996[1][16][10] = NormalizeDouble((ld_116 + ld_124) / 2.0, Digits); gda_996[1][17][10] = NormalizeDouble(ld_124, Digits); gda_996[1][18][10] = (ld_132 > 0.0) * NormalizeDouble((ld_124 + ld_132) / 2.0, Digits); gda_996[1][19][10] = NormalizeDouble(ld_132, Digits); gda_996[1][20][10] = NormalizeDouble((ld_132 + ld_140) / 2.0, Digits); gda_996[1][21][10] = NormalizeDouble(ld_140, Digits); } }