From 784b5227caaa434f785753cd61cf27f9f3c17b32 Mon Sep 17 00:00:00 2001 From: GODFREY KIGGUNDU <140074856+Kiggundug1@users.noreply.github.com> Date: Mon, 22 Jul 2024 04:45:05 +0300 Subject: [PATCH] Add files via upload --- !!Color Stochastic v1.02.mq4 | 426 + !!Color Stochastic.mq4 | 190 + !XPS v7 PROFIT.mq4 | 210 + #MTF_ Gann_HiLo_Activator_v2.mq4 | 41 + 10 AO2.mq4 | 84 + 10PipsPro.mq4 | 158 + 11 MACDDuffy.mq4 | 61 + 1_bars_back.mq4 | 25 + 3 MF3.mq4 | 92 + AAA!FT PVD$FLv1.mq4 | 59 + AAANeuro Forex Strength Trend Predictor.mq4 | 134 + ADX Crossing v.2.0.mq4 | 93 + ADX Crossing.mq4 | 79 + AI-FXRobot-V-1-nonexp.mq4 | 192 + ATM_Pure_Market_Price.mq4 | 68 + AccuScalper.mq4 | 1516 +++ Annajah_Forex_Pilot_V1.mq4 | 267 + BossEA-TraXXon.mq4 | 811 ++ CloveriX.mq4 | 328 + DSS Bressert.mq4 | 121 + DXTrade Daily Boxed Fibs&Pivots&Gann2.mq4 | 332 + Damiani_Volt.mq4 | 86 + DashBoard-Anil Panchal.mq4 | 762 ++ DoubleCCI-With_SMA.mq4 | 179 + Dynamic Fx - Awesome.mq4 | 81 + ...Gann HiLo ActivatorV2_Alert_Email_v1.1.mq4 | 176 + Dynamic Fx - Gann_hilo_activator_arrow.mq4 | 164 + Dynamic Fx - Heiken Ashi.mq4 | 101 + Dynamic Fx - Heiken_AshiH_sw_mtf.mq4 | 157 + Dynamic Fx - MACD_OsMA_4ColorHM_2L_mtf.mq4 | 190 + Dynamic Fx - Magnified Market Price.mq4 | 45 + Dynamic Fx - Spread - blk.mq4 | 70 + Dynamic Fx - SweetSpots.mq4 | 132 + Dynamic Fx - sFractals.mq4 | 202 + EA_HGNR_V.2.1_GU.mq4 | 90 + EA_HGNR_V.2.2_UCF.mq4 | 84 + EA_HGNR_V.2.2_UJ.mq4 | 84 + EMA Crossover.mq4 | 204 + EURO_BLASTER V3.mq4 | 689 ++ EnigmaG12~.mq4 | 1078 ++ FDM Buy Sell Pressure.mq4 | 84 + FR-Trend.mq4 | 149 + FR-TrendLines.mq4 | 92 + FXEnforcer_V1open.mq4 | 225 + FXkred_renko_counter_V1.05.mq4 | 196 + FiboPiv_Daily_DK.mq4 | 351 + FullFiboPiv_Weekly_DK.mq4 | 277 + GREEZLY_2007.mq4 | 1239 +++ IVY_EUR_ JPY_5.1.mq4 | 362 + IVY_EUR_USD_5.1.mq4 | 346 + IVY_USD_CHF_5.1.mq4 | 361 + Ilan 1.5 STD_3_LE_Ver_3.mq4 | 644 ++ Ilan_1.5_STD_3_LE_Ver_3.mq4 | 644 ++ Ilan_HiLo_RSI.mq4 | 436 + IndestructibleTrendWinner.mq4 | 90 + KijunTenkan+.mq4 | 125 + MTF_Waddah_Attar_ExplosionSA.mq4 | 253 + Magnified Market Price.mq4 | 50 + Master.mq4 | 34 + MedianRChart.mq4 | 364 + MedianRinfo.mq4 | 92 + New [EA] Sniper-educated.mq4 | 345 + New_Candle_Alarm.mq4 | 44 + Pipzu Extrapolated v1.1.mq4 | 337 + Pivot Points Multitimeframe.mq4 | 1756 +++ Primeval-EA v1.0.mq4 | 2592 +++++ RD-PivotLines.mq4 | 445 + RainbowMMA_01.mq4 | 89 + RainbowMMA_02.mq4 | 89 + RainbowMMA_03.mq4 | 89 + RainbowMMA_04.mq4 | 89 + RainbowMMA_05.mq4 | 89 + RainbowMMA_06.mq4 | 89 + RainbowMMA_07.mq4 | 89 + RainbowMMA_08.mq4 | 89 + RainbowMMA_09.mq4 | 89 + RainbowMMA_10.mq4 | 89 + RainbowMMA_11.mq4 | 89 + RoboMiner II v2.18.mq4 | 1409 +++ SAR ADX Expert Advisor.mq4 | 471 + Signal_Bars_Executive_v1.mq4 | 2353 ++++ Signal_Bars_v3_Daily.mq4 | 749 ++ Spread.mq4 | 70 + Swing line histo.mq4 | 315 + T3_2ColorHisto.mq4 | 238 + THV3 Trix called.mq4 | 893 ++ Trend_all_period.mq4 | 207 + Uranus v0.2.mq4 | 556 + Woodie_Trend.mq4 | 505 + ZUP_v82.mq4 | 9448 +++++++++++++++++ _Stochastic_Cross_Alert_SigOverlayM_cw.mq4 | 130 + adaptive adx.mq4 | 634 ++ ccDynamic_Trend_Multi_Currency_v4.mq4 | 3409 ++++++ gann_hilo_arrow_alert_colin.mq4 | 579 + gann_hilo_arrow_alert_colin11.mq4 | 579 + i-Sessions.mq4 | 167 + i_Trend.mq4 | 92 + nonlagdot.mq4 | 150 + x-ZZ.mq4 | 133 + "\320\222\302\251 Profit_$.mq4" | 45 + 100 files changed, 45905 insertions(+) create mode 100644 !!Color Stochastic v1.02.mq4 create mode 100644 !!Color Stochastic.mq4 create mode 100644 !XPS v7 PROFIT.mq4 create mode 100644 #MTF_ Gann_HiLo_Activator_v2.mq4 create mode 100644 10 AO2.mq4 create mode 100644 10PipsPro.mq4 create mode 100644 11 MACDDuffy.mq4 create mode 100644 1_bars_back.mq4 create mode 100644 3 MF3.mq4 create mode 100644 AAA!FT PVD$FLv1.mq4 create mode 100644 AAANeuro Forex Strength Trend Predictor.mq4 create mode 100644 ADX Crossing v.2.0.mq4 create mode 100644 ADX Crossing.mq4 create mode 100644 AI-FXRobot-V-1-nonexp.mq4 create mode 100644 ATM_Pure_Market_Price.mq4 create mode 100644 AccuScalper.mq4 create mode 100644 Annajah_Forex_Pilot_V1.mq4 create mode 100644 BossEA-TraXXon.mq4 create mode 100644 CloveriX.mq4 create mode 100644 DSS Bressert.mq4 create mode 100644 DXTrade Daily Boxed Fibs&Pivots&Gann2.mq4 create mode 100644 Damiani_Volt.mq4 create mode 100644 DashBoard-Anil Panchal.mq4 create mode 100644 DoubleCCI-With_SMA.mq4 create mode 100644 Dynamic Fx - Awesome.mq4 create mode 100644 Dynamic Fx - Gann HiLo ActivatorV2_Alert_Email_v1.1.mq4 create mode 100644 Dynamic Fx - Gann_hilo_activator_arrow.mq4 create mode 100644 Dynamic Fx - Heiken Ashi.mq4 create mode 100644 Dynamic Fx - Heiken_AshiH_sw_mtf.mq4 create mode 100644 Dynamic Fx - MACD_OsMA_4ColorHM_2L_mtf.mq4 create mode 100644 Dynamic Fx - Magnified Market Price.mq4 create mode 100644 Dynamic Fx - Spread - blk.mq4 create mode 100644 Dynamic Fx - SweetSpots.mq4 create mode 100644 Dynamic Fx - sFractals.mq4 create mode 100644 EA_HGNR_V.2.1_GU.mq4 create mode 100644 EA_HGNR_V.2.2_UCF.mq4 create mode 100644 EA_HGNR_V.2.2_UJ.mq4 create mode 100644 EMA Crossover.mq4 create mode 100644 EURO_BLASTER V3.mq4 create mode 100644 EnigmaG12~.mq4 create mode 100644 FDM Buy Sell Pressure.mq4 create mode 100644 FR-Trend.mq4 create mode 100644 FR-TrendLines.mq4 create mode 100644 FXEnforcer_V1open.mq4 create mode 100644 FXkred_renko_counter_V1.05.mq4 create mode 100644 FiboPiv_Daily_DK.mq4 create mode 100644 FullFiboPiv_Weekly_DK.mq4 create mode 100644 GREEZLY_2007.mq4 create mode 100644 IVY_EUR_ JPY_5.1.mq4 create mode 100644 IVY_EUR_USD_5.1.mq4 create mode 100644 IVY_USD_CHF_5.1.mq4 create mode 100644 Ilan 1.5 STD_3_LE_Ver_3.mq4 create mode 100644 Ilan_1.5_STD_3_LE_Ver_3.mq4 create mode 100644 Ilan_HiLo_RSI.mq4 create mode 100644 IndestructibleTrendWinner.mq4 create mode 100644 KijunTenkan+.mq4 create mode 100644 MTF_Waddah_Attar_ExplosionSA.mq4 create mode 100644 Magnified Market Price.mq4 create mode 100644 Master.mq4 create mode 100644 MedianRChart.mq4 create mode 100644 MedianRinfo.mq4 create mode 100644 New [EA] Sniper-educated.mq4 create mode 100644 New_Candle_Alarm.mq4 create mode 100644 Pipzu Extrapolated v1.1.mq4 create mode 100644 Pivot Points Multitimeframe.mq4 create mode 100644 Primeval-EA v1.0.mq4 create mode 100644 RD-PivotLines.mq4 create mode 100644 RainbowMMA_01.mq4 create mode 100644 RainbowMMA_02.mq4 create mode 100644 RainbowMMA_03.mq4 create mode 100644 RainbowMMA_04.mq4 create mode 100644 RainbowMMA_05.mq4 create mode 100644 RainbowMMA_06.mq4 create mode 100644 RainbowMMA_07.mq4 create mode 100644 RainbowMMA_08.mq4 create mode 100644 RainbowMMA_09.mq4 create mode 100644 RainbowMMA_10.mq4 create mode 100644 RainbowMMA_11.mq4 create mode 100644 RoboMiner II v2.18.mq4 create mode 100644 SAR ADX Expert Advisor.mq4 create mode 100644 Signal_Bars_Executive_v1.mq4 create mode 100644 Signal_Bars_v3_Daily.mq4 create mode 100644 Spread.mq4 create mode 100644 Swing line histo.mq4 create mode 100644 T3_2ColorHisto.mq4 create mode 100644 THV3 Trix called.mq4 create mode 100644 Trend_all_period.mq4 create mode 100644 Uranus v0.2.mq4 create mode 100644 Woodie_Trend.mq4 create mode 100644 ZUP_v82.mq4 create mode 100644 _Stochastic_Cross_Alert_SigOverlayM_cw.mq4 create mode 100644 adaptive adx.mq4 create mode 100644 ccDynamic_Trend_Multi_Currency_v4.mq4 create mode 100644 gann_hilo_arrow_alert_colin.mq4 create mode 100644 gann_hilo_arrow_alert_colin11.mq4 create mode 100644 i-Sessions.mq4 create mode 100644 i_Trend.mq4 create mode 100644 nonlagdot.mq4 create mode 100644 x-ZZ.mq4 create mode 100644 "\320\222\302\251 Profit_$.mq4" diff --git a/!!Color Stochastic v1.02.mq4 b/!!Color Stochastic v1.02.mq4 new file mode 100644 index 0000000..ad2172c --- /dev/null +++ b/!!Color Stochastic v1.02.mq4 @@ -0,0 +1,426 @@ +//+------------------------------------------------------------------+ +//| Color Stochastic.mq4 | +//| mladen | +//| | +//+------------------------------------------------------------------+ +#property copyright "mladen" +#property link "" + +#property indicator_separate_window +#property indicator_buffers 6 +#property indicator_minimum 0 +#property indicator_maximum 100 +#property indicator_color1 DimGray +#property indicator_style1 STYLE_DOT +#property indicator_color2 DimGray +#property indicator_color3 DarkGreen //UPPER +#property indicator_color4 Maroon //LOWER +#property indicator_color5 Lime //UPTREND +#property indicator_color6 Red //DOWNTREND +#property indicator_width3 4 +#property indicator_width4 4 +#property indicator_width5 4 +#property indicator_width6 4 +#define SignalName "StochasticSignal" + + + +//---- input parameters +// +// nice setings for trend = 35,10,1 +// +// + +extern string note1 = "Chart Time Frame"; +extern string note2 = "0=current time frame"; +extern string note3 = "1=M1, 5=M5, 15=M15, 30=M30"; +extern string note4 = "60=H1, 240=H4, 1440=D1"; +extern string note5 = "10080=W1, 43200=MN1"; +extern int timeFrame = 0; // {1=M1, 5=M5, 15=M15, ..., 1440=D1, 10080=W1, 43200=MN1} +extern string note6 = "Stochastic settings"; +extern int KPeriod = 14; +extern int DPeriod = 3; +extern int Slowing = 3; +extern string note7 = "0=sma, 1=ema, 2=smma, 3=lwma"; +extern int MAMethod = 0; +extern string note8 = "0=high/low, 1=close/close"; +extern int PriceField = 0; +extern string note9 = "overbought level"; +extern double overBought = 80; +extern string note10 = "oversold level"; +extern double overSold = 20; +extern bool showBars = false; +extern bool showArrows = false; +extern bool alertsOn = false; +extern bool alertsMessage = true; +extern bool alertsSound = false; +extern bool alertsEmail = false; + + +//---- buffers +// +// +// +// +// + +double KFull[]; +double DFull[]; +double Upper[]; +double Lower[]; +double Uptrend[]; +double Downtrend[]; + +// +// +// +// +// + +int TimeFrame; +datetime TimeArray[]; +int maxArrows; +int SignalGap; + + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ + +int init() +{ + + SetIndexBuffer(0,DFull); + SetIndexBuffer(1,KFull); + SetIndexBuffer(2,Upper); + SetIndexBuffer(3,Lower); + SetIndexBuffer(4,Uptrend); + SetIndexBuffer(5,Downtrend); + + // + // + // + // + // + + if (showBars) + { + SetIndexStyle(0,DRAW_NONE); + SetIndexStyle(1,DRAW_NONE); + SetIndexStyle(2,DRAW_HISTOGRAM); + SetIndexStyle(3,DRAW_HISTOGRAM); + SetIndexStyle(4,DRAW_HISTOGRAM); + SetIndexStyle(5,DRAW_HISTOGRAM); + SetIndexLabel(0,NULL); + SetIndexLabel(1,NULL); + SetIndexLabel(2,"Stochastic"); + SetIndexLabel(3,"Stochastic"); + SetIndexLabel(4,"Stochastic"); + SetIndexLabel(5,"Stochastic"); + } + else + { + SetIndexLabel(0,"Stochastic"); + SetIndexLabel(1,"Stochastic"); + SetIndexLabel(2,NULL); + SetIndexLabel(3,NULL); + SetIndexLabel(4,NULL); + SetIndexLabel(5,NULL); + SetIndexStyle(0,DRAW_LINE); + SetIndexStyle(1,DRAW_LINE); + SetIndexStyle(2,DRAW_LINE); + SetIndexStyle(3,DRAW_LINE); + SetIndexStyle(4,DRAW_NONE); + SetIndexStyle(5,DRAW_NONE); + DPeriod = MathMax(DPeriod,1); + if (DPeriod==1) { + SetIndexStyle(0,DRAW_NONE); + SetIndexLabel(0,NULL); + } + else { + SetIndexStyle(0,DRAW_LINE); + SetIndexLabel(0,"Signal"); + } + } + + // + // + // + // + // + + TimeFrame =stringToTimeFrame(timeFrame); + string shortName = "Stochastic ("+TimeFrameToString(TimeFrame)+","+KPeriod+","+DPeriod+","+Slowing+","+maDescription(MAMethod)+","+priceDescription(PriceField); + if (overBought < overSold) overBought = overSold; + if (overBought < 100) shortName = shortName+","+overBought; + if (overSold > 0) shortName = shortName+","+overSold; + IndicatorShortName(shortName+")"); + return(0); +} + +// +// +// +// +// + +int deinit() +{ + DeleteArrows(); + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ + +int start() +{ + int counted_bars=IndicatorCounted(); + int limit; + int i,y; + + + + + if(counted_bars<0) return(-1); + limit=MathMax(Bars-counted_bars,TimeFrame/Period()); + ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame); + + + // + // + // + // + // + + for(i=0,y=0; i=0; i--) + { + if (showBars) + { + Upper[i] = EMPTY_VALUE; + Lower[i] = EMPTY_VALUE; + while(true) + { + if (KFull[i] > overBought) { Upper[i] = 100; break;} + if (KFull[i] < overSold) { Lower[i] = 100; break;} + if (KFull[i] > KFull[i+1]) { Uptrend[i] = 100; break;} + if (KFull[i] < KFull[i+1]) { Downtrend[i] = 100; break;} + Uptrend[i] = Uptrend[i+1]; + Downtrend[i] = Downtrend[i+1]; + break; + } + } + else + { + if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; } + else { Upper[i] = EMPTY_VALUE; + if (Upper[i+2] == EMPTY_VALUE) + Upper[i+1] = EMPTY_VALUE; } + if (KFull[i] < overSold) { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; } + else { Lower[i] = EMPTY_VALUE; + if (Lower[i+2] == EMPTY_VALUE) + Lower[i+1] = EMPTY_VALUE; } + } + } + + // + // + // + // + // + + DeleteArrows(); + if (showArrows) + { + SignalGap = MathCeil(iATR(NULL,0,50,0)/Point); + for (i=0; ioverBought && KFull[i+1]overSold) DrawArrow(i,"down"); + } + } + if (alertsOn) + { + if (KFull[0]>overBought && KFull[1]overSold) doAlert(overBought+" line crossed down"); + } + + // + // + // + // + // + + return(0); +} + + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +// +// +// +// +// + +void DrawArrow(int i,string type) +{ + maxArrows++; + string name = StringConcatenate(SignalName,maxArrows); + + ObjectCreate(name,OBJ_ARROW,0,Time[i],0); + if (type=="up") + { + ObjectSet(name,OBJPROP_PRICE1,High[i]+(SignalGap*Point)); + ObjectSet(name,OBJPROP_ARROWCODE,242); + ObjectSet(name,OBJPROP_COLOR,Red); + } + else + { + ObjectSet(name,OBJPROP_PRICE1,Low[i]-(SignalGap*Point)); + ObjectSet(name,OBJPROP_ARROWCODE,241); + ObjectSet(name,OBJPROP_COLOR,LimeGreen); + } +} +void DeleteArrows() +{ + while(maxArrows>0) { ObjectDelete(StringConcatenate(SignalName,maxArrows)); maxArrows--; } +} + + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ + +void doAlert(string doWhat) +{ + static string previousAlert="nothing"; + static datetime previousTime; + string message; + + if (previousAlert != doWhat || previousTime != Time[0]) { + previousAlert = doWhat; + previousTime = Time[0]; + + // + // + // + // + // + + message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Stochastic ",doWhat); + if (alertsMessage) Alert(message); + if (alertsSound) PlaySound("alert2.wav"); + if (alertsEmail) SendMail(StringConcatenate(Symbol()," Stochastic crossing"),message); + } +} + + +//+------------------------------------------------------------------+ +//+------------------------------------------------------------------+ + +string priceDescription(int mode) +{ + string answer; + switch(mode) + { + case 0: answer = "Low/High" ; break; + case 1: answer = "Close/Close" ; break; + default: answer = "Invalid price field requested"; + Alert(answer); + } + return(answer); +} +string maDescription(int mode) +{ + string answer; + switch(mode) + { + case MODE_SMA: answer = "SMA" ; break; + case MODE_EMA: answer = "EMA" ; break; + case MODE_SMMA: answer = "SMMA" ; break; + case MODE_LWMA: answer = "LWMA" ; break; + default: answer = "Invalid MA mode requested"; + Alert(answer); + } + return(answer); +} +int stringToTimeFrame(string tfs) +{ + int tf=0; + tfs = StringUpperCase(tfs); + if (tfs=="M1" || tfs=="1") tf=PERIOD_M1; + if (tfs=="M5" || tfs=="5") tf=PERIOD_M5; + if (tfs=="M15"|| tfs=="15") tf=PERIOD_M15; + if (tfs=="M30"|| tfs=="30") tf=PERIOD_M30; + if (tfs=="H1" || tfs=="60") tf=PERIOD_H1; + if (tfs=="H4" || tfs=="240") tf=PERIOD_H4; + if (tfs=="D1" || tfs=="1440") tf=PERIOD_D1; + if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1; + if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1; + if (tf= 0) + { + char = StringGetChar(s, lenght); + + // + // + // + // + // + + if((char > 96 && char < 123) || (char > 223 && char < 256)) + s = StringSetChar(s, lenght, char - 32); + else + if(char > -33 && char < 0) + s = StringSetChar(s, lenght, char + 224); + lenght--; + } + + // + // + // + // + // + + return(s); +} \ No newline at end of file diff --git a/!!Color Stochastic.mq4 b/!!Color Stochastic.mq4 new file mode 100644 index 0000000..07828da --- /dev/null +++ b/!!Color Stochastic.mq4 @@ -0,0 +1,190 @@ +//+------------------------------------------------------------------+ +//| Color Stochastic.mq4 | +//| mladen | +//| | +//+------------------------------------------------------------------+ +#property copyright "mladen" +#property link "" + +#property indicator_separate_window +#property indicator_buffers 4 +#property indicator_minimum 0 +#property indicator_maximum 100 +#property indicator_color1 DimGray +#property indicator_style1 STYLE_DOT +#property indicator_color2 DimGray +#property indicator_color3 Lime +#property indicator_color4 Red +#property indicator_width3 2 +#property indicator_width4 2 + + + +//---- input parameters +// +// nice setings for trend = 35,10,1 +// +// + +extern string note1 = "Stochastic settings"; +extern int KPeriod = 30; +extern int Slowing = 10; +extern int DPeriod = 10; +extern string note4 = "0=sma, 1=ema, 2=smma, 3=lwma"; +extern int MAMethod = 0; +extern string note5 = "0=high/low, 1=close/close"; +extern int PriceField = 1; +extern string note6 = "overbought level"; +extern int overBought = 80; +extern string note7 = "oversold level"; +extern int overSold = 20; + + +//---- buffers +// +// +// +// +// + +double KFull[]; +double DFull[]; +double Upper[]; +double Lower[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ + +int init() +{ + SetIndexBuffer(0,DFull); + SetIndexBuffer(1,KFull); + SetIndexBuffer(2,Upper); + SetIndexBuffer(3,Lower); + SetIndexLabel(1,"Fast"); + SetIndexLabel(2,NULL); + SetIndexLabel(3,NULL); + + // + // + // + // + // + + DPeriod = MathMax(DPeriod,1); + if (DPeriod==1) { + SetIndexStyle(0,DRAW_NONE); + SetIndexLabel(0,NULL); + } + else { + SetIndexStyle(0,DRAW_LINE); + SetIndexLabel(0,"Slow"); + } + + // + // + // + // + // + + string shortName = "Stochastic ("+KPeriod+","+Slowing+","+DPeriod+","+maDescription(MAMethod)+","+priceDescription(PriceField); + if (overBought < overSold) overBought = overSold; + if (overBought < 100) shortName = shortName+","+overBought; + if (overSold > 0) shortName = shortName+","+overSold; + IndicatorShortName(shortName+")"); + return(0); +} + +// +// +// +// +// + +int deinit() +{ + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ + +int start() +{ + int counted_bars=IndicatorCounted(); + int limit; + int i; + + + + + if(counted_bars<0) return(-1); + limit=Bars-counted_bars; + + // + // + // + // + // + + for(i=limit; i>=0; i--) + { + KFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_MAIN,i); + DFull[i] = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_SIGNAL,i); + + // + // + // + // + // + + if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; } + else { Upper[i] = EMPTY_VALUE; + if (Upper[i+2] == EMPTY_VALUE) + Upper[i+1] = EMPTY_VALUE; } + if (KFull[i] < overSold) { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; } + else { Lower[i] = EMPTY_VALUE; + if (Lower[i+2] == EMPTY_VALUE) + Lower[i+1] = EMPTY_VALUE; } + } + + // + // + // + // + // + + return(0); +} +//+------------------------------------------------------------------+ +//+------------------------------------------------------------------+ + +string priceDescription(int mode) +{ + string answer; + switch(mode) + { + case 0: answer = "Low/High" ; break; + case 1: answer = "Close/Close" ; break; + default: answer = "Invalid price field requested"; + Alert(answer); + } + return(answer); +} +string maDescription(int mode) +{ + string answer; + switch(mode) + { + case MODE_SMA: answer = "SMA" ; break; + case MODE_EMA: answer = "EMA" ; break; + case MODE_SMMA: answer = "SMMA" ; break; + case MODE_LWMA: answer = "LWMA" ; break; + default: answer = "Invalid MA mode requested"; + Alert(answer); + } + return(answer); +} + diff --git a/!XPS v7 PROFIT.mq4 b/!XPS v7 PROFIT.mq4 new file mode 100644 index 0000000..d77d761 --- /dev/null +++ b/!XPS v7 PROFIT.mq4 @@ -0,0 +1,210 @@ + +// +----------------------------------------------------------------------------------------+ // +// | .-._______ XARD777 _______.-. | // +// |---( )_)______) Knowledge of the ancients (______(_( )---| // +// | ( ()___) \¦/ (___() ) | // +// | ()__) (o o) (__() | // +// |--(___()_)__________________________oOOo___(_)___oOOo_________________________(_()___)--| // +// |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____|_____| // +// | 2011 | // +// |----------------------------------------------------------------------------------------| // +// | File: !XPS v7 PROFIT.mq4 | // +// | Programming language: MQL4 | // +// | Development platform: MetaTrader 4 | // +// | End product: THIS SOFTWARE IS FOR USE ONLY BY XARD777 | // +// | | // +// | [Xard777 Proprietory Software] | // +// +----------------------------------------------------------------------------------------+ // + +#property indicator_chart_window + +// ------------------------------------------------------------------------------------------ // +// E X T E R N A L V A R I A B L E S // +// ------------------------------------------------------------------------------------------ // + +int Corner=1; +int Window=0; +color Warna_Text = Snow; +color Warna_Order_Sell = Orange; +color Warna_Order_Buy = DeepSkyBlue; +color Warna_Rugi = Orange; +color Warna_Laba = DeepSkyBlue; +string NamaFont = "Arial Black"; +int UkuranFont = 10; +double posX = 38; +double posY = -14; + +// ------------------------------------------------------------------------------------------ // +// I N T E R N A L V A R I A B L E S // +// ------------------------------------------------------------------------------------------ // + + + +int Font=9; +int x = NULL; + +// ------------------------------------------------------------------------------------------ // +// I N I T I A L I S A T I O N // +// ------------------------------------------------------------------------------------------ // + +int init() + { +//---- indicators +//---- + return(0); + } + +// ------------------------------------------------------------------------------------------ // +// D E - I N I T I A L I S A T I O N // +// ------------------------------------------------------------------------------------------ // + +int deinit() + { +//---- + int idx; + + if(x != NULL) { + for(idx = 0; idx= 0; i--) + { + if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true) + { + + if(OrderType() == OP_BUY) { + + DisplayText("Panel242"+j, OrderSymbol(), 12, Warna_Order_Buy, 0, 10, Font+28 + j * 18, "Arial Black"); + PL = (OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT)/10; + total = total + PL; + if(PL<0) DisplayText("Panel243"+j, DoubleToStr(PL, 0), 12, Warna_Rugi, 0, -30, Font+28 + j * 18, "Arial Black"); + else if(PL>0) DisplayText("Panel243"+j, "+"+DoubleToStr(PL, 0), 12, Warna_Laba, 0, -30, Font+28 + j * 18, "Arial Black"); + else DisplayText("Panel243"+j, DoubleToStr(PL, 0), 12, Warna_Text, 0, -30, Font+28 + j * 18, "Arial Black"); + } + else if(OrderType() == OP_SELL) { + + DisplayText("Panel242"+j, OrderSymbol(), 12, Warna_Order_Sell, 0, 10, Font+28 + j * 18, "Arial Black"); + PL = (OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT)/10; + total = total + PL; + if(PL<0) DisplayText("Panel243"+j, DoubleToStr(PL, 0), 12, Warna_Rugi, 0, -30, Font+28 + j * 18, "Arial Black"); + else if(PL>0) DisplayText("Panel243"+j,"+"+DoubleToStr(PL, 0), 12, Warna_Laba, 0, -30, Font+28 + j * 18, "Arial Black"); + else DisplayText("Panel243"+j,DoubleToStr(PL, 0), 12, Warna_Text, 0, -30, Font+28 + j * 18, "Arial Black"); + } + j=j+1; + } + } + + DisplayText("Total1","Total", 12, Warna_Text, 0, 25, Font+28 + j * 18, "Arial Black"); + + if(total<0) DisplayText("Total2", DoubleToStr(total, 0), 12, Warna_Rugi, 0, -30, Font+28 + j * 18, "Arial Black"); + else if (total>0) DisplayText("Total2","+" + DoubleToStr(total, 0), 12, Warna_Laba, 0, -30, Font+28 + j * 18, "Arial Black"); + else DisplayText("Total2", DoubleToStr(total, 0), 12, White, 0, -30, Font+28 + j * 18, "Arial Black"); + + x=j; + + return(0); + } +// ------------------------------------------------------------------------------------------ // +// E N D P R O G R A M // +// ------------------------------------------------------------------------------------------ // +/* + ud$$$**BILLION$bc. + u@**" PROJECT$$Nu + J ""#$$$$$$r + @ $$$$b + .F ^*3$$$ + :% 4 J$$$N + $ :F :$$$$$ + 4F 9 J$$$$$$$ + 4$ k 4$$$$bed$$$$$$$$$ + $$r 'F $$$$$$$$$$$$$$$$$r + $$$ b. $$$$$$$$$$$$$$$$$N + $$$$$k 3eeed$$b XARD777."$$$$$$$$$ + .@$**N. $$$$$" $$$$$$F'L $$$$$$$$$$$ $$$$$$$ + :$$L 'L $$$$$ 4$$$$$$ * $$$$$$$$$$F $$$$$$F edNc + @$$$$N ^k $$$$$ 3$$$$*% $F4$$$$$$$ $$$$$" d" z$N + $$$$$$ ^k '$$$" #$$$F .$ $$$$$c.u@$$$ J" @$$$$r + $$$$$$$b *u ^$L $$ $$$$$$$$$$$$u@ $$ d$$$$$$ + ^$$$$$$. "NL "N. z@* $$$ $$$$$$$$$$$$$P $P d$$$$$$$ + ^"*$$$$b '*L 9$E 4$$$ d$$$$$$$$$$$" d* J$$$$$r + ^$$$$u '$. $$$L "#" d$$$$$$".@$$ .@$" z$$$$*" + ^$$$$. ^$N.3$$$ 4u$$$$$$$ 4$$$ u$*" z$$$" + '*$$$$$$$$ *$b J$$$$$$$b u$$P $" d$$P + #$$$$$$ 4$ 3*$"$*$ $"$'c@@$$$$ .u@$$$P + "$$$$ ""F~$ $uNr$$$^&J$$$$F $$$$# + "$$ "$$$bd$.$W$$$$$$$$F $$" + ?k ?$$$$$$$$$$$F'* + 9$$bL z$$$$$$$$$$$F + $$$$ $$$$$$$$$$$$$ + '#$$c '$$$$$$$$$" + .@"#$$$$$$$$$$$$b + z* $$$$$$$$$$$$N. + e" z$$" #$$$k '*$$. + .u* u@$P" '#$$c "$$c + u@$*""" d$$" "$$$u ^*$$b. + :$F J$P" ^$$$c '"$$$$$$bL + d$$ .. @$# #$$b '#$ + 9$$$$$$b 4$$ ^$$k '$ + "$$6""$b u$$ '$ d$$$$$P + '$F $$$$$" ^b ^$$$$b$ + '$W$$$$" 'b@$$$$" + ^$$$*/ \ No newline at end of file diff --git a/#MTF_ Gann_HiLo_Activator_v2.mq4 b/#MTF_ Gann_HiLo_Activator_v2.mq4 new file mode 100644 index 0000000..94ccf51 --- /dev/null +++ b/#MTF_ Gann_HiLo_Activator_v2.mq4 @@ -0,0 +1,41 @@ +//+------------------------------------------------------------------+ +//| MTF_###Gann_HiLo_Activator_v2###.mq4 +//| MTF by Zathar, mod c codobro +//+------------------------------------------------------------------+ + +#property indicator_chart_window +#property indicator_buffers 1 +#property indicator_color1 Aqua +#property indicator_width1 2 + +extern int TimeFrame=0; +extern int Lookback=10; +double ExtMapBuffer1[]; + +int init() + { + //---- indicator line + SetIndexBuffer(0,ExtMapBuffer1); + SetIndexStyle(0,DRAW_LINE); + IndicatorShortName("MTF_###Gann_HiLo_Activator_v2###"); + SetIndexLabel(0,"MTF_Gann_HiLo"); + } +//---- + return(0); + + +int start() + { + datetime TimeArray[]; + int i,shift,limit,y=0,counted_bars=IndicatorCounted(); + + ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); + + limit=Bars-counted_bars+TimeFrame/Period(); + for(i=0,y=0;i0) counted_bars--; + limit=Bars-counted_bars; +//---- macd + for(int i=0; i=0; i--) + { + current=ExtBuffer0[i]; + prev=ExtBuffer0[i+1]; + if(current>prev) up=true; + if(current= l_str2time_36) { + Alert("The version has been expired!"); + return (0); + } + bool l_bool_40 = IsDemo(); + if (!l_bool_40) { + Alert("You can not use 10PipsPro EA with a real account!"); + return (0); + } + if (UseMM == TRUE) { + Lots = AccountEquity() * Risk / StopLoss / 1000.0; + if (Lots > 0.1) Lots = NormalizeDouble(Lots, 1); + else Lots = NormalizeDouble(Lots, 2); + } + if (EachTickMode && Bars != g_bars_136) gi_144 = FALSE; + int l_ord_total_4 = OrdersTotal(); + li_0 = 0; + double l_istochastic_44 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0); + double l_istochastic_52 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0); + double l_istochastic_60 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0); + double l_istochastic_68 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0); + double l_istochastic_76 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0); + double l_istochastic_84 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0); + double l_istochastic_92 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0); + double l_istochastic_100 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0); + bool li_108 = FALSE; + for (int l_pos_112 = 0; l_pos_112 < l_ord_total_4; l_pos_112++) { + OrderSelect(l_pos_112, SELECT_BY_POS, MODE_TRADES); + if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { + li_108 = TRUE; + if (OrderType() == OP_BUY) { + if (li_0 == 3 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) { + OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); + if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); + if (!EachTickMode) g_bars_136 = Bars; + li_108 = FALSE; + } else { + if (UseTrailingStop && TrailingStop > 0) { + if (Bid - OrderOpenPrice() > Point * TrailingStop) { + if (OrderStopLoss() < Bid - Point * TrailingStop) { + OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); + if (!EachTickMode) g_bars_136 = Bars; + } + } + } + } + } else { + if (li_0 == 4 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) { + OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); + if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); + if (!EachTickMode) g_bars_136 = Bars; + li_108 = FALSE; + } else { + if (UseTrailingStop && TrailingStop > 0) { + if (OrderOpenPrice() - Ask > Point * TrailingStop) { + if (OrderStopLoss() > Ask + Point * TrailingStop || OrderStopLoss() == 0.0) { + OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); + if (!EachTickMode) g_bars_136 = Bars; + } + } + } + } + } + } + } + if (l_istochastic_44 > l_istochastic_52 && l_istochastic_60 > l_istochastic_68) li_0 = 1; + if (l_istochastic_76 < l_istochastic_84 && l_istochastic_92 < l_istochastic_100) li_0 = 2; + if (li_0 == 1 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) { + if (!li_108) { + if (AccountFreeMargin() < 1000.0 * Lots) { + Print("We have no money. Free Margin = ", AccountFreeMargin()); + return (0); + } + if (UseStopLoss) l_price_12 = Ask - StopLoss * Point; + else l_price_12 = 0.0; + if (UseTakeProfit) l_price_20 = Ask + TakeProfit * Point; + else l_price_20 = 0.0; + l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, l_price_12, l_price_20, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); + if (l_ticket_8 > 0) { + if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) { + Print("BUY order opened : ", OrderOpenPrice()); + if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); + } else Print("Error opening BUY order : ", GetLastError()); + } + if (EachTickMode) gi_144 = TRUE; + if (!EachTickMode) g_bars_136 = Bars; + return (0); + } + } + if (li_0 == 2 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) { + if (!li_108) { + if (AccountFreeMargin() < 1000.0 * Lots) { + Print("We have no money. Free Margin = ", AccountFreeMargin()); + return (0); + } + if (UseStopLoss) l_price_12 = Bid + StopLoss * Point; + else l_price_12 = 0.0; + if (UseTakeProfit) l_price_20 = Bid - TakeProfit * Point; + else l_price_20 = 0.0; + l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, l_price_12, l_price_20, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); + if (l_ticket_8 > 0) { + if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) { + Print("SELL order opened : ", OrderOpenPrice()); + if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); + } else Print("Error opening SELL order : ", GetLastError()); + } + if (EachTickMode) gi_144 = TRUE; + if (!EachTickMode) g_bars_136 = Bars; + return (0); + } + } + if (!EachTickMode) g_bars_136 = Bars; + return (0); +} \ No newline at end of file diff --git a/11 MACDDuffy.mq4 b/11 MACDDuffy.mq4 new file mode 100644 index 0000000..d3287c7 --- /dev/null +++ b/11 MACDDuffy.mq4 @@ -0,0 +1,61 @@ +//+------------------------------------------------------------------+ +//| MACDDuffy.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net/ | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net/" +//---- indicator settings +#property indicator_separate_window +#property indicator_buffers 2 +#property indicator_color1 Lime +#property indicator_color2 Gold +#property indicator_width1 1 +//---- indicator parameters +extern int FastEMA=12; +extern int SlowEMA=26; +extern int SignalSMA=9; +//---- indicator buffers +double MacdBuffer[]; +double SignalBuffer[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- drawing settings + SetIndexStyle(0,DRAW_LINE); + SetIndexStyle(1,DRAW_LINE); + SetIndexDrawBegin(1,SignalSMA); + IndicatorDigits(Digits+1); +//---- indicator buffers mapping + SetIndexBuffer(0,MacdBuffer); + SetIndexBuffer(1,SignalBuffer); +//---- name for DataWindow and indicator subwindow label + IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")"); + SetIndexLabel(0,"MACD"); + SetIndexLabel(1,"Signal"); +//---- initialization done + return(0); + } +//+------------------------------------------------------------------+ +//| Moving Averages Convergence/Divergence | +//+------------------------------------------------------------------+ +int start() + { + int limit; + int counted_bars=IndicatorCounted(); +//---- last counted bar will be recounted + if(counted_bars>0) counted_bars--; + limit=Bars-counted_bars; +//---- macd counted in the 1-st buffer + for(int i=0; i gi80) +{ + return( 0 ); +} + +ArrayCopySeries( gi10092, MODE_TIME, Symbol(), gi80 ); +return( 0 ); +} + +int deinit() +{ + + +return( 0 ); +} + +int start() +{ +int li1, li2, li3, li4, li5, li6; +double ld1; +string ls1; + + + +li1 = IndicatorCounted(); +li2 = 300; +if (li1 < 0) return( (-1) ); +if (li1 > 0) li1 = li1-1; +li2 = (Bars - li1); +for (li4 = 0;(li4 < li2);li4 = li4+1) +{ if (Time[li4] >= gi10092[0]) { + li3 = 0; + } + else { + li3 = ArrayBsearch( gi10092, Time[(li4 - 1)], 0, 0, 2 ); + if (Period() <= gi80) li3 = li3+1; + } + + for (li5 = li3;(li5 < (li3 + 100));li5 = li5+1) + { ld1 = iCustom( 0, gi80, "ZigZag", gi76, 5, 3, 0, (li5 + 1) ); + if (ld1 != 0.0) break; + } + if (iClose( 0, 0, (li4 + 1) ) <= ld1) { + gd10088[li4] =ld1; + } + else { + gd10088[li4] = 0.0; + } + + if (iClose( 0, 0, (li4 + 1) ) >= ld1) { + gd10084[li4] =ld1; + } + else { + gd10084[li4] = 0.0; + } + + WindowRedraw(); +} +return( 0 ); +} + + diff --git a/AAA!FT PVD$FLv1.mq4 b/AAA!FT PVD$FLv1.mq4 new file mode 100644 index 0000000..7988b96 --- /dev/null +++ b/AAA!FT PVD$FLv1.mq4 @@ -0,0 +1,59 @@ + +// +----------------------------------------------------------------------------------------+ // +// | !FT PVD$FLv1 \¦/ | // +// | Knowledge of the ancients (т у) | // +// |_________________________________________________o0o___(_)___o0o________________________| // +// |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____|_____| // +// | 2011 | // +// |----------------------------------------------------------------------------------------| // +// | Programming language: MQL4 | // +// | Development platform: MetaTrader 4 | // +// | End product: Indicator for MetaTrader 4 designed | // +// | for Build 229 (current version) | // +// +----------------------------------------------------------------------------------------+ // + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 C'200,50,50' +#property indicator_width1 1 +#property indicator_color2 C'50,50,200' +#property indicator_width2 1 + +extern int GmtShift; +extern int MA_Period = 2; +extern int MA_Method = MODE_SMMA; +extern int PriceMode = PRICE_WEIGHTED; +double EXBUFFER[]; +double EXBUFFER1[]; + +double OPening,Buf; +int init() + { SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,3); + SetIndexArrow(0,168); + SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,3); + SetIndexArrow(1,168); + + SetIndexBuffer(0, EXBUFFER); + SetIndexBuffer(1, EXBUFFER1); + +return(0);} +int start() + { +int counted_bars = IndicatorCounted(); +int limit, i; +if(counted_bars == 0) + { if(Period() > PERIOD_H4) return(-1);} + if(counted_bars < 0) return(-1); + limit = (Bars - counted_bars) - 1; + for(i = limit; i >= 0; i--) + { if (TimeDayOfWeek(Time[i+1])!=0) + { if(TimeDay(Time[i]) != TimeDay(Time[i+1])) + { OPening = Open[i-GmtShift];}} + Buf = iMA(Symbol(),0,MA_Period,0,MA_Method,PriceMode,i); + EXBUFFER[i-GmtShift] = OPening; + EXBUFFER1[i-GmtShift] = OPening; + + + if ((OPening>Buf)){EXBUFFER1[i]=EMPTY_VALUE;}} +return(0); + } \ No newline at end of file diff --git a/AAANeuro Forex Strength Trend Predictor.mq4 b/AAANeuro Forex Strength Trend Predictor.mq4 new file mode 100644 index 0000000..72b959e --- /dev/null +++ b/AAANeuro Forex Strength Trend Predictor.mq4 @@ -0,0 +1,134 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ + +#property indicator_chart_window +#property indicator_buffers 8 +#property indicator_color1 Lime +#property indicator_color2 Red +#property indicator_color3 Green +#property indicator_color4 Maroon +#property indicator_color5 Lime +#property indicator_color6 Red +#property indicator_color7 Green +#property indicator_color8 Maroon + +extern int Sensitivity = 2; +int g_period_80; +int g_period_84; +double g_ibuf_88[]; +double g_ibuf_92[]; +double g_ibuf_96[]; +double g_ibuf_100[]; +double g_ibuf_104[]; +double g_ibuf_108[]; +double g_ibuf_112[]; +double g_ibuf_116[]; + +int init() { + ObjectCreate("Close line", OBJ_HLINE, 0, Time[40], Close[0]); + ObjectSet("Close line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Close line", OBJPROP_COLOR, Yellow); + SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 3); + SetIndexBuffer(0, g_ibuf_88); + SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 3); + SetIndexBuffer(1, g_ibuf_92); + SetIndexStyle(2, DRAW_HISTOGRAM, EMPTY, 3); + SetIndexBuffer(2, g_ibuf_96); + SetIndexStyle(3, DRAW_HISTOGRAM, EMPTY, 3); + SetIndexBuffer(3, g_ibuf_100); + SetIndexStyle(4, DRAW_HISTOGRAM, EMPTY, 0); + SetIndexBuffer(4, g_ibuf_104); + SetIndexStyle(5, DRAW_HISTOGRAM, EMPTY, 0); + SetIndexBuffer(5, g_ibuf_108); + SetIndexStyle(6, DRAW_HISTOGRAM, EMPTY, 0); + SetIndexBuffer(6, g_ibuf_112); + SetIndexStyle(7, DRAW_HISTOGRAM, EMPTY, 0); + SetIndexBuffer(7, g_ibuf_116); + IndicatorShortName("OBO TrendBars"); + return (0); +} + +int deinit() { + ObjectDelete("Close line"); + Comment(""); + return (0); +} + +int start() { + double l_icci_0; + double l_icci_8; + int li_16; + ObjectMove("Close line", 0, Time[20], Close[0]); + if (Sensitivity == 1) { + g_period_84 = 5; + g_period_80 = 14; + } + if (Sensitivity == 0 || Sensitivity == 2 || Sensitivity > 3) { + g_period_84 = 14; + g_period_80 = 50; + } + if (Sensitivity == 3) { + g_period_84 = 89; + g_period_80 = 200; + } + Comment("Neuro Forex Strength Trend Predictor: " + DoubleToStr(Sensitivity, 0)); + int l_ind_counted_20 = IndicatorCounted(); + if (Bars <= 15) return (0); + if (l_ind_counted_20 < 1) { + for (int li_24 = 1; li_24 <= 15; li_24++) { + g_ibuf_88[Bars - li_24] = 0.0; + g_ibuf_96[Bars - li_24] = 0.0; + g_ibuf_92[Bars - li_24] = 0.0; + g_ibuf_100[Bars - li_24] = 0.0; + g_ibuf_104[Bars - li_24] = 0.0; + g_ibuf_112[Bars - li_24] = 0.0; + g_ibuf_108[Bars - li_24] = 0.0; + g_ibuf_116[Bars - li_24] = 0.0; + } + } + if (l_ind_counted_20 > 0) li_16 = Bars - l_ind_counted_20; + if (l_ind_counted_20 == 0) li_16 = Bars - 15 - 1; + for (li_24 = li_16; li_24 >= 0; li_24--) { + l_icci_0 = iCCI(NULL, 0, g_period_84, PRICE_TYPICAL, li_24); + l_icci_8 = iCCI(NULL, 0, g_period_80, PRICE_TYPICAL, li_24); + g_ibuf_88[li_24] = EMPTY_VALUE; + g_ibuf_96[li_24] = EMPTY_VALUE; + g_ibuf_92[li_24] = EMPTY_VALUE; + g_ibuf_100[li_24] = EMPTY_VALUE; + g_ibuf_104[li_24] = EMPTY_VALUE; + g_ibuf_112[li_24] = EMPTY_VALUE; + g_ibuf_108[li_24] = EMPTY_VALUE; + g_ibuf_116[li_24] = EMPTY_VALUE; + if (l_icci_0 >= 0.0 && l_icci_8 >= 0.0) { + g_ibuf_88[li_24] = MathMax(Open[li_24], Close[li_24]); + g_ibuf_92[li_24] = MathMin(Open[li_24], Close[li_24]); + g_ibuf_104[li_24] = High[li_24]; + g_ibuf_108[li_24] = Low[li_24]; + } else { + if (l_icci_8 >= 0.0 && l_icci_0 < 0.0) { + g_ibuf_96[li_24] = MathMax(Open[li_24], Close[li_24]); + g_ibuf_100[li_24] = MathMin(Open[li_24], Close[li_24]); + g_ibuf_112[li_24] = High[li_24]; + g_ibuf_116[li_24] = Low[li_24]; + } else { + if (l_icci_0 < 0.0 && l_icci_8 < 0.0) { + g_ibuf_92[li_24] = MathMax(Open[li_24], Close[li_24]); + g_ibuf_88[li_24] = MathMin(Open[li_24], Close[li_24]); + g_ibuf_108[li_24] = High[li_24]; + g_ibuf_104[li_24] = Low[li_24]; + } else { + if (l_icci_8 < 0.0 && l_icci_0 > 0.0) { + g_ibuf_100[li_24] = MathMax(Open[li_24], Close[li_24]); + g_ibuf_96[li_24] = MathMin(Open[li_24], Close[li_24]); + g_ibuf_116[li_24] = High[li_24]; + g_ibuf_112[li_24] = Low[li_24]; + } + } + } + } + } + return (0); +} \ No newline at end of file diff --git a/ADX Crossing v.2.0.mq4 b/ADX Crossing v.2.0.mq4 new file mode 100644 index 0000000..83be42f --- /dev/null +++ b/ADX Crossing v.2.0.mq4 @@ -0,0 +1,93 @@ +//+------------------------------------------------------------------+ +//| ADX Crossing.mq4 +//| Amir +//+------------------------------------------------------------------+ +#property copyright "Author - Amir" + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 Lime +#property indicator_color2 Red + +//---- input parameters +extern int ADXbars=50; +extern int CountBars=350; +extern bool UseSound = True; +extern string SoundFile = "wait.waw"; + +//---- buffers +double val1[]; +double val2[]; +double b4plusdi,nowplusdi,b4minusdi,nowminusdi; +bool SoundBuy = False; +bool SoundSell = False; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { + string short_name; +//---- indicator line + IndicatorBuffers(2); + SetIndexStyle(0,DRAW_ARROW); + SetIndexArrow(0,108); + SetIndexStyle(1,DRAW_ARROW); + SetIndexArrow(1,108); + SetIndexBuffer(0,val1); + SetIndexBuffer(1,val2); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| AltrTrend_Signal_v2_2 | +//+------------------------------------------------------------------+ +int start() + { + if (CountBars>=Bars) CountBars=Bars; + SetIndexDrawBegin(0,Bars-CountBars); + SetIndexDrawBegin(1,Bars-CountBars); + int i,shift,limit,CountedBars = IndicatorCounted(); + +if (CountedBars < 1) + { + for (i=0; i<=CountBars; i++) {val1[i] = 0.0; val2[i] = 0.0;} + } + +if(CountedBars > 0) CountedBars--; +limit = Bars - CountedBars; + +for (shift = limit; shift>=0; shift--) +{ + b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift+1); + nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift); + b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift+1); + nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift); +if (b4plusdinowminusdi) +{ + val1[shift]=Low[shift]-5*Point; +} +if (b4plusdi>b4minusdi && nowplusdi=Bars) CountBars=Bars; + SetIndexDrawBegin(0,Bars-CountBars); + SetIndexDrawBegin(1,Bars-CountBars); + int i,shift,counted_bars=IndicatorCounted(); + + + //---- check for possible errors + if(counted_bars<0) return(-1); + + //---- initial zero + if(counted_bars<1) + { + for(i=1;i<=CountBars;i++) val1[CountBars-i]=0.0; + for(i=1;i<=CountBars;i++) val2[CountBars-i]=0.0; + } + +for (shift = CountBars; shift>=0; shift--) +{ + + b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift-1); + nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift); + b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift-1); + nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift); +if (b4plusdi>b4minusdi && nowplusdinowminusdi) +{ + val2[shift]=High[shift]+5*Point; +} + + +} + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/AI-FXRobot-V-1-nonexp.mq4 b/AI-FXRobot-V-1-nonexp.mq4 new file mode 100644 index 0000000..230bfff --- /dev/null +++ b/AI-FXRobot-V-1-nonexp.mq4 @@ -0,0 +1,192 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, Trading Automatics Ltd" +#property link "http://www.tradingautomatics.com" + +extern int MA = 8; +extern int NumberOfCloses = 5; +extern bool UseMoneyManagement = TRUE; +extern double Risk = 2.0; +extern double Lots = 0.1; +extern int BETrigger = 40; +extern int SL = 80; +extern int TP = 40; +extern int MagicNumber = 7645034; +extern int Slippage = 3; +extern bool Broker5Digits = FALSE; +int gi_128 = 0; + +int init() { + if (Broker5Digits) { + SL = 10 * SL; + TP = 10 * TP; + Slippage = 10 * Slippage; + BETrigger = 10 * BETrigger; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double l_ima_0; + double l_ima_8; + double l_icustom_16; + double l_icustom_24; + double l_icustom_32; + double l_icustom_40; + int l_ticket_56; + bool li_48 = TRUE; + int l_ticket_60 = 0; + int l_cmd_64 = -1; + int li_68 = 0; + int li_72 = 0; + int li_76 = 0; + double l_price_80 = 0; + double ld_unused_88 = 0; + li_72 = GetLongsNumber(); + li_76 = GetShortsNumber(); + li_68 = li_72 + li_76; + for (int l_pos_96 = 0; l_pos_96 < OrdersTotal(); l_pos_96++) { + OrderSelect(l_pos_96, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + l_ticket_60 = OrderTicket(); + l_cmd_64 = OrderType(); + break; + } + } + if (gi_128 != Time[0]) { + l_icustom_24 = iCustom(Symbol(), 0, "Heiken Ashi", 0, 1); + l_icustom_16 = iCustom(Symbol(), 0, "Heiken Ashi", 1, 1); + l_ima_8 = iMA(Symbol(), 0, MA, 0, MODE_SMA, PRICE_CLOSE, 1); + if (l_icustom_16 > l_icustom_24 && Close[1] > l_ima_8) { + for (int li_52 = 2; li_52 < NumberOfCloses + 1; li_52++) { + l_icustom_40 = iCustom(Symbol(), 0, "Heiken Ashi", 0, li_52); + l_icustom_32 = iCustom(Symbol(), 0, "Heiken Ashi", 1, li_52); + l_ima_0 = iMA(Symbol(), 0, MA, 0, MODE_SMA, PRICE_CLOSE, li_52); + if (l_icustom_40 > l_icustom_32 || Close[li_52] < l_ima_0) { + li_52 = 999; + li_48 = FALSE; + break; + } + } + if (li_48 && li_72 == 0) { + CloseAllShorts(); + if (SL > 0) l_price_80 = Ask - SL * Point; + l_ticket_56 = OrderSend(Symbol(), OP_BUY, GetLots(), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue); + if (l_ticket_56 > 0) OrderModify(l_ticket_56, OrderOpenPrice(), l_price_80, 0, 0, CLR_NONE); + } + } + if (l_icustom_16 < l_icustom_24 && Close[1] < l_ima_8) { + for (li_52 = 2; li_52 < NumberOfCloses + 1; li_52++) { + l_icustom_40 = iCustom(Symbol(), 0, "Heiken Ashi", 0, li_52); + l_icustom_32 = iCustom(Symbol(), 0, "Heiken Ashi", 1, li_52); + l_ima_0 = iMA(Symbol(), 0, MA, 0, MODE_SMA, PRICE_CLOSE, li_52); + if (l_icustom_40 < l_icustom_32 || Close[li_52] > l_ima_0) { + li_52 = 999; + li_48 = FALSE; + break; + } + } + if (li_48 && li_76 == 0) { + CloseAllLongs(); + if (SL > 0) l_price_80 = Bid + SL * Point; + l_ticket_56 = OrderSend(Symbol(), OP_SELL, GetLots(), Bid, Slippage, 0, 0, "", MagicNumber, 0, Red); + if (l_ticket_56 > 0) OrderModify(l_ticket_56, OrderOpenPrice(), l_price_80, 0, 0, CLR_NONE); + } + } + gi_128 = Time[0]; + } + if (li_68 > 0) { + if (BETrigger > 0) HandleBreakEven(); + if (OrderLots() > 3.0 * GetLots() / 4.0) { + if (l_cmd_64 == OP_BUY) { + if (Bid >= OrderOpenPrice() + TP * Point) { + Print(1); + OrderClose(l_ticket_60, OrderLots() / 2.0, Bid, Slippage, Blue); + } + } + if (l_cmd_64 == OP_SELL) + if (Ask <= OrderOpenPrice() - TP * Point) OrderClose(l_ticket_60, OrderLots() / 2.0, Ask, Slippage, Red); + } + } + return (0); +} + +void HandleBreakEven() { + for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { + OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + if (OrderType() == OP_BUY) { + if (Bid >= OrderOpenPrice() + BETrigger * Point && OrderStopLoss() < OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, CLR_NONE); + } else { + if (OrderType() == OP_SELL) + if (Ask <= OrderOpenPrice() - BETrigger * Point && OrderStopLoss() > OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, CLR_NONE); + } + } + } +} + +int GetLongsNumber() { + int l_count_0 = 0; + for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) l_count_0++; + } + return (l_count_0); +} + +int GetShortsNumber() { + int l_count_0 = 0; + for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) l_count_0++; + } + return (l_count_0); +} + +void CloseAllLongs() { + int l_ord_total_0 = OrdersTotal(); + for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue); + } + } +} + +void CloseAllShorts() { + int l_ord_total_0 = OrdersTotal(); + for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red); + } + } +} + +double GetLots() { + double ld_ret_0; + double ld_8; + double l_lotstep_32; + double l_marginrequired_40; + if (UseMoneyManagement) { + l_lotstep_32 = MarketInfo(Symbol(), MODE_LOTSTEP); + l_marginrequired_40 = MarketInfo(Symbol(), MODE_MARGINREQUIRED); + ld_ret_0 = AccountBalance() * Risk / 100.0 / l_marginrequired_40; + ld_8 = MathMod(ld_ret_0, l_lotstep_32); + if (ld_8 != 0.0) ld_ret_0 -= ld_8; + } else ld_ret_0 = Lots; + double l_minlot_16 = MarketInfo(Symbol(), MODE_MINLOT); + double l_maxlot_24 = MarketInfo(Symbol(), MODE_MAXLOT); + if (ld_ret_0 < l_minlot_16) ld_ret_0 = l_minlot_16; + if (ld_ret_0 > l_maxlot_24) ld_ret_0 = l_maxlot_24; + return (ld_ret_0); +} diff --git a/ATM_Pure_Market_Price.mq4 b/ATM_Pure_Market_Price.mq4 new file mode 100644 index 0000000..dfb0b72 --- /dev/null +++ b/ATM_Pure_Market_Price.mq4 @@ -0,0 +1,68 @@ +//+------------------------------------------------------------------+ +//| Magnified Market PriceV2.mq4 ver1.4 by Habeeb | +//| Modified David M. Edwards to shrink final digit +//| Best used with font sizes near the default. 01/21/09 +//+------------------------------------------------------------------+ + +#property indicator_chart_window + + extern string note1 = "Change font colors automatically? True = Yes"; + extern bool Bid_Ask_Colors = False; + extern string note2 = "Default Font Color"; + extern color FontColor = Black; + extern string note3 = "Font Size"; + extern int FontSize=26; + extern string note4 = "Font Type"; + extern string FontType="Arial Bold"; + extern string note5 = "Display the price in what corner?"; + extern string note6 = "Upper left=0; Upper right=1"; + extern string note7 = "Lower left=2; Lower right=3"; + extern int WhatCorner=3; + extern int LastDigitDiff = 10; + + + double Old_Price; + +int init() + { + return(0); + } + +int deinit() + { + ObjectDelete("Market_Price_LabelA"); + ObjectDelete("Market_Price_LabelB"); + return(0); + } + +int start() + { + int DigitOffset = FontSize - 8; + string BidA, BidB, Base_Price, Market_Price; + if (Bid_Ask_Colors == True) + { + if (Bid > Old_Price) FontColor = LawnGreen; + if (Bid < Old_Price) FontColor = Red; + Old_Price = Bid; + } + + Base_Price = DoubleToStr(Bid, Digits); // Full base as string + int SLength = StringLen(Base_Price); + + + BidA = StringSubstr(Base_Price, 0, SLength-1); + BidB = StringSubstr(Base_Price, SLength-1, 1); + + ObjectCreate("Market_Price_LabelA", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Market_Price_LabelA", BidA, FontSize, FontType, FontColor); + ObjectSet("Market_Price_LabelA", OBJPROP_CORNER, WhatCorner); + ObjectSet("Market_Price_LabelA", OBJPROP_XDISTANCE, DigitOffset); + ObjectSet("Market_Price_LabelA", OBJPROP_YDISTANCE, 1); + + ObjectCreate("Market_Price_LabelB", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Market_Price_LabelB", BidB, FontSize-LastDigitDiff, FontType, FontColor); + ObjectSet("Market_Price_LabelB", OBJPROP_CORNER, WhatCorner); + ObjectSet("Market_Price_LabelB", OBJPROP_XDISTANCE, 1); + ObjectSet("Market_Price_LabelB", OBJPROP_YDISTANCE, 1); + + } \ No newline at end of file diff --git a/AccuScalper.mq4 b/AccuScalper.mq4 new file mode 100644 index 0000000..66543bd --- /dev/null +++ b/AccuScalper.mq4 @@ -0,0 +1,1516 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Forex MegaDroid Team" +#property link "http://www.forex-megadroid.com" + +#include +#include + +#import "AccuScalper.dll" + int GetGmtOffset(int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, double& a9[], int& a10[]); + void Activate(string a0, int a1, int a2, string a3, int a4); + int GetState(); + int GetStatus(); + int Increment(string a0); + bool Decrement(int a0); + bool IsTradeTime(int a0, int a1, int a2, int a3, int a4); + bool s1_Buy(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, int a8, int a9); + bool s1_Sell(double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7, int a8, int a9); + bool s2_Buy(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7); + bool s2_Sell(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7); + bool s1_Init(int a0, int& a1[], int& a2[], int& a3[], int& a4[], int& a5[], int& a6[], int& a7[], int& a8[], int& a9[], int& a10[], int& a11[], double& a12[], double& a13[], double& a14[], double& a15[], int& a16[], int& a17[], int& a18[], int& a19[], int& a20[], int& a21[]); + bool s2_Init(int a0, int& a1[], int& a2[], int& a3[], double& a4[], int& a5[], int& a6[], int& a7[], int& a8[], double& a9[], double& a10[], double& a11[], int& a12[], int& a13[], int& a14[], int& a15[], int& a16[], int& a17[]); +#import + +extern string Ver.1.00 = ""; +extern string _1 = "System Parameters"; +extern bool Stealth = TRUE; +extern bool Aggressive = TRUE; +extern bool NFA = FALSE; +extern double GmtOffset = 0.0; +extern bool AutoLocalGmtOffset = TRUE; +extern bool AutoServerGmtOffset = TRUE; +extern int S1_Reference = 888333; +extern int S2_Reference = 333888; +string ReceiptCode = "111111"; +extern string _2 = "Comment Position"; +extern int TopPadding = 30; +extern int LeftPadding = 20; +extern color TextColor1 = WhiteSmoke; +extern color TextColor2 = LightGray; +extern string _3 = "Strategy Parameters"; +extern int Slippage = 3; +extern bool SendEmails = FALSE; +extern string OrderComments = ""; +extern string _4 = "Order Management"; +extern double LotSize = 0.1; +extern string _5 = "Ratio Order Management"; +extern double RiskLevel = 0.1; +extern bool RecoveryMode = TRUE; +bool gi_220 = FALSE; +double gd_224 = 1000.0; +double gd_232 = 0.2; +bool gi_240 = FALSE; +bool gi_244 = TRUE; +bool gi_248 = TRUE; +int gi_252 = 3; +bool gi_256 = TRUE; +int gi_260; +int g_datetime_264; +int gi_268; +double g_hour_272; +int gi_280; +int g_spread_284; +int g_spread_288; +int g_stoplevel_292; +double gd_296; +double gd_304; +double gd_312; +bool gi_320 = FALSE; +int gi_324 = 0; +int gi_328 = 0; +int gi_332; +string gs_336; +string gs_344; +string gs_352; +int g_timeframe_360 = PERIOD_M15; +int gi_364 = 10; +int gi_368 = 50; +int gi_372 = 200; +int gi_376 = 20; +int gi_380 = 0; +int gi_384 = 16711680; +int gi_388 = 255; +int g_period_392 = 6; +int g_period_396 = 20; +int g_period_400 = 8; +double gd_404 = 70.0; +double gd_412 = 30.0; +double gd_420 = 64.0; +double gd_428 = 36.0; +bool gi_436 = TRUE; +bool gi_440 = TRUE; +bool gi_444 = TRUE; +int gi_448 = 12; +bool gi_452 = TRUE; +int gi_456 = 20; +bool gi_460 = TRUE; +bool gi_464 = FALSE; +double gd_468 = 1.0; +double gd_476 = 24.0; +bool gi_484 = TRUE; +double gd_488 = 1.0; +double gd_496 = 1.0; +bool gi_504 = FALSE; +int gi_508 = 0; +bool gi_512 = TRUE; +bool gi_516 = TRUE; +int gi_520 = 21; +int gi_524 = 1; +int gi_528 = 21; +int gi_532 = 0; +int g_timeframe_536 = PERIOD_M5; +int gi_540 = 35; +int gi_544 = 60; +int gi_548 = 200; +int gi_552 = 20; +double gd_556 = 1.0; +int gi_564 = 0; +int gi_568 = 16748574; +int gi_572 = 9639167; +int gi_576 = 36; +int g_period_580 = 168; +int g_period_584 = 275; +bool gi_588 = TRUE; +bool gi_592 = FALSE; +bool gi_596 = TRUE; +double gd_600 = 1.0; +double gd_608 = 12.0; +double gd_616 = 24.0; +bool gi_624 = FALSE; +bool gi_628 = FALSE; +int gi_632 = 0; +bool gi_636 = TRUE; +bool gi_640 = TRUE; +int gi_644 = 21; +int gi_648 = 4; +int gi_652 = 21; +int gi_656 = 0; +int gi_660 = 0; +int gi_664 = 0; +int gi_668 = 0; +int gi_672; +int gi_676; +int gi_680; +int gi_684; +double gd_688 = 0.0; +double gd_696 = 0.0; +bool gi_704 = FALSE; +bool gi_708; +bool gi_712; +int gi_716; +int g_count_720 = 0; +int g_ticket_724 = -2; +int g_ticket_728 = -2; +double g_ord_profit_732 = 0.0; +double g_ord_profit_740 = 0.0; +int g_ticket_748 = -2; +int g_ticket_752 = -2; +double g_ord_profit_756 = 0.0; +double g_ord_profit_764 = 0.0; +int gi_772 = 0; +int gi_776 = 0; +int gi_780 = 0; +int gi_784 = 0; +double g_irsi_788; +double g_irsi_796; +double g_irsi_804; +double g_irsi_812; +double g_icci_820; +double g_icci_828; +double g_icci_836; +double g_ima_860; +bool gi_868 = TRUE; +bool gi_872 = TRUE; +double g_ihigh_876 = 0.0; +double g_ilow_884 = 0.0; +bool gi_892 = FALSE; +int gi_896 = 0; +int gi_900 = 0; +int gi_904 = 0; +int gi_908 = 0; +int gi_912; +int gi_916; +int gi_920 = 0; +int gi_924 = 0; +int gi_928; +int g_datetime_932 = 0; +int g_datetime_936 = 0; +int g_ticket_940 = 0; +int g_datetime_944 = 0; +int g_ticket_948 = 0; +int g_datetime_952 = 0; +bool gi_956 = TRUE; +int g_datetime_960 = 0; +int g_datetime_964 = 0; +int gi_968 = 0; +double g_icci_972; +double g_icci_980; +double g_ihigh_988; +double g_ilow_996; +double g_ihigh_1004; +double g_ilow_1012; +bool gi_1020 = FALSE; +int gi_1024 = 0; +int gi_1028 = 0; +int gi_1032 = 0; +int gi_1036 = 0; +int gi_1040; +int gi_1044; +int g_ticket_1048 = -1; +int gi_1052; +int gi_1056; +int g_datetime_1060; +int g_datetime_1064; +double g_ord_open_price_1068; +int g_ticket_1076 = -1; +int gi_1080; +int gi_1084; +int g_datetime_1088; +int g_datetime_1092; +double g_ord_open_price_1096; +bool gi_1104 = TRUE; +int g_datetime_1108 = 0; +int g_datetime_1112 = 0; +string gsa_1116[] = {".", "..", "...", "....", "....."}; +int gi_unused_1120 = 0; +int gi_unused_1124 = 0; +string gs_1128 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +bool gi_1136 = FALSE; + +int S1_CheckSymbol() { + int lia_0[1]; + int lia_4[1]; + int lia_8[1]; + int lia_12[1]; + int lia_16[1]; + int lia_20[1]; + int lia_24[1]; + int lia_28[1]; + int lia_32[1]; + int lia_36[1]; + int lia_40[1]; + double lda_44[1]; + double lda_48[1]; + double lda_52[1]; + double lda_56[1]; + int lia_60[1]; + int lia_64[1]; + int lia_68[1]; + int lia_72[1]; + int lia_76[1]; + int lia_80[1]; + if (s1_Init(gi_332, lia_0, lia_4, lia_8, lia_12, lia_16, lia_20, lia_24, lia_28, lia_32, lia_36, lia_40, lda_44, lda_48, lda_52, lda_56, lia_60, lia_64, lia_68, lia_72, lia_76, lia_80)) { + gi_364 = lia_0[0]; + gi_372 = lia_4[0]; + gi_376 = lia_8[0]; + gi_380 = lia_12[0]; + g_period_392 = lia_16[0]; + g_period_396 = lia_20[0]; + g_period_400 = lia_24[0]; + gd_404 = lia_28[0]; + gd_412 = lia_32[0]; + gd_420 = lia_36[0]; + gd_428 = lia_40[0]; + gd_468 = lda_44[0]; + gd_476 = lda_48[0]; + gd_488 = lda_52[0]; + gd_496 = lda_56[0]; + gi_508 = lia_60[0]; + gi_520 = lia_64[0]; + gi_524 = lia_68[0]; + gi_528 = lia_72[0]; + gi_532 = lia_76[0]; + g_timeframe_360 = lia_80[0]; + return (1); + } + return (0); +} + +int S2_CheckSymbol() { + int lia_0[1]; + int lia_4[1]; + int lia_8[1]; + int lia_12[1]; + double lda_16[1]; + int lia_20[1]; + int lia_24[1]; + int lia_28[1]; + double lda_32[1]; + double lda_36[1]; + double lda_40[1]; + int lia_44[1]; + int lia_48[1]; + int lia_52[1]; + int lia_56[1]; + int lia_60[1]; + int lia_64[1]; + if (s2_Init(gi_332, lia_0, lia_4, lia_8, lda_16, lia_12, lia_20, lia_24, lia_28, lda_32, lda_36, lda_40, lia_44, lia_48, lia_52, lia_56, lia_60, lia_64)) { + gi_540 = lia_0[0]; + gi_548 = lia_4[0]; + gi_552 = lia_8[0]; + gd_556 = lda_16[0]; + gi_564 = lia_12[0]; + gi_576 = lia_20[0]; + g_period_580 = lia_24[0]; + g_period_584 = lia_28[0]; + gd_600 = lda_32[0]; + gd_608 = lda_36[0]; + gd_616 = lda_40[0]; + gi_632 = lia_44[0]; + gi_644 = lia_48[0]; + gi_648 = lia_52[0]; + gi_652 = lia_56[0]; + gi_656 = lia_60[0]; + g_timeframe_536 = lia_64[0]; + return (1); + } + return (0); +} + +int init() { + double l_global_var_8; + double ld_16; + if (gi_256) gi_260 = 0; + else gi_260 = 1; + gi_332 = Increment(Symbol()); + gi_676 = LeftPadding; + gi_672 = TopPadding; + if (gi_680 != LeftPadding || gi_684 != TopPadding) { + gi_680 = LeftPadding; + gi_684 = TopPadding; + } else GetPos(0, gi_676, gi_672); + gi_664 = 0; + gi_660 = 0; + gs_336 = "Swissy Accu-Scalper" + " ver: " + "1.00" + " Symbol: " + Symbol(); + PrintLN(gs_336, TextColor2); + PrintSep(); + ObjectsRedraw(); + for (int l_count_0 = 0; !IsStopped() && !IsConnected() || StringLen(AccountName()) <= 0; l_count_0++) { + PrintLN("Waiting for connection" + PPrint(l_count_0), TextColor1, 2, 2); + ObjectsRedraw(); + Sleep(150); + } + PrintLN("Authentication...", TextColor1, 2, 2); + ObjectsRedraw(); + int li_4 = 0; + ReceiptCode = StringTrimLeft(StringTrimRight(ReceiptCode)); + ReceiptCode = StringSubstr(ReceiptCode, StringLen(ReceiptCode) - 8); + if (StringLen(ReceiptCode) <= 0) { + if (GlobalVariableCheck("GV_AccuScalper_REC")) { + l_global_var_8 = GlobalVariableGet("GV_AccuScalper_REC"); + ReceiptCode = Base36Encode(l_global_var_8); + } else li_4 |= 32; + } else { + ld_16 = Base36Decode(ReceiptCode); + if (GlobalVariableSet("GV_AccuScalper_REC", ld_16) == 0) li_4 |= 64; + } + Activate("1.00", AccountNumber(), IsDemo(), StringTrimLeft(StringTrimRight(ReceiptCode)), 1); + gi_324 = GetState(); + gi_324 |= li_4; + PrintResponse(gi_324, 2, 2); + PrintSep(); + ObjectsRedraw(); + bool li_24 = FALSE; + bool li_28 = FALSE; + li_24 = S1_CheckSymbol(); + li_28 = S2_CheckSymbol(); + if (li_24) { + gi_244 = TRUE; + if (Aggressive) gi_248 = li_28; + else gi_248 = FALSE; + } else { + if (li_28) { + gi_244 = FALSE; + gi_248 = TRUE; + } else { + gi_248 = FALSE; + gi_244 = FALSE; + } + } + if (!gi_244 && !gi_248) { + gs_344 = "Error:"; + gs_352 = "This currency is not supported!"; + } else { + gs_344 = "Aggressive:"; + gs_352 = BPrint(gi_244 && gi_248); + if (Aggressive && !(gi_244 && gi_248)) gs_352 = gs_352 + " (not supported)"; + } + PrintLN(gs_344); + PrintLN(gs_352, TextColor2, gi_664, gi_660 - 1, 5 * (StringLen(gs_344) + 1)); + PrintSep(); + ObjectsRedraw(); + if (!gi_244 && !gi_248) MessageBox("You have selected the wrong currency pair!\nPlease attach Accu-Scalper to a EURCHF chart.", gs_336 + ": Warning", MB_ICONEXCLAMATION); + gd_312 = gd_224; + gi_328 = 0; + if (!IsTesting()) gi_320 = TRUE; + return (0); +} + +int deinit() { + Decrement(gi_332); + if (IsTesting()) { + if (!IsVisualMode()) { + PrintLN("GmtOffset:"); + PrintLN(DoubleToStr(GmtOffset, 1), TextColor2, gi_664, gi_660 - 1, 55); + PrintSep(); + PrintLN("Digits:"); + PrintLN(Digits, TextColor2, gi_664, gi_660 - 1, 35); + PrintLN("Spread:"); + PrintLN(StringConcatenate(DoubleToStr(g_spread_284 / gd_296, 1), " (", g_spread_284, " pips)"), TextColor2, gi_664, gi_660 - 1, 40); + PrintSep(); + } + return (0); + } + switch (UninitializeReason()) { + case REASON_CHARTCLOSE: + case REASON_REMOVE: + Deleteobjects(0, gi_668); + gi_668 = 0; + break; + case REASON_RECOMPILE: + case REASON_CHARTCHANGE: + case REASON_PARAMETERS: + case REASON_ACCOUNT: + Deleteobjects(1, gi_668); + gi_668 = 1; + } + return (0); +} + +int waitForContext() { + for (int l_count_0 = 0; IsTradeContextBusy() && l_count_0 < 20; l_count_0++) Sleep(15); + if (l_count_0 >= 20) Print("Trade context is buisy more than ", DoubleToStr(15 * l_count_0 / 1000, 2), " seconds"); + else + if (l_count_0 > 0) Print("Trade context was buisy ", DoubleToStr(15 * l_count_0 / 1000, 2), " seconds"); + return (l_count_0); +} + +int openOrder(int a_cmd_0, double a_lots_4, double a_price_12, double a_price_20, double a_price_28, int a_magic_36, color a_color_40, bool ai_44) { + int l_error_68; + double l_price_48 = 0; + double l_price_56 = 0; + if (!ai_44) { + l_price_48 = a_price_20; + l_price_56 = a_price_28; + } + waitForContext(); + int l_ticket_64 = OrderSend(Symbol(), a_cmd_0, a_lots_4, a_price_12, Slippage * gd_296, l_price_56, l_price_48, OrderComments, a_magic_36, 0, a_color_40); + if (l_ticket_64 > 0) { + if (ai_44) { + if (OrderSelect(l_ticket_64, SELECT_BY_TICKET)) { + waitForContext(); + OrderModify(l_ticket_64, OrderOpenPrice(), a_price_28, a_price_20, 0, a_color_40); + } + } + if (SendEmails) SendMail(gs_336, "Open " + OpPrint(a_cmd_0) + ": [" + Symbol() + "] " + NormalizeDouble(a_price_12, Digits)); + } else { + l_error_68 = GetLastError(); + if (!ai_44) return (openOrder(a_cmd_0, a_lots_4, a_price_12, a_price_20, a_price_28, a_magic_36, a_color_40, 1)); + Print(OpPrint(a_cmd_0) + " operation failed - error(", l_error_68, "): ", ErrorDescription(l_error_68)); + } + return (l_ticket_64); +} + +int closeOrder(int ai_0, color a_color_4) { + double l_price_8; + int l_error_20; + for (int l_count_16 = 0; l_count_16 < 20; l_count_16++) { + if (waitForContext() > 5) RefreshRates(); + if (ai_0 == 0) l_price_8 = Bid; + else l_price_8 = Ask; + if (OrderClose(OrderTicket(), OrderLots(), l_price_8, Slippage * gd_296, a_color_4)) return (-1); + l_error_20 = GetLastError(); + Print("Order close operation failed - error(", l_error_20, "): ", ErrorDescription(l_error_20)); + RefreshRates(); + } + Print("Order close operation failed"); + return (OrderTicket()); +} + +double MMLots(double ad_0, double ad_8, int &ai_16) { + return (NormalizeLots(ad_0 * ad_8 / MarketInfo(Symbol(), MODE_MARGINREQUIRED) / (AccountLeverage() / 100.0), ai_16)); +} + +double NormalizeLots(double ad_0, int &ai_8) { + double l_lotstep_20 = MarketInfo(Symbol(), MODE_LOTSTEP); + double l_minlot_28 = MarketInfo(Symbol(), MODE_MINLOT); + double l_maxlot_36 = MarketInfo(Symbol(), MODE_MAXLOT); + double ld_ret_12 = MathCeil(ad_0 / l_lotstep_20) * l_lotstep_20; + ai_8 = 0; + if (ld_ret_12 < l_minlot_28) { + ld_ret_12 = l_minlot_28; + ai_8 = -1; + } + if (ld_ret_12 > l_maxlot_36) { + ld_ret_12 = l_maxlot_36; + ai_8 = 1; + } + return (ld_ret_12); +} + +void CountBalance(double ad_0) { + gd_688 += ad_0; + if (gd_696 < gd_688) gd_696 = gd_688; +} + +double RecoveryLot(double ad_0) { + int li_8; + if (gd_696 > gd_688 && gi_772 > gi_780) return (NormalizeLots(2.0 * ad_0, li_8)); + gi_780 = gi_772; + return (ad_0); +} + +int RecoverTrades() { + int l_count_0 = 0; + gd_688 = 0; + gd_696 = 0; + for (int l_pos_4 = OrdersHistoryTotal() - 1; l_pos_4 >= 0; l_pos_4--) { + if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_HISTORY)) { + if (OrderMagicNumber() != S1_Reference && OrderMagicNumber() != S2_Reference) continue; + CountBalance(OrderProfit()); + l_count_0++; + } + } + return (l_count_0); +} + +int Recover(int a_magic_0, int a_cmd_4) { + for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { + if (OrderSelect(l_pos_8, SELECT_BY_POS)) { + if (OrderMagicNumber() == a_magic_0) { + if (OrderSymbol() == Symbol()) + if (OrderType() == a_cmd_4) return (OrderTicket()); + } + } + } + return (-1); +} + +void RefreshOrders() { + g_count_720 = 0; + for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { + if (OrderSelect(l_pos_0, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol()) + if (OrderMagicNumber() != S1_Reference && OrderMagicNumber() != S2_Reference) g_count_720++; + } + } +} + +int FIFOrule() { + return (g_count_720 <= 0 && g_ticket_724 < 0 && g_ticket_728 < 0 && g_ticket_748 < 0 && g_ticket_752 < 0); +} + +int s1_direction() { + if (g_icci_820 >= 0.0 || g_irsi_788 >= 50.0) g_datetime_936 = g_datetime_264; + if (g_icci_820 <= 0.0 || g_irsi_788 <= 50.0) g_datetime_932 = g_datetime_264; + if (g_datetime_936 > 0 && g_datetime_264 - g_datetime_936 > 3600.0 * gd_488) return (2); + if (g_datetime_932 > 0 && g_datetime_264 - g_datetime_932 > 3600.0 * gd_488) return (3); + if (g_datetime_936 == 0 || g_datetime_932 == 0) return (0); + return (1); +} + +void s1_dayRange() { + int l_shift_0; + if (g_datetime_264 - gi_280 < 3600.0 * gi_448) l_shift_0 = iBarShift(NULL, g_timeframe_360, gi_280 - 86400); + else l_shift_0 = iBarShift(NULL, g_timeframe_360, gi_280); + g_ihigh_876 = iHigh(NULL, g_timeframe_360, iHighest(NULL, g_timeframe_360, MODE_HIGH, l_shift_0 - gi_260, gi_260)); + g_ilow_884 = iLow(NULL, g_timeframe_360, iLowest(NULL, g_timeframe_360, MODE_LOW, l_shift_0 - gi_260, gi_260)); +} + +void s1_setRules() { + int li_0; + HideTestIndicators(TRUE); + g_irsi_788 = iRSI(NULL, g_timeframe_360, g_period_392, PRICE_CLOSE, gi_260); + g_irsi_796 = iRSI(NULL, g_timeframe_360, g_period_392, PRICE_CLOSE, gi_260 + 1); + g_irsi_804 = iRSI(NULL, g_timeframe_360, g_period_392, PRICE_CLOSE, gi_260 + 2); + if (gi_436) g_irsi_812 = iRSI(NULL, PERIOD_M1, g_period_396, PRICE_CLOSE, gi_260); + g_icci_820 = iCCI(NULL, g_timeframe_360, g_period_400, PRICE_TYPICAL, gi_260); + g_icci_828 = iCCI(NULL, g_timeframe_360, g_period_400, PRICE_TYPICAL, gi_260 + 1); + g_icci_836 = iCCI(NULL, g_timeframe_360, g_period_400, PRICE_TYPICAL, gi_260 + 2); + g_ima_860 = iMA(NULL, g_timeframe_360, g_period_400, 0, MODE_SMA, PRICE_MEDIAN, gi_260); + if (gi_452) { + if (g_irsi_788 >= 50 - gi_456 / 2 && g_irsi_788 <= gi_456 / 2 + 50) { + gi_868 = TRUE; + gi_872 = TRUE; + } + } + if (gi_444) s1_dayRange(); + if (gi_484) { + li_0 = gi_920; + gi_920 = s1_direction(); + if (li_0 != gi_920) { + gi_924 = li_0; + if (gi_920 == 1) gi_928 = g_datetime_264 + 3600.0 * gd_496; + } + } + if (gi_508 > 0) { + if (g_spread_284 > gi_508 * gd_296) { + if (g_spread_288 < g_spread_284) { + Print("Strategy1: Safe spread limit exceeded: spread = ", g_spread_284); + if (gi_512) Print("Strategy1: Using DayDirection filter"); + } + gi_892 = TRUE; + } else gi_892 = FALSE; + } + HideTestIndicators(FALSE); + if (gi_892) { + gi_912 = gi_528; + gi_916 = gi_532; + return; + } + gi_912 = gi_520; + gi_916 = gi_524; +} + +int s1_openBuyRule() { + double l_iclose_0; + double l_iclose_8; + int l_shift_16; + int l_shift_20; + if (!gi_868) return (0); + if (gi_892 && !gi_512) return (0); + if (gi_484) { + if (gi_920 == 2) return (0); + if (g_datetime_264 <= gi_928) + if (gi_924 == 2) return (0); + } + if (gi_504 || gi_892) { + if (g_datetime_264 - gi_280 < 43200.0) { + l_shift_16 = iBarShift(NULL, g_timeframe_360, gi_280 - 86400); + l_shift_20 = iBarShift(NULL, g_timeframe_360, gi_280); + } else { + l_shift_16 = iBarShift(NULL, g_timeframe_360, gi_280); + l_shift_20 = gi_260; + } + l_iclose_8 = iClose(NULL, g_timeframe_360, l_shift_16); + l_iclose_0 = iClose(NULL, g_timeframe_360, l_shift_20); + if (l_iclose_0 < l_iclose_8) return (0); + } + return (s1_Buy(Ask, g_icci_820, g_irsi_788, g_irsi_812, g_ima_860, gd_412, gd_428, gi_364 * gd_296 * Point, gi_440, gi_436)); +} + +int s1_openSellRule() { + double l_iclose_0; + double l_iclose_8; + int l_shift_16; + int l_shift_20; + if (!gi_872) return (0); + if (gi_892 && !gi_512) return (0); + if (gi_484) { + if (gi_920 == 3) return (0); + if (g_datetime_264 <= gi_928) + if (gi_924 == 3) return (0); + } + if (gi_504 || gi_892) { + if (g_datetime_264 - gi_280 < 43200.0) { + l_shift_16 = iBarShift(NULL, g_timeframe_360, gi_280 - 86400); + l_shift_20 = iBarShift(NULL, g_timeframe_360, gi_280); + } else { + l_shift_16 = iBarShift(NULL, g_timeframe_360, gi_280); + l_shift_20 = gi_260; + } + l_iclose_8 = iClose(NULL, g_timeframe_360, l_shift_16); + l_iclose_0 = iClose(NULL, g_timeframe_360, l_shift_20); + if (l_iclose_0 > l_iclose_8) return (0); + } + return (s1_Sell(Bid, g_icci_820, g_irsi_788, g_irsi_812, g_ima_860, gd_404, gd_420, gi_364 * gd_296 * Point, gi_440, gi_436)); +} + +bool s1_closeBuyRule() { + if (Stealth || OrderTakeProfit() == 0.0) { + if (gi_364 > 0) + if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_364 * Point * gd_296, Digits)) return (TRUE); + } + if (OrderStopLoss() == 0.0) { + if (gi_900 > 0) + if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_900 * Point * gd_296, Digits)) return (TRUE); + } + if (gi_464) { + if (g_ticket_940 != OrderTicket()) { + g_datetime_944 = OrderOpenTime(); + g_ticket_940 = OrderTicket(); + } + if (g_icci_820 >= 0.0 || g_irsi_788 >= 50.0) g_datetime_944 = g_datetime_264; + if (g_icci_836 < g_icci_828 && g_irsi_804 < g_irsi_796) g_datetime_944 = iTime(NULL, g_timeframe_360, gi_260); + if (g_datetime_264 - g_datetime_944 > 3600.0 * gd_468 && OrderProfit() < 0.0) return (TRUE); + } + if (gi_460) { + if (g_datetime_264 - OrderOpenTime() > 3600.0 * gd_468) { + if (g_icci_820 > 0.0 && g_irsi_788 > 50.0 && OrderProfit() > 0.0) return (TRUE); + if (g_datetime_264 - OrderOpenTime() > 3600.0 * gd_476) return (TRUE); + } + } + return (FALSE); +} + +bool s1_closeSellRule() { + if (Stealth || OrderTakeProfit() == 0.0) { + if (gi_364 > 0) + if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_364 * Point * gd_296, Digits)) return (TRUE); + } + if (OrderStopLoss() == 0.0) { + if (gi_908 > 0) + if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_908 * Point * gd_296, Digits)) return (TRUE); + } + if (gi_464) { + if (g_ticket_948 != OrderTicket()) { + g_datetime_952 = OrderOpenTime(); + g_ticket_948 = OrderTicket(); + } + if (g_icci_820 <= 0.0 || g_irsi_788 <= 50.0) g_datetime_952 = g_datetime_264; + if (g_icci_836 > g_icci_828 && g_irsi_804 > g_irsi_796) g_datetime_952 = iTime(NULL, g_timeframe_360, gi_260); + if (g_datetime_264 - g_datetime_952 > 3600.0 * gd_468 && OrderProfit() < 0.0) return (TRUE); + } + if (gi_460) { + if (g_datetime_264 - OrderOpenTime() > 3600.0 * gd_468) { + if (g_icci_820 < 0.0 && g_irsi_788 < 50.0 && OrderProfit() > 0.0) return (TRUE); + if (g_datetime_264 - OrderOpenTime() > 3600.0 * gd_476) return (TRUE); + } + } + return (FALSE); +} + +int s1_openBuy() { + double ld_0 = 0; + double ld_8 = 0; + if (g_ilow_884 > 0.0) { + gi_900 = (Bid - g_ilow_884 + Point * gd_296) / Point; + if (gi_372 > 0 && gi_900 > gi_372 * gd_296) gi_900 = gi_372 * gd_296; + if (gi_900 < gi_376 * gd_296) gi_900 = gi_376 * gd_296; + } else gi_900 = gi_376 * gd_296; + if (gi_900 < g_stoplevel_292) gi_900 = g_stoplevel_292; + if (Stealth) gi_896 = gi_368 * gd_296; + else gi_896 = gi_364 * gd_296; + if (gi_896 < g_stoplevel_292) gi_896 = g_stoplevel_292; + ld_8 = NormalizeDouble(Bid - gi_900 * Point, Digits); + ld_0 = NormalizeDouble(Ask + gi_896 * Point, Digits); + return (openOrder(OP_BUY, gd_304, Ask, ld_0, ld_8, S1_Reference, gi_384, 0)); +} + +int s1_openSell() { + double ld_0 = 0; + double ld_8 = 0; + if (g_ihigh_876 > 0.0) { + gi_908 = (g_ihigh_876 - Ask + Point * gd_296) / Point; + if (gi_372 > 0 && gi_908 > gi_372 * gd_296) gi_908 = gi_372 * gd_296; + if (gi_908 < gi_376 * gd_296) gi_908 = gi_376 * gd_296; + } else gi_908 = gi_376 * gd_296; + if (gi_908 < g_stoplevel_292) gi_908 = g_stoplevel_292; + if (Stealth) gi_904 = gi_368 * gd_296; + else gi_904 = gi_364 * gd_296; + if (gi_904 < g_stoplevel_292) gi_904 = g_stoplevel_292; + ld_8 = NormalizeDouble(Ask + gi_908 * Point, Digits); + ld_0 = NormalizeDouble(Bid - gi_904 * Point, Digits); + return (openOrder(OP_SELL, gd_304, Bid, ld_0, ld_8, S1_Reference, gi_388, 0)); +} + +int s1_buyControl() { + int li_ret_16; + double l_ord_takeprofit_0 = OrderTakeProfit(); + double l_ord_stoploss_8 = OrderStopLoss(); + if (l_ord_takeprofit_0 == 0.0 || l_ord_stoploss_8 == 0.0) { + if (l_ord_takeprofit_0 == 0.0) { + if (gi_896 < g_stoplevel_292) gi_896 = g_stoplevel_292; + l_ord_takeprofit_0 = NormalizeDouble(Ask + gi_896 * Point, Digits); + } + if (l_ord_stoploss_8 == 0.0) { + if (gi_900 < g_stoplevel_292) gi_900 = g_stoplevel_292; + l_ord_stoploss_8 = NormalizeDouble(Bid - gi_900 * Point, Digits); + } + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), l_ord_stoploss_8, l_ord_takeprofit_0, 0, Green); + } + if (s1_closeBuyRule()) { + li_ret_16 = closeOrder(0, Violet); + if (li_ret_16 < 0) return (li_ret_16); + } + if (gi_380 > 0) { + if (Bid - OrderOpenPrice() > Point * gd_296 * gi_380) { + if (OrderStopLoss() < Bid - Point * gd_296 * gi_380 || OrderStopLoss() == 0.0) { + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * gd_296 * gi_380, Digits), OrderTakeProfit(), 0, Green); + } + } + } + return (OrderTicket()); +} + +int s1_sellControl() { + int li_ret_16; + double l_ord_takeprofit_0 = OrderTakeProfit(); + double l_ord_stoploss_8 = OrderStopLoss(); + if (l_ord_takeprofit_0 == 0.0 || l_ord_stoploss_8 == 0.0) { + if (l_ord_takeprofit_0 == 0.0) { + if (gi_904 < g_stoplevel_292) gi_904 = g_stoplevel_292; + l_ord_takeprofit_0 = NormalizeDouble(Bid - gi_904 * Point, Digits); + } + if (l_ord_stoploss_8 == 0.0) { + if (gi_908 < g_stoplevel_292) gi_908 = g_stoplevel_292; + l_ord_stoploss_8 = NormalizeDouble(Ask + gi_908 * Point, Digits); + } + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), l_ord_stoploss_8, l_ord_takeprofit_0, 0, Red); + } + if (s1_closeSellRule()) { + li_ret_16 = closeOrder(1, Violet); + if (li_ret_16 < 0) return (li_ret_16); + } + if (gi_380 > 0) { + if (OrderOpenPrice() - Ask > Point * gd_296 * gi_380) { + if (OrderStopLoss() > Ask + Point * gd_296 * gi_380 || OrderStopLoss() == 0.0) { + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * gd_296 * gi_380, Digits), OrderTakeProfit(), 0, Red); + } + } + } + return (OrderTicket()); +} + +void run_Strategy1() { + int l_day_of_week_8; + gi_708 = TRUE; + if (g_ticket_724 == -2) { + g_ticket_724 = Recover(S1_Reference, OP_BUY); + if (g_ticket_724 >= 0) { + OrderSelect(g_ticket_724, SELECT_BY_TICKET); + OrderPrint(); + Print("Strategy1: Order found:"); + } + } + if (g_ticket_728 == -2) { + g_ticket_728 = Recover(S1_Reference, OP_SELL); + if (g_ticket_728 >= 0) { + OrderSelect(g_ticket_728, SELECT_BY_TICKET); + OrderPrint(); + Print("Strategy1: Order found:"); + } + } + s1_setRules(); + if ((gi_912 < gi_916 && (g_hour_272 >= gi_912 && g_hour_272 <= gi_916 - 1)) || (gi_912 >= gi_916 && g_hour_272 >= gi_912 || g_hour_272 <= gi_916 - 1)) gi_708 = TRUE; + else gi_708 = FALSE; + if (gi_708 && gi_516) { + l_day_of_week_8 = TimeDayOfWeek(gi_268); + if ((l_day_of_week_8 == 5 && g_hour_272 >= gi_912) || (l_day_of_week_8 == 1 && gi_912 >= gi_916 && g_hour_272 <= gi_916 - 1)) gi_708 = FALSE; + else + if (l_day_of_week_8 > 5 || l_day_of_week_8 < 1) gi_708 = FALSE; + } + if (gi_956 != gi_708) { + if (gi_708) gi_772++; + gi_956 = gi_708; + } + if (g_ticket_724 >= 0) { + if (OrderSelect(g_ticket_724, SELECT_BY_TICKET)) { + if (OrderCloseTime() == 0) g_ticket_724 = s1_buyControl(); + else g_ticket_724 = -1; + g_ord_profit_732 = OrderProfit(); + if (g_ticket_724 < 0) CountBalance(g_ord_profit_732); + } else { + g_ticket_724 = -2; + g_ord_profit_732 = 0; + } + } + if (g_ticket_728 >= 0) { + if (OrderSelect(g_ticket_728, SELECT_BY_TICKET)) { + if (OrderCloseTime() == 0) g_ticket_728 = s1_sellControl(); + else g_ticket_728 = -1; + g_ord_profit_740 = OrderProfit(); + if (g_ticket_728 < 0) CountBalance(g_ord_profit_740); + } else { + g_ticket_728 = -2; + g_ord_profit_740 = 0; + } + } + int li_0 = s1_openBuyRule(); + int li_4 = s1_openSellRule(); + if (!gi_708 || !gi_716 || gi_704) return; + if (NFA && !FIFOrule()) return; + if (g_datetime_960 != iTime(NULL, g_timeframe_360, gi_260) && li_0 && g_ticket_724 < 0) { + g_ticket_724 = s1_openBuy(); + if (g_ticket_724 < 0) return; + g_datetime_960 = iTime(NULL, g_timeframe_360, gi_260); + if (gi_452) { + gi_868 = FALSE; + gi_872 = TRUE; + } + gi_784++; + return; + } + if (g_datetime_964 != iTime(NULL, g_timeframe_360, gi_260) && li_4 && g_ticket_728 < 0) { + g_ticket_728 = s1_openSell(); + if (g_ticket_728 >= 0) { + g_datetime_964 = iTime(NULL, g_timeframe_360, gi_260); + if (gi_452) { + gi_868 = TRUE; + gi_872 = FALSE; + } + gi_784++; + } + } +} + +void s2_setRules() { + HideTestIndicators(TRUE); + if (gi_588 || gi_596) g_icci_972 = iCCI(NULL, g_timeframe_536, g_period_580, PRICE_TYPICAL, gi_260); + if (gi_592) g_icci_980 = iCCI(NULL, g_timeframe_536, g_period_584, PRICE_TYPICAL, gi_260); + g_ihigh_988 = iHigh(NULL, g_timeframe_536, iHighest(NULL, g_timeframe_536, MODE_HIGH, gi_576, 1)); + g_ilow_996 = iLow(NULL, g_timeframe_536, iLowest(NULL, g_timeframe_536, MODE_LOW, gi_576, 1)); + if (gi_632 > 0) { + if (g_spread_284 > gi_632 * gd_296) { + if (g_spread_288 < g_spread_284) { + Print("Strategy2: Safe spread limit exceeded: spread = ", g_spread_284); + if (gi_636) Print("Strategy2: Using DayDirection filter"); + } + gi_1020 = TRUE; + } else gi_1020 = FALSE; + } + HideTestIndicators(TRUE); + if (gi_1020) { + gi_1040 = gi_652; + gi_1044 = gi_656; + return; + } + gi_1040 = gi_644; + gi_1044 = gi_648; +} + +int s2_openBuyRule() { + double l_iclose_0; + double l_iclose_8; + int l_shift_16; + int l_shift_20; + if (gi_1020 && !gi_636) return (0); + if (gi_628 || gi_1020) { + if (g_datetime_264 - gi_280 < 43200.0) { + l_shift_16 = iBarShift(NULL, g_timeframe_536, gi_280 - 86400); + l_shift_20 = iBarShift(NULL, g_timeframe_536, gi_280); + } else { + l_shift_16 = iBarShift(NULL, g_timeframe_536, gi_280); + l_shift_20 = gi_260; + } + l_iclose_8 = iClose(NULL, g_timeframe_536, l_shift_16); + l_iclose_0 = iClose(NULL, g_timeframe_536, l_shift_20); + if (l_iclose_0 < l_iclose_8) return (0); + } + return (s2_Buy(Ask, Bid, g_icci_972, g_icci_980, g_ilow_996, g_ihigh_988, gi_588, gi_592)); +} + +int s2_openSellRule() { + double l_iclose_0; + double l_iclose_8; + int l_shift_16; + int l_shift_20; + if (gi_1020 && !gi_636) return (0); + if (gi_628 || gi_1020) { + if (g_datetime_264 - gi_280 < 43200.0) { + l_shift_16 = iBarShift(NULL, g_timeframe_536, gi_280 - 86400); + l_shift_20 = iBarShift(NULL, g_timeframe_536, gi_280); + } else { + l_shift_16 = iBarShift(NULL, g_timeframe_536, gi_280); + l_shift_20 = gi_260; + } + l_iclose_8 = iClose(NULL, g_timeframe_536, l_shift_16); + l_iclose_0 = iClose(NULL, g_timeframe_536, l_shift_20); + if (l_iclose_0 > l_iclose_8) return (0); + } + return (s2_Sell(Ask, Bid, g_icci_972, g_icci_980, g_ilow_996, g_ihigh_988, gi_588, gi_592)); +} + +bool s2_closeBuyRule() { + double l_ord_profit_0; + if (Stealth || OrderTakeProfit() == 0.0) { + if (gi_540 > 0) + if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_540 * Point * gd_296, Digits)) return (TRUE); + } + if (OrderStopLoss() == 0.0) { + if (gi_1028 > 0) + if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_1028 * Point * gd_296, Digits)) return (TRUE); + } + if (gi_596) { + if (g_ticket_1048 != OrderTicket()) { + gi_1052 = 0; + gi_1056 = 0; + g_datetime_1064 = OrderOpenTime(); + g_datetime_1060 = g_datetime_1064; + g_ticket_1048 = OrderTicket(); + g_ord_open_price_1068 = OrderOpenPrice(); + } + l_ord_profit_0 = OrderProfit(); + if (Ask > g_ord_open_price_1068) { + gi_1052 += g_datetime_264 - g_datetime_1060; + g_datetime_1060 = g_datetime_264; + } else { + gi_1056 += g_datetime_264 - g_datetime_1060; + g_datetime_1060 = g_datetime_264; + } + if (g_datetime_264 - g_datetime_1064 > 3600.0 * gd_600) { + if (g_icci_972 > 0.0 && l_ord_profit_0 > 0.0 && gi_1052 < gi_1056) return (TRUE); + if (g_icci_972 > 100.0 && l_ord_profit_0 > 0.0) return (TRUE); + if (g_datetime_264 - g_datetime_1064 > 3600.0 * gd_608 && l_ord_profit_0 > 0.0) return (TRUE); + if (g_datetime_264 - g_datetime_1064 > 3600.0 * gd_616) return (TRUE); + } + } + if (gi_624) return (Bid >= g_ihigh_988); + return (Bid >= g_ihigh_1004); +} + +bool s2_closeSellRule() { + double l_ord_profit_0; + if (Stealth || OrderTakeProfit() == 0.0) { + if (gi_540 > 0) + if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_540 * Point * gd_296, Digits)) return (TRUE); + } + if (OrderStopLoss() == 0.0) { + if (gi_1036 > 0) + if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_1036 * Point * gd_296, Digits)) return (TRUE); + } + if (gi_596) { + if (g_ticket_1076 != OrderTicket()) { + gi_1080 = 0; + gi_1084 = 0; + g_datetime_1092 = OrderOpenTime(); + g_datetime_1088 = g_datetime_1092; + g_ticket_1076 = OrderTicket(); + g_ord_open_price_1096 = OrderOpenPrice(); + } + l_ord_profit_0 = OrderProfit(); + if (Bid < g_ord_open_price_1096) { + gi_1080 += g_datetime_264 - g_datetime_1088; + g_datetime_1088 = g_datetime_264; + } else { + gi_1084 += g_datetime_264 - g_datetime_1088; + g_datetime_1088 = g_datetime_264; + } + if (g_datetime_264 - g_datetime_1092 > 3600.0 * gd_600) { + if (g_icci_972 < 0.0 && l_ord_profit_0 > 0.0 && gi_1080 < gi_1084) return (TRUE); + if (g_icci_972 < -100.0 && l_ord_profit_0 > 0.0) return (TRUE); + if (g_datetime_264 - g_datetime_1092 > 3600.0 * gd_608 && l_ord_profit_0 > 0.0) return (TRUE); + if (g_datetime_264 - g_datetime_1092 > 3600.0 * gd_616) return (TRUE); + } + } + if (gi_624) return (Ask <= g_ilow_996); + return (Ask <= g_ilow_1012); +} + +int s2_openBuy() { + double ld_0 = 0; + double ld_8 = 0; + if (gd_556 > 0.0) { + gi_1028 = gd_556 * (g_ihigh_988 - g_ilow_996) / Point; + if (gi_548 > 0 && gi_1028 > gi_548 * gd_296) gi_1028 = gi_548 * gd_296; + if (gi_1028 < gi_552 * gd_296) gi_1028 = gi_552 * gd_296; + } else gi_1028 = gi_552 * gd_296; + if (gi_1028 < g_stoplevel_292) gi_1028 = g_stoplevel_292; + if (Stealth) gi_1024 = gi_544 * gd_296; + else gi_1024 = gi_540 * gd_296; + if (gi_1024 < g_stoplevel_292) gi_1024 = g_stoplevel_292; + ld_8 = NormalizeDouble(Bid - gi_1028 * Point, Digits); + ld_0 = NormalizeDouble(Ask + gi_1024 * Point, Digits); + return (openOrder(OP_BUY, gd_304, Ask, ld_0, ld_8, S2_Reference, gi_568, 0)); +} + +int s2_openSell() { + double ld_0 = 0; + double ld_8 = 0; + if (gd_556 > 0.0) { + gi_1036 = gd_556 * (g_ihigh_988 - g_ilow_996) / Point; + if (gi_548 > 0 && gi_1036 > gi_548 * gd_296) gi_1036 = gi_548 * gd_296; + if (gi_1036 < gi_552 * gd_296) gi_1036 = gi_552 * gd_296; + } else gi_1036 = gi_552 * gd_296; + if (gi_1036 < g_stoplevel_292) gi_1036 = g_stoplevel_292; + if (Stealth) gi_1032 = gi_544 * gd_296; + else gi_1032 = gi_540 * gd_296; + if (gi_1032 < g_stoplevel_292) gi_1032 = g_stoplevel_292; + ld_8 = NormalizeDouble(Ask + gi_1036 * Point, Digits); + ld_0 = NormalizeDouble(Bid - gi_1032 * Point, Digits); + return (openOrder(OP_SELL, gd_304, Bid, ld_0, ld_8, S2_Reference, gi_572, 0)); +} + +int s2_buyControl() { + int li_ret_16; + double l_ord_takeprofit_0 = OrderTakeProfit(); + double l_ord_stoploss_8 = OrderStopLoss(); + if (l_ord_takeprofit_0 == 0.0 || l_ord_stoploss_8 == 0.0) { + if (l_ord_takeprofit_0 == 0.0) { + if (gi_1024 < g_stoplevel_292) gi_1024 = g_stoplevel_292; + l_ord_takeprofit_0 = NormalizeDouble(Ask + gi_1024 * Point, Digits); + } + if (l_ord_stoploss_8 == 0.0) { + if (gi_1028 < g_stoplevel_292) gi_1028 = g_stoplevel_292; + l_ord_stoploss_8 = NormalizeDouble(Bid - gi_1028 * Point, Digits); + } + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), l_ord_stoploss_8, l_ord_takeprofit_0, 0, Green); + } + if (s2_closeBuyRule()) { + li_ret_16 = closeOrder(0, Violet); + if (li_ret_16 < 0) return (li_ret_16); + } + if (gi_564 > 0) { + if (Bid - OrderOpenPrice() > Point * gd_296 * gi_564) { + if (OrderStopLoss() < Bid - Point * gd_296 * gi_564 || OrderStopLoss() == 0.0) { + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * gd_296 * gi_564, Digits), OrderTakeProfit(), 0, Green); + } + } + } + return (OrderTicket()); +} + +int s2_sellControl() { + int li_ret_16; + double l_ord_takeprofit_0 = OrderTakeProfit(); + double l_ord_stoploss_8 = OrderStopLoss(); + if (l_ord_takeprofit_0 == 0.0 || l_ord_stoploss_8 == 0.0) { + if (l_ord_takeprofit_0 == 0.0) { + if (gi_1032 < g_stoplevel_292) gi_1032 = g_stoplevel_292; + l_ord_takeprofit_0 = NormalizeDouble(Bid - gi_1032 * Point, Digits); + } + if (l_ord_stoploss_8 == 0.0) { + if (gi_1036 < g_stoplevel_292) gi_1036 = g_stoplevel_292; + l_ord_stoploss_8 = NormalizeDouble(Ask + gi_1036 * Point, Digits); + } + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), l_ord_stoploss_8, l_ord_takeprofit_0, 0, Red); + } + if (s2_closeSellRule()) { + li_ret_16 = closeOrder(1, Violet); + if (li_ret_16 < 0) return (li_ret_16); + } + if (gi_564 > 0) { + if (OrderOpenPrice() - Ask > Point * gd_296 * gi_564) { + if (OrderStopLoss() > Ask + Point * gd_296 * gi_564 || OrderStopLoss() == 0.0) { + waitForContext(); + OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * gd_296 * gi_564, Digits), OrderTakeProfit(), 0, Red); + } + } + } + return (OrderTicket()); +} + +void run_Strategy2() { + int l_day_of_week_8; + gi_712 = TRUE; + if (g_ticket_748 == -2) { + g_ticket_748 = Recover(S2_Reference, OP_BUY); + if (g_ticket_748 >= 0) { + OrderSelect(g_ticket_748, SELECT_BY_TICKET); + OrderPrint(); + Print("Strategy2: Order found:"); + } + } + if (g_ticket_752 == -2) { + g_ticket_752 = Recover(S2_Reference, OP_SELL); + if (g_ticket_752 >= 0) { + OrderSelect(g_ticket_752, SELECT_BY_TICKET); + OrderPrint(); + Print("Strategy2: Order found:"); + } + } + s2_setRules(); + if ((gi_1040 < gi_1044 && (g_hour_272 >= gi_1040 && g_hour_272 <= gi_1044 - 1)) || (gi_1040 >= gi_1044 && g_hour_272 >= gi_1040 || g_hour_272 <= gi_1044 - 1)) gi_712 = TRUE; + else gi_712 = FALSE; + if (gi_712 && gi_640) { + l_day_of_week_8 = TimeDayOfWeek(gi_268); + if ((l_day_of_week_8 == 5 && g_hour_272 >= gi_1040) || (l_day_of_week_8 == 1 && gi_1040 >= gi_1044 && g_hour_272 <= gi_1044 - 1)) gi_712 = FALSE; + else + if (l_day_of_week_8 > 5 || l_day_of_week_8 < 1) gi_712 = FALSE; + } + if (gi_1104 != gi_712) { + if (gi_712) { + g_ord_profit_756 = 0; + g_ord_profit_764 = 0; + gi_776++; + } + gi_1104 = gi_712; + } + if (g_ticket_748 >= 0) { + if (OrderSelect(g_ticket_748, SELECT_BY_TICKET)) { + if (OrderCloseTime() == 0) g_ticket_748 = s2_buyControl(); + else g_ticket_748 = -1; + g_ord_profit_756 = OrderProfit(); + if (g_ticket_748 < 0) CountBalance(g_ord_profit_756); + } else { + g_ticket_748 = -2; + g_ord_profit_756 = 0; + } + } + if (g_ticket_752 >= 0) { + if (OrderSelect(g_ticket_752, SELECT_BY_TICKET)) { + if (OrderCloseTime() == 0) g_ticket_752 = s2_sellControl(); + else g_ticket_752 = -1; + g_ord_profit_764 = OrderProfit(); + if (g_ticket_752 < 0) CountBalance(g_ord_profit_764); + } else { + g_ticket_752 = -2; + g_ord_profit_764 = 0; + } + } + int li_0 = s2_openBuyRule(); + int li_4 = s2_openSellRule(); + if (!gi_712 || !gi_716 || gi_704) return; + if (NFA && !FIFOrule()) return; + if (g_datetime_1108 != iTime(NULL, g_timeframe_536, gi_260) && li_0 && g_ticket_748 < 0 && g_ord_profit_756 >= 0.0) { + g_ticket_748 = s2_openBuy(); + if (g_ticket_748 < 0) return; + g_datetime_1108 = iTime(NULL, g_timeframe_536, gi_260); + g_ihigh_1004 = g_ihigh_988; + g_ilow_1012 = g_ilow_996; + g_ord_profit_764 = 0; + gi_968++; + return; + } + if (g_datetime_1112 != iTime(NULL, g_timeframe_536, gi_260) && li_4 && g_ticket_752 < 0 && g_ord_profit_764 >= 0.0) { + g_ticket_752 = s2_openSell(); + if (g_ticket_752 >= 0) { + g_datetime_1112 = iTime(NULL, g_timeframe_536, gi_260); + g_ihigh_1004 = g_ihigh_988; + g_ilow_1012 = g_ilow_996; + g_ord_profit_756 = 0; + gi_968++; + } + } +} + +void Refresh(bool ai_0) { + double lda_4[1]; + int lia_8[4]; + if (ai_0) RefreshRates(); + g_datetime_264 = TimeCurrent(); + if (!IsTesting() && AutoServerGmtOffset || AutoLocalGmtOffset) { + gi_328 = GetGmtOffset(gi_332, TimeYear(g_datetime_264), TimeMonth(g_datetime_264), TimeDay(g_datetime_264), TimeHour(g_datetime_264), TimeMinute(g_datetime_264), TimeSeconds(g_datetime_264), 0, AutoServerGmtOffset, lda_4, lia_8); + if (gi_328 == 4 && !AutoLocalGmtOffset) gi_328 = 0; + else GmtOffset = lda_4[0]; + gi_520 = lia_8[0]; + gi_524 = lia_8[1]; + gi_644 = lia_8[2]; + gi_648 = lia_8[3]; + } + gi_268 = g_datetime_264 - 3600.0 * GmtOffset; + g_hour_272 = TimeHour(gi_268); + gi_280 = g_datetime_264 - 3600.0 * g_hour_272 - 60 * TimeMinute(gi_268) - TimeSeconds(gi_268); + g_spread_284 = MarketInfo(Symbol(), MODE_SPREAD); + g_stoplevel_292 = MarketInfo(Symbol(), MODE_STOPLEVEL); + gd_296 = 0.0001 / Point; + if (Digits < 4) gd_296 = 100.0 * gd_296; +} + +string BPrint(bool ai_0) { + if (ai_0) return ("True"); + return ("False"); +} + +string CPrint(bool ai_0, string as_4, string as_12 = "") { + if (ai_0) return (as_4); + return (as_12); +} + +string OpPrint(int ai_0) { + switch (ai_0) { + case 0: + return ("Buy"); + case 1: + return ("Sell"); + } + return ("Order"); +} + +string GMPrint(int ai_0) { + switch (ai_0) { + case 1: + return ("automatic: server"); + case 2: + return ("automatic: server"); + case 4: + return ("automatic: local"); + } + return ("manual"); +} + +string DPrint(int ai_0) { + switch (ai_0) { + case 1: + return ("Correction"); + case 3: + return ("Upward Impulse"); + case 2: + return ("Downward Impulse"); + } + return (""); +} + +string PPrint(int ai_0) { + int li_4 = MathMod(ai_0, 5); + return (gsa_1116[li_4]); +} + +string PrintStatus(int ai_0) { + switch (ai_0) { + case 1: + return ("Assessing market volume"); + case 2: + return ("Checking volatility"); + case 3: + return ("Monitoring spread"); + case 4: + return ("Determining direction"); + case 5: + return ("Reviewing price range"); + case 6: + return ("Calculating probability"); + } + return (""); +} + +void PrintResponse(int ai_0, int ai_4 = -1, int ai_8 = -1) { + if (ai_4 == -1) ai_4 = gi_664; + if (ai_8 == -1) ai_8 = gi_660; + gi_664 = ai_4; + gi_660 = ai_8; + if (ai_0 & 16384 > 0) PrintLN("Authenticated", TextColor1); + else PrintLN("Authentication failed - error(" + ai_0 + ")", TextColor1); + if (ai_0 & 512 > 0) PrintLN("Attention: Upgrade available", TextColor1); + if (ai_0 & 1024 > 0) PrintLN("Error: Upgrade required", TextColor1); + if (ai_0 & 1 > 0) PrintLN("Error: WinINet initialisation failed", TextColor1); + if (ai_0 & 2 > 0) PrintLN("Error: WinINet connection failed", TextColor1); + if (ai_0 & 4 > 0) PrintLN("Error: Invalid account number", TextColor1); + if (ai_0 & 8 > 0) PrintLN("Error: Invalid account status", TextColor1); + if (ai_0 & 16 > 0) PrintLN("Error: Dll and Expert versions mismatch", TextColor1); + if (ai_0 & 128 > 0) PrintLN("Error: Unable to retrieve authentication code", TextColor1); + if (ai_0 & 256 > 0) PrintLN("Error: Server response failure", TextColor1); + if (ai_0 & 2048 > 0) PrintLN("Error: Invalid authorisation details", TextColor1); + if (ai_0 & 4096 > 0) PrintLN("Error: Authorisation declined", TextColor1); +} + +string GetObjName(int ai_0) { + return (StringConcatenate("Swissy Accu-Scalper", " lb: ", ai_0)); +} + +void GetPos(int ai_0, int &ai_4, int &ai_8) { + string l_name_12 = GetObjName(ai_0); + if (ObjectFind(l_name_12) == 0) { + ai_4 = ObjectGet(l_name_12, OBJPROP_XDISTANCE); + ai_8 = ObjectGet(l_name_12, OBJPROP_YDISTANCE); + } +} + +void PrintLN(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) { + if (a_color_8 == CLR_NONE) a_color_8 = TextColor1; + if (ai_12 == -1) ai_12 = gi_664; + if (ad_16 == -1.0) ad_16 = gi_660; + string l_name_28 = GetObjName(ai_12); + if (ObjectFind(l_name_28) != 0) { + ObjectCreate(l_name_28, OBJ_LABEL, 0, 0, 0); + ObjectSet(l_name_28, OBJPROP_CORNER, 0); + } + ObjectSetText(l_name_28, a_text_0, 8, "Tahoma", a_color_8); + ObjectSet(l_name_28, OBJPROP_XDISTANCE, gi_676 + ai_24); + ObjectSet(l_name_28, OBJPROP_YDISTANCE, gi_672 + 14.0 * ad_16); + if (gi_660 < ad_16 + 1.0) gi_660 = ad_16 + 1.0; + if (gi_664 < ai_12 + 1) gi_664 = ai_12 + 1; + if (gi_668 < ai_12) gi_668 = ai_12; +} + +void PrintSep(int ai_0 = -1, double ad_4 = -1.0, int ai_12 = 0) { + if (ai_0 == -1) ai_0 = gi_664; + if (ad_4 == -1.0) ad_4 = gi_660; + PrintLN("_______", TextColor2, ai_0, ad_4 - 0.3, ai_12); + if (gi_660 < ad_4 + 1.0) gi_660 = ad_4 + 1.0; +} + +void Deleteobjects(int ai_0, int ai_4) { + for (int li_8 = ai_0; li_8 <= ai_4; li_8++) ObjectDelete(GetObjName(li_8)); +} + +double Base36Decode(string as_0) { + int li_24; + as_0 = StringUpper(as_0); + int l_str_len_8 = StringLen(as_0); + double ld_ret_12 = 0; + for (int li_20 = 0; li_20 < l_str_len_8; li_20++) { + li_24 = StringFind(gs_1128, StringSubstr(as_0, l_str_len_8 - li_20 - 1, 1)); + ld_ret_12 += li_24 * MathPow(36, li_20); + } + return (ld_ret_12); +} + +string Base36Encode(double ad_0) { + string l_str_concat_8 = ""; + for (ad_0 = MathAbs(ad_0); ad_0 >= 1.0; ad_0 = MathFloor(ad_0 / 36.0)) l_str_concat_8 = StringConcatenate(StringSubstr(gs_1128, MathMod(ad_0, 36), 1), l_str_concat_8); + return (l_str_concat_8); +} + +string StringUpper(string as_0) { + int li_8; + int li_20; + int l_str_len_16 = StringLen(as_0); + for (int li_12 = 0; li_12 < l_str_len_16; li_12++) { + li_20 = 0; + li_8 = StringGetChar(as_0, li_12); + if (li_8 > '`' && li_8 < '{') li_20 = li_8 - 32; + if (li_8 > 'Я' && li_8 < 256) li_20 = li_8 - 32; + if (li_8 == 'ё') li_20 = 168; + if (li_20 > 0) as_0 = StringSetChar(as_0, li_12, li_20); + } + return (as_0); +} + +int start() { + int li_4; + int li_8; + if (!gi_244 && !gi_248) return (0); + int li_0 = GetState(); + if (Bars < 100) { + Print("Bars less than 100"); + return (0); + } + if (gi_320) { + gi_320 = FALSE; + li_4 = RecoverTrades(); + Print("Orders in history: ", li_4, " profit made: ", DoubleToStr(gd_688, 2)); + } + if (gi_220 && RiskLevel > 0.0) { + if (gi_240) while (AccountBalance() < gd_312 / (gd_232 + 1.0)) gd_312 /= (gd_232 + 1.0); + while (AccountBalance() > gd_312) gd_312 *= (gd_232 + 1.0); + gd_304 = MMLots(RiskLevel, gd_312, li_8); + } else { + if (RiskLevel > 0.0) { + gd_304 = MMLots(RiskLevel, AccountFreeMargin(), li_8); + if (RecoveryMode) gd_304 = RecoveryLot(gd_304); + } else gd_304 = NormalizeLots(LotSize, li_8); + } + double ld_12 = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED) * gd_304, 8); + g_spread_288 = g_spread_284; + Refresh(0); + gi_704 = NormalizeDouble(AccountFreeMargin(), 8) < ld_12; + gi_716 = IsTradeTime(Symbol(), TimeYear(gi_268), TimeMonth(gi_268), TimeDay(gi_268), gi_252); + if (NFA) RefreshOrders(); + if (gi_244) run_Strategy1(); + Refresh(1); + gi_704 = NormalizeDouble(AccountFreeMargin(), 8) < ld_12; + if (gi_248) run_Strategy2(); + if (IsTesting() && !IsVisualMode()) return (0); + GetPos(0, gi_676, gi_672); + gi_664 = 0; + gi_660 = 0; + PrintLN(gs_336, TextColor2); + PrintSep(); + PrintResponse(gi_324); + PrintSep(); + PrintLN(gs_344); + PrintLN(gs_352, TextColor2, gi_664, gi_660 - 1, 5 * (StringLen(gs_344) + 1)); + PrintSep(); + string ls_20 = DoubleToStr(GmtOffset, 1); + if (!IsTesting()) ls_20 = StringConcatenate(ls_20, " (", GMPrint(gi_328), ")"); + PrintLN("ServerTime:"); + PrintLN(TimeToStr(g_datetime_264), TextColor2, gi_664, gi_660 - 1, 60); + PrintLN("UtcTime:"); + PrintLN(TimeToStr(gi_268), TextColor2, gi_664, gi_660 - 1, 45); + PrintLN("GmtOffset:"); + PrintLN(ls_20, TextColor2, gi_664, gi_660 - 1, 55); + PrintSep(); + PrintLN("Digits:"); + PrintLN(Digits, TextColor2, gi_664, gi_660 - 1, 35); + PrintLN("Spread:"); + PrintLN(StringConcatenate(DoubleToStr(g_spread_284 / gd_296, 1), " (", g_spread_284, " pips)"), TextColor2, gi_664, gi_660 - 1, 40); + PrintSep(); + PrintLN("Lot:"); + PrintLN(DoubleToStr(gd_304, 2), TextColor2, gi_664, gi_660 - 1, 25); + switch (li_8) { + case 1: + PrintLN("Maximum Lot size exeeded!"); + break; + case -1: + PrintLN("Minimum Lot size exeeded!"); + } + if (gi_1136 != gi_704) { + if (gi_704) Print("Not enough money! Available margin = ", DoubleToStr(AccountFreeMargin(), 2), ", Required margin = ", DoubleToStr(ld_12, 2)); + gi_1136 = gi_704; + } + if (gi_704) { + PrintSep(); + PrintLN("Not enough money!"); + PrintLN("Available margin ="); + PrintLN(DoubleToStr(AccountFreeMargin(), 2), TextColor2, gi_664, gi_660 - 1, 90); + PrintLN("Required margin ="); + PrintLN(DoubleToStr(ld_12, 2), TextColor2, gi_664, gi_660 - 1, 90); + } + PrintSep(); + if (IsTesting()) PrintLN("Backtesting"); + else PrintLN(PrintStatus(GetStatus())); + PrintSep(); + if (gi_244 && gi_484) { + if (gi_920 == 0) PrintLN("Analyzing market"); + else PrintLN(DPrint(gi_920) + " detected"); + if (g_datetime_264 <= gi_928 && gi_920 != gi_924 && gi_924 != 0) PrintLN(DPrint(gi_924) + " fading: " + TimeToStr(gi_928 - g_datetime_264, TIME_SECONDS)); + } else PrintLN(CPrint(gi_708 || gi_712, "Running", "Collecting Data")); + if (NFA && g_count_720 > 0) { + PrintSep(); + PrintLN("Waiting for trades to close: "); + PrintLN(g_count_720, TextColor2, gi_664, gi_660 - 1, 125); + } + if (g_ticket_724 >= 0 || g_ticket_728 >= 0 || g_ticket_748 >= 0 || g_ticket_728 >= 0) { + PrintSep(); + if (g_ticket_724 >= 0) PrintLN("Strategy1: Long position open"); + if (g_ticket_728 >= 0) PrintLN("Strategy1: Short position open"); + if (g_ticket_748 >= 0) PrintLN("Strategy2: Long position open"); + if (g_ticket_752 >= 0) PrintLN("Strategy2: Short position open"); + } + Deleteobjects(gi_664, gi_668); + gi_668 = gi_664 - 1; + ObjectsRedraw(); + return (0); +} \ No newline at end of file diff --git a/Annajah_Forex_Pilot_V1.mq4 b/Annajah_Forex_Pilot_V1.mq4 new file mode 100644 index 0000000..b78a881 --- /dev/null +++ b/Annajah_Forex_Pilot_V1.mq4 @@ -0,0 +1,267 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.223.1c [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +extern double Lots = 0.1; +extern double MaximumRisk = 0.08; +extern double TakeProfit = 20.0; +extern double TrailingStop = 30.0; +extern double DecreaseFactor = 3.0; +extern double MovingPeriod = 30.0; +extern double MovingShift = 0.0; +extern double sarstep = 0.0001; +extern string Stockhastick = "Between 1 -49: Recommended 27"; +extern double istocklevel = 27.0; +extern string Close_Level = "Between 1 -49: Recommended 35"; +extern double CloseLevel = 37.0; +extern double max = 92.0; +extern double min = 8.0; +extern bool Ready = TRUE; +extern bool Trade = TRUE; +extern bool reverse = FALSE; +extern bool optimize = FALSE; +extern bool myfinance = FALSE; +string gs_208; +string gs_dummy_216; +string gs_224; +string gs_232; +string gs_240; +string gs_248; + +int CalculateCurrentOrders(string as_unused_0) { + int l_count_8 = 0; + int l_count_12 = 0; + for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) { + if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES) == FALSE) break; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == 20050610) { + if (OrderType() == OP_BUY) l_count_8++; + if (OrderType() == OP_SELL) l_count_12++; + } + } + if (l_count_8 > 0) return (l_count_8); + return (-l_count_12); +} + +double LotsOptimized() { + double l_lots_0 = Lots; + int l_hist_total_8 = OrdersHistoryTotal(); + int l_count_12 = 0; + l_lots_0 = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 1000.0, 0); + if (DecreaseFactor > 0.0) { + for (int l_pos_16 = l_hist_total_8 - 1; l_pos_16 >= 0; l_pos_16--) { + if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_HISTORY) == FALSE) { + Print("Error in history!"); + break; + } + if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue; + if (OrderProfit() > 0.0) break; + if (OrderProfit() < 0.0) l_count_12++; + } + if (l_count_12 > 1) l_lots_0 = NormalizeDouble(l_lots_0 - l_lots_0 * l_count_12 / DecreaseFactor, 1); + } + if (l_lots_0 < 0.1) l_lots_0 = 0.1; + if (l_lots_0 > 50.0) l_lots_0 = 50; + return (l_lots_0); +} + +int init() { + ObjectCreate("lineSupport", OBJ_HLINE, 0, 0, 0); + ObjectSet("lineSupport", OBJPROP_COLOR, Blue); + ObjectCreate("lineResist", OBJ_HLINE, 0, 0, 0); + ObjectSet("lineResist", OBJPROP_COLOR, Red); + ObjectCreate("LongTermTrend", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("LongTermTrend", OBJPROP_XDISTANCE, 10); + ObjectSet("LongTermTrend", OBJPROP_YDISTANCE, 20); + ObjectSetText("LongTermTrend", "Long Term", 14, "Tahoma", Aqua); + ObjectCreate("MidTermTrend", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("MidTermTrend", OBJPROP_XDISTANCE, 10); + ObjectSet("MidTermTrend", OBJPROP_YDISTANCE, 35); + ObjectSetText("MidTermTrend", "Mid Term", 14, "Tahoma", Aqua); + ObjectCreate("ShortTermTrend", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("ShortTermTrend", OBJPROP_XDISTANCE, 10); + ObjectSet("ShortTermTrend", OBJPROP_YDISTANCE, 50); + ObjectSetText("ShortTermTrend", "Short Term", 14, "Tahoma", Aqua); + ObjectCreate("CurrentPrice", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("CurrentPrice", OBJPROP_XDISTANCE, 10); + ObjectSet("CurrentPrice", OBJPROP_YDISTANCE, 65); + ObjectSetText("CurrentPrice", "Current Price ?", 14, "Tahoma", Lime); + ObjectCreate("lblTrendType4", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("lblTrendType4", OBJPROP_XDISTANCE, 420); + ObjectSet("lblTrendType4", OBJPROP_YDISTANCE, 10); + ObjectSetText("lblTrendType4", "Indicator By AyobHussin (http://ayobhussin.com/myforex)", 10, "Tahoma", LimeGreen); + ObjectCreate("lblTrendType6", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("lblTrendType6", OBJPROP_XDISTANCE, 420); + ObjectSet("lblTrendType6", OBJPROP_YDISTANCE, 25); + ObjectSetText("lblTrendType6", "Kelajuan ", 10, "Tahoma", Aqua); + ObjectCreate("lblAlerToBuy", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("lblAlerToBuy", OBJPROP_XDISTANCE, 420); + ObjectSet("lblAlerToBuy", OBJPROP_YDISTANCE, 40); + ObjectSetText("lblAlerToBuy", "Buy/Sell ", 10, "Tahoma", Aqua); + ObjectCreate("lblText", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("lblText", OBJPROP_XDISTANCE, 420); + ObjectSet("lblText", OBJPROP_YDISTANCE, 60); + ObjectSetText("lblText", "Late? ", 10, "Tahoma", Aqua); + ObjectCreate("read", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("read", OBJPROP_XDISTANCE, 10); + ObjectSet("read", OBJPROP_YDISTANCE, 120); + ObjectSetText("read", "Not Ready", 10, "Tahoma", Aqua); + return (0); +} + +void CheckForOpen() { + int l_ticket_8; + double l_ima_12; + double l_ima_20; + double l_ima_28; + double l_ima_36; + double l_ima_44; + double l_istochastic_52; + double l_istochastic_60; + double l_isar_68; +// if (AccountNumber() != 889161533) { +// Alert("Wrong AccountNumber"); +// return; + // } + if (Volume[0] <= 1.0) { + l_ima_12 = iMA(NULL, 0, MovingPeriod, MovingShift, MODE_SMA, PRICE_CLOSE, 0); + l_ima_20 = iMA(NULL, 0, 240, MovingShift, MODE_SMA, PRICE_CLOSE, 0); + l_ima_28 = iMA(NULL, 0, 100, 100, MODE_SMA, PRICE_CLOSE, 0); + l_ima_36 = iMA(NULL, 0, 180, 0, MODE_SMA, PRICE_CLOSE, 0); + l_ima_44 = iMA(NULL, 0, 240, 0, MODE_SMA, PRICE_CLOSE, 0); + l_istochastic_52 = iStochastic(NULL, 0, 15, 7, 10, MODE_SMA, 0, MODE_MAIN, 0); + l_istochastic_60 = iStochastic(NULL, 0, 240, 5, 10, MODE_SMA, 0, MODE_MAIN, 0); + l_isar_68 = iSAR(NULL, 0, sarstep, 0.2, 0); + if (l_istochastic_52 >= max) gs_208 = "ReadyToSell..."; + if (l_istochastic_52 <= min) gs_208 = "ReadyToBuy..."; + if (l_istochastic_52 > min && l_istochastic_52 < max) gs_208 = "Stanby..."; + if (Close[1] > l_ima_12) gs_224 = "Up !"; + if (Close[1] < l_ima_12) gs_224 = "Down !"; + if (Trade != FALSE) { + if (gs_208 == "ReadyToSell...") { + if (optimize == TRUE) { + l_ticket_8 = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, 3, 0, Bid - TakeProfit * Point, "", 20050610, 0, Red); + if (reverse != TRUE) return; + l_ticket_8 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, 3, 0, Ask + TakeProfit * Point, "", 20050610, 0, Blue); + return; + } + if (optimize == FALSE) { + l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, Bid - TakeProfit * Point, "", 20050610, 0, Red); + if (reverse != TRUE) return; + l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, Ask + TakeProfit * Point, "", 20050610, 0, Blue); + return; + } + } + if (Trade != FALSE) { + if (gs_208 == "ReadyToBuy...") { + if (optimize != TRUE) { + if (optimize != FALSE) { + } + } + } + } + } + } +} + +void CheckForClose() { + double l_ima_0; + double l_isar_24; + double l_istochastic_8 = iStochastic(NULL, 0, 15, 3, 1, MODE_SMA, 0, MODE_MAIN, 0); + double l_ima_16 = iMA(NULL, 0, 50, 30, MODE_SMA, PRICE_CLOSE, 0); + if (Volume[0] <= 1.0) { + l_ima_0 = iMA(NULL, 0, MovingPeriod, MovingShift, MODE_SMA, PRICE_CLOSE, 0); + l_isar_24 = iSAR(NULL, 0, 0.0001, 0.2, 0); + for (int l_pos_32 = 0; l_pos_32 < OrdersTotal(); l_pos_32++) { + if (OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES) == FALSE) break; + if (OrderMagicNumber() != 20050610 || OrderSymbol() != Symbol()) continue; + if (OrderType() == OP_BUY) { + if (!(Bid > l_isar_24 && l_istochastic_8 > CloseLevel + 50.0 || Bid < l_isar_24 && l_istochastic_8 > CloseLevel + 50.0)) break; + OrderClose(OrderTicket(), OrderLots(), Bid, 3, White); + return; + } + if (TrailingStop > 0.0) { + if (Bid - OrderOpenPrice() > Point * TrailingStop) + if (OrderStopLoss() < Bid - Point * TrailingStop) break; + } + if (OrderType() == OP_SELL) { + if (!(Ask < l_isar_24 && l_istochastic_8 < 50 - CloseLevel || Ask > l_isar_24 && l_istochastic_8 < 50 - CloseLevel)) break; + OrderClose(OrderTicket(), OrderLots(), Ask, 3, White); + return; + } + if (TrailingStop > 0.0) { + if (OrderOpenPrice() - Ask > Point * TrailingStop) + if (OrderStopLoss() > Ask + Point * TrailingStop || OrderStopLoss() == 0.0) break; + } + } + } +} + +void start() { + double l_color_0; + double l_color_8; + double l_color_16; + double l_color_24; + double l_color_32; + double l_ima_40 = iMA(NULL, 0, 10, MovingShift, MODE_SMA, PRICE_CLOSE, 0); + double l_isar_48 = iSAR(NULL, 0, 0.0001, 0.2, 0); + double l_isar_56 = iSAR(NULL, 0, 0.0002, 0.2, 0); + double l_isar_64 = iSAR(NULL, 0, 0.0003, 0.2, 0); + double l_istochastic_72 = iStochastic(NULL, 0, 15, 7, 10, MODE_SMA, 0, MODE_MAIN, 0); + if (l_istochastic_72 > 75.0) { + gs_208 = "ReadyToSell..."; + l_color_32 = Red; + } + if (l_istochastic_72 < 25.0) { + gs_208 = "ReadyToBuy..."; + l_color_32 = LimeGreen; + } + if (l_istochastic_72 > 25.0 && l_istochastic_72 < 75.0) { + gs_208 = "Stanby..."; + l_color_32 = Yellow; + } + if (Close[1] > l_ima_40) { + gs_224 = "Up !"; + l_color_16 = LimeGreen; + } + if (Close[1] < l_ima_40) { + gs_224 = "Down !"; + l_color_16 = Red; + } + if (l_ima_40 > l_isar_48) { + gs_248 = "UpTrend !"; + l_color_0 = LimeGreen; + } + if (l_ima_40 < l_isar_48) { + gs_248 = "DownTrend !"; + l_color_0 = Red; + } + if (l_ima_40 > l_isar_56) { + gs_240 = "UpTrend !"; + l_color_8 = LimeGreen; + } + if (l_ima_40 < l_isar_56) { + gs_240 = "DownTrend !"; + l_color_8 = Red; + } + if (l_ima_40 > l_isar_64) { + gs_232 = "UpTrend !"; + l_color_24 = LimeGreen; + } + if (l_ima_40 < l_isar_64) { + gs_232 = "DownTrend !"; + l_color_24 = Red; + } + Comment("Istochastic30 =", l_istochastic_72); + ObjectSetText("ShortTermTrend", "Short Term Trend => " + gs_232, 14, "Tohama", l_color_24); + ObjectSetText("MidTermTrend", "Mid Term Trend => " + gs_240, 14, "Tohama", l_color_8); + ObjectSetText("LongTermTrend", "Long Term Trend => " + gs_248, 14, "Tohama", l_color_0); + ObjectSetText("CurrentPrice", "Current Price => " + gs_224, 14, "Tohama", l_color_16); + ObjectSetText("read", "==> " + gs_208, 14, "Tohama", l_color_32); + if (Bars < 100 || IsTradeAllowed() == FALSE) return; + if (CalculateCurrentOrders(Symbol()) == 0) { + CheckForOpen(); + return; + } + CheckForClose(); +} \ No newline at end of file diff --git a/BossEA-TraXXon.mq4 b/BossEA-TraXXon.mq4 new file mode 100644 index 0000000..8e6fa03 --- /dev/null +++ b/BossEA-TraXXon.mq4 @@ -0,0 +1,811 @@ + +#property copyright "Copyright © 2009, Bekbolatov@fxmail.ru" +#property link "Bekbolatov@fxmail.ru" + +#import "Boss.DLL" + bool fun2(double a0, int a1, double a2, double a3, int a4, int a5, double a6); + bool fun3(double a0, int a1, double a2, double a3, int a4, int a5, double a6); + bool fun4(double a0, int a1, int a2); +#import + +extern string _Notification_for_place_ = "M15-EURGPB,EURCHF,GBPCHF,USDCAD only!"; +bool gi_84 = TRUE; +double gd_unused_88 = 0.1; +extern double ManyManagment_0_100 = 0.0; +extern double MaxSpread = 5.1; +bool gi_unused_112 = FALSE; +double gd_unused_116 = 1.5; +double gd_unused_124 = 10.0; +extern int GMT_offset = 1; +bool gi_136 = TRUE; +bool gi_140 = TRUE; +int gi_144 = 0; +bool gi_148 = TRUE; +bool gi_152 = TRUE; +bool gi_156 = FALSE; +int gi_160 = 0; +bool gi_164 = FALSE; +int g_period_168 = 100; +int g_applied_price_172 = PRICE_CLOSE; +int g_ma_method_176 = MODE_SMA; +extern int MagicNumber = 543210; +int g_color_184 = Blue; +int g_color_188 = Red; +extern bool WriteLog = TRUE; +extern bool WriteDebugLog = FALSE; +extern bool PrintLogOnChart = TRUE; +string gs_unused_204 = "012345"; +int gi_212 = 6; +int gi_216 = 112; +int gi_220 = 25; +int gi_224 = 60; +int gi_228 = 3; +int gi_232 = 140; +int gi_236 = 2; +int gi_240 = 170; +int gi_244 = 0; +int gi_248 = 200; +int gi_252 = -1; +int gi_256 = 240; +int gi_260 = -4; +double gd_264 = 0.3; +int gi_272 = 5; +int gi_276 = 53; +int gi_280 = 25; +int gi_284 = 75; +int gi_288 = 3; +int gi_292 = 100; +int gi_296 = 2; +int gi_300 = 135; +int gi_304 = 0; +int gi_308 = 210; +int gi_312 = -1; +int gi_316 = 245; +int gi_320 = -4; +double gd_324 = 0.2; +int gi_332 = 10; +int gi_336 = 75; +int gi_340 = 75; +int gi_344 = 80; +int gi_348 = 3; +int gi_352 = 145; +int gi_356 = 2; +int gi_360 = 180; +int gi_364 = 0; +int gi_368 = 205; +int gi_372 = -1; +int gi_376 = 250; +int gi_380 = -4; +double gd_384 = 0.15; +int gi_392 = 10; +int gi_396 = 58; +int gi_400 = 23; +int gi_404 = 80; +int gi_408 = 3; +int gi_412 = 145; +int gi_416 = 2; +int gi_420 = 180; +int gi_424 = 0; +int gi_428 = 205; +int gi_432 = -1; +int gi_436 = 250; +int gi_440 = -4; +double gd_444 = 0.35; +int gi_452 = 21; +int gi_456 = 1; +int gi_460 = 50; +int g_period_464 = 8; +int g_period_468 = 6; +int gi_472 = 30; +int g_period_476 = 20; +int gi_480 = 36; +int gi_484 = 20; +int g_period_488 = 5; +int g_applied_price_492 = PRICE_CLOSE; +int g_ma_method_496 = MODE_SMA; +int gi_500 = 4; +int gi_504 = 3; +int gi_508 = 150; +int gi_512 = 21; +int gi_516 = 40; +int gi_520 = 21; +bool gi_528 = TRUE; +int gi_532; +double gd_536; +double g_maxlot_544; +double g_minlot_552; +double g_lotstep_560; +double gd_568; +string g_symbol_576; +bool gi_584 = TRUE; +bool gi_588 = TRUE; +int g_datetime_592; +int g_datetime_596; +int g_datetime_600; +int gi_604; +int gi_608; +int gi_612; +int gi_616; +int gi_620; +int gi_624; +int gi_628; +int gi_632; +int gi_636; +int gi_640; +int gi_644; +int gi_648; +int gi_652; +int gi_656; +int gi_660; +int gi_664; +int gi_668; +int gi_672; +int gi_676; +int gi_680; +int gi_684; +int gi_688; +int gi_692; +int gi_696; +double gd_700; +double gd_708; +double gd_716; +double gd_724; +double gd_732; +double gd_740; +double gd_748; +double gd_756; +double gd_764; +double gd_772; +double gd_780; +double gda_unused_936[]; +double gda_unused_940[]; +string gs_dummy_944; +string gs_dummy_952; +string gs_dummy_960; +bool gi_unused_968 = TRUE; + +int init() { + string ls_0; + if (!IsDllsAllowed()) { + Comment("Warning: Set Parameter \"AllowDLL Imports\" ON in menu Tools -> Options -> ExpertAdvisors."); + gi_528 = FALSE; + return (0); + } + g_symbol_576 = Symbol(); + if (Digits < 4) { + gd_536 = 0.01; + gi_532 = 2; + } else { + gd_536 = 0.0001; + gi_532 = 4; + } + g_maxlot_544 = MarketInfo(g_symbol_576, MODE_MAXLOT); + g_minlot_552 = MarketInfo(g_symbol_576, MODE_MINLOT); + g_lotstep_560 = MarketInfo(g_symbol_576, MODE_LOTSTEP); + gd_568 = MarketInfo(g_symbol_576, MODE_MARGINREQUIRED) * g_lotstep_560; + if (gi_84) { + ls_0 = StringSubstr(g_symbol_576, 0, 6); + if ((ls_0 != "EURGBP" && ls_0 != "EURCHF" && ls_0 != "GBPCHF" && ls_0 != "USDCAD") || Period() != PERIOD_M15) { + Alert("Use scalper system only on EURCHF, EURGPB, GBPCHF or USDCAD M15."); + Print("Use scalper system only on EURCHF, EURGPB, GBPCHF or USDCAD M15."); + Comment("Error: Wrong TimeFrame or Currency Pair! Read instructions!"); + gi_528 = FALSE; + return (0); + } + if (ls_0 == "EURGBP") { + gi_620 = gi_212; + gi_624 = gi_216; + gi_628 = gi_220; + gd_700 = gd_264; + gi_632 = gi_224; + gi_640 = gi_232; + gi_648 = gi_240; + gi_656 = gi_248; + gi_664 = gi_256; + gi_636 = gi_228; + gi_644 = gi_236; + gi_652 = gi_244; + gi_660 = gi_252; + gi_668 = gi_260; + } else { + if (ls_0 == "EURCHF") { + gi_620 = gi_272; + gi_624 = gi_276; + gi_628 = gi_280; + gd_700 = gd_324; + gi_632 = gi_284; + gi_640 = gi_292; + gi_648 = gi_300; + gi_656 = gi_308; + gi_664 = gi_316; + gi_636 = gi_288; + gi_644 = gi_296; + gi_652 = gi_304; + gi_660 = gi_312; + gi_668 = gi_320; + } else { + if (ls_0 == "GBPCHF") { + gi_620 = gi_332; + gi_624 = gi_336; + gi_628 = gi_340; + gd_700 = gd_384; + gi_632 = gi_344; + gi_640 = gi_352; + gi_648 = gi_360; + gi_656 = gi_368; + gi_664 = gi_376; + gi_636 = gi_348; + gi_644 = gi_356; + gi_652 = gi_364; + gi_660 = gi_372; + gi_668 = gi_380; + } else { + gi_620 = gi_392; + gi_624 = gi_396; + gi_628 = gi_400; + gd_700 = gd_444; + gi_632 = gi_404; + gi_640 = gi_412; + gi_648 = gi_420; + gi_656 = gi_428; + gi_664 = gi_436; + gi_636 = gi_408; + gi_644 = gi_416; + gi_652 = gi_424; + gi_660 = gi_432; + gi_668 = gi_440; + } + } + } + gd_716 = (-1 * gi_624) * gd_536; + gd_708 = gi_620 * gd_536; + gi_672 = 60 * gi_632; + gi_676 = 60 * gi_640; + gi_680 = 60 * gi_648; + gi_684 = 60 * gi_656; + gi_688 = 60 * gi_664; + gd_724 = gi_636 * gd_536; + gd_732 = gi_644 * gd_536; + gd_740 = gi_652 * gd_536; + gd_748 = gi_660 * gd_536; + gd_756 = gi_668 * gd_536; + gd_780 = NormalizeDouble(gi_628 * gd_536, gi_532); + gd_764 = (MarketInfo(g_symbol_576, MODE_SPREAD) + 0.1) * Point; + gd_772 = NormalizeDouble(gi_624 * gd_536, gi_532); + gi_604 = 100 - gi_472; + gi_608 = 100 - gi_480; + gi_612 = gi_484 / 2 + 50; + gi_616 = 50 - gi_484 / 2; + gi_692 = gi_452 + GMT_offset; + gi_696 = gi_456 + GMT_offset; + while (true) { + if (gi_692 >= 24) { + gi_692 -= 24; + continue; + } + if (gi_692 >= 0) break; + gi_692 += 24; + } + while (true) { + if (gi_696 >= 24) { + gi_696 -= 24; + continue; + } + if (gi_696 >= 0) break; + gi_696 += 24; + } + if (g_period_168 <= 0) gi_164 = FALSE; + if (g_applied_price_172 < PRICE_CLOSE || g_applied_price_172 > PRICE_WEIGHTED) gi_164 = FALSE; + if (g_ma_method_176 < MODE_SMA || g_ma_method_176 > MODE_LWMA) gi_164 = FALSE; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + if (!gi_528) return (0); + Scalper(); + return (0); +} + +void Scalper() { + double l_irsi_0; + double l_irsi_8; + double l_ima_16; + int l_count_24; + double l_ima_28; + g_datetime_592 = TimeCurrent(); + if (!IsConnected()) { + Comment("" + + "\n" + + "Boss" + + "\n" + + "------------------------------------------------" + + "\n" + + "BROKER INFORMATION:" + + "\n" + + "Broker Company: " + AccountCompany() + + "\n" + + "------------------------------------------------" + + "\n" + + "ACCOUNT INFORMATION:" + + "\n" + + "Account Name: " + AccountName() + + "\n" + + "Account Number: " + AccountNumber() + + "\n" + + "Account Leverage: " + DoubleToStr(AccountLeverage(), 0) + + "\n" + + "Account Balance: " + DoubleToStr(AccountBalance(), 2) + + "\n" + + "Account Currency: " + AccountCurrency() + + "\n" + + "Account Equity: " + DoubleToStr(AccountEquity(), 2) + + "\n" + + "------------------------------------------------" + + "\n" + + "MARGIN INFORMATION:" + + "\n" + + "Free Margin: " + DoubleToStr(AccountFreeMargin(), 2) + + "\n" + + "Used Margin: " + DoubleToStr(AccountMargin(), 2) + + "\n" + + "------------------------------------------------" + + "\n" + + "Actual Server Time " + TimeToStr(TimeCurrent(), TIME_SECONDS) + + "\n" + + "------------------------------------------------"); + return; + } + if (PrintLogOnChart) { + Comment("" + + "\n" + + "Boss" + + "\n" + + "------------------------------------------------" + + "\n" + + "BROKER INFORMATION:" + + "\n" + + "Broker Company: " + AccountCompany() + + "\n" + + "------------------------------------------------" + + "\n" + + "ACCOUNT INFORMATION:" + + "\n" + + "Account Name: " + AccountName() + + "\n" + + "Account Number: " + AccountNumber() + + "\n" + + "Account Leverage: " + DoubleToStr(AccountLeverage(), 0) + + "\n" + + "Account Balance: " + DoubleToStr(AccountBalance(), 2) + + "\n" + + "Account Currency: " + AccountCurrency() + + "\n" + + "Account Equity: " + DoubleToStr(AccountEquity(), 2) + + "\n" + + "------------------------------------------------" + + "\n" + + "MARGIN INFORMATION:" + + "\n" + + "Free Margin: " + DoubleToStr(AccountFreeMargin(), 2) + + "\n" + + "Used Margin: " + DoubleToStr(AccountMargin(), 2) + + "\n" + + "------------------------------------------------" + + "\n" + + "Actual Server Time " + TimeToStr(TimeCurrent(), TIME_SECONDS) + + "\n" + + "------------------------------------------------"); + } + if (gi_136) WatchLevels(); + if (gi_140) NoiseFilter(); + SetOrderLevels(); + if (Ask - Bid <= gd_764) { + if (DayOfWeek() != 0) { + if (!gi_156) + if (DayOfWeek() == 5) return; + if (DayOfWeek() == 1 && Hour() < gi_692) return; + if (Scalper_IsTradeTime()) { + if (gi_144 > 0) + if (Scalper_IsRelaxHours()) return; + if (gi_148) + if (Scalper_CheckSimpleHeightFilter()) return; + if (gi_152) + if (Scalper_CheckTrendFilter()) return; + if (gi_160 != 0) { + if (Scalper_HaveTrade()) { + if (!(WriteDebugLog)) return; + Print("Already have one trade inside this interval of time."); + return; + } + } + HideTestIndicators(TRUE); + l_irsi_0 = iRSI(NULL, 0, g_period_468, PRICE_CLOSE, 0); + l_irsi_8 = iRSI(NULL, PERIOD_M1, g_period_476, PRICE_CLOSE, 0); + l_ima_16 = iMA(NULL, 0, g_period_464, 0, MODE_SMA, PRICE_MEDIAN, 1); + if (fun2(Ask + 0.0002, ExistPosition(), l_irsi_0, l_irsi_8, gi_480, gi_472, l_ima_16)) { + if (gi_584) { + if (!gi_164) l_count_24 = 0; + else { + l_ima_28 = iMA(NULL, 0, g_period_168, 0, g_ma_method_176, g_applied_price_172, 0); + if (Close[0] <= l_ima_28) l_count_24++; + } + if (l_count_24 == 0) { + OpenPosition(OP_BUY, gi_620, gi_624); + gi_584 = FALSE; + gi_588 = TRUE; + } + } + } + if (fun3(Bid - 0.0002, ExistPosition(), l_irsi_0, l_irsi_8, gi_608, gi_604, l_ima_16)) { + if (gi_588) { + if (!gi_164) l_count_24 = 0; + else { + l_ima_28 = iMA(NULL, 0, g_period_168, 0, g_ma_method_176, g_applied_price_172, 0); + if (Close[0] >= l_ima_28) l_count_24++; + } + if (l_count_24 == 0) { + OpenPosition(OP_SELL, gi_620, gi_624); + gi_588 = FALSE; + gi_584 = TRUE; + } + } + } + if (fun4(l_irsi_0, gi_612, gi_616)) { + gi_588 = TRUE; + gi_584 = TRUE; + } + } + } + } +} + +bool Scalper_IsRelaxHours() { + int l_datetime_16; + bool li_20; + double ld_24; + double ld_32; + double ld_40; + int l_datetime_52; + int l_ticket_0 = -1; + int li_4 = OrdersHistoryTotal() - 1; + int l_datetime_8 = -2147483648; + for (int l_pos_12 = li_4; l_pos_12 >= 0; l_pos_12--) { + if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_HISTORY)) { + if (OrderMagicNumber() == MagicNumber) { + if (OrderSymbol() == g_symbol_576) { + l_datetime_16 = OrderCloseTime(); + if (l_datetime_8 < l_datetime_16) { + l_datetime_8 = l_datetime_16; + l_ticket_0 = OrderTicket(); + } + } + } + } + } + if (l_ticket_0 < 0) return (FALSE); + if (OrderSelect(l_ticket_0, SELECT_BY_TICKET)) { + li_20 = FALSE; + ld_24 = NormalizeDouble(OrderOpenPrice(), gi_532); + ld_32 = NormalizeDouble(OrderClosePrice(), gi_532); + ld_40 = NormalizeDouble(OrderStopLoss(), gi_532); + if (OrderType() == OP_BUY) { + if (ld_32 <= ld_40 && ld_40 != 0.0) li_20 = TRUE; + else + if (ld_24 - ld_32 >= gd_772) li_20 = TRUE; + } else { + if (ld_32 >= ld_40 && ld_40 != 0.0) li_20 = TRUE; + else + if (ld_32 - ld_24 >= gd_772) li_20 = TRUE; + } + } else return (FALSE); + if (!li_20) return (FALSE); + int l_shift_48 = iBarShift(NULL, PERIOD_H1, l_datetime_8, FALSE); + if (l_shift_48 < gi_144) { + l_datetime_52 = iTime(NULL, PERIOD_H1, 0); + if (g_datetime_600 != l_datetime_52) { + if (WriteLog) Print("Relax Hours Left = " + DoubleToStr(l_shift_48 - gi_144, 0) + " (after StopLoss)."); + g_datetime_600 = l_datetime_52; + } + return (TRUE); + } + return (FALSE); +} + +bool Scalper_CheckTrendFilter() { + double ld_4; + double ld_12; + double ld_20; + if (gi_500 <= 0) return (FALSE); + for (int li_0 = 0; li_0 <= gi_504; li_0++) { + ld_4 = NormalizeDouble(iMA(NULL, 0, g_period_488, 0, g_ma_method_496, g_applied_price_492, li_0), gi_532); + ld_12 = NormalizeDouble(iMA(NULL, 0, g_period_488, 0, g_ma_method_496, g_applied_price_492, li_0 + gi_500), gi_532); + ld_20 = 100.0 * MathAbs(ld_4 - ld_12) / ld_12; + if (ld_20 > gd_700) break; + } + if (li_0 > gi_504) return (FALSE); + if (WriteDebugLog) { + Print("Trade is forbidden by the filter TrendFilter."); + if (li_0 != 0) Print("Relax Bars Left = " + DoubleToStr(gi_504 - li_0, 0) + " (after MaxPercentMove)."); + } + return (TRUE); +} + +bool Scalper_CheckSimpleHeightFilter() { + int l_datetime_4; + bool li_0 = FALSE; + if (NormalizeDouble(iHigh(NULL, PERIOD_M15, 1) - iLow(NULL, PERIOD_M15, 1), gi_532) > gd_780) li_0 = TRUE; + if (NormalizeDouble(iHigh(NULL, PERIOD_M15, 2) - iLow(NULL, PERIOD_M15, 2), gi_532) > gd_780) li_0 = TRUE; + if (li_0) { + l_datetime_4 = iTime(NULL, PERIOD_M15, 0); + if (g_datetime_596 != l_datetime_4) { + if (WriteLog) Print("Trade is forbidden by the filter SimpleHeightFilter."); + g_datetime_596 = l_datetime_4; + } + return (TRUE); + } + return (FALSE); +} + +int Scalper_IsTradeTime() { + int l_hour_0 = TimeHour(g_datetime_592); + if (gi_692 < gi_696 && l_hour_0 < gi_692 || l_hour_0 >= gi_696) return (0); + if (gi_692 > gi_696 && (l_hour_0 < gi_692 && l_hour_0 >= gi_696)) return (0); + if (gi_696 == 0) gi_696 = 24; + if (Hour() == gi_696 - 1 && Minute() >= gi_460) return (0); + return (1); +} + +int ExistPosition() { + int l_ord_total_0 = OrdersTotal(); + for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) { + if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) { + if (OrderMagicNumber() == MagicNumber) { + if (OrderSymbol() == g_symbol_576) + if (OrderType() <= OP_SELL) return (1); + } + } + } + return (0); +} + +int OpenPosition(int a_cmd_0, int ai_unused_4, int ai_unused_8) { + double l_price_20; + color l_color_28; + string ls_36; + double ld_12 = LotsOptimized(); + if (AccountFreeMarginCheck(g_symbol_576, a_cmd_0, ld_12) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */) { + Print("You don\'t have free margin."); + Comment("You don\'t have free margin."); + return (-1); + } + if (Ask - Bid > MaxSpread / 10000.0) return (0); + RefreshRates(); + if (a_cmd_0 == OP_BUY) { + l_price_20 = Ask; + l_color_28 = g_color_184; + } else { + l_price_20 = Bid; + l_color_28 = g_color_188; + } + int l_ticket_32 = OrderSend(g_symbol_576, a_cmd_0, ld_12, l_price_20, MarketInfo(g_symbol_576, MODE_SPREAD), 0, 0, 0, MagicNumber, 0, l_color_28); + if (l_ticket_32 < 0) { + if (WriteDebugLog) { + if (a_cmd_0 == OP_BUY) ls_36 = "OP_BUY"; + else ls_36 = "OP_SELL"; + Print("Open: OrderSend(", ls_36, ") error = ", GetLastError()); + } + } + return (l_ticket_32); +} + +void NoiseFilter() { + int li_12; + double l_price_16; + double ld_24; + int li_32; + double ld_36; + bool l_ord_close_44; + string ls_48; + int l_spread_0 = MarketInfo(g_symbol_576, MODE_SPREAD); + int li_4 = OrdersTotal() - 1; + for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) { + if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + if (WriteDebugLog) Print("NoiseFilter: OrderSelect() error = ", GetLastError()); + } else { + if (OrderMagicNumber() == MagicNumber) { + if (OrderType() <= OP_SELL) { + if (OrderSymbol() == g_symbol_576) { + li_12 = g_datetime_592 - OrderOpenTime(); + if (li_12 > gi_672) { + l_price_16 = NormalizeDouble(OrderClosePrice(), gi_532); + ld_24 = NormalizeDouble(OrderOpenPrice(), gi_532); + li_32 = 0; + if (OrderType() == OP_BUY) ld_36 = l_price_16 - ld_24; + else ld_36 = ld_24 - l_price_16; + if (li_12 < gi_676 && ld_36 >= gd_724) li_32 = 1; + else { + if (li_12 > gi_676 && li_12 < gi_680 && ld_36 >= gd_732) li_32 = 2; + else { + if (li_12 > gi_680 && li_12 < gi_684 && ld_36 >= gd_740) li_32 = 3; + else { + if (li_12 > gi_684 && li_12 < gi_688 && ld_36 >= gd_748) li_32 = 4; + else + if (li_12 > gi_688 && ld_36 >= gd_756) li_32 = 5; + } + } + } + if (li_32 != 0) { + RefreshRates(); + l_ord_close_44 = OrderClose(OrderTicket(), OrderLots(), l_price_16, l_spread_0, g_color_184); + if (!l_ord_close_44) { + if (WriteDebugLog) { + if (OrderType() == OP_BUY) ls_48 = "OP_BUY"; + else ls_48 = "OP_SELL"; + Print("NoiseFilter: OrderClose(", ls_48, ") error = ", GetLastError()); + } + } + } + } + } + } + } + } + } +} + +void WatchLevels() { + double l_price_12; + double ld_20; + double ld_28; + bool l_ord_close_36; + if (gi_620 <= 0 && gi_624 <= 0) return; + int l_spread_0 = MarketInfo(g_symbol_576, MODE_SPREAD); + int li_4 = OrdersTotal() - 1; + for (int l_pos_8 = li_4; l_pos_8 >= 0; l_pos_8--) { + if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + if (WriteDebugLog) Print("WatchLevels: OrderSelect() error = ", GetLastError()); + } else { + if (OrderMagicNumber() == MagicNumber) { + if (OrderType() <= OP_SELL) { + if (OrderSymbol() == g_symbol_576) { + l_price_12 = NormalizeDouble(OrderClosePrice(), gi_532); + ld_20 = NormalizeDouble(OrderOpenPrice(), gi_532); + if (OrderType() == OP_BUY) { + ld_28 = l_price_12 - ld_20; + if ((gd_708 > 0.0 && ld_28 >= gd_708) || (gd_716 < 0.0 && ld_28 <= gd_716)) { + if (WriteDebugLog) Print("WatchLevels: level for close BUY"); + l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), l_price_12, l_spread_0, g_color_184); + if (!l_ord_close_36) + if (WriteDebugLog) Print("WatchLevels: OrderClose(OP_BUY) error = ", GetLastError()); + } + } else { + ld_28 = ld_20 - l_price_12; + if ((gd_708 > 0.0 && ld_28 >= gd_708) || (gd_716 < 0.0 && ld_28 <= gd_716)) { + if (WriteDebugLog) Print("WatchLevels: level for close SELL"); + l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), l_price_12, l_spread_0, g_color_188); + if (!l_ord_close_36) + if (WriteDebugLog) Print("WatchLevels: OrderClose(OP_SELL) error = ", GetLastError()); + } + } + } + } + } + } + } +} + +double LotsOptimized() { + double ld_ret_0 = MathFloor(ManyManagment_0_100 * AccountEquity() / MarketInfo(Symbol(), MODE_MARGINREQUIRED)) * MarketInfo(Symbol(), MODE_MINLOT); + if (ld_ret_0 > MarketInfo(Symbol(), MODE_MAXLOT)) ld_ret_0 = MarketInfo(Symbol(), MODE_MAXLOT); + if (ld_ret_0 < MarketInfo(Symbol(), MODE_MINLOT)) ld_ret_0 = MarketInfo(Symbol(), MODE_MINLOT); + return (ld_ret_0); +} + +void SetOrderLevels() { + double ld_16; + double l_price_24; + double ld_32; + double ld_40; + bool li_48; + int li_52; + int li_56; + double l_price_60; + double l_price_68; + bool l_bool_76; + double ld_0 = NormalizeDouble(MarketInfo(g_symbol_576, MODE_STOPLEVEL) * Point, Digits); + int li_8 = OrdersTotal() - 1; + for (int l_pos_12 = li_8; l_pos_12 >= 0; l_pos_12--) { + if (!OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) { + if (WriteDebugLog) Print("SetOrderLevels: OrderSelect() error = ", GetLastError()); + } else { + if (OrderMagicNumber() == MagicNumber) { + if (OrderType() <= OP_SELL) { + if (OrderSymbol() == g_symbol_576) { + ld_16 = NormalizeDouble(OrderClosePrice(), gi_532); + l_price_24 = NormalizeDouble(OrderOpenPrice(), gi_532); + ld_32 = NormalizeDouble(OrderStopLoss(), gi_532); + ld_40 = NormalizeDouble(OrderTakeProfit(), gi_532); + li_48 = TRUE; + li_52 = 0; + li_56 = 0; + if (ld_32 == 0.0) { + if (gi_136) li_52 = gi_508 + MathRand() % gi_512; + else li_52 = gi_624; + if (li_52 != 0) { + if (OrderType() == OP_BUY) { + l_price_60 = NormalizeDouble(l_price_24 - li_52 * gd_536, gi_532); + if (ld_16 - l_price_60 <= ld_0) li_48 = FALSE; + } else { + l_price_60 = NormalizeDouble(l_price_24 + li_52 * gd_536, gi_532); + if (l_price_60 - ld_16 <= ld_0) li_48 = FALSE; + } + } + } else l_price_60 = ld_32; + if (ld_40 == 0.0) { + if (gi_136) li_56 = gi_516 + MathRand() % gi_520; + else li_56 = gi_620; + if (li_56 != 0) { + if (OrderType() == OP_BUY) { + l_price_68 = NormalizeDouble(l_price_24 + li_56 * gd_536, gi_532); + if (l_price_68 - ld_16 <= ld_0) li_48 = FALSE; + } else { + l_price_68 = NormalizeDouble(l_price_24 - li_56 * gd_536, gi_532); + if (ld_16 - l_price_68 <= ld_0) li_48 = FALSE; + } + } + } else l_price_68 = ld_40; + if (li_52 != 0 && li_56 != 0 && li_48) { + l_bool_76 = OrderModify(OrderTicket(), l_price_24, l_price_60, l_price_68, 0, CLR_NONE); + if (!l_bool_76) + if (WriteDebugLog) Print("SetOrderLevels: OrderClose(OP_SELL) error = ", GetLastError()); + } + } + } + } + } + } +} + +bool Scalper_HaveTrade() { + int l_datetime_28; + if (gi_452 == gi_456) return (FALSE); + int l_datetime_0 = TimeCurrent(); + int li_4 = iTime(NULL, PERIOD_D1, 0); + int l_hour_8 = TimeHour(l_datetime_0); + int li_unused_12 = 0; + if (gi_452 > gi_456) + if (l_hour_8 < gi_452) li_4 -= 86400; + li_4 += 3600 * gi_452; + int li_16 = OrdersTotal() - 1; + int l_datetime_20 = -2147483648; + for (int l_pos_24 = li_16; l_pos_24 >= 0; l_pos_24--) { + if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES)) { + if (OrderMagicNumber() == MagicNumber) { + if (OrderSymbol() == g_symbol_576) { + l_datetime_28 = OrderOpenTime(); + if (l_datetime_20 < l_datetime_28) l_datetime_20 = l_datetime_28; + } + } + } + } + if (l_datetime_20 >= li_4) return (TRUE); + li_16 = OrdersHistoryTotal() - 1; + l_datetime_20 = -2147483648; + for (l_pos_24 = li_16; l_pos_24 >= 0; l_pos_24--) { + if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_HISTORY)) { + if (OrderMagicNumber() == MagicNumber) { + if (OrderSymbol() == g_symbol_576) { + l_datetime_28 = OrderOpenTime(); + if (l_datetime_20 < l_datetime_28) l_datetime_20 = l_datetime_28; + } + } + } + } + if (l_datetime_20 >= li_4) return (TRUE); + return (FALSE); +} \ No newline at end of file diff --git a/CloveriX.mq4 b/CloveriX.mq4 new file mode 100644 index 0000000..878fea4 --- /dev/null +++ b/CloveriX.mq4 @@ -0,0 +1,328 @@ +extern string CloveriX_works_on__________ = " ====== EURGBP and EURCHF ===== "; +extern double Risk = 0.25; +extern double MaxTP = 10.0; +extern string Trading_Hours_Settings_______ = "[ GMT_Offset = Market Watch - GMT ]"; +extern int GMT_Offset = 1; +extern string ADDITIONAL_SETTINGS______ = "==============================="; +extern bool VariableSpreads = FALSE; +extern double VarSpreadFix = 3.0; +extern bool PlaceExternalTP = FALSE; +extern bool CloseOnlyByExtTP = FALSE; +extern bool Spread5PipsAlert = FALSE; +extern bool ErrorAlert = FALSE; +extern bool UseFixedSL = FALSE; +extern double FixedSL = 0.0; + +int g_hour_160; +int g_error_164; +bool gi_168; +bool gi_172; +bool gi_176; +int gi_180; +int gi_184; +int g_slippage_188; +int g_slippage_192; +int gi_196 = 4; +double gda_200[3]; +double gda_204[3]; +double gd_208 = 0; +double gd_216 = 0; +double gd_224 = 0; +double gd_232 = 0; +double gd_240 = 0; +double gd_248 = 0; +double gd_256 = 0; +double g_ima_264; +double g_ima_272; +double g_ima_280; +double gd_288; +double gd_296; +double gd_304; +double gd_312; +double gd_328; +double gd_336; +double gd_344; +double g_price_352; +double gd_360; +double g_datetime_376; +double gd_392; +double gd_400; +double gd_408; +double g_digits_416; +string gs_424; +string gs_unused_432 = "0"; +bool gi_440 = FALSE; +int iFileNo = 0; + +int init() +{ + gs_424 = StringSubstr(Symbol(), 0, 6); + gd_248 = 10000.0 * (Ask - Bid); + if(gs_424 == "EURCHF" || gs_424 != "EURGBP" && Period() == PERIOD_M15) + Coment(); + gi_180 = GMT_Offset + 21; + gi_184 = GMT_Offset + 23; + g_digits_416 = Digits; + if(gi_180 > 23) + gi_180 -= 24; + if(gi_184 > 23) + gi_184 -= 24; + g_datetime_376 = iTime(NULL, PERIOD_M15, 1); + MaxTP /= 10000.0; + FixedSL /= 10000.0; + g_slippage_188 = 0; + g_slippage_192 = 1; + if(PlaceExternalTP == TRUE && CloseOnlyByExtTP == TRUE) + gi_440 = TRUE; + return(0); +} + +int start() +{ + if((gs_424 != "EURCHF" && gs_424 != "EURGBP") || Period() != PERIOD_M15) + { + Alert("------------------", "\n", "WRONG TRADING PAIR OR TIMEFRAME"); + return; + } + if(!IsExpertEnabled()) + { + Alert("EXPERTS ARE NOT ALLOWED"); + return; + } + Coment(); + HideTestIndicators(TRUE); + if(gi_180 < gi_184 && Hour() > gi_184 || Hour() < gi_180 && OrdersTotal() == 0) + return; + if(gi_180 > gi_184 && (Hour() > gi_184 && Hour() < gi_180) && OrdersTotal() == 0) + return; + gi_168 = FALSE; + gi_172 = FALSE; + gi_176 = FALSE; + g_hour_160 = Hour(); + g_error_164 = GetLastError(); + gd_240 = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), MarketInfo(Symbol(), MODE_FREEZELEVEL)) / 10000.0; + RefreshRates(); + gda_200[0] = High[1]; + gda_200[1] = High[2]; + gda_200[2] = High[3]; + gda_204[0] = Low[1]; + gda_204[1] = Low[2]; + gda_204[2] = Low[3]; + gd_248 = 10000.0 * (Ask - Bid); + gd_256 = Ask - Bid; + if(FixedSL < gd_240 + gd_256 && UseFixedSL) + { + Alert("Incorrect FixedSL. Check parameters."); + return; + } + g_ima_264 = iMA(NULL, 0, 9, 0, MODE_SMA, PRICE_MEDIAN, 1); + g_ima_272 = iMA(NULL, 0, 9, 0, MODE_SMA, PRICE_MEDIAN, 2); + g_ima_280 = iMA(NULL, 0, 9, 0, MODE_SMA, PRICE_MEDIAN, 3); + gd_288 = NormalizeDouble(iRSI(NULL, 0, 7, PRICE_OPEN, 0), 4); + gd_296 = NormalizeDouble(iRSI(NULL, 0, 7, PRICE_OPEN, 1), 4); + gd_304 = NormalizeDouble(iWPR(NULL, 0, 14, 0), 4); + gd_312 = NormalizeDouble(iWPR(NULL, 0, 14, 1), 4); + if(VariableSpreads == TRUE) + { + gd_360 = VarSpreadFix / 10000.0; + gi_196 = 6; + } + else + gd_360 = Ask - Bid; + if(iBarShift(NULL, PERIOD_M15, g_datetime_376, FALSE) != 0) + { + g_datetime_376 = TimeCurrent(); + PrepareParameters(); + } + CHF(); + gi_168 = FALSE; + gi_172 = FALSE; + gi_176 = FALSE; + GBP(); + if(g_error_164 >= 2/* COMMON_ERROR */ && g_error_164 != 130/* INVALID_STOPS */ && g_error_164 != 4099/* END_OF_FILE */ && g_error_164 != 4108/* INVALID_TICKET */ && + g_error_164 != 4103/* CANNOT_OPEN_FILE */ && g_error_164 != 4051/* INVALID_FUNCTION_PARAMETER_VALUE */ && ErrorAlert == TRUE) + Alert("error # ", g_error_164, " Find a definition here http://docs.mql4.com/constants/errors"); + return(0); +} + +void PrepareParameters() +{ + gd_328 = MathMin(gd_216, gd_232); + gd_344 = MathMax(gd_208, gd_224); + if(g_ima_264 > g_ima_280) + gd_408 = 1; + else + { + if(g_ima_264 < g_ima_280) + gd_408 = -1; + else + gd_408 = 0; + } + if(g_ima_264 > gd_208+0.0002) + gd_392 = 1; + else + { + if(g_ima_264 < gd_216-0.0002) + gd_392 = -1; + else + gd_392 = 0; + } + if((g_ima_264 > gda_200[0]) && (g_ima_272 > gda_200[1]) && (g_ima_280 > gda_200[2])) + gd_400 = 1; + else + { + if((g_ima_264 < gda_204[0]) && (g_ima_272 < gda_204[1]) && (g_ima_280 < gda_204[2])) + gd_400 = -1; + else + gd_400 = 0; + } + gd_208 = NormalizeDouble((gda_200[0]+gda_200[1]+gda_200[2])/3, 4)-0.00006; + gd_216 = NormalizeDouble((gda_204[0]+gda_204[1]+gda_204[2])/3, 4)+0.00006; + gd_232 = NormalizeDouble((gda_200[0]+gda_200[1]+gda_200[2])/3, 4)-0.0006; + gd_224 = NormalizeDouble((gda_204[0]+gda_204[1]+gda_204[2])/3, 4)+0.0006; + gd_336 = gd_328 + 0.0001; + g_price_352 = gd_344 - 0.0001; + return(0); +} + +double Lot() +{ + double ld_0 = NormalizeDouble(AccountBalance() / 1000.0 * Risk, 1); + + ld_0 = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), ld_0); + ld_0 = MathMax(MarketInfo(Symbol(), MODE_MINLOT), ld_0); + return(ld_0); +} + +int Coment() +{ + Comment("------------------", + "\n", "CloveriX is Enabled", + "\n", "------------------", + "\n", "======= SERVER TIME =======", + "\n", "Trading Start Hour: ", gi_180, ":00", + "\n", "Trading End Hour: ", gi_184, ":00", + "\n", "------------------", + "\n", "Risk = ", 100.0 * Risk, "%", + "\n", "TradingLot = ", Lot(), + "\n", "Current Spread = ", gd_248, + "\n", "Max Available Spread = ", gi_196); + return(0); +} + +int OC(double a_price_0) +{ + OrderClose(OrderTicket(), OrderLots(), a_price_0, g_slippage_192, Red); + return(0); +} + +int OrderModif() +{ + for(int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) + { + if(OrderSelect(l_pos_0, SELECT_BY_POS) == TRUE && OrderMagicNumber() == 318200 || OrderMagicNumber() == 318201 && StringSubstr(OrderSymbol(), 0, 6) == gs_424) + { + gi_168 = TRUE; + RefreshRates(); + if(OrderType() == OP_BUY) + { + if((gd_392 == 1.0 && Bid >= gda_200[0]) || (gd_400 == 1.0 && Bid >= gda_200[0]) || (Bid >= g_price_352 - 0.00001 && gi_440 == FALSE)) + { + OC(Bid); + return; + } + if(g_price_352 - OrderOpenPrice() > MaxTP && g_price_352 - Bid >= gd_240 && PlaceExternalTP == TRUE) + if((Ask - OrderStopLoss() >= gd_240 && FixedSL) || !FixedSL) + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() + MaxTP, 0, CLR_NONE); + if(g_price_352 - OrderOpenPrice() <= MaxTP && g_price_352 != OrderTakeProfit() && g_price_352 - Bid >= gd_240 && PlaceExternalTP == TRUE) + if((Ask - OrderStopLoss() >= gd_240 && FixedSL) || !FixedSL) + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), g_price_352, 0, CLR_NONE); + if(Bid - OrderOpenPrice() > MaxTP - 0.0001 && gi_440 == FALSE) + { + OC(Bid); + return; + } + } + if(OrderType() == OP_SELL) + { + if((gd_392 == 2.0 && Bid <= gda_204[0]) || (gd_400 == 2.0 && Bid <= gda_204[0]) || (Ask - gd_360 <= gd_336 + 0.00001 && gi_440 == FALSE)) + { + OC(Ask); + return; + } + if(OrderOpenPrice() - gd_336 - gd_360 > MaxTP && Ask - gd_336 - gd_360 >= gd_240 && PlaceExternalTP == TRUE) + if((Ask - OrderStopLoss() >= gd_240 && FixedSL) || !FixedSL) + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() - MaxTP, 0, CLR_NONE); + if(OrderOpenPrice() - gd_336 - gd_360 <= MaxTP && gd_336 + gd_360 != OrderTakeProfit() && Ask - gd_336 - gd_360 >= gd_240 && PlaceExternalTP == TRUE) + if((Ask - OrderStopLoss() >= gd_240 && FixedSL) || !FixedSL) + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), gd_336 + gd_360, 0, CLR_NONE); + if(OrderOpenPrice() - Ask > MaxTP - 0.0001 && gi_440 == FALSE) + { + OC(Ask); + return; + } + } + } + } + return(0); +} + +int CheckParam() +{ + if(gd_248 >= gi_196 + 1 && Spread5PipsAlert == TRUE) + Alert("Spread is higher than ", gi_196, " pips - NO TRADE"); + if((DayOfWeek() == 5 && g_hour_160 > 12) || (DayOfWeek() == 1 && g_hour_160 < 12)) + gi_172 = TRUE; + if(gi_180 > gi_184 && g_hour_160 >= gi_180 || g_hour_160 < gi_184) + gi_176 = TRUE; + if(gi_180 < gi_184 && g_hour_160 >= gi_180 && g_hour_160 < gi_184) + gi_176 = TRUE; + return(0); +} + +string GBP() +{ + double l_price_0; + + if(gs_424 != "EURGBP" || DayOfWeek() == 0) + return; + Coment(); + CheckParam(); + OrderModif(); + if(gi_168 != TRUE) + { + RefreshRates(); + if(FixedSL != 0.0 && UseFixedSL == TRUE) + l_price_0 = Ask - FixedSL; + if(gd_408 == 1.0 && gi_172 != TRUE && gd_248 <= gi_196 && Ask - gd_360 <= gd_328 && gi_168 != TRUE && gi_176 == TRUE) + OrderSend(Symbol(), OP_BUY, Lot(), Ask, g_slippage_188, l_price_0, 0, 0, 318200, 0, Blue); + if(FixedSL != 0.0 && UseFixedSL == TRUE) + l_price_0 = Bid + FixedSL; + if(gd_408 == 2.0 && gi_172 != TRUE && gd_248 <= gi_196 && Bid >= gd_344 && gi_168 != TRUE && gi_176 == TRUE) + OrderSend(Symbol(), OP_SELL, Lot(), Bid, g_slippage_188, l_price_0, 0, 0, 318201, 0, Blue); + } + return(""); +} + +void CHF() +{ + double l_price_0; + + if(gs_424 != "EURCHF" || DayOfWeek() == 0) + return; + Coment(); + CheckParam(); + OrderModif(); + if(gi_168 != TRUE) + { + RefreshRates(); + if(FixedSL != 0.0 && UseFixedSL == TRUE) + l_price_0 = Ask - FixedSL; + if(gd_408 == 1.0 && gi_172 != TRUE && gd_248 <= gi_196 && Ask - gd_360 <= gd_328 && gi_168 != TRUE && gi_176 == TRUE) + OrderSend(Symbol(), OP_BUY, Lot(), Ask, g_slippage_188, l_price_0, 0, 0, 318200, 0, Blue); + if(FixedSL != 0.0 && UseFixedSL == TRUE) + l_price_0 = Bid + FixedSL; + if(gd_408 == 2.0 && gi_172 != TRUE && gd_248 <= gi_196 && Bid >= gd_344 && gi_168 != TRUE && gi_176 == TRUE) + OrderSend(Symbol(), OP_SELL, Lot(), Bid, g_slippage_188, l_price_0, 0, 0, 318201, 0, Blue); + } +} \ No newline at end of file diff --git a/DSS Bressert.mq4 b/DSS Bressert.mq4 new file mode 100644 index 0000000..107b177 --- /dev/null +++ b/DSS Bressert.mq4 @@ -0,0 +1,121 @@ +//+------------------------------------------------------------------+ +//| Robby DSS Bressert Colored.mq4 | +//| Jaanus Jantson | +//| http://fx.jantson.ee; jaanus@jantson.ee | +//| Copyright © 2008, MetaQuotes Software Corp. | +//| http://www.metaquotes.net/ | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2008, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net/" + +#property indicator_separate_window +#property indicator_minimum 0 +#property indicator_maximum 100 +#property indicator_buffers 3 +#property indicator_color1 OrangeRed +#property indicator_width1 3 +#property indicator_color2 Blue +#property indicator_width2 2 +#property indicator_color3 Red +#property indicator_width3 2 +#property indicator_level1 20 +#property indicator_level2 80 + + +extern int EMA_period=8; +extern int Stochastic_period=13; + + +double DssBuffer[]; +double MitBuffer[]; +double DssBuffer_UP[]; +double DssBuffer_DW[]; + + +double smooth_coefficient; + + +int init() +{ + IndicatorBuffers(4); + SetIndexBuffer(0,DssBuffer); + SetIndexStyle(0,DRAW_LINE); + SetIndexBuffer(1,DssBuffer_UP); + SetIndexStyle(1,DRAW_ARROW); + SetIndexArrow(1,159); + SetIndexBuffer(2,DssBuffer_DW); + SetIndexStyle(2,DRAW_ARROW); + SetIndexArrow(2,159); + + SetIndexBuffer(3,MitBuffer); + + SetIndexEmptyValue(0, 0.0); + SetIndexLabel(0, "DSS"); + SetIndexEmptyValue(1, 0.0); + SetIndexLabel(1, "DSS Up"); + SetIndexEmptyValue(2, 0.0); + SetIndexLabel(2, "DSS Down"); + + IndicatorShortName ("DSS("+EMA_period+","+Stochastic_period+")"); + + smooth_coefficient = 2.0 / (1.0 + EMA_period); + return(0); +} + + +int start() +{ + int i, limit, counted_bars=IndicatorCounted(), Bar_OK; + if (counted_bars == 0) limit = Bars - Stochastic_period; + if (counted_bars > 0) limit = Bars - counted_bars; + + double HighRange, LowRange; + double delta, MIT; + for (i = limit; i >= 0; i--) + { + HighRange = High[iHighest(NULL,0,MODE_HIGH,Stochastic_period,i)]; + LowRange = Low[iLowest(NULL,0,MODE_LOW,Stochastic_period,i)]; + delta = Close[i] - LowRange; + MIT = delta/(HighRange - LowRange)*100.0; + MitBuffer[i] = smooth_coefficient * (MIT - MitBuffer[i+1]) + MitBuffer[i+1]; + } + + double DSS; + for (i = limit; i >= 0; i--) + { + HighRange = MitBuffer[ArrayMaximum(MitBuffer, Stochastic_period, i)]; + LowRange = MitBuffer[ArrayMinimum(MitBuffer, Stochastic_period, i)]; + delta = MitBuffer[i] - LowRange; + DSS = delta/(HighRange - LowRange)*100.0; + DssBuffer[i] = smooth_coefficient * (DSS - DssBuffer[i+1]) + DssBuffer[i+1]; + } + + for (i = limit; i >= 0; i--) + { + //DssBuffer_UP[i]=EMPTY_VALUE; + //DssBuffer_DW[i]=EMPTY_VALUE; + Bar_OK=0; + + if(DssBuffer[i]>DssBuffer[i+1]) + { + DssBuffer_UP[i]=DssBuffer[i]; + Bar_OK=1; + DssBuffer_DW[i] = 0.0; + } + + if(DssBuffer[i] 0) countted--; + int barcount = Bars - countted; + int atrstd = MathMax(Sed_atr, Sed_std); + if (barcount > atrstd + 5) countedbar = barcount - atrstd; + else countedbar = barcount; + for (int i = countedbar; i >= 0; i--) { + atr = iATR(NULL, 0, Vis_atr, i); + Buff_1 = BufferC[i + 1]; + Buff_2 = BufferC[i + 3]; + ATR_value = NormalizeDouble(atr, Digits); + if (lag_supressor) atr_2 = atr / iATR(NULL, 0, Sed_atr, i) + Buff_X * (Buff_1 - Buff_2); + else atr_2 = atr / iATR(NULL, 0, Sed_atr, i); + std = iStdDev(NULL, 0, Vis_std, 0, MODE_LWMA, PRICE_TYPICAL, i); + ATD_value = NormalizeDouble(std, Digits); + std /= iStdDev(NULL, 0, Sed_std, 0, MODE_LWMA, PRICE_TYPICAL, i); + T_Level = Threshold_level; + T_Level -= std; + if (i == 0) { + if (atr_2 > T_Level) { + IndicatorShortName("TRADE " + " A(" + DoubleToStr(Vis_atr, 0) + "/" + DoubleToStr(Sed_atr, 0) + ")= " + DoubleToStr(atr_2, 2) + ", " + DoubleToStr(Threshold_level, 1) + + " - S(" + DoubleToStr(Vis_std, 0) + "/" + DoubleToStr(Sed_std, 0) + ")= " + DoubleToStr(T_Level, 2) + " "); + } else { + IndicatorShortName("DO NOT trade " + "A(" + DoubleToStr(Vis_atr, 0) + "/" + DoubleToStr(Sed_atr, 0) + ")= " + DoubleToStr(atr_2, 2) + ", " + DoubleToStr(Threshold_level, 1) + + " - S(" + DoubleToStr(Vis_std, 0) + "/" + DoubleToStr(Sed_std, 0) + ")= " + DoubleToStr(T_Level, 2) + " "); + } + } + if (atr_2 > T_Level) { + BufferC[i] = atr_2; + BufferB[i] = -1; + } else { + BufferC[i] = atr_2; + BufferB[i] = 0.03; + } + BufferA[i] = T_Level; + } + return (0); +} \ No newline at end of file diff --git a/DashBoard-Anil Panchal.mq4 b/DashBoard-Anil Panchal.mq4 new file mode 100644 index 0000000..3f6ebd6 --- /dev/null +++ b/DashBoard-Anil Panchal.mq4 @@ -0,0 +1,762 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2007." +#property link "http://www.ekosignal.com" + +#property indicator_chart_window + +int gi_unused_76 = 7; +extern bool Corner_of_Chart_RIGHT_TOP = TRUE; +extern bool Show_Price = TRUE; +extern bool Show_Xtra_Details = TRUE; +extern bool Show_Smaller_Size = TRUE; +int gi_100 = 0; +int gi_104 = 20; +int g_color_108 = LightSteelBlue; +int g_color_112 = LightSteelBlue; +int g_period_116 = 12; +int g_period_120 = 26; +int g_period_124 = 9; +int g_applied_price_128 = PRICE_CLOSE; +int g_period_132 = 14; +int g_applied_price_136 = PRICE_CLOSE; +int g_period_140 = 13; +int g_applied_price_144 = PRICE_CLOSE; +int g_period_148 = 5; +int g_period_152 = 3; +int g_slowing_156 = 3; +int g_ma_method_160 = MODE_EMA; +int g_period_164 = 5; +int g_period_168 = 9; +int g_ma_method_172 = MODE_EMA; +int g_applied_price_176 = PRICE_CLOSE; + +int init() { + return (0); +} + +int deinit() { + ObjectsDeleteAll(0, OBJ_LABEL); + return (0); +} + +int start() { + color l_color_0; + color l_color_4; + color l_color_8; + color l_color_12; + color l_color_16; + color l_color_20; + color l_color_24; + color l_color_28; + color l_color_32; + color l_color_36; + color l_color_40; + color l_color_44; + color l_color_48; + color l_color_52; + string ls_unused_56; + color l_color_64; + color l_color_68; + int l_ind_counted_72 = IndicatorCounted(); + string l_text_76 = ""; + string l_text_84 = ""; + string l_text_92 = ""; + string l_text_100 = ""; + string l_text_108 = ""; + string l_text_116 = ""; + string l_text_124 = ""; + double l_imacd_132 = iMACD(NULL, PERIOD_M1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_140 = iMACD(NULL, PERIOD_M1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_148 = iMACD(NULL, PERIOD_M5, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_156 = iMACD(NULL, PERIOD_M5, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_164 = iMACD(NULL, PERIOD_M15, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_172 = iMACD(NULL, PERIOD_M15, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_180 = iMACD(NULL, PERIOD_M30, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_188 = iMACD(NULL, PERIOD_M30, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_196 = iMACD(NULL, PERIOD_H1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_204 = iMACD(NULL, PERIOD_H1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_212 = iMACD(NULL, PERIOD_H4, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_220 = iMACD(NULL, PERIOD_H4, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + double l_imacd_228 = iMACD(NULL, PERIOD_D1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_MAIN, 0); + double l_imacd_236 = iMACD(NULL, PERIOD_D1, g_period_116, g_period_120, g_period_124, g_applied_price_128, MODE_SIGNAL, 0); + if (l_imacd_132 > l_imacd_140) { + l_text_100 = "-"; + l_color_12 = Green; + } + if (l_imacd_132 <= l_imacd_140) { + l_text_100 = "-"; + l_color_12 = Tomato; + } + if (l_imacd_132 > l_imacd_140 && l_imacd_132 > 0.0) { + l_text_100 = "-"; + l_color_12 = Lime; + } + if (l_imacd_132 <= l_imacd_140 && l_imacd_132 < 0.0) { + l_text_100 = "-"; + l_color_12 = Red; + } + if (l_imacd_148 > l_imacd_156) { + l_text_108 = "-"; + l_color_16 = Green; + } + if (l_imacd_148 <= l_imacd_156) { + l_text_108 = "-"; + l_color_16 = Tomato; + } + if (l_imacd_148 > l_imacd_156 && l_imacd_148 > 0.0) { + l_text_108 = "-"; + l_color_16 = Lime; + } + if (l_imacd_148 <= l_imacd_156 && l_imacd_148 < 0.0) { + l_text_108 = "-"; + l_color_16 = Red; + } + if (l_imacd_164 > l_imacd_172) { + l_text_116 = "-"; + l_color_20 = Green; + } + if (l_imacd_164 <= l_imacd_172) { + l_text_116 = "-"; + l_color_20 = Tomato; + } + if (l_imacd_164 > l_imacd_172 && l_imacd_164 > 0.0) { + l_text_116 = "-"; + l_color_20 = Lime; + } + if (l_imacd_164 <= l_imacd_172 && l_imacd_164 < 0.0) { + l_text_116 = "-"; + l_color_20 = Red; + } + if (l_imacd_180 > l_imacd_188) { + l_text_124 = "-"; + l_color_24 = Green; + } + if (l_imacd_180 <= l_imacd_188) { + l_text_124 = "-"; + l_color_24 = Tomato; + } + if (l_imacd_180 > l_imacd_188 && l_imacd_180 > 0.0) { + l_text_124 = "-"; + l_color_24 = Lime; + } + if (l_imacd_180 <= l_imacd_188 && l_imacd_180 < 0.0) { + l_text_124 = "-"; + l_color_24 = Red; + } + if (l_imacd_196 > l_imacd_204) { + l_text_84 = "-"; + l_color_4 = Green; + } + if (l_imacd_196 <= l_imacd_204) { + l_text_84 = "-"; + l_color_4 = Tomato; + } + if (l_imacd_196 > l_imacd_204 && l_imacd_196 > 0.0) { + l_text_84 = "-"; + l_color_4 = Lime; + } + if (l_imacd_196 <= l_imacd_204 && l_imacd_196 < 0.0) { + l_text_84 = "-"; + l_color_4 = Red; + } + if (l_imacd_212 > l_imacd_220) { + l_text_92 = "-"; + l_color_8 = Green; + } + if (l_imacd_212 <= l_imacd_220) { + l_text_92 = "-"; + l_color_8 = Tomato; + } + if (l_imacd_212 > l_imacd_220 && l_imacd_212 > 0.0) { + l_text_92 = "-"; + l_color_8 = Lime; + } + if (l_imacd_212 <= l_imacd_220 && l_imacd_212 < 0.0) { + l_text_92 = "-"; + l_color_8 = Red; + } + if (l_imacd_228 > l_imacd_236) { + l_text_76 = "-"; + l_color_0 = Green; + } + if (l_imacd_228 <= l_imacd_236) { + l_text_76 = "-"; + l_color_0 = Tomato; + } + if (l_imacd_228 > l_imacd_236 && l_imacd_228 > 0.0) { + l_text_76 = "-"; + l_color_0 = Lime; + } + if (l_imacd_228 <= l_imacd_236 && l_imacd_228 < 0.0) { + l_text_76 = "-"; + l_color_0 = Red; + } + if (Corner_of_Chart_RIGHT_TOP == 1) { + ObjectCreate("Numbers", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Numbers", " M1 M5 M15 M30 H1 H4 D1", 6, "Tahoma Narrow", g_color_108); + ObjectSet("Numbers", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Numbers", OBJPROP_XDISTANCE, gi_104 + 19); + ObjectSet("Numbers", OBJPROP_YDISTANCE, gi_100 + 25); + } + if (Corner_of_Chart_RIGHT_TOP == 0) { + ObjectCreate("Numbers", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Numbers", "D1 H4 H1 M30 M15 M5 M1", 6, "Tahoma Narrow", g_color_108); + ObjectSet("Numbers", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Numbers", OBJPROP_XDISTANCE, gi_104 + 15); + ObjectSet("Numbers", OBJPROP_YDISTANCE, gi_100 + 25); + } + ObjectCreate("SSignalMACDM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM1t", "MACD", 6, "Tahoma Narrow", g_color_108); + ObjectSet("SSignalMACDM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM1t", OBJPROP_XDISTANCE, gi_104 + 155); + ObjectSet("SSignalMACDM1t", OBJPROP_YDISTANCE, gi_100 + 35); + ObjectCreate("SSignalMACDM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM1", l_text_100, 45, "Tahoma Narrow", l_color_12); + ObjectSet("SSignalMACDM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM1", OBJPROP_XDISTANCE, gi_104 + 130); + ObjectSet("SSignalMACDM1", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM5", l_text_108, 45, "Tahoma Narrow", l_color_16); + ObjectSet("SSignalMACDM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM5", OBJPROP_XDISTANCE, gi_104 + 110); + ObjectSet("SSignalMACDM5", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM15", l_text_116, 45, "Tahoma Narrow", l_color_20); + ObjectSet("SSignalMACDM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM15", OBJPROP_XDISTANCE, gi_104 + 90); + ObjectSet("SSignalMACDM15", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM30", l_text_124, 45, "Tahoma Narrow", l_color_24); + ObjectSet("SSignalMACDM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM30", OBJPROP_XDISTANCE, gi_104 + 70); + ObjectSet("SSignalMACDM30", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDH1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDH1", l_text_84, 45, "Tahoma Narrow", l_color_4); + ObjectSet("SSignalMACDH1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH1", OBJPROP_XDISTANCE, gi_104 + 50); + ObjectSet("SSignalMACDH1", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDH4", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDH4", l_text_92, 45, "Tahoma Narrow", l_color_8); + ObjectSet("SSignalMACDH4", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH4", OBJPROP_XDISTANCE, gi_104 + 30); + ObjectSet("SSignalMACDH4", OBJPROP_YDISTANCE, gi_100 + 2); + ObjectCreate("SSignalMACDD1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDD1", l_text_76, 45, "Tahoma Narrow", l_color_0); + ObjectSet("SSignalMACDD1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDD1", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("SSignalMACDD1", OBJPROP_YDISTANCE, gi_100 + 2); + double l_irsi_244 = iRSI(NULL, PERIOD_D1, g_period_132, g_applied_price_136, 0); + double l_irsi_252 = iRSI(NULL, PERIOD_H4, g_period_132, g_applied_price_136, 0); + double l_irsi_260 = iRSI(NULL, PERIOD_H1, g_period_132, g_applied_price_136, 0); + double l_irsi_268 = iRSI(NULL, PERIOD_M30, g_period_132, g_applied_price_136, 0); + double l_irsi_276 = iRSI(NULL, PERIOD_M15, g_period_132, g_applied_price_136, 0); + double l_irsi_284 = iRSI(NULL, PERIOD_M5, g_period_132, g_applied_price_136, 0); + double l_irsi_292 = iRSI(NULL, PERIOD_M1, g_period_132, g_applied_price_136, 0); + double l_istochastic_300 = iStochastic(NULL, PERIOD_D1, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_308 = iStochastic(NULL, PERIOD_H4, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_316 = iStochastic(NULL, PERIOD_H1, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_324 = iStochastic(NULL, PERIOD_M30, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_332 = iStochastic(NULL, PERIOD_M15, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_340 = iStochastic(NULL, PERIOD_M5, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_istochastic_348 = iStochastic(NULL, PERIOD_M1, g_period_148, g_period_152, g_slowing_156, g_ma_method_160, 0, MODE_MAIN, 0); + double l_icci_356 = iCCI(NULL, PERIOD_D1, g_period_140, g_applied_price_144, 0); + double l_icci_364 = iCCI(NULL, PERIOD_H4, g_period_140, g_applied_price_144, 0); + double l_icci_372 = iCCI(NULL, PERIOD_H1, g_period_140, g_applied_price_144, 0); + double l_icci_380 = iCCI(NULL, PERIOD_M30, g_period_140, g_applied_price_144, 0); + double l_icci_388 = iCCI(NULL, PERIOD_M15, g_period_140, g_applied_price_144, 0); + double l_icci_396 = iCCI(NULL, PERIOD_M5, g_period_140, g_applied_price_144, 0); + double l_icci_404 = iCCI(NULL, PERIOD_M1, g_period_140, g_applied_price_144, 0); + string l_text_412 = ""; + string l_text_420 = ""; + string l_text_428 = ""; + string l_text_436 = ""; + string l_text_444 = ""; + string l_text_452 = ""; + string l_text_460 = ""; + string ls_unused_468 = ""; + l_text_460 = "-"; + color l_color_476 = Orange; + l_text_444 = "-"; + color l_color_480 = Orange; + l_text_412 = "-"; + color l_color_484 = Orange; + l_text_452 = "-"; + color l_color_488 = Orange; + l_text_420 = "-"; + color l_color_492 = Orange; + l_text_428 = "-"; + color l_color_496 = Orange; + l_text_436 = "-"; + color l_color_500 = Orange; + if (l_irsi_244 > 50.0 && l_istochastic_300 > 40.0 && l_icci_356 > 0.0) { + l_text_460 = "-"; + l_color_476 = Lime; + } + if (l_irsi_252 > 50.0 && l_istochastic_308 > 40.0 && l_icci_364 > 0.0) { + l_text_444 = "-"; + l_color_480 = Lime; + } + if (l_irsi_260 > 50.0 && l_istochastic_316 > 40.0 && l_icci_372 > 0.0) { + l_text_412 = "-"; + l_color_484 = Lime; + } + if (l_irsi_268 > 50.0 && l_istochastic_324 > 40.0 && l_icci_380 > 0.0) { + l_text_452 = "-"; + l_color_488 = Lime; + } + if (l_irsi_276 > 50.0 && l_istochastic_332 > 40.0 && l_icci_388 > 0.0) { + l_text_420 = "-"; + l_color_492 = Lime; + } + if (l_irsi_284 > 50.0 && l_istochastic_340 > 40.0 && l_icci_396 > 0.0) { + l_text_428 = "-"; + l_color_496 = Lime; + } + if (l_irsi_292 > 50.0 && l_istochastic_348 > 40.0 && l_icci_404 > 0.0) { + l_text_436 = "-"; + l_color_500 = Lime; + } + if (l_irsi_244 < 50.0 && l_istochastic_300 < 60.0 && l_icci_356 < 0.0) { + l_text_460 = "-"; + l_color_476 = Red; + } + if (l_irsi_252 < 50.0 && l_istochastic_308 < 60.0 && l_icci_364 < 0.0) { + l_text_444 = "-"; + l_color_480 = Red; + } + if (l_irsi_260 < 50.0 && l_istochastic_316 < 60.0 && l_icci_372 < 0.0) { + l_text_412 = "-"; + l_color_484 = Red; + } + if (l_irsi_268 < 50.0 && l_istochastic_324 < 60.0 && l_icci_380 < 0.0) { + l_text_452 = "-"; + l_color_488 = Red; + } + if (l_irsi_276 < 50.0 && l_istochastic_332 < 60.0 && l_icci_388 < 0.0) { + l_text_420 = "-"; + l_color_492 = Red; + } + if (l_irsi_284 < 50.0 && l_istochastic_340 < 60.0 && l_icci_396 < 0.0) { + l_text_428 = "-"; + l_color_496 = Red; + } + if (l_irsi_292 < 50.0 && l_istochastic_348 < 60.0 && l_icci_404 < 0.0) { + l_text_436 = "-"; + l_color_500 = Red; + } + ObjectCreate("SignalSTRM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1t", "STR", 6, "Tahoma Narrow", g_color_108); + ObjectSet("SignalSTRM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1t", OBJPROP_XDISTANCE, gi_104 + 155); + ObjectSet("SignalSTRM1t", OBJPROP_YDISTANCE, gi_100 + 43); + ObjectCreate("SignalSTRM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1", l_text_436, 45, "Tahoma Narrow", l_color_500); + ObjectSet("SignalSTRM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1", OBJPROP_XDISTANCE, gi_104 + 130); + ObjectSet("SignalSTRM1", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM5", l_text_428, 45, "Tahoma Narrow", l_color_496); + ObjectSet("SignalSTRM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM5", OBJPROP_XDISTANCE, gi_104 + 110); + ObjectSet("SignalSTRM5", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM15", l_text_420, 45, "Tahoma Narrow", l_color_492); + ObjectSet("SignalSTRM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM15", OBJPROP_XDISTANCE, gi_104 + 90); + ObjectSet("SignalSTRM15", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM30", l_text_452, 45, "Tahoma Narrow", l_color_488); + ObjectSet("SignalSTRM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM30", OBJPROP_XDISTANCE, gi_104 + 70); + ObjectSet("SignalSTRM30", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM60", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM60", l_text_412, 45, "Tahoma Narrow", l_color_484); + ObjectSet("SignalSTRM60", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM60", OBJPROP_XDISTANCE, gi_104 + 50); + ObjectSet("SignalSTRM60", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM240", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM240", l_text_444, 45, "Tahoma Narrow", l_color_480); + ObjectSet("SignalSTRM240", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM240", OBJPROP_XDISTANCE, gi_104 + 30); + ObjectSet("SignalSTRM240", OBJPROP_YDISTANCE, gi_100 + 10); + ObjectCreate("SignalSTRM1440", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1440", l_text_460, 45, "Tahoma Narrow", l_color_476); + ObjectSet("SignalSTRM1440", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1440", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("SignalSTRM1440", OBJPROP_YDISTANCE, gi_100 + 10); + double l_ima_504 = iMA(Symbol(), PERIOD_M1, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_512 = iMA(Symbol(), PERIOD_M1, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_520 = iMA(Symbol(), PERIOD_M5, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_528 = iMA(Symbol(), PERIOD_M5, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_536 = iMA(Symbol(), PERIOD_M15, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_544 = iMA(Symbol(), PERIOD_M15, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_552 = iMA(Symbol(), PERIOD_M30, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_560 = iMA(Symbol(), PERIOD_M30, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_568 = iMA(Symbol(), PERIOD_H1, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_576 = iMA(Symbol(), PERIOD_H1, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_584 = iMA(Symbol(), PERIOD_H4, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_592 = iMA(Symbol(), PERIOD_H4, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_600 = iMA(Symbol(), PERIOD_D1, g_period_164, 0, g_ma_method_172, g_applied_price_176, 0); + double l_ima_608 = iMA(Symbol(), PERIOD_D1, g_period_168, 0, g_ma_method_172, g_applied_price_176, 0); + string l_text_616 = ""; + string l_text_624 = ""; + string l_text_632 = ""; + string l_text_640 = ""; + string l_text_648 = ""; + string l_text_656 = ""; + string l_text_664 = ""; + if (l_ima_504 > l_ima_512) { + l_text_616 = "-"; + l_color_28 = Lime; + } + if (l_ima_504 <= l_ima_512) { + l_text_616 = "-"; + l_color_28 = Red; + } + if (l_ima_520 > l_ima_528) { + l_text_624 = "-"; + l_color_32 = Lime; + } + if (l_ima_520 <= l_ima_528) { + l_text_624 = "-"; + l_color_32 = Red; + } + if (l_ima_536 > l_ima_544) { + l_text_632 = "-"; + l_color_36 = Lime; + } + if (l_ima_536 <= l_ima_544) { + l_text_632 = "-"; + l_color_36 = Red; + } + if (l_ima_552 > l_ima_560) { + l_text_640 = "-"; + l_color_40 = Lime; + } + if (l_ima_552 <= l_ima_560) { + l_text_640 = "-"; + l_color_40 = Red; + } + if (l_ima_568 > l_ima_576) { + l_text_648 = "-"; + l_color_44 = Lime; + } + if (l_ima_568 <= l_ima_576) { + l_text_648 = "-"; + l_color_44 = Red; + } + if (l_ima_584 > l_ima_592) { + l_text_656 = "-"; + l_color_48 = Lime; + } + if (l_ima_584 <= l_ima_592) { + l_text_656 = "-"; + l_color_48 = Red; + } + if (l_ima_600 > l_ima_608) { + l_text_664 = "-"; + l_color_52 = Lime; + } + if (l_ima_600 <= l_ima_608) { + l_text_664 = "-"; + l_color_52 = Red; + } + ObjectCreate("SignalEMAM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1t", "EMA", 6, "Tahoma Narrow", g_color_108); + ObjectSet("SignalEMAM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1t", OBJPROP_XDISTANCE, gi_104 + 155); + ObjectSet("SignalEMAM1t", OBJPROP_YDISTANCE, gi_100 + 51); + ObjectCreate("SignalEMAM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1", l_text_616, 45, "Tahoma Narrow", l_color_28); + ObjectSet("SignalEMAM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1", OBJPROP_XDISTANCE, gi_104 + 130); + ObjectSet("SignalEMAM1", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM5", l_text_624, 45, "Tahoma Narrow", l_color_32); + ObjectSet("SignalEMAM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM5", OBJPROP_XDISTANCE, gi_104 + 110); + ObjectSet("SignalEMAM5", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM15", l_text_632, 45, "Tahoma Narrow", l_color_36); + ObjectSet("SignalEMAM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM15", OBJPROP_XDISTANCE, gi_104 + 90); + ObjectSet("SignalEMAM15", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM30", l_text_640, 45, "Tahoma Narrow", l_color_40); + ObjectSet("SignalEMAM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM30", OBJPROP_XDISTANCE, gi_104 + 70); + ObjectSet("SignalEMAM30", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM60", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM60", l_text_648, 45, "Tahoma Narrow", l_color_44); + ObjectSet("SignalEMAM60", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM60", OBJPROP_XDISTANCE, gi_104 + 50); + ObjectSet("SignalEMAM60", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM240", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM240", l_text_656, 45, "Tahoma Narrow", l_color_48); + ObjectSet("SignalEMAM240", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM240", OBJPROP_XDISTANCE, gi_104 + 30); + ObjectSet("SignalEMAM240", OBJPROP_YDISTANCE, gi_100 + 18); + ObjectCreate("SignalEMAM1440", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1440", l_text_664, 45, "Tahoma Narrow", l_color_52); + ObjectSet("SignalEMAM1440", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1440", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("SignalEMAM1440", OBJPROP_YDISTANCE, gi_100 + 18); + double l_ima_672 = iMA(Symbol(), 0, 1, 0, MODE_EMA, PRICE_CLOSE, 0); + string l_dbl2str_680 = DoubleToStr(l_ima_672, Digits); + if (Show_Smaller_Size == FALSE) { + if (Show_Price == TRUE) { + ObjectCreate("Signalprice", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Signalprice", "" + l_dbl2str_680 + "", 33, "Arial", l_color_488); + ObjectSet("Signalprice", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("Signalprice", OBJPROP_YDISTANCE, gi_100 + 58); + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Price == TRUE) { + ObjectCreate("Signalprice", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Signalprice", "" + l_dbl2str_680 + "", 15, "Arial", l_color_488); + ObjectSet("Signalprice", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("Signalprice", OBJPROP_YDISTANCE, gi_100 + 60); + } + } + int li_688 = 0; + int li_692 = 0; + int li_696 = 0; + int li_700 = 0; + int li_704 = 0; + int li_708 = 0; + li_688 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point; + for (li_708 = 1; li_708 <= 5; li_708++) li_692 = li_692 + (iHigh(NULL, PERIOD_D1, li_708) - iLow(NULL, PERIOD_D1, li_708)) / Point; + for (li_708 = 1; li_708 <= 10; li_708++) li_696 = li_696 + (iHigh(NULL, PERIOD_D1, li_708) - iLow(NULL, PERIOD_D1, li_708)) / Point; + for (li_708 = 1; li_708 <= 20; li_708++) li_700 = li_700 + (iHigh(NULL, PERIOD_D1, li_708) - iLow(NULL, PERIOD_D1, li_708)) / Point; + li_692 /= 5; + li_696 /= 10; + li_700 /= 20; + li_704 = (li_688 + li_692 + li_696 + li_700) / 4; + string ls_unused_712 = ""; + string ls_unused_720 = ""; + string l_dbl2str_728 = ""; + string l_dbl2str_736 = ""; + string l_dbl2str_744 = ""; + string l_dbl2str_752 = ""; + string ls_unused_760 = ""; + string ls_unused_768 = ""; + string ls_776 = ""; + double l_iopen_784 = iOpen(NULL, PERIOD_D1, 0); + double l_iclose_792 = iClose(NULL, PERIOD_D1, 0); + double ld_800 = (Ask - Bid) / Point; + double l_ihigh_808 = iHigh(NULL, PERIOD_D1, 0); + double l_ilow_816 = iLow(NULL, PERIOD_D1, 0); + l_dbl2str_736 = DoubleToStr((l_iclose_792 - l_iopen_784) / Point, 0); + l_dbl2str_728 = DoubleToStr(ld_800, Digits - 4); + l_dbl2str_744 = DoubleToStr(li_704, Digits - 4); + ls_776 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point; + l_dbl2str_752 = DoubleToStr((l_ihigh_808 - l_ilow_816) / Point, 0); + if (l_iclose_792 >= l_iopen_784) { + ls_unused_760 = "-"; + l_color_64 = Lime; + } + if (l_iclose_792 < l_iopen_784) { + ls_unused_760 = "-"; + l_color_64 = OrangeRed; + } + if (l_dbl2str_744 > ls_776) { + ls_unused_768 = "-"; + l_color_68 = Lime; + } + if (l_dbl2str_744 < ls_776) { + ls_unused_768 = "-"; + l_color_68 = OrangeRed; + } + if (Show_Smaller_Size == FALSE) { + if (Show_Xtra_Details == TRUE) { + if (Show_Price == TRUE) { + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7", "Spread", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, gi_100 + 100); + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8", "" + l_dbl2str_728 + "", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, gi_100 + 100); + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9", "Pips to Open", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, gi_100 + 115); + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10", "" + l_dbl2str_736 + "", 12, "Arial Bold", l_color_64); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, gi_100 + 115); + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11", "Hi to Low", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, gi_100 + 130); + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12", "" + l_dbl2str_752 + "", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, gi_100 + 130); + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13", "Daily Av", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, gi_100 + 145); + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14", "" + l_dbl2str_744 + "", 12, "Arial Bold", l_color_68); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, gi_100 + 145); + } + } + } + if (Show_Smaller_Size == FALSE) { + if (Show_Xtra_Details == TRUE) { + if (Show_Price == FALSE) { + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7", "Spread", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, gi_100 + 60); + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8", "" + l_dbl2str_728 + "", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, gi_100 + 60); + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9", "Pips to Open", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, gi_100 + 75); + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10", "" + l_dbl2str_736 + "", 12, "Arial Bold", l_color_64); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, gi_100 + 75); + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11", "Hi to Low", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, gi_100 + 90); + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12", "" + l_dbl2str_752 + "", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, gi_100 + 90); + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13", "Daily Av", 12, "Arial", g_color_112); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, gi_104 + 45); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, gi_100 + 105); + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14", "" + l_dbl2str_744 + "", 12, "Arial Bold", l_color_68); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, gi_100 + 105); + } + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Xtra_Details == TRUE) { + if (Show_Price == TRUE) { + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7", "Spread", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, gi_100 + 80); + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8", "" + l_dbl2str_728 + "", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, gi_100 + 80); + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9", "Pips to Open", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, gi_100 + 95); + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10", "" + l_dbl2str_736 + "", 9, "Arial Bold", l_color_64); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, gi_100 + 95); + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11", "Hi to Low", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, gi_100 + 110); + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12", "" + l_dbl2str_752 + "", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, gi_100 + 110); + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13", "Daily Av", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, gi_100 + 125); + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14", "" + l_dbl2str_744 + "", 9, "Arial Bold", l_color_68); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, gi_100 + 125); + } + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Xtra_Details == TRUE) { + if (Show_Price == FALSE) { + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7", "Spread", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, gi_100 + 60); + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8", "" + l_dbl2str_728 + "", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, gi_100 + 60); + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9", "Pips to Open", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, gi_100 + 75); + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10", "" + l_dbl2str_736 + "", 9, "Arial Bold", l_color_64); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, gi_100 + 75); + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11", "Hi to Low", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, gi_100 + 90); + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12", "" + l_dbl2str_752 + "", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, gi_100 + 90); + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13", "Daily Av", 9, "Arial", g_color_112); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, gi_104 + 40); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, gi_100 + 105); + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14", "" + l_dbl2str_744 + "", 9, "Arial Bold", l_color_68); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, gi_104 + 10); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, gi_100 + 105); + } + } + } + return (0); +} \ No newline at end of file diff --git a/DoubleCCI-With_SMA.mq4 b/DoubleCCI-With_SMA.mq4 new file mode 100644 index 0000000..2545298 --- /dev/null +++ b/DoubleCCI-With_SMA.mq4 @@ -0,0 +1,179 @@ +//+------------------------------------------------------------------+ +//| DoubleCCI-With_EMA.mq4 | +//| Copyright © 2005, Jason Robinson (jnrtrading). | +//| http://www.jnrtrading.co.uk | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)." +#property link "http://www.jnrtrading.co.uk" + +#property indicator_separate_window +#property indicator_buffers 6 +#property indicator_color1 Lime +#property indicator_color2 OrangeRed +#property indicator_color3 DarkKhaki +#property indicator_color4 Yellow +#property indicator_color5 Black +//#property indicator_color6 Black +#property indicator_width1 3 +#property indicator_width2 3 +#property indicator_width3 2 +#property indicator_width4 1 +#property indicator_width5 2 +//#property indicator_width6 1 +#property indicator_level1 100 +#property indicator_level2 100 +#property indicator_level3 250 +#property indicator_level4 350 +#property indicator_level5 -350 +#property indicator_level6 -250 +#property indicator_level7 -100 +#property indicator_level8 -100 + +//---- input parameters +extern int TrendCCI_period = 89; +extern int EntryCCI_period = 21; +extern bool Zero_cross_alert = false; +extern int Alert_level__Includes_negative = 0; +extern bool Show_SMA = true; +extern int SMA_period=30; +extern string SMA_of_TrendCCI_or_EntryCCI = "EntryCCI"; +extern bool Automatic_timeframe_setting; +extern int M1_TrendCCI_period = 89; +extern int M1_EntryCCI_period = 21; +extern int M5_TrendCCI_period = 89; +extern int M5_EntryCCI_period = 21; +extern int M15_TrendCCI_period = 14; +extern int M15_EntryCCI_period = 6; +extern int M30_TrendCCI_period = 14; +extern int M30_EntryCCI_period = 6; +extern int H1_TrendCCI_period = 14; +extern int H1_EntryCCI_period = 6; +extern int H4_TrendCCI_period = 14; +extern int H4_EntryCCI_period = 6; +extern int D1_TrendCCI_period = 14; +extern int D1_EntryCCI_period = 6; +extern int W1_TrendCCI_period = 14; +extern int W1_EntryCCI_period = 6; +extern int MN_TrendCCI_period = 14; +extern int MN_EntryCCI_period = 6; + + +double TrendCCIBuffer[]; +double CCIHistogramUpBuffer[]; +double CCIHistogramDownBuffer[]; +double EntryCCIBuffer[]; +double SMA[]; +//double ZeroLine[]; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators + SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2); + SetIndexBuffer(2, TrendCCIBuffer); + SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2); + SetIndexBuffer(3, EntryCCIBuffer); + SetIndexStyle(0, DRAW_HISTOGRAM, 0, 4); + SetIndexBuffer(0, CCIHistogramUpBuffer); + SetIndexStyle(1, DRAW_HISTOGRAM, 0, 4); + SetIndexBuffer(1, CCIHistogramDownBuffer); + SetIndexBuffer(4, SMA); + SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2); + /*SetIndexBuffer(5, ZeroLine); + SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 1);*/ + + +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custor indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() { + + int limit, trendCCI, entryCCI; + static datetime prevtime = 0; + int counted_bars = IndicatorCounted(); +//---- check for possible errors + if(counted_bars < 0) return(-1); +//---- last counted bar will be recounted + if(counted_bars > 0) counted_bars--; + + limit=Bars-counted_bars; + + if (Automatic_timeframe_setting == true) { + switch(Period()) { + case 1: trendCCI = M1_TrendCCI_period; entryCCI = M1_EntryCCI_period; break; + case 5: trendCCI = M5_TrendCCI_period; entryCCI = M5_EntryCCI_period; break; + case 15: trendCCI = M15_TrendCCI_period; entryCCI = M15_EntryCCI_period; break; + case 30: trendCCI = M30_TrendCCI_period; entryCCI = M30_EntryCCI_period; break; + case 60: trendCCI = H1_TrendCCI_period; entryCCI = H1_EntryCCI_period; break; + case 240: trendCCI = H4_TrendCCI_period; entryCCI = H4_EntryCCI_period; break; + case 1440: trendCCI = D1_TrendCCI_period; entryCCI = D1_EntryCCI_period; break; + case 10080: trendCCI = W1_TrendCCI_period; entryCCI = W1_EntryCCI_period; break; + case 43200: trendCCI = MN_TrendCCI_period; entryCCI = MN_EntryCCI_period; break; + } + } + else { + trendCCI = TrendCCI_period; + entryCCI = EntryCCI_period; + } + IndicatorShortName("(TrendCCI: " + trendCCI + ", EntryCCI: " + entryCCI + ") "); + for( int i = 0; i <= limit; i++) { //int i = limit; i >= 0; i--) { //int i = 0; i <= limit; i++) { + TrendCCIBuffer[i] = iCCI(NULL, 0, trendCCI, PRICE_TYPICAL, i); + + if (TrendCCIBuffer[i] >= 0 ) + CCIHistogramUpBuffer[i] = TrendCCIBuffer[i]; + else + CCIHistogramUpBuffer[i] = 0; + + if (TrendCCIBuffer[i] < 0 ) + CCIHistogramDownBuffer[i] = TrendCCIBuffer[i]; + else + CCIHistogramDownBuffer[i]=0; + + EntryCCIBuffer[i] = iCCI(NULL, 0, entryCCI, PRICE_CLOSE, i); + //ZeroLine[i] = 0; + + } + if (Show_SMA == true) { + if (SMA_of_TrendCCI_or_EntryCCI == "TrendCCI") + for(i=0; i= -Alert_level__Includes_negative)) { + Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed below zero"); + } + } + else if(EntryCCIBuffer[0] > Alert_level__Includes_negative) { + if((TrendCCIBuffer[0] > Alert_level__Includes_negative) && (TrendCCIBuffer[1] <= Alert_level__Includes_negative)) { + Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed above zero"); + } + } + prevtime = Time[0]; + } + } +//---- + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Dynamic Fx - Awesome.mq4 b/Dynamic Fx - Awesome.mq4 new file mode 100644 index 0000000..88eda6a --- /dev/null +++ b/Dynamic Fx - Awesome.mq4 @@ -0,0 +1,81 @@ +//+------------------------------------------------------------------+ +//| Awesome.mq4 | +//| Copyright © 2005, MetaQuotes Software Corp. | +//| http://www.metaquotes.net/ | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2005, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net/" +//---- indicator settings +#property indicator_separate_window +#property indicator_buffers 3 +#property indicator_color1 Black +#property indicator_color2 Black +#property indicator_color3 White + +//---- indicator buffers +double ExtBuffer0[]; +double ExtBuffer1[]; +double ExtBuffer2[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { + //---- drawing settings + SetIndexStyle(0,DRAW_NONE); + SetIndexStyle(1,DRAW_HISTOGRAM); + SetIndexStyle(2,DRAW_HISTOGRAM); + IndicatorDigits(Digits+1); + SetIndexDrawBegin(0,34); + SetIndexDrawBegin(1,34); + SetIndexDrawBegin(2,34); +//---- 3 indicator buffers mapping + SetIndexBuffer(0,ExtBuffer0); + SetIndexBuffer(1,ExtBuffer1); + SetIndexBuffer(2,ExtBuffer2); +//---- name for DataWindow and indicator subwindow label + IndicatorShortName("AO"); + SetIndexLabel(1,NULL); + SetIndexLabel(2,NULL); +//---- initialization done + return(0); + } +//+------------------------------------------------------------------+ +//| Awesome Oscillator | +//+------------------------------------------------------------------+ +int start() + { + int limit; + int counted_bars=IndicatorCounted(); + double prev,current; +//---- last counted bar will be recounted + if(counted_bars>0) counted_bars--; + limit=Bars-counted_bars; +//---- macd + for(int i=0; i=0; i--) + { + current=ExtBuffer0[i]; + prev=ExtBuffer0[i+1]; + if(current>prev) up=true; + if(current=0;shift--) +{ + + +VALUE1=iMA(NULL,0,R,0,Gann_MA_mode,PRICE_HIGH,shift+1); +VALUE2=iMA(NULL,0,R,0,Gann_MA_mode,PRICE_LOW,shift+1); +MA_Period_val=iMA(NULL,0,MA_Period,0,MA_method,PRICE_CLOSE,shift+1); + +if (Close[shift+1]VALUE1 ) Swing=1; +if(dots) +{ +if (Swing==1) { + HighBuffer[shift]=VALUE2; + LowBuffer[shift]=0; + if(VALUE1 > MA_Period_val){ + if(Alert_On && Swing != old_Swing){ + PlaySound("Alert.wav"); + Alert("HiLo dot below MA "+Symbol()+" "+Period()+", "+MA_Period+""); + old_Swing = Swing; + if (Email_on) SendMail(AlertMSG,"Dot below MA"+MA_Period); + } + } +} +if (Swing==-1) { + LowBuffer[shift]=VALUE1; + HighBuffer[shift]=0; + if(VALUE2 < MA_Period_val){ + if(Alert_On && Swing != old_Swing){ + PlaySound("Alert.wav"); + Alert("HiLo dot below MA "+Symbol()+" "+Period()+", "+MA_Period+""); + old_Swing = Swing; + if (Email_on) SendMail(AlertMSG,"Dot above MA"+MA_Period); + } + } +} + +} + +if(line) +{ +if (Swing==1) { + LineBuffer[shift]=VALUE2; + if(VALUE1 > MA_Period_val){ + if(Alert_On && Swing != old_Swing){ + PlaySound("Alert.wav"); + Alert("HiLo line X below MA", MA_Period); + old_Swing = Swing; + if (Email_on) SendMail(AlertMSG,"Line below MA"+MA_Period); + } + } +} + + +if (Swing==-1) { + LineBuffer[shift]=VALUE1; + if(VALUE2 < MA_Period_val){ + if(Alert_On && Swing != old_Swing){ + PlaySound("Alert.wav"); + Alert("HiLo line X above MA", MA_Period); + old_Swing = Swing; + if (Email_on) SendMail(AlertMSG,"Line above MA"+MA_Period); + } + } +} +} + + + //---- +} + return(0); + } +//+------------------------------------------------------------------+ + diff --git a/Dynamic Fx - Gann_hilo_activator_arrow.mq4 b/Dynamic Fx - Gann_hilo_activator_arrow.mq4 new file mode 100644 index 0000000..6511a67 --- /dev/null +++ b/Dynamic Fx - Gann_hilo_activator_arrow.mq4 @@ -0,0 +1,164 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Zoltan Laszlo Ferenci" +#property link "http://www.metatraderprogrammer.com" + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 Black +#property indicator_color2 Black + +double g_ibuf_76[]; +double g_ibuf_80[]; +string gs_dummy_84; +int gi_unused_92 = 0; +bool gi_unused_96 = FALSE; +extern bool email_alert = FALSE; +extern bool sound_alert = TRUE; +extern bool popup_alert = TRUE; +extern bool sound_repeat = TRUE; +extern bool popup_repeat = FALSE; +extern string sound_filename = "alert.wav"; +extern double alertevery = 5.0; +extern int maxrepeat = 2; +extern int signal_bar = 0; +extern int alert_bar = 1; +extern string gannhilo_name = "###Gann_HiLo_Activator_v2###"; +extern int gannhilo_lookback = 10; +extern int ma_period = 1; +extern int ma_mode = 0; +bool gi_168 = TRUE; +bool gi_172 = TRUE; +bool gi_176 = TRUE; +bool gi_180 = FALSE; +int g_datetime_184 = 0; +int g_datetime_188 = 0; +int gi_192 = 0; +bool gi_196 = TRUE; +bool gi_200 = TRUE; +int g_count_204 = 0; +int g_period_208 = 200; + +string ordobjname(int ai_0, string as_4) { + return (DoubleToStr(ai_0, 0) + as_4); +} + +string obj_getdesc(string a_name_0, int ai_8 = -1) { + if (ai_8 != -1) a_name_0 = ordobjname(ai_8, a_name_0); + return (ObjectDescription(a_name_0)); +} + +void obj_loadbool(string as_0, int &ai_8, int ai_12 = -1) { + string ls_16 = obj_getdesc(as_0, ai_12); + if (ls_16 != "") ai_8 = MathRound(StrToDouble(ls_16)); +} + +int init() { + SetIndexStyle(0, DRAW_ARROW); + SetIndexArrow(0, 217); + SetIndexBuffer(0, g_ibuf_76); + SetIndexEmptyValue(0, 0.0); + SetIndexStyle(1, DRAW_ARROW); + SetIndexArrow(1, 218); + SetIndexBuffer(1, g_ibuf_80); + SetIndexEmptyValue(1, 0.0); + return (0); +} + +int deinit() { + return (0); +} + +int signal(int ai_0) { + int li_ret_4 = 0; + double l_icustom_8 = iCustom(Symbol(), 0, gannhilo_name, gannhilo_lookback, 0, ai_0); + double l_icustom_16 = iCustom(Symbol(), 0, gannhilo_name, gannhilo_lookback, 0, ai_0 + 1); + double l_ima_24 = iMA(Symbol(), 0, ma_period, 0, ma_mode, PRICE_CLOSE, ai_0); + double l_ima_32 = iMA(Symbol(), 0, ma_period, 0, ma_mode, PRICE_CLOSE, ai_0 + 1); + if (l_ima_24 > l_icustom_8 && l_ima_32 <= l_icustom_16) li_ret_4 = 1; + if (l_ima_24 < l_icustom_8 && l_ima_32 >= l_icustom_16) li_ret_4 = 2; + return (li_ret_4); +} + +int start() { + int li_12; + int l_ind_counted_0 = IndicatorCounted(); + int li_4 = Bars - l_ind_counted_0; + for (int li_8 = 0; li_8 < li_4; li_8++) { + li_12 = signal(li_8 + signal_bar); + if (li_12 == 2) { + g_ibuf_80[li_8] = High[li_8] + iATR(Symbol(), 0, g_period_208, li_8) / 3.0; + g_ibuf_76[li_8] = EMPTY_VALUE; + } + if (li_12 == 1) { + g_ibuf_76[li_8] = Low[li_8] - iATR(Symbol(), 0, g_period_208, li_8) / 3.0; + g_ibuf_80[li_8] = EMPTY_VALUE; + } + if (li_12 == 0) { + g_ibuf_76[li_8] = EMPTY_VALUE; + g_ibuf_80[li_8] = EMPTY_VALUE; + } + } + Comment(""); + li_12 = 0; + if (g_ibuf_76[alert_bar] != EMPTY_VALUE) li_12 = 1; + if (g_ibuf_80[alert_bar] != EMPTY_VALUE) li_12 = 2; + signal_alert(li_12); + return (0); +} + +void alert_check(int ai_0) { + isfirsttick(); + if (gi_192 == -1) gi_192 = ai_0; + if ((gi_180 && gi_172) || (gi_192 != ai_0 && gi_168)) { + g_datetime_188 = 0; + gi_200 = TRUE; + gi_196 = TRUE; + } else gi_200 = FALSE; + if (gi_176) { + if (gi_200) { + if (gi_192 == ai_0) gi_196 = FALSE; + else gi_196 = TRUE; + } + } else gi_196 = TRUE; + if (gi_200) gi_192 = ai_0; +} + +void signal_alert(int ai_0) { + string ls_4; + int l_datetime_12; + alert_check(ai_0); + if (gi_196) { + if (ai_0 != 0) { + if (ai_0 == 1) ls_4 = "BUY signal on "; + if (ai_0 == 2) ls_4 = "SELL signal on "; + ls_4 = ls_4 + Symbol(); + l_datetime_12 = TimeCurrent(); + if (gi_200) { + g_count_204 = 0; + g_datetime_188 = 0; + } + if (gi_200 || (alertevery > 0.0 && l_datetime_12 - g_datetime_188 > alertevery && g_count_204 < maxrepeat)) { + if (email_alert && gi_200) SendMail(ls_4, ls_4); + if (popup_alert && gi_200 || popup_repeat) Alert(ls_4); + if (sound_alert && gi_200 || sound_repeat) PlaySound(sound_filename); + g_datetime_188 = l_datetime_12; + g_count_204++; + } + } + } +} + +int isfirsttick() { + int l_datetime_0 = iTime(Symbol(), 0, 0); + if (l_datetime_0 == g_datetime_184) { + gi_180 = FALSE; + return (gi_180); + } + g_datetime_184 = l_datetime_0; + gi_180 = TRUE; + return (gi_180); +} \ No newline at end of file diff --git a/Dynamic Fx - Heiken Ashi.mq4 b/Dynamic Fx - Heiken Ashi.mq4 new file mode 100644 index 0000000..3f98d7f --- /dev/null +++ b/Dynamic Fx - Heiken Ashi.mq4 @@ -0,0 +1,101 @@ +//+------------------------------------------------------------------+ +//| Heiken Ashi.mq4 | +//| Copyright c 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//+------------------------------------------------------------------+ +//| For Heiken Ashi we recommend next chart settings ( press F8 or | +//| select on menu 'Charts'->'Properties...'): | +//| - On 'Color' Tab select 'Black' for 'Line Graph' | +//| - On 'Common' Tab disable 'Chart on Foreground' checkbox and | +//| select 'Line Chart' radiobutton | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" + +#property indicator_chart_window +#property indicator_buffers 4 +#property indicator_color1 White +#property indicator_color2 Navy +#property indicator_color3 White +#property indicator_color4 Navy +//---- buffers +double ExtMapBuffer1[]; +double ExtMapBuffer2[]; +double ExtMapBuffer3[]; +double ExtMapBuffer4[]; +//---- +int ExtCountedBars=0; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//|------------------------------------------------------------------| +int init() + { +//---- indicators + SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, White); + SetIndexBuffer(0, ExtMapBuffer1); + SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, Navy); + SetIndexBuffer(1, ExtMapBuffer2); + SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, White); + SetIndexBuffer(2, ExtMapBuffer3); + SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, Navy); + SetIndexBuffer(3, ExtMapBuffer4); +//---- + SetIndexDrawBegin(0,10); + SetIndexDrawBegin(1,10); + SetIndexDrawBegin(2,10); + SetIndexDrawBegin(3,10); +//---- indicator buffers mapping + SetIndexBuffer(0,ExtMapBuffer1); + SetIndexBuffer(1,ExtMapBuffer2); + SetIndexBuffer(2,ExtMapBuffer3); + SetIndexBuffer(3,ExtMapBuffer4); +//---- initialization done + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- TODO: add your code here + +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { + double haOpen, haHigh, haLow, haClose; + if(Bars<=10) return(0); + ExtCountedBars=IndicatorCounted(); +//---- check for possible errors + if (ExtCountedBars<0) return(-1); +//---- last counted bar will be recounted + if (ExtCountedBars>0) ExtCountedBars--; + int pos=Bars-ExtCountedBars-1; + while(pos>=0) + { + haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2; + haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4; + haHigh=MathMax(High[pos], MathMax(haOpen, haClose)); + haLow=MathMin(Low[pos], MathMin(haOpen, haClose)); + if (haOpenPeriod()) { + int PerINT=TimeFrame/Period()+1; + datetime TimeArr[]; ArrayResize(TimeArr,PerINT); + ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); + for(i=0;i=TimeArray[0]) { + /******************************************************** + Refresh buffers: buffer[i] = buffer[0]; + ********************************************************/ + + ExtMapBuffer1[i]=ExtMapBuffer1[0]; + ExtMapBuffer2[i]=ExtMapBuffer2[0]; + ExtMapBuffer3[i]=ExtMapBuffer3[0]; + ExtMapBuffer4[i]=ExtMapBuffer4[0]; + + } } } +//++++++++++++++++++++++++++++++++++++++++++++++++ Raff + + return(0); + } +//+---------------------------------------------------------------+ \ No newline at end of file diff --git a/Dynamic Fx - MACD_OsMA_4ColorHM_2L_mtf.mq4 b/Dynamic Fx - MACD_OsMA_4ColorHM_2L_mtf.mq4 new file mode 100644 index 0000000..f7d4bd2 --- /dev/null +++ b/Dynamic Fx - MACD_OsMA_4ColorHM_2L_mtf.mq4 @@ -0,0 +1,190 @@ +//+------------------------------------------------------------------+ +//| MACD_OsMA_ColorLH.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net/ | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net/" +//---- indicator settings +#property indicator_separate_window +#property indicator_buffers 6 +#property indicator_color1 Black +#property indicator_color2 Black +#property indicator_color3 White +#property indicator_color4 White +#property indicator_color5 CLR_NONE +#property indicator_color6 CLR_NONE + + + +//---- indicator buffers +extern int FastEMA =12; +extern int SlowEMA =26; +extern int SignalSMA =9; +extern int AppliedPrice =PRICE_CLOSE; +extern double OsmaMultiplier = 3; +extern int TimeFrame = 0; +extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; +extern string note_AppliedPrice = "0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6"; +string IndicatorFileName; + + +double ind_buffer1[], ind_buffer1s[]; +double ind_buffer2[], ind_buffer2s[]; +double ind_buffer3[]; +double ind_buffer4[]; +double ind_buffer5[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- 1 additional buffer used for counting. + IndicatorBuffers(7); + //---- drawing settings + SetIndexStyle(0,DRAW_HISTOGRAM); + SetIndexStyle(1,DRAW_HISTOGRAM); + SetIndexStyle(2,DRAW_HISTOGRAM); + SetIndexStyle(3,DRAW_HISTOGRAM); + + SetIndexStyle(4,DRAW_LINE); + SetIndexStyle(5,DRAW_LINE); + + IndicatorDigits(Digits+2); + + SetIndexDrawBegin(0,34); + SetIndexDrawBegin(1,34); + SetIndexDrawBegin(2,34); + SetIndexDrawBegin(3,34); + + SetIndexDrawBegin(4,34); + SetIndexDrawBegin(5,34); + +//---- 3 indicator buffers mapping + SetIndexBuffer(0,ind_buffer1) ; + +//---- 3 indicator buffers mapping + if(!SetIndexBuffer(0,ind_buffer1) && + !SetIndexBuffer(1,ind_buffer1s) && + !SetIndexBuffer(2,ind_buffer2) && + !SetIndexBuffer(3,ind_buffer2s) && + !SetIndexBuffer(4,ind_buffer4) && + !SetIndexBuffer(5,ind_buffer5) && + !SetIndexBuffer(6,ind_buffer3)) + Print("cannot set indicator buffers!"); + + SetIndexLabel(0,""); + SetIndexLabel(1,""); + SetIndexLabel(2,""); + SetIndexLabel(3,""); + + +//---- name for DataWindow and indicator subwindow label + + IndicatorFileName = WindowExpertName(); + IndicatorShortName("MACD_OsMA["+TimeFrame+"]("+FastEMA+","+SlowEMA+","+SignalSMA+")"); + if (TimeFrame < Period()) TimeFrame = Period(); + + +//---- initialization done + return(0); + } +//+------------------------------------------------------------------+ +//| Awesome Oscillator | +//+------------------------------------------------------------------+ +int start() + { + int counted_bars1=IndicatorCounted(); + int limit1,i1; + if(counted_bars1 < 0) return(-1); + limit1 = Bars-counted_bars1; + if (TimeFrame != Period()) + { + limit1 = MathMax(limit1,TimeFrame/Period()); + datetime TimeArray[]; + ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame); + for(i1=0,int y=0; i10) counted_bars--; + limit=Bars-counted_bars; +//---- macd counted in the 1-st additional buffer + for(int i=0; i=0; i--) + { + current=ind_buffer3[i]; + prev=ind_buffer3[i+1]; + if (((current<0)&&(prev>0))||(current<0)) up= false; + if (((current>0)&&(prev<0))||(current>0)) up= true; + + if(!up) + { + if(current > prev) + { + ind_buffer1[i]=0.0; + ind_buffer1s[i]=0.0; + ind_buffer2[i]=0.0; + ind_buffer2s[i]=current; + } + else + { + ind_buffer1[i]=0.0; + ind_buffer1s[i]=0.0; + ind_buffer2[i]=current; + ind_buffer2s[i]=0.0; + } + } + else + { + if(current < prev) + { + ind_buffer1[i]=0.0; + ind_buffer1s[i]=current; + ind_buffer2[i]=0.0; + ind_buffer2s[i]=0.0; + } + else + { + ind_buffer1[i]=current; + ind_buffer1s[i]=0.0; + ind_buffer2[i]=0.0; + ind_buffer2s[i]=0.0; + } + } + } +//---- done + return(0); + } + diff --git a/Dynamic Fx - Magnified Market Price.mq4 b/Dynamic Fx - Magnified Market Price.mq4 new file mode 100644 index 0000000..a401969 --- /dev/null +++ b/Dynamic Fx - Magnified Market Price.mq4 @@ -0,0 +1,45 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ + +#property indicator_chart_window + +extern string note1 = "Change font colors automatically? True = Yes"; +extern bool Bid_Ask_Colors = FALSE; +extern string note2 = "Default Font Color"; +extern color FontColor = Black; +extern string note3 = "Font Size"; +extern int FontSize = 12; +extern string note4 = "Font Type"; +extern string FontType = "Arial Bold"; +extern string note5 = "Display the price in what corner?"; +extern string note6 = "Upper left=0; Upper right=1"; +extern string note7 = "Lower left=2; Lower right=3"; +extern int WhatCorner = 2; +double g_bid_156; + +int init() { + return (0); +} + +int deinit() { + ObjectDelete("Market_Price_Label"); + return (0); +} + +int start() { + if (Bid_Ask_Colors == TRUE) { + if (Bid > g_bid_156) FontColor = LawnGreen; + if (Bid < g_bid_156) FontColor = Red; + g_bid_156 = Bid; + } + string l_dbl2str_0 = DoubleToStr(Bid, Digits); + ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Market_Price_Label", l_dbl2str_0, FontSize, FontType, FontColor); + ObjectSet("Market_Price_Label", OBJPROP_CORNER, WhatCorner); + ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 4); + ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, 10); + return (0); +} \ No newline at end of file diff --git a/Dynamic Fx - Spread - blk.mq4 b/Dynamic Fx - Spread - blk.mq4 new file mode 100644 index 0000000..7918c5d --- /dev/null +++ b/Dynamic Fx - Spread - blk.mq4 @@ -0,0 +1,70 @@ +//+------------------------------------------------------------------+ +//| Spread.mq4 | +//| Copyright © 2009, Andriy Moraru | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2009, Andriy Moraru" +#property link "http://www.earnforex.com" + +#property indicator_chart_window + +extern color font_color = Black; +extern int font_size = 8; +extern string font_face = "Arial Bold"; +extern int corner = 2; //0 - for top-left corner, 1 - top-right, 2 - bottom-left, 3 - bottom-right +extern int spread_distance_x = 4; +extern int spread_distance_y = 2; +extern bool normalize = false; //If true then the spread is normalized to traditional pips + +double Poin; +int n_digits = 0; +double divider = 1; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ + //Checking for unconvetional Point digits number + if (Point == 0.00001) Poin = 0.0001; //5 digits + else if (Point == 0.001) Poin = 0.01; //3 digits + else Poin = Point; //Normal + + ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0); + ObjectSet("Spread", OBJPROP_CORNER, corner); + ObjectSet("Spread", OBJPROP_XDISTANCE, spread_distance_x); + ObjectSet("Spread", OBJPROP_YDISTANCE, spread_distance_y); + double spread = MarketInfo(Symbol(), MODE_SPREAD); + + if ((Poin > Point) && (normalize)) + { + divider = 10.0; + n_digits = 1; + } + + ObjectSetText("Spread", "Spread: " + DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) + " points.", font_size, font_face, font_color); + + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() +{ + ObjectDelete("Spread"); + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ + RefreshRates(); + + double spread = (Ask - Bid) / Point; + ObjectSetText("Spread", "Spread: " + DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) + " points.", font_size, font_face, font_color); + + return(0); +} +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Dynamic Fx - SweetSpots.mq4 b/Dynamic Fx - SweetSpots.mq4 new file mode 100644 index 0000000..db65621 --- /dev/null +++ b/Dynamic Fx - SweetSpots.mq4 @@ -0,0 +1,132 @@ +//+------------------------------------------------------------------+ +//| SweetSpots.mq4 | +//| | +//| | +//+------------------------------------------------------------------+ +#property copyright "Copyright Shimodax" +#property link "http://www.strategybuilderfx.com" + +#property indicator_chart_window + +/* Introduction: + + This indicator shows lines at sweet spots (50 and 100 + pips levels). It is recommended to turn off the grid. + + Enjoy! + + Markus +*/ + +extern int NumLinesAboveBelow= 100; +extern int SweetSpotMainLevels= 100; +extern color LineColorMain= DarkSlateGray; +extern int LineStyleMain= STYLE_DOT; +extern bool ShowSubLevels= true; +extern int sublevels= 250; +extern color LineColorSub= DarkSlateGray; +extern int LineStyleSub= STYLE_DOT; + + + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ + return(0); +} + +int deinit() +{ + int obj_total= ObjectsTotal(); + + for (int i= obj_total; i>=0; i--) { + string name= ObjectName(i); + + if (StringSubstr(name,0,11)=="[SweetSpot]") + ObjectDelete(name); + } + + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ + static datetime timelastupdate= 0; + static datetime lasttimeframe= 0; + + + // no need to update these buggers too often + if (CurTime()-timelastupdate < 600 && Period()==lasttimeframe) + return (0); + + deinit(); // delete all previous lines + + int i, ssp1, style, ssp, thickness; //sublevels= 50; + double ds1; + color linecolor; + + if (!ShowSubLevels) + sublevels*= 2; + + ssp1= Bid / Point; + ssp1= ssp1 - ssp1%sublevels; + + for (i= -NumLinesAboveBelow; i 2) + { + nCountedBars--; + i = Bars - nCountedBars - 1; + } +//----Up and Down Fractals + while(i >= 2) + { + //----Fractals up + bFound = false; + dCurrent = High[i]; + if(dCurrent > High[i+1] && dCurrent > High[i+2] && dCurrent > High[i-1] && + dCurrent > High[i-2]) + { + bFound = true; + ExtUpFractalsBuffer[i] = dCurrent; + } + //----6 bars Fractal + if(!bFound && (Bars - i - 1) >= 3) + { + if(dCurrent == High[i+1] && dCurrent > High[i+2] && dCurrent > High[i+3] && + dCurrent > High[i-1] && dCurrent > High[i-2]) + { + bFound = true; + ExtUpFractalsBuffer[i] = dCurrent; + } + } + //----7 bars Fractal + if(!bFound && (Bars - i - 1) >= 4) + { + if(dCurrent >= High[i+1] && dCurrent == High[i+2] && dCurrent > High[i+3] && + dCurrent > High[i+4] && dCurrent > High[i-1] && dCurrent > High[i-2]) + { + bFound = true; + ExtUpFractalsBuffer[i] = dCurrent; + } + } + //----8 bars Fractal + if(!bFound && (Bars - i - 1) >= 5) + { + if(dCurrent >= High[i+1] && dCurrent == High[i+2] && dCurrent == High[i+3] && + dCurrent > High[i+4] && dCurrent > High[i+5] && dCurrent > High[i-1] && + dCurrent > High[i-2]) + { + bFound = true; + ExtUpFractalsBuffer[i] = dCurrent; + } + } + //----9 bars Fractal + if(!bFound && (Bars - i - 1) >= 6) + { + if(dCurrent >= High[i+1] && dCurrent == High[i+2] && dCurrent >= High[i+3] && + dCurrent == High[i+4] && dCurrent > High[i+5] && dCurrent > High[i+6] && + dCurrent > High[i-1] && dCurrent > High[i-2]) + { + bFound = true; + ExtUpFractalsBuffer[i] = dCurrent; + } + } + //----Fractals down + bFound = false; + dCurrent = Low[i]; + if(dCurrent < Low[i+1] && dCurrent < Low[i+2] && dCurrent < Low[i-1] && + dCurrent < Low[i-2]) + { + bFound = true; + ExtDownFractalsBuffer[i] = dCurrent; + } + //----6 bars Fractal + if(!bFound && (Bars - i - 1) >= 3) + { + if(dCurrent == Low[i+1] && dCurrent < Low[i+2] && dCurrent < Low[i+3] && + dCurrent < Low[i-1] && dCurrent < Low[i-2]) + { + bFound = true; + ExtDownFractalsBuffer[i] = dCurrent; + } + } + //----7 bars Fractal + if(!bFound && (Bars - i - 1) >= 4) + { + if(dCurrent <= Low[i+1] && dCurrent == Low[i+2] && dCurrent < Low[i+3] && + dCurrent < Low[i+4] && + dCurrent < Low[i-1] && dCurrent < Low[i-2]) + { + bFound = true; + ExtDownFractalsBuffer[i] = dCurrent; + } + } + //----8 bars Fractal + if(!bFound && (Bars - i - 1) >= 5) + { + if(dCurrent <= Low[i+1] && dCurrent == Low[i+2] && dCurrent==Low[i+3] && + dCurrent < Low[i+4] && dCurrent < Low[i+5] && dCurrent < Low[i-1] && + dCurrent < Low[i-2]) + { + bFound = true; + ExtDownFractalsBuffer[i] = dCurrent; + } + } + //----9 bars Fractal + if(!bFound && (Bars - i- 1) >= 6) + { + if(dCurrent <= Low[i+1] && dCurrent == Low[i+2] && dCurrent <= Low[i+3] && + dCurrent == Low[i+4] && dCurrent < Low[i+5] && dCurrent < Low[i+6] && + dCurrent < Low[i-1] && dCurrent < Low[i-2]) + { + bFound = true; + ExtDownFractalsBuffer[i] = dCurrent; + } + } + i--; + } +// Статические переменные, в которых хранятся время последнего бара и направление +// последнего сигнала + static int PrevSignal = 0, PrevTime = 0; +// Если баром для анализа выбран не 0-й, нам нет смысла проверять сигнал несколько раз. +// Если не начался новый бар, выходим. + if(SIGNAL_BAR > 0 && Time[0] <= PrevTime) + return(0); +// Отмечаем, что этот бар проверен + PrevTime = Time[0]; +// Если предыдущий сигнал был СЕЛЛ или это первый запуск (PrevSignal=0) + if(PrevSignal <= 0) + { + if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0) + { + PrevSignal = 1; + Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!"); + } + } + if(PrevSignal >= 0) + { + if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0) + { + PrevSignal = -1; + Alert("sFractals (", Symbol(), ", ", Period(), ") - SELL!!!"); + } + } +//---- + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/EA_HGNR_V.2.1_GU.mq4 b/EA_HGNR_V.2.1_GU.mq4 new file mode 100644 index 0000000..5b27894 --- /dev/null +++ b/EA_HGNR_V.2.1_GU.mq4 @@ -0,0 +1,90 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, High Gain No Risk" +#property link "http://www.highgainnorisk.com" + +int gi_76 = 12; +int gi_80 = 8; +int g_slippage_84 = 2; +int g_magic_88 = 11111; +int gi_92 = 200; +int gi_unused_96 = 6; +int gi_unused_100 = 11; +double gd_104 = 0.01; +double gd_unused_112 = 0.03; +double gd_unused_120 = -0.01; +double gd_unused_128 = 20.0; +double gd_unused_136 = 203.0; +double g_ord_open_price_152; +double g_ord_open_price_160; +double g_lots_168; +string gs_200 = "EU"; +string g_comment_208 = "GU"; +string gs_unused_216 = "UJ"; +string g_comment_224 = "EA_Off"; +int g_count_232; +int g_count_236; +int gi_244; +int gi_unused_256 = 0; +int gi_unused_260 = 0; +int gi_unused_264 = 0; +int gi_unused_268 = 0; +bool gi_276; +bool gi_280; +int gi_284 = 000000; + +int init() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_208, g_magic_88, 0, Blue); + return (0); +} + +int deinit() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_224, g_magic_88, 0, Blue); + return (0); +} + +int start() { + int li_unused_12; + int li_0 = AccountEquity(); + double ld_4 = li_0 % gi_92; + gi_244 = (li_0 - ld_4) / gi_92; + g_lots_168 = NormalizeDouble(gd_104 * gi_244, Digits); + if (g_lots_168 < gd_104) g_lots_168 = gd_104; + g_lots_168 = gd_104; + if (myComment()) li_unused_12 = 0; + g_count_232 = 0; + g_count_236 = 0; + gi_276 = FALSE; + gi_280 = FALSE; + for (int l_pos_16 = 0; l_pos_16 <= OrdersTotal() - 1; l_pos_16++) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_208) { + g_count_232++; + g_ord_open_price_152 = OrderOpenPrice(); + } + if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_208) { + g_count_236++; + g_ord_open_price_160 = OrderOpenPrice(); + } + if (OrderMagicNumber() == g_magic_88 && OrderComment() == gs_200) gi_276 = TRUE; + if (OrderType() == OP_BUYSTOP && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_208) gi_280 = TRUE; + } + if (gi_276 == FALSE) Alert("EA pada pair EUR/USD belum siap!"); + if (OrdersTotal() == 0 || (gi_280 != TRUE && g_count_232 + g_count_236 < 1)) OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_208, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_232 == 0 || (g_count_232 > 0 && Bid <= g_ord_open_price_152 - gi_80 * Point)) OrderSend(Symbol(), OP_BUY, g_lots_168, Ask, g_slippage_84, 0, Ask + gi_76 * Point, g_comment_208, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_236 == 0 || (g_count_236 > 0 && Ask >= g_ord_open_price_160 + gi_80 * Point)) OrderSend(Symbol(), OP_SELL, g_lots_168, Bid, g_slippage_84, 0, Bid - gi_76 * Point, g_comment_208, g_magic_88, 0, Red); + return (0); +} + +int IzinTrade() { + //if ((Day() > 26 && Month() >= 12 && Year() >= 2009) || IsDemo() || AccountNumber() != gi_284 || IsTesting() || gi_276 != TRUE) return (0); + return (1); +} + +bool myComment() { + Comment("EA_HGNR_V.2"); + return (FALSE); +} \ No newline at end of file diff --git a/EA_HGNR_V.2.2_UCF.mq4 b/EA_HGNR_V.2.2_UCF.mq4 new file mode 100644 index 0000000..79d5151 --- /dev/null +++ b/EA_HGNR_V.2.2_UCF.mq4 @@ -0,0 +1,84 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, High Gain No Risk" +#property link "http://www.highgainnorisk.com" + +int gi_76 = 12; +int gi_80 = 3; +int g_slippage_84 = 2; +int g_magic_88 = 11111; +int gi_92 = 200; +int gi_unused_96 = 6; +int gi_unused_100 = 11; +double gd_104 = 0.01; +double gd_unused_112 = 0.03; +double g_lots_128; +double g_ord_open_price_136; +double g_ord_open_price_144; +string gs_ucf_152 = "UCF"; +string gs_160 = "EU"; +string g_comment_168 = "EA_Off"; +int g_count_176; +int g_count_180; +int g_count_184; +int g_count_188; +int gi_192; +bool gi_196; +int gi_200 = 000000; + +int init() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, gs_ucf_152, g_magic_88, 0, Blue); + return (0); +} + +int deinit() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_168, g_magic_88, 0, Blue); + return (0); +} + +int start() { + int li_unused_12; + int li_0 = AccountEquity(); + double ld_4 = li_0 % gi_92; + gi_192 = (li_0 - ld_4) / gi_92; + g_lots_128 = NormalizeDouble(gd_104 * gi_192, Digits); + if (g_lots_128 < gd_104) g_lots_128 = gd_104; + g_lots_128 = gd_104; + if (COMMENT()) li_unused_12 = 0; + g_count_176 = 0; + g_count_180 = 0; + g_count_184 = 0; + g_count_188 = 0; + gi_196 = FALSE; + for (int l_pos_16 = 0; l_pos_16 <= OrdersTotal() - 1; l_pos_16++) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_ucf_152) { + g_count_176++; + g_ord_open_price_136 = OrderOpenPrice(); + } + if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_ucf_152) { + g_count_180++; + g_ord_open_price_144 = OrderOpenPrice(); + } + if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_160) g_count_184++; + if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_160) g_count_188++; + if (OrderType() == OP_BUYSTOP && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_ucf_152) gi_196 = TRUE; + } + if (OrdersTotal() == 0 || (gi_196 != TRUE && g_count_176 + g_count_180 < 1)) OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, gs_ucf_152, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_184 > g_count_176 && MathAbs((g_ord_open_price_136 - Ask) / Point) >= gi_80 || g_count_176 < 1) OrderSend(Symbol(), OP_BUY, g_lots_128, Ask, g_slippage_84, 0, Ask + gi_76 * Point, gs_ucf_152, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_188 > g_count_180 && MathAbs((g_ord_open_price_144 - Bid) / Point) >= gi_80 || g_count_180 < 1) OrderSend(Symbol(), OP_SELL, g_lots_128, Bid, g_slippage_84, 0, Bid - gi_76 * Point, gs_ucf_152, g_magic_88, 0, Red); + return (0); +} + +int IzinTrade() { + //if ((Day() > 26 && Month() >= 12 && Year() >= 2009) || AccountNumber() != gi_200 || IsDemo() || IsTesting()) return (0); + return (1); +} + +bool COMMENT() { + Comment("EA_HGNR_V.2"); + return (FALSE); +} \ No newline at end of file diff --git a/EA_HGNR_V.2.2_UJ.mq4 b/EA_HGNR_V.2.2_UJ.mq4 new file mode 100644 index 0000000..3760747 --- /dev/null +++ b/EA_HGNR_V.2.2_UJ.mq4 @@ -0,0 +1,84 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, High Gain No Risk" +#property link "http://www.highgainnorisk.com" + +int gi_76 = 12; +int gi_80 = 3; +int g_slippage_84 = 2; +int g_magic_88 = 11111; +int gi_92 = 200; +int gi_unused_96 = 6; +int gi_unused_100 = 11; +double gd_104 = 0.01; +double gd_unused_112 = 0.03; +double g_lots_128; +double g_ord_open_price_136; +double g_ord_open_price_144; +string g_comment_152 = "UJ"; +string gs_160 = "GU"; +string g_comment_168 = "EA_Off"; +int g_count_176; +int g_count_180; +int g_count_184; +int g_count_188; +int gi_192; +bool gi_196; +int gi_200 = 000000; + +int init() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_152, g_magic_88, 0, Blue); + return (0); +} + +int deinit() { + OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_168, g_magic_88, 0, Blue); + return (0); +} + +int start() { + int li_unused_12; + int li_0 = AccountEquity(); + double ld_4 = li_0 % gi_92;s + gi_192 = (li_0 - ld_4) / gi_92; + g_lots_128 = NormalizeDouble(gd_104 * gi_192, Digits); + if (g_lots_128 < gd_104) g_lots_128 = gd_104; + g_lots_128 = gd_104; + if (COMMENT()) li_unused_12 = 0; + g_count_176 = 0; + g_count_180 = 0; + g_count_184 = 0; + g_count_188 = 0; + gi_196 = FALSE; + for (int l_pos_16 = 0; l_pos_16 <= OrdersTotal() - 1; l_pos_16++) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_152) { + g_count_176++; + g_ord_open_price_136 = OrderOpenPrice(); + } + if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_152) { + g_count_180++; + g_ord_open_price_144 = OrderOpenPrice(); + } + if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_160) g_count_184++; + if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_88 && OrderComment() == gs_160) g_count_188++; + if (OrderType() == OP_BUYSTOP && OrderMagicNumber() == g_magic_88 && OrderComment() == g_comment_152) gi_196 = TRUE; + } + if (OrdersTotal() == 0 || (gi_196 != TRUE && g_count_176 + g_count_180 < 1)) OrderSend(Symbol(), OP_BUYSTOP, 0.01, Ask + 500.0 * Point, 5, 0, 0, g_comment_152, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_184 > g_count_176 && MathAbs((g_ord_open_price_136 - Ask) / Point) >= gi_80 || g_count_176 < 1) OrderSend(Symbol(), OP_BUY, g_lots_128, Ask, g_slippage_84, 0, Ask + gi_76 * Point, g_comment_152, g_magic_88, 0, Blue); + if (IzinTrade() && g_count_188 > g_count_180 && MathAbs((g_ord_open_price_136 - Bid) / Point) >= gi_80 || g_count_180 < 1) OrderSend(Symbol(), OP_SELL, g_lots_128, Bid, g_slippage_84, 0, Bid - gi_76 * Point, g_comment_152, g_magic_88, 0, Red); + return (0); +} + +int IzinTrade() { + //if ((Day() > 26 && Month() >= 12 && Year() >= 2009) || AccountNumber() != gi_200 || IsDemo() || IsTesting()) return (0); + return (1); +} + +bool COMMENT() { + Comment("EA_HGNR_V.2"); + return (FALSE); +} \ No newline at end of file diff --git a/EMA Crossover.mq4 b/EMA Crossover.mq4 new file mode 100644 index 0000000..18e63b8 --- /dev/null +++ b/EMA Crossover.mq4 @@ -0,0 +1,204 @@ +//+------------------------------------------------------------------+ +//| EMA-Crossover_Signal.mq4 | +//| Copyright © 2005, Jason Robinson (jnrtrading) | +//| http://www.jnrtading.co.uk | +//+------------------------------------------------------------------+ + +/* + +------------------------------------------------------------------+ + | Allows you to enter two ema periods and it will then show you at | + | Which point they crossed over. It is more usful on the shorter | + | periods that get obscured by the bars / candlesticks and when | + | the zoom level is out. Also allows you then to remove the emas | + | from the chart. (emas are initially set at 5 and 6) | + +------------------------------------------------------------------+ +*/ +#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)" +#property link "http://www.jnrtrading.co.uk" + +#property indicator_chart_window +#property indicator_buffers 3 +#property indicator_color1 SeaGreen +#property indicator_color2 Red +#property indicator_color3 Blue + +double CrossUp[]; +double CrossDown[]; +//double signal[]; +extern bool DisplayArrows = true; +extern bool AlertOn = false; +extern bool EmailOn = false; +extern int FasterEMA = 1; +extern int SlowerEMA = 11; +double alertTag; + + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators + SetIndexStyle(0, DRAW_ARROW, EMPTY, 2); + SetIndexArrow(0, 233); + SetIndexBuffer(0, CrossUp); + SetIndexStyle(1, DRAW_ARROW, EMPTY, 2); + SetIndexArrow(1, 234); + SetIndexBuffer(1, CrossDown); + //SetIndexStyle(2, DRAW_NONE); + //SetIndexArrow(2, 235); + //SetIndexBuffer(2, signal); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() { + int limit, i, counter; + double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter; + double Range, AvgRange; + + int counted_bars=IndicatorCounted(); +//---- check for possible errors + if(counted_bars<0) return(-1); +//---- last counted bar will be recounted + if(counted_bars>0) counted_bars--; + + limit = Bars - counted_bars; + + //signal[0] = 0; + + for(i = 0; i <= limit; i++) { + + counter=i; + Range=0; + AvgRange=0; + for (counter = i; counter <= i+9; counter++) + { + AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); + } + Range=AvgRange/10; + + fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i); + fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); + fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); + + slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i); + slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); + slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); + + if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) { + + if (DisplayArrows) CrossUp[i] = Low[i] - Range*0.5; + + if ( i == 1 && alertTag != Time[0]) { + + if (AlertOn) Alert("BUY signal at " + Ask + " on ",Symbol()," ",Period()); + if (EmailOn) Send_Email("BUY"); + + } + + //signal[i-1] = 1; + alertTag = Time[0]; + + } else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) { + + if (DisplayArrows) CrossDown[i] = High[i] + Range*0.5; + + if ( i == 1 && alertTag != Time[0]) { + + if (AlertOn) Alert("SELL signal at " + Bid + " on ",Symbol()," ",Period()); + if (EmailOn) Send_Email("SELL"); + + } + + //signal[i-1] = -1; + alertTag = Time[0]; + + } + + } + + return(0); +} + +//+------------------------------------------------------------------+ +//| Function to send Alert Notifications by E-mail | +//+------------------------------------------------------------------+ +void Send_Email(string event) +{ + + string email_subject; + string email_body; + + email_subject = Symbol() + ": " + event + " signal alert"; + + email_body = email_body + "\nPeriod: " + Period(); + //email_body = email_body + "\nTime: " + Year()+"."+formatDateTime(Month())+"."+formatDateTime(Day()) + " " + // + formatDateTime(Hour()) + ":" + formatDateTime(Minute()) + ":" + formatDateTime(Seconds()); + email_body = email_body + "\nTime: " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS); + + if (event == "BUY") + email_body = email_body + "\nPrice: " + DoubleToStr(Ask,5); + else if (event == "SELL") + email_body = email_body + "\nPrice: " + DoubleToStr(Bid,5); + + email_body = email_body + "\n*****Open Trades*****"; + + for(int cnt=OrdersTotal()-1;cnt>=0;cnt--) + { + OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES); + email_body = email_body + "\n------------------------"; + email_body = email_body + "\nOrder Symbol: " + OrderSymbol(); + email_body = email_body + "\nOrder Open Price: " + DoubleToStr(OrderOpenPrice(),5); + email_body = email_body + "\nOrder Profit: " + DoubleToStr(ProfitInPips(OrderTicket()),1) + " pips (" + + DoubleToStr(OrderProfit(),2) + " " + AccountCurrency() + ")"; + email_body = email_body + "\n------------------------"; + } + + email_body = email_body + "\n*****Account Information*****"; + email_body = email_body + "\nCurrent Balance: " + DoubleToStr(AccountBalance(),2) + " " + AccountCurrency(); + email_body = email_body + "\nCurrent Equity: " + DoubleToStr(AccountEquity(),2) + " " + AccountCurrency(); + + SendMail(email_subject, email_body); + + return(0); +} + +/*string formatDateTime(int value) { + if (value >= 10) + return (value); + else + return ("0" + value); +}*/ + +double ProfitInPips(int ticket) { + + double ProfitInPips = 0; + + if (OrderSelect(ticket, SELECT_BY_TICKET) && (OrderType() == OP_BUY || OrderType() == OP_SELL)) { + ProfitInPips = MathAbs((OrderOpenPrice()-OrderClosePrice())/Point); + + if (OrderType() == OP_BUY && OrderOpenPrice() > OrderClosePrice() ) + ProfitInPips = -ProfitInPips; + else if (OrderType() == OP_SELL && OrderOpenPrice() < OrderClosePrice() ) + ProfitInPips = -ProfitInPips; + + } + + if (Digits == 5 || Digits == 3) + ProfitInPips = ProfitInPips/10; + + return (NormalizeDouble(ProfitInPips,1)); +} \ No newline at end of file diff --git a/EURO_BLASTER V3.mq4 b/EURO_BLASTER V3.mq4 new file mode 100644 index 0000000..9dd7302 --- /dev/null +++ b/EURO_BLASTER V3.mq4 @@ -0,0 +1,689 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, Forex Spiritual Team " +#property link "http://www.euro-blaster.com" + +extern string EA_Name = "EURO_BLASTER"; +extern string Creator = "Copyright © 2009, Forex Spiritual Team"; +extern int MagicNo = 2345; +extern string Part1 = "=== Time Management ==="; +extern bool Use_Time_Mgmt = TRUE; +extern bool Trade_On_Friday = FALSE; +extern string Part1_1 = "= Start-End Time ="; +extern int TradeStartHour = 0; +extern int TradeStartMinutes = 0; +extern int TradeEndHour = 12; +extern int TradeEndMinutes = 0; +extern string Part1_2 = "= Start-End Time 2 ="; +extern int TradeStartHour2 = 12; +extern int TradeStartMinutes2 = 0; +extern int TradeEndHour2 = 23; +extern int TradeEndMinutes2 = 0; +extern string Part2 = "=== Trading Management ==="; +extern bool MM = TRUE; +extern bool Aggresive_Lot_Size = FALSE; +extern double RiskPercent = 5.0; +extern double LotSize = 0.01; +extern double Max_Lot_Size = 100.0; +extern int MaxOrder = 5; +extern double StopTime = 0.0; +extern double TakeProfit = 25.0; +extern double Min_Auto_TP = 10.0; +extern double StopLoss = 300.0; +extern double Slippage = 3.0; +extern double TrailingStop = 0.0; +extern bool TrailingProfit = FALSE; +extern int TrailingPips = 1; +extern bool Profit_Protection = FALSE; +extern double Percent_Over_Balance = 3.0; +extern bool BreakEven = TRUE; +extern int BreakEvenPips = 10; +extern bool HedgeAllowed = FALSE; +extern string Wish_U_Have = "=== Good Luck ==="; +int g_period_292 = 10; +double gd_unused_296 = 5.0; +double gd_unused_304 = 10.0; +double gd_unused_312 = 22.0; +double gd_unused_320 = 20.0; +double gd_unused_328 = 26.0; +double gd_unused_336 = 13.0; +double gd_unused_344 = 15.0; +double gd_unused_352 = 10.0; +double gd_360; +double g_minlot_368; +double g_lotstep_376; +double gd_384; +int gi_392; +double g_price_396; +double g_point_412; +int g_slippage_420; +bool gi_unused_424 = FALSE; +int gi_428 = 23; +int gi_432 = 30; +int gi_436 = 100; +int gi_440 = 0; +int gi_444 = 0; + +int init() { + if (Point == 0.00001) g_point_412 = 0.0001; + else { + if (Point == 0.001) g_point_412 = 0.01; + else g_point_412 = Point; + } + return (0); +} + +int deinit() { + return (0); +} + +int Crossed(double ad_0, double ad_8) { + if (ad_0 > ad_8) gi_444 = 1; + if (ad_0 < ad_8) gi_444 = 2; + if (gi_444 != gi_440) { + gi_440 = gi_444; + return (gi_440); + } + return (0); +} + +double Predict() { + double l_ima_4; + double l_ima_28; + double l_ima_36; + double l_istddev_132; + double ld_ret_172; + double ld_44 = 0; + double ld_52 = 0; + double ld_68 = 0; + double ld_76 = 0; + double ld_unused_84 = 0; + double ld_unused_92 = 0; + double ld_100 = 0; + double ld_108 = 0; + double ld_116 = 0; + double ld_124 = 0; + double ld_140 = 0; + double ld_unused_60 = 0; + double ld_156 = 0; + double ld_164 = 0; + double ld_180 = 0; + double ld_20 = 0; + double l_ima_12 = iMA(NULL, 0, g_period_292, 0, MODE_SMA, PRICE_CLOSE, 0); + for (int li_0 = 1; li_0 <= g_period_292; li_0++) { + l_ima_4 = iMA(NULL, 0, g_period_292, 0, MODE_SMA, PRICE_CLOSE, li_0); + l_ima_28 = iMA(NULL, 0, g_period_292, 0, MODE_SMA, PRICE_HIGH, li_0); + l_ima_36 = iMA(NULL, 0, g_period_292, 0, MODE_SMA, PRICE_LOW, li_0); + l_istddev_132 = iStdDev(NULL, 0, g_period_292, 0, MODE_SMA, PRICE_CLOSE, li_0); + ld_44 += (High[li_0] + Low[li_0]) / 2.0; + ld_52 += Close[li_0]; + ld_68 += ld_44 - ld_52; + ld_76 += l_ima_4; + ld_124 += l_istddev_132; + ld_156 += Close[li_0] - Open[li_0] - (Close[li_0 - 1] - (Open[li_0 - 1])); + ld_20 = ld_20 + (l_ima_28 - l_ima_4) + (l_ima_36 - l_ima_4); + } + ld_100 = ld_44 / g_period_292; + ld_108 = ld_52 / g_period_292; + ld_116 = ld_76 / g_period_292; + ld_140 = ld_124 / g_period_292; + ld_180 = ld_68 / g_period_292; + ld_164 = ld_156 / g_period_292; + if (ld_180 > 0.0 && l_ima_12 > ld_116 && ld_164 > 0.0 && Open[0] < l_ima_12 + ld_140 && Open[0] > l_ima_12) ld_ret_172 = 1; + if (ld_180 < 0.0 && l_ima_12 < ld_116 && ld_164 < 0.0 && Open[0] > l_ima_12 - ld_140 && Open[0] < l_ima_12) ld_ret_172 = 2; + if (ld_180 > 0.0 && l_ima_12 > ld_116 && ld_164 > 0.0 && Open[0] < l_ima_12 - ld_140) ld_ret_172 = 3; + if (ld_180 < 0.0 && l_ima_12 < ld_116 && ld_164 < 0.0 && Open[0] > l_ima_12 + ld_140) ld_ret_172 = 4; + return (ld_ret_172); +} + +double Predict2() { + double ld_ret_68; + double ld_28 = 0; + double ld_36 = 0; + double ld_44 = 0; + double ld_52 = 0; + double ld_60 = 0; + double ld_76 = 0; + double ld_100 = 0; + double ld_116 = 0; + double ld_132 = 0; + double l_istddev_84 = 0; + double ld_148 = 0; + double ld_156 = 0; + double ld_164 = 0; + l_istddev_84 = iStdDev(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, 0); + double l_istddev_92 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0); + double l_ima_4 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 0); + double l_ima_12 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 1); + double l_ima_20 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 2); + for (int li_0 = 1; li_0 <= 20; li_0++) { + ld_28 += Close[li_0]; + ld_36 += High[li_0] - Low[li_0]; + ld_44 += Close[li_0] - Open[li_0]; + if (li_0 <= 10) { + ld_148 += Close[li_0]; + ld_156 += High[li_0] - Low[li_0]; + ld_164 += Close[li_0] - Open[li_0]; + } + } + ld_52 = ld_28 / 20.0; + ld_60 = ld_36 / 20.0; + ld_76 = ld_44 / 20.0; + double ld_172 = ld_148 / 10.0; + double ld_180 = ld_156 / 10.0; + double ld_188 = ld_164 / 10.0; + ld_132 = (Open[0] - ld_172) / l_istddev_84; + double ld_140 = (Open[0] - ld_52) / l_istddev_92; + ld_100 = ld_172 + 0.308 * ld_180; + double ld_108 = ld_52 + 0.18 * ld_60; + ld_116 = ld_172 - 0.308 * ld_180; + double ld_124 = ld_52 - 0.18 * ld_60; + if ((l_ima_4 - l_ima_20 > l_ima_12 - l_ima_20 + 2.0 * g_point_412 && ld_188 > 0.0 && ld_164 > 0.0 && Open[0] > ld_116 && Open[0] <= ld_172 + ld_132 * ld_188 && ld_132 < 0.0 && + High[1] - Low[1] < 1.777 * ld_180) || (l_ima_4 - l_ima_20 > l_ima_12 - l_ima_20 + 2.0 * g_point_412 && ld_76 > 0.0 && ld_44 > 0.0 && Open[0] > ld_124 && Open[0] <= ld_52 + ld_132 * ld_76 && ld_140 < 0.0 && High[1] - Low[1] < 1.586 * ld_180)) ld_ret_68 = 1; + if ((l_ima_4 - l_ima_20 < l_ima_12 - l_ima_20 - 2.0 * g_point_412 && ld_188 < 0.0 && ld_164 < 0.0 && Open[0] < ld_100 && Open[0] >= ld_172 + ld_132 * ld_188 && ld_132 > 0.0 && + High[1] - Low[1] < 1.777 * ld_180) || (l_ima_4 - l_ima_20 < l_ima_12 - l_ima_20 - 2.0 * g_point_412 && ld_76 < 0.0 && ld_44 < 0.0 && Open[0] < ld_108 && Open[0] >= ld_52 + ld_132 * ld_76 && ld_140 > 0.0 && High[1] - Low[1] < 1.586 * ld_180)) ld_ret_68 = 2; + if (l_ima_4 - l_ima_20 > l_ima_12 - l_ima_20 + 2.0 * g_point_412 && ld_76 > 0.0 && ld_44 > 0.0 && Open[0] > ld_124 && Open[0] <= ld_52 + ld_132 * ld_76 && ld_140 < 0.0 && + High[1] - Low[1] > 1.586 * ld_180) ld_ret_68 = 3; + if (l_ima_4 - l_ima_20 < l_ima_12 - l_ima_20 - 2.0 * g_point_412 && ld_76 < 0.0 && ld_44 < 0.0 && Open[0] < ld_108 && Open[0] >= ld_52 + ld_132 * ld_76 && ld_140 > 0.0 && + High[1] - Low[1] > 1.586 * ld_180) ld_ret_68 = 4; + return (ld_ret_68); +} + +int start() { + int l_ticket_4; + double l_price_24; + bool li_436; + bool li_440; + bool li_444; + bool li_448; + bool li_452; + bool li_456; + bool li_460; + bool li_464; + bool li_468; + bool li_472; + bool li_476; + bool li_480; + double l_price_592; + double ld_600; + int l_hour_12 = TimeHour(TimeCurrent()); + int l_count_16 = 0; + int l_count_20 = 0; + string ls_32 = "2009.31.10"; + int l_str2time_40 = StrToTime(ls_32); + double l_high_524 = High[iHighest(NULL, 0, MODE_HIGH, gi_436, 0)]; + double l_low_532 = Low[iLowest(NULL, 0, MODE_LOW, gi_436, 0)]; + double l_imacd_44 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0); + double l_imacd_52 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1); + double l_imacd_60 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0); + double l_imacd_68 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1); + double l_ima_84 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_HIGH, 0); + double l_ima_156 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_HIGH, 1); + double l_ima_76 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_LOW, 0); + double l_ima_148 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_LOW, 1); + double l_ima_92 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 0); + double l_ima_164 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 5); + double l_ima_172 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 1); + double l_ima_116 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 0); + double l_ima_124 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 1); + double l_ima_132 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 2); + double l_ima_180 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, 1); + double l_ima_140 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 5); + double l_ima_100 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 0); + double l_ima_108 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 1); + double l_ima_540 = iMA(NULL, 0, gi_436, 0, MODE_SMA, PRICE_CLOSE, 0); + double l_istddev_548 = iStdDev(NULL, 0, gi_436, 0, MODE_SMA, PRICE_CLOSE, 0); + double l_istddev_228 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0); + double l_istddev_236 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 1); + double l_iwpr_188 = iWPR(NULL, 0, 26, 0); + double l_iwpr_196 = iWPR(NULL, 0, 26, 1); + double l_iwpr_204 = iWPR(NULL, 0, 26, 2); + double l_iwpr_212 = iWPR(NULL, 0, 114, 0); + double l_iwpr_220 = iWPR(NULL, 0, 114, 1); + double l_idemarker_244 = iDeMarker(NULL, 0, 13, 0); + double l_idemarker_252 = iDeMarker(NULL, 0, 13, 1); + double l_idemarker_260 = iDeMarker(NULL, 0, 13, 2); + double l_istochastic_268 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_MAIN, 0); + double l_istochastic_276 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_MAIN, 1); + double l_istochastic_284 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 0); + double l_istochastic_292 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 1); + if (l_istochastic_276 < l_istochastic_292 - 5.0 && l_istochastic_268 >= l_istochastic_284) li_444 = TRUE; + if (l_istochastic_276 > l_istochastic_292 + 5.0 && l_istochastic_268 <= l_istochastic_284) li_448 = TRUE; + if (l_istochastic_276 > l_istochastic_292 && l_istochastic_268 > l_istochastic_284) li_452 = TRUE; + if (l_istochastic_276 < l_istochastic_292 && l_istochastic_268 < l_istochastic_284) li_456 = TRUE; + double l_istochastic_404 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_MAIN, 0); + double l_istochastic_412 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_MAIN, 1); + double l_istochastic_420 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 0); + double l_istochastic_428 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 1); + if (l_istochastic_412 < l_istochastic_428 - 5.0 && l_istochastic_404 >= l_istochastic_420) li_460 = TRUE; + if (l_istochastic_412 > l_istochastic_428 + 5.0 && l_istochastic_404 <= l_istochastic_420) li_464 = TRUE; + if (l_istochastic_412 < l_istochastic_428 && l_istochastic_404 >= l_istochastic_420) li_468 = TRUE; + if (l_istochastic_412 > l_istochastic_428 && l_istochastic_404 <= l_istochastic_420) li_472 = TRUE; + if (l_istochastic_412 > l_istochastic_428 && l_istochastic_404 > l_istochastic_420) li_476 = TRUE; + if (l_istochastic_412 < l_istochastic_428 && l_istochastic_404 < l_istochastic_420) li_480 = TRUE; + double l_irsi_300 = iRSI(NULL, 0, 14, PRICE_CLOSE, 0); + double l_irsi_308 = iRSI(NULL, 0, 14, PRICE_CLOSE, 1); + double l_irsi_324 = iRSI(NULL, 0, 14, PRICE_CLOSE, 2); + double ld_unused_316 = 0; + if (l_irsi_300 < 30.0) ld_unused_316 = 1; + if (l_irsi_300 > 70.0) ld_unused_316 = 2; + double l_ibands_372 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, 1); + double l_ibands_380 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, 2); + double l_ibands_388 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, 1); + double l_ibands_396 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, 2); + double l_iadx_332 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MAIN, 0); + double l_iadx_340 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_PLUSDI, 0); + double l_iadx_356 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_PLUSDI, 1); + double l_iadx_348 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MINUSDI, 0); + double l_iadx_364 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MINUSDI, 1); + if (l_iadx_340 > l_iadx_348) li_440 = TRUE; + if (l_iadx_348 > l_iadx_340) li_436 = TRUE; + if (l_iadx_332 < 30.0) { + li_436 = FALSE; + li_440 = FALSE; + } + if (TimeCurrent() >= l_str2time_40) { + Alert("Euro Blaster... Expired!!! Please contact EB support to extend it."); + return (0); + } + bool li_556 = FALSE; + bool li_560 = FALSE; + int li_564 = Crossed(l_ima_108, l_ima_172); + int li_unused_568 = MarketInfo(Symbol(), MODE_STOPLEVEL); + gd_360 = MarketInfo(Symbol(), MODE_MAXLOT); + g_minlot_368 = MarketInfo(Symbol(), MODE_MINLOT); + g_lotstep_376 = MarketInfo(Symbol(), MODE_LOTSTEP); + gd_384 = MarketInfo(Symbol(), MODE_MARGINREQUIRED) * g_lotstep_376; + gi_392 = 3600 * gi_428 + 60 * gi_432; + g_slippage_420 = Slippage; + double l_price_572 = StopLoss; + double l_lots_580 = LotsOptimized(); + if (l_price_572 <= 0.0) l_price_572 = 0; + if (TakeProfit <= 0.0) g_price_396 = 0; + int l_ord_total_8 = OrdersTotal(); + if (l_ord_total_8 > 0) { + for (int l_pos_588 = 0; l_pos_588 < l_ord_total_8; l_pos_588++) { + OrderSelect(l_pos_588, SELECT_BY_POS); + if (OrderMagicNumber() == MagicNo) { + if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) l_count_16++; + else l_count_20++; + if (OrderType() == OP_BUY && !HedgeAllowed) li_556 = TRUE; + if (OrderType() == OP_SELL && !HedgeAllowed) li_560 = TRUE; + } + } + } + if (l_count_16 < MaxOrder) { + if (DayOfWeek() == 5 && !Trade_On_Friday && Use_Time_Mgmt) return (0); + if (Use_Time_Mgmt && !isTradeTime()) return (0); + if (Bars < 100) { + Print("bars less than 100"); + return (0); + } + if (AccountFreeMargin() < 100.0 * LotsOptimized()) { + Print("We have not enough money. Free Margin = ", AccountFreeMargin()); + return (0); + } + if (l_count_16 > 0) + if (TimeCurrent() - OrderOpenTime() < 60.0 * StopTime) return (0); + if (li_560 == FALSE) { + if ((l_ima_100 > l_ima_108 && l_ima_92 > l_ima_172 + 2.0 * g_point_412 && Open[0] < l_ima_92 + l_istddev_228 && (l_istochastic_404 > l_istochastic_412 && l_istochastic_420 > l_istochastic_428) || + (l_istochastic_268 > l_istochastic_276 && l_istochastic_284 > l_istochastic_292) && l_iwpr_188 < -15.0 && l_iwpr_188 > l_iwpr_196 + 3.0 && li_452 && l_ima_116 > l_ima_92 && Open[0] > l_ima_100) || + (l_iwpr_212 > l_iwpr_220 && l_iwpr_212 > -20.0 && l_iwpr_220 > -20.0 && l_iwpr_188 > l_iwpr_196 + 25.0 && l_iwpr_188 < -15.0 && l_iwpr_196 < l_iwpr_204 && l_istddev_228 > l_istddev_236 && + l_idemarker_244 > l_idemarker_252 && l_ima_116 > l_ima_140 && li_452 && l_iadx_332 > 20.0 && Open[0] < Close[0] && Open[0] > Close[1]) || (Close[1] < l_ima_92 - 3.0 * l_istddev_236 && l_iwpr_188 > l_iwpr_196 + 3.0 && l_iwpr_188 < -75.0 && li_452 && (l_istochastic_268 >= 20.0 && l_istddev_228 > l_istddev_236) || + l_iwpr_196 < l_iwpr_204) || (l_ima_84 > l_ima_116 && l_ima_84 > l_ima_156 && l_ima_156 < l_ima_116 && Open[0] > Close[1] && l_ima_92 > l_ima_164 + 2.0 * g_point_412 && Open[1] < Close[1] && li_452 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_idemarker_244 > l_idemarker_252 && l_iadx_340 > l_iadx_348) || + (l_imacd_44 > l_imacd_52 && l_imacd_44 < (-3.0 * g_point_412) && l_imacd_44 > l_imacd_60 && l_imacd_52 < l_imacd_68 && li_452 && l_iwpr_188 > l_iwpr_196 && li_440 && + l_ima_180 > l_ima_124 && Close[1] < Open[0] && Close[1] > Open[1] && l_istddev_228 > l_istddev_236) || (l_iwpr_188 >= -75.0 && l_iwpr_188 > l_iwpr_196 + 9.0 && l_iwpr_196 < l_iwpr_204 - 5.0 && Open[2] < Close[2] && Open[1] > Close[2] && Open[1] < Close[1] && li_452 && l_istochastic_268 < 80.0 && l_ima_116 > l_ima_124 + 5.0 * g_point_412 && l_iadx_332 > 25.0 && l_iadx_340 > 25.0 && l_ima_180 > l_ima_124) || + (li_564 == 1 && l_iadx_340 > 25.0 && l_iwpr_188 > l_iwpr_196 + 12.0 && l_iadx_332 > 25.0 && l_iadx_340 > l_iadx_356 || l_ima_180 > l_ima_124 && l_ima_92 >= l_ima_172 && + l_ima_108 < l_ima_140 && li_452) || (Close[1] > l_ima_124 && Open[1] < l_ima_124 && l_ima_180 > l_ima_124 && l_iadx_332 > 30.0 && l_iadx_340 > 25.0 && l_ima_92 > l_ima_164 + 3.0 * g_point_412 && li_452 && l_istochastic_268 < 75.0 && l_iwpr_188 > l_iwpr_196 + 18.0 && l_iwpr_196 > l_iwpr_204 + 7.0) || + (l_ima_100 > l_ima_108 && l_ima_116 > l_ima_124 && l_ima_92 > l_ima_172 && l_ima_92 > l_ima_164 + 0.0005 && l_ima_116 - l_ima_124 > l_ima_92 - l_ima_172 && l_ima_100 - l_ima_92 > l_ima_108 - l_ima_172 && + li_452 && l_iwpr_188 < -15.0 && l_iwpr_188 > l_iwpr_196 + 15.0 && l_ima_100 > l_ima_116 && l_ima_116 > l_ima_92 && Open[0] > l_ima_100)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Ask + TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if ((li_444 && l_imacd_44 > l_imacd_52 && l_imacd_44 > l_imacd_60 && l_ima_180 > l_ima_124 && li_440 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_istochastic_268 > l_istochastic_276 && + l_istochastic_284 > l_istochastic_292 + 1.0) || (li_444 && l_imacd_44 > l_imacd_52 && l_imacd_44 > l_imacd_60 && Open[0] > Close[1] && l_ima_116 < l_ima_124 && l_iwpr_188 > l_iwpr_196 + 9.0 && li_440 && l_ima_180 > l_ima_124) || + (li_444 && l_istochastic_268 < 30.0 && Open[1] > l_ima_148 && Close[1] > l_ima_140 && Open[0] > l_ima_84 && l_ima_116 < l_ima_140 && l_ima_116 < l_ima_124 && l_iwpr_188 > l_iwpr_196 + + 5.0) || (li_444 && Open[1] > l_ima_148 && Open[0] > l_ima_84 && Open[0] < Close[1] && l_iwpr_188 > l_iwpr_196 + 7.0 && l_idemarker_244 > l_idemarker_252 + 0.08 && l_istddev_228 > l_istddev_236)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Ask + TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if ((Close[4] < Close[3] && Close[3] > Close[2] && Close[2] > Close[1] && Open[0] > Close[1] && High[1] - Close[1] < Open[1] - Low[1] && l_ima_116 > l_ima_140 + 0.0005 && + l_iwpr_188 > l_iwpr_196 + 9.0 && l_iadx_332 > 25.0 && l_iadx_340 > 25.0 && l_iwpr_196 > l_iwpr_204) || (Open[1] < Close[1] && Close[2] < l_ima_92 && Close[1] > l_ima_92 && Open[1] > l_ima_100 && Open[0] > l_ima_84 && l_ima_92 > l_ima_164 + 5.0 * g_point_412 && l_iwpr_188 < -5.0 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_idemarker_244 > l_idemarker_252 && l_idemarker_252 > l_idemarker_260) || + (l_iadx_340 > l_iadx_356 && l_iadx_356 < l_iadx_364 && l_iadx_340 >= l_iadx_348 && l_iadx_332 >= 35.0 && l_iadx_340 > 25.0 && l_iwpr_188 > l_iwpr_196 + 15.0 && li_452) || + (l_irsi_308 < l_irsi_324 && l_irsi_300 > l_irsi_308 + 5.0 && l_irsi_308 < 30.0 && l_ima_180 > l_ima_124 && l_iadx_332 > 25.0 && l_iadx_340 > 25.0)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Ask + TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if ((li_460 && Open[1] > l_ima_148 && Open[0] > l_ima_84 && Open[1] < Close[1] && l_ima_92 > l_ima_172 + 2.0 * g_point_412 && l_iadx_332 > 25.0 && l_iadx_340 > 25.0 && + l_iwpr_188 > l_iwpr_196 + 9.0 && l_ima_180 > l_ima_124) || (li_460 && l_imacd_44 > l_imacd_52 && l_imacd_44 < 0.0 && l_imacd_44 > l_imacd_60 && l_iadx_332 > 25.0 && l_iadx_340 > 25.0 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_istochastic_404 > l_istochastic_412 && l_istochastic_420 > l_istochastic_428 + 1.0) || + ((li_468 && l_istochastic_412 < 25.0) || (li_460 && l_istochastic_412 < 30.0) && l_ima_92 > l_ima_172 + 2.0 * g_point_412 && l_ima_180 > l_ima_124)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Ask + TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if ((Close[2] < l_ibands_380 && Close[1] > l_ibands_372 && Open[0] > Close[1] && Open[1] < l_ibands_372 && li_476 && l_iwpr_188 > l_iwpr_196 + 9.0 && l_idemarker_244 > l_idemarker_252 && + l_ima_180 > l_ima_124 && l_ima_116 < l_ima_92) || (Close[3] > l_ima_140 && Open[2] > l_ima_124 && Open[1] < Close[1] && Open[1] > Close[2] && Close[1] > l_ima_92 + 2.2 * l_istddev_236 && Open[0] > Close[1] && li_452 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_iwpr_188 < -15.0 && l_idemarker_244 > l_idemarker_252) || + (l_ima_124 < l_ima_132 - 1.0 * g_point_412 && l_ima_116 > l_ima_124 + 0.0002 && l_ima_116 > l_ima_132 + 1.0 * g_point_412 && l_ima_124 < l_ima_172 && li_452 || li_476 && + Open[0] > Close[1] && l_ima_92 > l_ima_164) || (l_ima_172 - l_ima_540 < l_ima_92 - l_ima_540 && l_ima_92 < (l_high_524 + l_low_532) / 2.0 - 2.0 * l_istddev_548 && l_ima_92 - l_ima_540 > l_istddev_228 && li_476) || + (iSAR(NULL, 0, 0.02, 0.2, 1) > Close[1] && iSAR(NULL, 0, 0.02, 0.2, 0) < Close[0] && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 1) > iClose(NULL, PERIOD_M15, 1) && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 0) < iOpen(NULL, PERIOD_M15, 0) && + iSAR(NULL, PERIOD_M30, 0.02, 0.2, 1) > iClose(NULL, PERIOD_M30, 1) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 0) < iOpen(NULL, PERIOD_M30, 0) && (l_ima_92 > l_ima_164 && + l_imacd_44 > l_imacd_52 && l_imacd_44 < -0.0003 && l_ima_100 < l_ima_108))) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Ask + TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if (Predict() == 1.0 || Predict() == 3.0 && (l_istochastic_268 < 40.0 && Open[1] < l_ima_148 && l_ima_92 > l_ima_140 && Open[0] > Close[1] && li_452) || (l_istochastic_412 < 40.0 && + l_ima_92 > l_ima_172 && l_ima_180 > l_ima_124 && li_452) || (Open[2] > l_ima_124 && Open[1] < Close[1] && Open[0] > Close[1] && li_452 && l_iwpr_188 > l_iwpr_196 + 7.0 && l_istochastic_268 < 45.0 && l_idemarker_244 > l_idemarker_252 + 0.05)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_580, Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Ask + (l_istddev_228 + l_istddev_236) / 2.0 + Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if (Predict2() == 1.0 && l_istochastic_268 < 50.0 && l_iwpr_188 > l_iwpr_196 + 5.0 && l_idemarker_244 > l_idemarker_252 + 0.05 && (Open[1] > l_ima_148 && l_ima_116 < l_ima_140) || + Open[2] < Close[2] && li_452 && Open[0] > Close[1] && Open[1] > Close[1]) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_580, Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Ask + (l_istddev_228 + l_istddev_236) / 2.0 + Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if (Predict2() == 3.0 && Open[0] > Close[1] && Open[1] < Close[1] && l_iwpr_188 > l_iwpr_196 && li_452) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_580, Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Ask + (l_istddev_228 + l_istddev_236) / 2.0 + Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + if ((Predict() == 1.0 || Predict2() == 1.0 || Predict2() == 3.0 && Open[0] < (l_high_524 + l_low_532) / 2.0 - 5.0 * g_point_412 && li_452 && l_imacd_44 > l_imacd_52 && + l_istochastic_268 < 45.0 && l_iwpr_188 > -90.0 && l_iwpr_188 > l_iwpr_196 + 5.0) || (Predict() == 1.0 && Open[0] > Close[1] && Open[1] < Close[1] && li_452 && l_istochastic_268 < 75.0 && l_imacd_44 > l_imacd_52 && l_ima_116 > l_ima_124 && l_iwpr_188 > l_iwpr_196 + 5.0 && l_idemarker_244 > l_idemarker_252 + 0.1)) { + l_ticket_4 = OrderSend(Symbol(), OP_BUY, l_lots_580, Ask, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Green); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Ask - StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Ask + Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening BUY order : ", GetLastError()); + return (0); + } + } + if (li_556 == FALSE) { + if ((l_ima_100 < l_ima_108 && l_ima_92 < l_ima_172 - 2.0 * g_point_412 && Open[0] >= l_ima_92 - l_istddev_228 && (l_istochastic_404 < l_istochastic_412 && l_istochastic_420 < l_istochastic_428) || + (l_istochastic_268 < l_istochastic_276 && l_istochastic_284 < l_istochastic_292) && l_iwpr_188 > -85.0 && l_iwpr_188 < l_iwpr_196 - 3.0 && li_456 && l_ima_116 < l_ima_92 && Open[0] < l_ima_100) || + (l_iwpr_212 < l_iwpr_220 && l_iwpr_212 < -80.0 && l_iwpr_220 < -80.0 && l_iwpr_188 < l_iwpr_196 - 25.0 && l_iwpr_188 > -85.0 && l_iwpr_196 > l_iwpr_204 && l_istddev_228 > l_istddev_236 && + l_idemarker_244 < l_idemarker_252 && l_ima_116 < l_ima_140 && li_456 && l_iadx_332 > 20.0 && Open[0] > Close[0] && Open[0] < Close[1]) || (Close[1] > l_ima_92 + 3.0 * l_istddev_236 && l_iwpr_188 < l_iwpr_196 - 3.0 && l_iwpr_188 > -25.0 && li_456 && (l_istochastic_268 <= 80.0 && l_istddev_228 > l_istddev_236) || + l_iwpr_196 > l_iwpr_204) || (l_ima_76 < l_ima_116 && l_ima_76 < l_ima_148 && l_ima_148 > l_ima_116 && Open[0] < Close[1] && l_ima_92 < l_ima_164 - 2.0 * g_point_412 && Open[1] > Close[1] && li_456 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_idemarker_244 < l_idemarker_252 && l_iadx_348 > l_iadx_340) || + (l_imacd_44 < l_imacd_52 && l_imacd_44 > 3.0 * g_point_412 && l_imacd_44 < l_imacd_60 && l_imacd_52 > l_imacd_68 && li_456 && l_iwpr_188 < l_iwpr_196 && li_436 && l_ima_180 < l_ima_124 && + Close[1] > Open[0] && Close[1] < Open[1] && l_istddev_228 > l_istddev_236) || (l_iwpr_188 <= -25.0 && l_iwpr_188 < l_iwpr_196 - 9.0 && l_iwpr_196 > l_iwpr_204 + 5.0 && Open[2] > Close[2] && Open[1] < Close[2] && Open[1] > Close[1] && li_456 && l_istochastic_268 > 20.0 && l_ima_116 < l_ima_124 - 5.0 * g_point_412 && l_iadx_332 > 25.0 && l_iadx_348 > 25.0 && l_ima_180 < l_ima_124) || + (li_564 == 2 && l_iadx_348 > 25.0 && l_iwpr_188 < l_iwpr_196 - 12.0 && l_iadx_332 > 25.0 && l_iadx_348 > l_iadx_364 || l_ima_180 < l_ima_124 && l_ima_92 <= l_ima_172 && + l_ima_108 > l_ima_140 && li_456 && l_istochastic_268 > 25.0) || (Close[1] < l_ima_124 && Open[1] > l_ima_124 && l_ima_180 < l_ima_124 && l_iadx_332 > 30.0 && l_iadx_348 > 25.0 && l_ima_92 < l_ima_164 - 3.0 * g_point_412 && li_456 && l_istochastic_268 > 25.0 && l_iwpr_188 < l_iwpr_196 - 18.0 && l_iwpr_196 < l_iwpr_204 - 7.0) || + (l_ima_100 < l_ima_108 && l_ima_116 < l_ima_124 && l_ima_92 < l_ima_172 && l_ima_92 < l_ima_164 - 5.0 * g_point_412 && l_ima_124 - l_ima_116 > l_ima_172 - l_ima_92 && + l_ima_92 - l_ima_100 > l_ima_172 - l_ima_108 && li_456 && l_iwpr_188 > -85.0 && l_iwpr_188 < l_iwpr_196 - 15.0 && l_ima_100 < l_ima_116 && l_ima_116 < l_ima_92 && Open[0] < l_ima_100)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Bid - TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if ((li_448 && l_imacd_44 < l_imacd_52 && l_imacd_44 < l_imacd_60 && l_ima_180 < l_ima_124 && li_436 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_istochastic_268 < l_istochastic_276 && + l_istochastic_284 < l_istochastic_292 - 1.0) || (li_448 && l_imacd_44 < l_imacd_52 && l_imacd_44 < l_imacd_60 && Open[0] < Close[1] && l_ima_116 > l_ima_124 && l_iwpr_188 < l_iwpr_196 - 9.0 && li_436 && l_ima_180 < l_ima_124) || + (li_448 && l_istochastic_268 > 70.0 && Open[1] < l_ima_156 && Close[1] < l_ima_140 && Open[0] < l_ima_76 && l_ima_116 > l_ima_140 && l_ima_116 > l_ima_124 && l_iwpr_188 < l_iwpr_196 - 5.0) || + (li_448 && Open[1] < l_ima_156 && Open[0] < l_ima_76 && Open[0] > Close[1] && l_iwpr_188 < l_iwpr_196 - 7.0 && l_idemarker_244 < l_idemarker_252 - 0.08 && l_istddev_228 > l_istddev_236)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Bid - TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if ((Close[4] > Close[3] && Close[3] < Close[2] && Close[2] < Close[1] && Open[0] > Close[1] && Close[1] - Low[1] < High[1] - Open[1] && l_ima_116 < l_ima_140 - 0.0005 && + l_iwpr_188 < l_iwpr_196 - 9.0 && l_iadx_332 > 25.0 && l_iadx_348 > 25.0 && l_iwpr_196 < l_iwpr_204) || (Open[1] > Close[1] && Close[2] > l_ima_92 && Close[1] < l_ima_92 && Open[1] < l_ima_100 && Open[0] < l_ima_76 && l_ima_92 < l_ima_164 - 5.0 * g_point_412 && l_iwpr_188 > -95.0 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_idemarker_244 < l_idemarker_252 && l_idemarker_252 < l_idemarker_260) || + (l_iadx_348 > l_iadx_364 && l_iadx_356 > l_iadx_364 && l_iadx_340 <= l_iadx_348 && l_iadx_332 >= 35.0 && l_iadx_348 > 25.0 && l_iwpr_188 < l_iwpr_196 - 15.0 && li_456) || + (l_irsi_308 > l_irsi_324 && l_irsi_300 < l_irsi_308 - 5.0 && l_irsi_308 > 70.0 && l_ima_180 < l_ima_124 && l_iadx_332 > 25.0 && l_iadx_348 > 25.0)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Bid - TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if ((li_464 && Open[1] < l_ima_156 && Open[0] < l_ima_76 && Open[1] > Close[1] && l_ima_92 < l_ima_172 - 0.0002 && l_iadx_332 > 25.0 && l_iadx_348 > 25.0 && l_iwpr_188 < l_iwpr_196 - 9.0 && + l_ima_180 < l_ima_124) || (li_464 && l_imacd_44 < l_imacd_52 && l_imacd_44 > 0.0 && l_imacd_44 < l_imacd_60 && l_iadx_332 > 25.0 && l_iadx_348 > 25.0 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_istochastic_404 < l_istochastic_412 && l_istochastic_420 < l_istochastic_428 - 1.0) || + ((li_472 && l_istochastic_412 > 75.0) || (li_464 && l_istochastic_412 > 70.0) && l_ima_92 < l_ima_172 - 2.0 * g_point_412 && l_ima_180 < l_ima_124)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Bid - TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if ((Close[2] > l_ibands_396 && Close[1] < l_ibands_388 && Open[0] < Close[1] && Open[1] > l_ibands_388 && li_480 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_idemarker_244 < l_idemarker_252 - 0.05 && + l_ima_180 < l_ima_124 && l_ima_116 > l_ima_92) || (Close[3] < l_ima_140 && Open[2] < l_ima_124 && Open[1] > Close[1] && Open[1] < Close[2] && Close[1] < l_ima_92 - 2.2 * l_istddev_236 && Open[0] < Close[1] && li_456 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_iwpr_188 > -85.0 && l_idemarker_244 < l_idemarker_252) || + (l_ima_124 > l_ima_132 + 1.0 * g_point_412 && l_ima_116 < l_ima_124 - 2.0 * g_point_412 && l_ima_116 < l_ima_132 - 1.0 * g_point_412 && l_ima_124 > l_ima_172 && li_456 || + li_480 && Open[0] < Close[1] && l_ima_92 < l_ima_164) || (l_ima_172 - l_ima_540 > l_ima_92 - l_ima_540 && l_ima_92 > (l_high_524 + l_low_532) / 2.0 + 2.0 * l_istddev_548 && l_ima_540 - l_ima_92 > l_istddev_228 && li_480) || + (iSAR(NULL, 0, 0.02, 0.2, 1) < Close[1] && iSAR(NULL, 0, 0.02, 0.2, 0) > Close[0] && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 1) < iClose(NULL, PERIOD_M15, 1) && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 0) > iOpen(NULL, PERIOD_M15, 0) && + iSAR(NULL, PERIOD_M30, 0.02, 0.2, 1) < iClose(NULL, PERIOD_M30, 1) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 0) > iOpen(NULL, PERIOD_M30, 0) && (l_ima_92 < l_ima_164 && + l_imacd_44 < l_imacd_52 && l_imacd_44 > 0.0003 && l_ima_100 < l_ima_108))) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (TakeProfit > 0.0) g_price_396 = Bid - TakeProfit * g_point_412; + if (l_price_572 > 0.0 || g_price_396 > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if (Predict() == 2.0 || Predict() == 4.0 && (l_istochastic_268 > 60.0 && Open[1] > l_ima_156 && l_ima_92 < l_ima_140 && Open[1] < Close[1] && Open[0] < Close[1] && + li_456) || (l_istochastic_412 > 60.0 && l_ima_92 < l_ima_172 && l_ima_180 < l_ima_124 && li_456) || (Open[2] < l_ima_124 && Open[1] > Close[1] && Open[0] < Close[1] && li_456 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_istochastic_268 > 55.0 && l_idemarker_244 < l_idemarker_252 - 0.05)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Bid - (l_istddev_228 + l_istddev_236) / 2.0 - Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if (Predict2() == 2.0 && l_istochastic_268 > 50.0 && l_iwpr_188 < l_iwpr_196 - 5.0 && l_idemarker_244 < l_idemarker_252 - 0.05 && (Open[1] < l_ima_156 && l_ima_116 > l_ima_140) || + Open[2] > Close[2] && li_456 && Open[0] < Close[1] && Open[1] < Close[1]) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Bid - (l_istddev_228 + l_istddev_236) / 2.0 - Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if (Predict2() == 4.0 && Open[0] < Close[1] && Open[1] > Close[1] && l_iwpr_188 < l_iwpr_196 && li_456) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Bid - (l_istddev_228 + l_istddev_236) / 2.0 - Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + if ((Predict() == 2.0 || Predict2() == 2.0 || Predict2() == 4.0 && Open[0] > (l_high_524 + l_low_532) / 2.0 + 5.0 * g_point_412 && li_456 && l_istochastic_268 > 55.0 && + l_imacd_44 < l_imacd_52 && l_iwpr_188 < -20.0 && l_iwpr_188 < l_iwpr_196 - 7.0) || (Predict() == 2.0 && Open[0] < Close[1] && Open[1] > Close[1] && li_456 && l_istochastic_268 > 25.0 && l_imacd_44 < l_imacd_52 && l_ima_116 < l_ima_124 && l_iwpr_188 < l_iwpr_196 - 7.0 && l_idemarker_244 < l_idemarker_252 - 0.1)) { + l_ticket_4 = OrderSend(Symbol(), OP_SELL, l_lots_580, Bid, g_slippage_420, 0, 0, "Euro_Blaster", MagicNo, 0, Red); + if (l_ticket_4 > 0) { + if (OrderSelect(l_ticket_4, SELECT_BY_TICKET, MODE_TRADES)) Print("SELL order opened : ", OrderOpenPrice()); + if (l_price_572 > 0.0) l_price_572 = Bid + StopLoss * g_point_412; + if (Min_Auto_TP > 0.0) g_price_396 = Bid - Min_Auto_TP * g_point_412; + if (l_price_572 > 0.0 || Min_Auto_TP > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), l_price_572, g_price_396, 0, CLR_NONE); + } else Print("Error opening SELL order : ", GetLastError()); + return (0); + } + } + } + for (int l_pos_0 = 0; l_pos_0 < l_count_16; l_pos_0++) { + if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == TRUE) { + if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo) { + l_price_592 = OrderStopLoss(); + ld_600 = AccountBalance() * (Percent_Over_Balance / 100.0); + if (OrderType() == OP_BUY) { + if (AccountFreeMargin() <= 0.0 || (Profit_Protection && AccountProfit() >= ld_600)) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_420, Violet); + return (0); + } + if (StopLoss == 0.0 && TakeProfit == 0.0 && Min_Auto_TP == 0.0 && OrderOpenPrice() - Bid >= 500.0 * g_point_412) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_420, Violet); + return (0); + } + if (BreakEven) { + if (Bid > OrderOpenPrice() + BreakEvenPips * g_point_412 && OrderStopLoss() < OrderOpenPrice()) { + RefreshRates(); + if (BreakEvenPips > TrailingStop && TrailingStop > 0.0) BreakEvenPips = TrailingStop; + l_price_592 = Bid - g_point_412 * BreakEvenPips; + OrderModify(OrderTicket(), OrderOpenPrice(), l_price_592, OrderTakeProfit(), 0, CLR_NONE); + return (0); + } + } + if (TrailingStop <= 0.0) continue; + if (Bid - OrderOpenPrice() <= g_point_412 * TrailingStop) continue; + if (l_price_592 >= Bid - g_point_412 * TrailingStop) continue; + RefreshRates(); + l_price_592 = Bid - g_point_412 * TrailingStop; + l_price_24 = OrderTakeProfit(); + if (l_istochastic_268 < 50.0 && li_452 && l_imacd_44 > l_imacd_52) l_price_24 = OrderTakeProfit() + TrailingPips * g_point_412; + OrderModify(OrderTicket(), OrderOpenPrice(), l_price_592, l_price_24, 0, Blue); + return (0); + } + if (AccountFreeMargin() <= 0.0 || (Profit_Protection && AccountProfit() >= ld_600)) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_420, Violet); + return (0); + } + if (StopLoss == 0.0 && TakeProfit == 0.0 && Min_Auto_TP == 0.0 && Ask - OrderOpenPrice() >= 500.0 * g_point_412) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_420, Violet); + return (0); + } + if (BreakEven) { + if (Ask < OrderOpenPrice() - BreakEvenPips * g_point_412 && OrderStopLoss() > OrderOpenPrice()) { + RefreshRates(); + if (BreakEvenPips > TrailingStop && TrailingStop > 0.0) BreakEvenPips = TrailingStop; + l_price_592 = Ask + g_point_412 * BreakEvenPips; + OrderModify(OrderTicket(), OrderOpenPrice(), l_price_592, OrderTakeProfit(), 0, CLR_NONE); + return (0); + } + } + if (TrailingStop > 0.0) { + if (OrderOpenPrice() - Ask > g_point_412 * TrailingStop) { + if (l_price_592 > Ask + g_point_412 * TrailingStop || l_price_592 == 0.0) { + RefreshRates(); + l_price_592 = Ask + g_point_412 * TrailingStop; + l_price_24 = OrderTakeProfit(); + if (l_istochastic_268 > 50.0 && li_456 && l_imacd_44 < l_imacd_52) l_price_24 = OrderTakeProfit() - TrailingPips * g_point_412; + OrderModify(OrderTicket(), OrderOpenPrice(), l_price_592, l_price_24, 0, Red); + return (0); + } + } + } + } + } + } + Comment("\n", " Copyright © 2009, Forex Spiritual Team", + "\n", " ======================================", + "\n", " Broker Time : ", TimeToStr(TimeCurrent()), + "\n", + "\n", " Highest Price in ", gi_436, " Bars Period : ", l_high_524, + "\n", " Lowest Price in ", gi_436, " Bars Period : ", l_low_532, + "\n", " Current Price -> Bid : ", Bid, " Ask : ", Ask, + "\n", + "\n", " Balance : ", AccountBalance(), + "\n", " Equity : ", AccountEquity(), + "\n", " Orders Total : ", OrdersTotal(), + "\n", " Total Profit/Loss : ", AccountProfit(), + "\n", + "\n", " Orders Lot Size : ", OrderLots(), + "\n", " Next Lot Size : ", l_lots_580, + "\n"); + return (0); +} + +double LotsOptimized() { + if (!MM) return (LotSize); + double ld_0 = StopLoss; + if (ld_0 == 0.0) ld_0 = 500; + double l_marginrequired_8 = MarketInfo(Symbol(), MODE_MARGINREQUIRED); + if (Max_Lot_Size > 0.0 && Max_Lot_Size < gd_360) gd_360 = Max_Lot_Size; + double ld_ret_16 = AccountFreeMargin() * RiskPercent / (100.0 * (MaxOrder * ld_0) / l_marginrequired_8); + if (Aggresive_Lot_Size) ld_ret_16 = AccountFreeMargin() * RiskPercent / (10000 * MaxOrder / l_marginrequired_8); + if (g_lotstep_376 < 0.1) ld_ret_16 = NormalizeDouble(MathFloor(ld_ret_16 / gd_384) * g_lotstep_376, 2); + else ld_ret_16 = NormalizeDouble(MathFloor(ld_ret_16 / gd_384) * g_lotstep_376, 1); + if (ld_ret_16 < g_minlot_368) ld_ret_16 = g_minlot_368; + if (ld_ret_16 > gd_360) ld_ret_16 = gd_360; + return (ld_ret_16); +} + +bool isTradeTime() { + int l_str2time_4; + int l_str2time_8; + int l_str2time_12; + int l_str2time_16; + int l_datetime_0 = TimeCurrent(); + if (Use_Time_Mgmt) { + l_str2time_4 = StrToTime(TradeStartHour + ":" + TradeStartMinutes); + l_str2time_8 = StrToTime(TradeEndHour + ":" + TradeEndMinutes); + l_str2time_12 = StrToTime(TradeStartHour2 + ":" + TradeStartMinutes2); + l_str2time_16 = StrToTime(TradeEndHour2 + ":" + TradeEndMinutes2); + if (l_str2time_4 < l_str2time_8 && (l_datetime_0 >= l_str2time_4 && l_datetime_0 <= l_str2time_8)) return (TRUE); + if (l_str2time_12 > l_str2time_4 && l_str2time_12 >= l_str2time_8 && l_datetime_0 >= l_str2time_8) + if (l_str2time_12 < l_str2time_16 && (l_datetime_0 >= l_str2time_12 && l_datetime_0 <= l_str2time_16)) return (TRUE); + } + return (FALSE); +} diff --git a/EnigmaG12~.mq4 b/EnigmaG12~.mq4 new file mode 100644 index 0000000..6ef6b92 --- /dev/null +++ b/EnigmaG12~.mq4 @@ -0,0 +1,1078 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#import "EnigmaG12Core.dll" + int Initialize(string a0, int a1, int a2, string a3, int a4); + int GetSettings(string a0, int& a1[], int& a2[], int& a3[], int& a4[], int& a5[], int& a6[], int& a7[], int& a8[], int& a9[], int& a10[], int& a11[], int& a12[], int& a13[], int& a14[], int& a15[], int& a16[], double& a17[], double& a18[], double& a19[], double& a20[], double& a21[], double& a22[], int& a23[], int& a24[]); + void GetVersionInfo(int& a0[], int& a1[], int& a2[], int& a3[]); +#import + +bool gi_76 = FALSE; +bool gi_80 = FALSE; +int gi_84 = 0; +int gi_88 = -1; +int gi_92 = -1; +int gi_96 = -1; +int gi_100 = -1; +extern double mmRisk = 0.05; +extern bool hedgingWorkaround = FALSE; +int gi_116 = 0; +int gi_120 = 0; +int gi_124 = 0; +int gi_128 = 0; +int gi_132 = 0; +int gi_136 = 0; +int gi_140 = 0; +int gi_144 = 0; +int gi_148 = 0; +int gi_152 = 0; +int gi_156 = 0; +int gi_160 = 0; +int gi_164 = 0; +int gi_168 = 0; +int gi_172 = 0; +int gi_176 = 0; +double gd_180 = 0.0; +double gd_188 = 0.0; +double gd_196 = 0.0; +double gd_204 = 0.0; +double gd_212 = 0.0; +double gd_220 = 0.0; +int gi_228 = 0; +double gda_232[5]; +int gi_236 = 0; +int gia_240[6] = {0, 0, 20, 40, 60, 80}; +int gi_244 = 0; +int g_cmd_248 = -1; +int gi_unused_252 = -1; +bool gi_256 = FALSE; +bool gi_260 = FALSE; +double g_ihigh_264 = 0.0; +double g_ilow_272 = 200.0; +double g_price_280 = 0.0; +double g_price_288 = 200.0; +int gi_296 = 0; +int gi_300 = 0; +bool gi_304 = TRUE; +bool gi_308 = TRUE; +double g_ihigh_312 = 0.0; +double g_ilow_320 = 200.0; +int g_datetime_328 = 0; +int g_datetime_332 = 0; +bool gi_336 = TRUE; +bool gi_340 = TRUE; +bool gi_344 = FALSE; +bool gi_348 = FALSE; +int gi_352 = 0; +double gd_356 = 0.0; +bool gi_364 = FALSE; +int g_hour_368 = -1; + +bool isDayBlacklisted(int ai_unused_0) { + return (FALSE); +} + +void validateInputParameters() { + if (gi_116 < 0 || gi_116 > 24 || gi_120 < 0 || gi_120 > 24 || gi_124 < 0 || gi_124 > 24) { + gi_256 = FALSE; + return; + } + int li_0 = 60 * gi_116; + int li_4 = 60 * gi_120; + if (li_4 < li_0) { + gi_256 = FALSE; + return; + } + if (MathAbs(gi_136) > 50.0 || MathAbs(gi_132) > 50.0) gi_256 = FALSE; + if (gi_140 != 1 && gi_140 != 2 && gi_140 != 3) gi_256 = FALSE; + if (MathAbs(gi_144) > 50.0 || MathAbs(gi_148) > 50.0 || MathAbs(gi_152) > 50.0 || MathAbs(gi_156) > 50.0 || MathAbs(gi_160) > 50.0 || MathAbs(gi_164) > 50.0) gi_256 = FALSE; + if (gi_168 != 1) gi_256 = FALSE; + if (MathAbs(gi_172) > 150.0) gi_256 = FALSE; + gi_256 = TRUE; +} + +void analyzeYesterday() { + analyzeYesterdayHourly(); +} + +void analyzeToday() { + double l_ihigh_0; + double l_ilow_8; + int l_datetime_16 = iTime(Symbol(), PERIOD_D1, 0); + int li_20 = 0; + int l_datetime_24 = iTime(Symbol(), PERIOD_H1, li_20); + g_ihigh_312 = 0.0; + g_ilow_320 = 300.0; + while (l_datetime_24 >= l_datetime_16) { + l_ihigh_0 = iHigh(Symbol(), PERIOD_H1, li_20); + l_ilow_8 = iLow(Symbol(), PERIOD_H1, li_20); + if (l_ihigh_0 > g_ihigh_312) g_ihigh_312 = l_ihigh_0; + if (l_ilow_8 < g_ilow_320) g_ilow_320 = l_ilow_8; + li_20++; + l_datetime_24 = iTime(Symbol(), PERIOD_H1, li_20); + } +} + +void analyzeYesterdayHourly() { + double l_ihigh_0; + double l_ilow_8; + bool li_16 = FALSE; + if (TimeHour(TimeCurrent()) >= 24 - gi_84 && TimeDayOfWeek(TimeCurrent()) != 0) li_16 = TRUE; + int l_datetime_20 = iTime(Symbol(), PERIOD_D1, 0); + int li_24 = l_datetime_20 - 3600 * gi_84; + if (li_16) li_24 += 86400; + int l_datetime_28 = iTime(Symbol(), PERIOD_D1, 1); + int li_32 = l_datetime_28 - 3600 * gi_84; + if (li_16) li_32 += 86400; + if (StringFind(AccountCompany(), "Alpari") == -1) { + if (TimeDayOfWeek(li_24) == 0 || TimeDayOfWeek(li_24) == 1) { + if (TimeDayOfWeek(li_32) == 0 || TimeDayOfWeek(li_32) == 6) { + l_datetime_28 = iTime(Symbol(), PERIOD_D1, 2); + li_32 = l_datetime_28 - 3600 * gi_84; + if (li_16) li_32 += 86400; + } + } + } + g_ihigh_264 = 0.0; + g_ilow_272 = 300.0; + int li_36 = gi_84 + 73; + int l_datetime_40 = 0; + while (true) { + l_datetime_40 = iTime(Symbol(), PERIOD_H1, li_36); + if (l_datetime_40 >= li_32) break; + li_36--; + if (li_36 > 0) continue; + break; + } + int li_44 = l_datetime_40 + 3600 * gi_116; + int li_48 = l_datetime_40 + 3600 * gi_120; + if (li_36 > 0) { + } + int li_52 = 0; + int li_56 = 0; + while (true) { + l_datetime_40 = iTime(Symbol(), PERIOD_H1, li_36); + if (l_datetime_40 >= li_24) break; + l_ihigh_0 = iHigh(Symbol(), PERIOD_H1, li_36); + l_ilow_8 = iLow(Symbol(), PERIOD_H1, li_36); + if (l_ihigh_0 >= g_ihigh_264) { + g_ihigh_264 = l_ihigh_0; + li_52 = l_datetime_40; + } + if (l_ilow_8 <= g_ilow_272) { + g_ilow_272 = l_ilow_8; + li_56 = l_datetime_40; + } + li_36--; + } + double ld_60 = 0.0001; + if (StringFind(Symbol(), "JPY") != -1) ld_60 = 0.01; + g_ihigh_264 = NormalizeDouble(g_ihigh_264, 4); + g_ilow_272 = NormalizeDouble(g_ilow_272, 4); + g_price_280 = NormalizeDouble(g_ihigh_264 + gi_132 * ld_60, 4); + g_price_288 = NormalizeDouble(g_ilow_272 + gi_136 * ld_60, 4); + if (li_52 < li_44 || li_52 >= li_48) gi_304 = TRUE; + else gi_304 = FALSE; + if (li_56 < li_44 || li_56 >= li_48) gi_308 = TRUE; + else gi_308 = FALSE; + gi_296 = li_52; + gi_300 = li_56; + int li_68 = gi_296 + 3600 * gi_124; + int li_72 = gi_300 + 3600 * gi_124; + if (ObjectFind("sellRange") != 0) { + ObjectCreate("sellRange", OBJ_RECTANGLE, 0, MathMax(li_68, l_datetime_40), g_price_280, l_datetime_40 + 86400, g_price_280 + ld_60 * gia_240[gi_228]); + ObjectSet("sellRange", OBJPROP_COLOR, LightBlue); + } else { + ObjectSet("sellRange", OBJPROP_TIME1, MathMax(li_68, l_datetime_40)); + ObjectSet("sellRange", OBJPROP_PRICE1, g_price_280); + ObjectSet("sellRange", OBJPROP_TIME2, l_datetime_40 + 86400); + ObjectSet("sellRange", OBJPROP_PRICE2, g_price_280 + ld_60 * gia_240[gi_228]); + ObjectSet("sellRange", OBJPROP_COLOR, LightBlue); + } + if (ObjectFind("buyRange") != 0) { + ObjectCreate("buyRange", OBJ_RECTANGLE, 0, MathMax(li_72, l_datetime_40), g_price_288, l_datetime_40 + 86400, g_price_288 - ld_60 * gia_240[gi_228]); + ObjectSet("buyRange", OBJPROP_COLOR, LightGreen); + return; + } + ObjectSet("buyRange", OBJPROP_TIME1, MathMax(li_72, l_datetime_40)); + ObjectSet("buyRange", OBJPROP_PRICE1, g_price_288); + ObjectSet("buyRange", OBJPROP_TIME2, l_datetime_40 + 86400); + ObjectSet("buyRange", OBJPROP_PRICE2, g_price_288 - ld_60 * gia_240[gi_228]); + ObjectSet("buyRange", OBJPROP_COLOR, LightGreen); +} + +void validateYesterdayValues() { + if (g_ilow_272 > 0.0 && g_ihigh_264 > g_ilow_272) { + gi_260 = TRUE; + return; + } + gi_260 = FALSE; +} + +int isOurMagicNumber(int ai_0) { + if (ai_0 == 12121212 || ai_0 == 12121213 || ai_0 == 12121214 || ai_0 == 12121215 || ai_0 == 12121216) return (1); + return (0); +} + +void initState() { + double ld_0; + double ld_8; + int li_unused_16 = 0; + int li_unused_20 = 0; + bool li_24 = FALSE; + bool li_28 = FALSE; + int l_ord_total_32 = OrdersTotal(); + for (int l_pos_36 = 0; l_pos_36 < l_ord_total_32; l_pos_36++) { + if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) { + if (isOurMagicNumber(OrderMagicNumber()) && OrderSymbol() == Symbol()) { + if (OrderType() == OP_SELL) li_24 = TRUE; + else { + if (OrderType() == OP_BUY) li_28 = TRUE; + else { + if (OrderType() == OP_SELLLIMIT) li_unused_16 = 1; + else + if (OrderType() == OP_BUYLIMIT) li_unused_20 = 1; + } + } + } + } + } + validateInputParameters(); + if (gi_256 == FALSE) { + gi_244 = 1; + return; + } + analyzeYesterday(); + validateYesterdayValues(); + if (gi_260) { + analyzeToday(); + if (g_ihigh_312 > g_ihigh_264 || gi_304) gi_336 = FALSE; + if (g_ilow_320 < g_ilow_272 || gi_308) gi_340 = FALSE; + ld_0 = 10000.0; + if (StringFind(Symbol(), "JPY") != -1) ld_0 = 100.0; + ld_8 = MathAbs(g_ihigh_264 - g_ilow_272) * ld_0; + if (ld_8 < gi_128) { + gi_340 = FALSE; + gi_336 = FALSE; + } + if (li_24 || li_28) { + gi_244 = 4; + if (li_24) { + g_cmd_248 = TRUE; + return; + } + g_cmd_248 = FALSE; + return; + } + if (gi_336 || gi_340 && !isDayBlacklisted(TimeCurrent())) { + gi_244 = 3; + return; + } + closePositions(); + gi_244 = 5; + return; + } + closePositions(); + gi_244 = 2; +} + +void closePositions() { + int l_ord_total_0; + int l_pos_4; + bool li_8 = FALSE; + int l_count_12 = 0; + for (l_count_12 = 0; l_count_12 < 30; l_count_12++) { + if (IsTradeContextBusy()) Sleep(1000); + else { + li_8 = TRUE; + break; + } + } + if (li_8) { + l_ord_total_0 = OrdersTotal(); + l_count_12 = 0; + l_pos_4 = 0; + for (l_count_12 = 0; l_count_12 < l_ord_total_0; l_count_12++) { + if (OrderSelect(l_pos_4, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && isOurMagicNumber(OrderMagicNumber())) { + if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 0); + else { + if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 0); + else { + if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket()); + else l_pos_4++; + } + } + } else l_pos_4++; + } else l_pos_4++; + } + } +} + +void deleteAllPending(int a_cmd_0) { + int l_ord_total_4 = OrdersTotal(); + int l_count_8 = 0; + int l_pos_12 = 0; + for (l_count_8 = 0; l_count_8 < l_ord_total_4; l_count_8++) { + if (OrderSelect(l_pos_12, SELECT_BY_POS)) { + if (OrderType() == a_cmd_0 && OrderSymbol() == Symbol() && isOurMagicNumber(OrderMagicNumber()) && OrderMagicNumber() != 12121212) OrderDelete(OrderTicket()); + else l_pos_12++; + } + } +} + +void computeOrderVolumes() { + int li_0; + double ld_4; + double ld_12; + double ld_20; + double ld_28; + double ld_36; + double ld_44; + if (gi_176 == 1) { + gda_232[0] = NormalizeDouble(gd_180, 1); + gda_232[1] = NormalizeDouble(gd_188, 1); + gda_232[2] = NormalizeDouble(gd_196, 1); + gda_232[3] = NormalizeDouble(gd_204, 1); + gda_232[4] = NormalizeDouble(gd_212, 1); + return; + } + if (gi_176 == 2) { + li_0 = 0; + if (gi_228 >= 1) li_0 += gi_172; + if (gi_228 >= 2) li_0 += gi_172 - 20; + if (gi_228 >= 3) li_0 += gi_172 - 40; + if (gi_228 >= 4) li_0 += gi_172 - 60; + if (gi_228 >= 5) li_0 += gi_172 - 80; + ld_4 = mmRisk * AccountBalance(); + ld_12 = 0.0; + if (MarketInfo(Symbol(), MODE_MINLOT) < 0.1) ld_12 = NormalizeDouble(ld_4 / (li_0 * MarketInfo(Symbol(), MODE_LOTSIZE) / 100000.0) / 10.0, 2); + else ld_12 = NormalizeDouble(ld_4 / (li_0 * MarketInfo(Symbol(), MODE_LOTSIZE) / 100000.0) / 10.0, 1); + ld_12 = MathMax(ld_12, MarketInfo(Symbol(), MODE_MINLOT)); + gda_232[0] = ld_12; + gda_232[1] = ld_12; + gda_232[2] = ld_12; + gda_232[3] = ld_12; + gda_232[4] = ld_12; + Print("mmMode: 2, orderSize: " + ld_12); + return; + } + if (gi_176 == 3) { + li_0 = 0; + if (gi_228 >= 1) li_0 += gi_172; + if (gi_228 >= 2) li_0 += gi_172 - 20; + if (gi_228 >= 3) li_0 += gi_172 - 40; + if (gi_228 >= 4) li_0 += gi_172 - 60; + if (gi_228 >= 5) li_0 += gi_172 - 80; + ld_4 = mmRisk * AccountBalance(); + gd_220 = 10.0 * gd_220; + ld_20 = 0.0; + ld_20 = ld_4; + Print("mmRisk: " + ld_4); + ld_28 = 0.0; + for (int li_52 = 1; li_52 < gi_228; li_52++) ld_28 += li_52 * (gia_240[li_52 + 1]); + ld_28 *= gd_220; + Print("f2: " + ld_28); + ld_20 += ld_28; + ld_36 = 0.0; + for (li_52 = 1; li_52 < gi_228; li_52++) ld_36 += li_52; + ld_36 *= gi_172 * gd_220; + Print("f3: " + ld_36); + ld_20 -= ld_36; + ld_44 = 0.0; + for (li_52 = 1; li_52 <= gi_228; li_52++) ld_44 += gia_240[li_52]; + Print("f4: " + ld_44); + ld_20 /= (gi_172 * gi_228 - ld_44); + ld_20 = NormalizeDouble(ld_20 / 10.0, 1); + Print("X: " + ld_20); + gd_220 /= 10.0; + gda_232[0] = ld_20; + for (li_52 = 1; li_52 < gi_228; li_52++) gda_232[li_52] = ld_20 + li_52 * gd_220; + } else { + if (gi_176 == 4) { + li_0 = 0; + if (gi_228 >= 1) li_0 += gi_172; + if (gi_228 >= 2) li_0 += gi_172 - 20; + if (gi_228 >= 3) li_0 += gi_172 - 40; + if (gi_228 >= 4) li_0 += gi_172 - 60; + if (gi_228 >= 5) li_0 += gi_172 - 80; + ld_4 = mmRisk * AccountBalance(); + ld_20 = 0.0; + ld_20 = ld_4; + Print("mmRisk: " + ld_4); + ld_28 = 0.0; + for (li_52 = 1; li_52 <= gi_228; li_52++) ld_28 += MathPow(gd_220, li_52 - 1); + ld_28 *= gi_172; + Print("f2: " + ld_28); + ld_36 = 0.0; + for (li_52 = 1; li_52 < gi_228; li_52++) ld_36 += (gia_240[li_52 + 1]) * MathPow(gd_220, li_52); + Print("f3: " + ld_36); + ld_20 /= (ld_28 - ld_36); + ld_20 = NormalizeDouble(ld_20 / 10.0, 1); + Print("X: " + ld_20); + gda_232[0] = ld_20; + for (li_52 = 1; li_52 < gi_228; li_52++) gda_232[li_52] = NormalizeDouble(ld_20 * MathPow(gd_220, li_52), 1); + } + } +} + +void updateOrders() { + bool li_0 = FALSE; + bool li_4 = FALSE; + bool li_8 = FALSE; + bool li_12 = FALSE; + double l_price_16 = 0.0; + double l_price_24 = 0.0; + double ld_32 = 1.0; + int l_ord_total_40 = OrdersTotal(); + int l_pos_44 = 0; + for (l_pos_44 = 0; l_pos_44 < l_ord_total_40; l_pos_44++) { + if (OrderSelect(l_pos_44, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == 12121212) { + if (OrderType() == OP_BUYLIMIT) { + if (gi_340 && TimeCurrent() >= gi_300 + 3600 * gi_124) { + ld_32 = 0.0001; + if (StringFind(Symbol(), "JPY") != -1) ld_32 = 0.01; + li_8 = TRUE; + if (MathAbs(OrderOpenPrice() - g_price_288) >= ld_32) { + l_price_16 = g_price_288 - gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_288 + gi_144 * ld_32; + else l_price_24 = g_price_288 + gi_148 * ld_32; + if (OrderModify(OrderTicket(), g_price_288, l_price_16, l_price_24, 0)) li_12 = TRUE; + } + } else { + OrderDelete(OrderTicket()); + li_8 = FALSE; + } + } else { + if (OrderType() == OP_SELLLIMIT && gi_336) { + if (gi_336 && TimeCurrent() >= gi_296 + 3600 * gi_124) { + ld_32 = 0.0001; + if (StringFind(Symbol(), "JPY") != -1) ld_32 = 0.01; + li_0 = TRUE; + if (MathAbs(OrderOpenPrice() - g_price_280) >= ld_32) { + l_price_16 = g_price_280 + gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_280 - gi_144 * ld_32; + else l_price_24 = g_price_280 - gi_148 * ld_32; + if (OrderModify(OrderTicket(), g_price_280, l_price_16, l_price_24, 0)) li_4 = TRUE; + } + } else { + OrderDelete(OrderTicket()); + li_0 = FALSE; + } + } + } + } + } + } + if (li_12 || !(gi_340 && TimeCurrent() >= gi_300 + 3600 * gi_124)) deleteAllPending(OP_BUYLIMIT); + if (li_4 || !(gi_336 && TimeCurrent() >= gi_296 + 3600 * gi_124)) deleteAllPending(OP_SELLLIMIT); + ld_32 = 0.0001; + if (StringFind(Symbol(), "JPY") != -1) ld_32 = 0.01; + bool li_48 = FALSE; + bool li_52 = TRUE; + bool li_56 = TRUE; + if (!li_0 && gi_336 && TimeCurrent() >= gi_296 + 3600 * gi_124) { + computeOrderVolumes(); + li_48 = TRUE; + l_price_16 = g_price_280 + gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_280 - gi_144 * ld_32; + else l_price_24 = g_price_280 - gi_148 * ld_32; + if (g_price_280 - MarketInfo(Symbol(), MODE_BID) < 10.0 * ld_32) li_52 = FALSE; + if (li_52) { + if (OrderSend(Symbol(), OP_SELLLIMIT, gda_232[0], g_price_280, 0, l_price_16, l_price_24, "EnigmaG12Sell", 12121212) < 0) { + Print("OrderSend failed with error: ", GetLastError()); + Print("Parameters: " + 3 + "," + gda_232[0] + "," + g_price_280 + ",0," + l_price_16 + "," + l_price_24 + "EnigmaG12Sell," + 12121212); + li_52 = FALSE; + } + } + } + if (li_4 || !li_0 && gi_336 && TimeCurrent() >= gi_296 + 3600 * gi_124) { + if (!li_48) { + computeOrderVolumes(); + li_48 = TRUE; + } + l_price_16 = g_price_280 + gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_280 - gi_144 * ld_32; + else l_price_24 = g_price_280 - gi_148 * ld_32; + if (li_52 && gi_228 >= 2) + if (OrderSend(Symbol(), OP_SELLLIMIT, gda_232[1], g_price_280 + gia_240[2] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Sell", 12121213) < 0) li_52 = FALSE; + if (li_52 && gi_228 >= 3) + if (OrderSend(Symbol(), OP_SELLLIMIT, gda_232[2], g_price_280 + gia_240[3] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Sell", 12121214) < 0) li_52 = FALSE; + if (li_52 && gi_228 >= 4) + if (OrderSend(Symbol(), OP_SELLLIMIT, gda_232[3], g_price_280 + gia_240[4] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Sell", 12121215) < 0) li_52 = FALSE; + if (li_52 && gi_228 >= 5) + if (OrderSend(Symbol(), OP_SELLLIMIT, gda_232[4], g_price_280 + gia_240[5] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Sell", 12121216) < 0) li_52 = FALSE; + } + if (!li_8 && gi_340 && TimeCurrent() >= gi_300 + 3600 * gi_124) { + if (!li_48) { + computeOrderVolumes(); + li_48 = TRUE; + } + l_price_16 = g_price_288 - gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_288 + gi_144 * ld_32; + else l_price_24 = g_price_288 + gi_148 * ld_32; + if (MarketInfo(Symbol(), MODE_ASK) - g_price_288 < 10.0 * ld_32) li_56 = FALSE; + if (li_56) { + if (OrderSend(Symbol(), OP_BUYLIMIT, gda_232[0], g_price_288, 0, l_price_16, l_price_24, "EnigmaG12Buy", 12121212) < 0) { + Print("OrderSend failed with error: ", GetLastError()); + Print("Parameters: " + 2 + "," + gda_232[0] + "," + g_price_288 + ",0," + l_price_16 + "," + l_price_24 + "EnigmaG12Buy," + 12121212); + li_56 = FALSE; + } + } + } + if (li_12 || !li_8 && gi_340 && TimeCurrent() >= gi_300 + 3600 * gi_124) { + if (!li_48) { + computeOrderVolumes(); + li_48 = TRUE; + } + l_price_16 = g_price_288 - gi_172 * ld_32; + if (gi_140 == 1 || gi_140 == 3) l_price_24 = g_price_288 + gi_144 * ld_32; + else l_price_24 = g_price_288 + gi_148 * ld_32; + if (li_56 && gi_228 >= 2) + if (OrderSend(Symbol(), OP_BUYLIMIT, gda_232[1], g_price_288 - gia_240[2] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Buy", 12121213) < 0) li_56 = FALSE; + if (li_56 && gi_228 >= 3) + if (OrderSend(Symbol(), OP_BUYLIMIT, gda_232[2], g_price_288 - gia_240[3] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Buy", 12121214) < 0) li_56 = FALSE; + if (li_56 && gi_228 >= 4) + if (OrderSend(Symbol(), OP_BUYLIMIT, gda_232[3], g_price_288 - gia_240[4] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Buy", 12121215) < 0) li_56 = FALSE; + if (li_56 && gi_228 >= 5) + if (OrderSend(Symbol(), OP_BUYLIMIT, gda_232[4], g_price_288 - gia_240[5] * ld_32, 0, l_price_16, l_price_24, "EnigmaG12Buy", 12121216) < 0) li_56 = FALSE; + } +} + +void updateOrderTPs(int ai_0) { + double ld_4; + double ld_12; + double l_ord_open_price_20; + double ld_28; + int li_36; + int l_ord_total_40 = OrdersTotal(); + int l_pos_44 = 0; + double l_price_48 = 0.0; + double ld_56 = 0.0001; + if (StringFind(Symbol(), "JPY") != -1) ld_56 = 0.01; + if (ai_0 == 1) { + for (l_pos_44 = 0; l_pos_44 < l_ord_total_40; l_pos_44++) { + if (OrderSelect(l_pos_44, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == 12121212) { + if (g_cmd_248 == OP_BUY && OrderType() == OP_BUY) { + if (gi_140 == 1) l_price_48 = OrderOpenPrice() + gi_144 * ld_56; + else { + if (gi_140 == 2) l_price_48 = OrderOpenPrice() + gi_148 * ld_56; + else + if (gi_140 == 3) l_price_48 = OrderOpenPrice() + gi_144 * ld_56; + } + Print("updateOrderTPs OrderModify"); + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_48, OrderExpiration()); + gd_356 = OrderOpenPrice(); + return; + } + if (g_cmd_248 == OP_SELL && OrderType() == OP_SELL) { + if (gi_140 == 1) l_price_48 = OrderOpenPrice() - gi_144 * ld_56; + else { + if (gi_140 == 2) l_price_48 = OrderOpenPrice() - gi_148 * ld_56; + else + if (gi_140 == 3) l_price_48 = OrderOpenPrice() - gi_144 * ld_56; + } + Print("updateOrderTPs OrderModify"); + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_48, OrderExpiration()); + gd_356 = OrderOpenPrice(); + return; + } + } + } + } + } else { + ld_4 = 0; + ld_12 = 0.0; + gd_356 = 0.0; + for (l_pos_44 = 0; l_pos_44 < l_ord_total_40; l_pos_44++) { + if (OrderSelect(l_pos_44, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && isOurMagicNumber(OrderMagicNumber())) { + if (g_cmd_248 == OP_BUY && OrderType() == OP_BUY) { + gd_356 += OrderOpenPrice() * OrderLots(); + ld_12 += OrderLots(); + ld_4++; + } else { + if (g_cmd_248 == OP_SELL && OrderType() == OP_SELL) { + gd_356 += OrderOpenPrice() * OrderLots(); + ld_12 += OrderLots(); + ld_4++; + } + } + } + } + } + gd_356 = NormalizeDouble(gd_356 / ld_12, 4); + Print("avg price: " + gd_356); + l_ord_open_price_20 = 0.0; + if (gi_140 == 3) { + for (l_pos_44 = 0; l_pos_44 < l_ord_total_40; l_pos_44++) { + if (OrderSelect(l_pos_44, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == 12121212 && OrderType() == g_cmd_248) { + if (g_cmd_248 == OP_BUY && OrderType() == OP_BUY) { + l_ord_open_price_20 = OrderOpenPrice(); + break; + } + if (g_cmd_248 == OP_SELL && OrderType() == OP_SELL) { + l_ord_open_price_20 = OrderOpenPrice(); + break; + } + } + } + } + } + for (l_pos_44 = 0; l_pos_44 < l_ord_total_40; l_pos_44++) { + if (OrderSelect(l_pos_44, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && isOurMagicNumber(OrderMagicNumber())) { + ld_28 = gi_148; + if (OrderMagicNumber() == 12121212) ld_28 = gi_148; + else { + if (OrderMagicNumber() == 12121213) ld_28 = gi_152; + else { + if (OrderMagicNumber() == 12121214) ld_28 = gi_156; + else { + if (OrderMagicNumber() == 12121215) ld_28 = gi_160; + else + if (OrderMagicNumber() == 12121216) ld_28 = gi_164; + } + } + } + li_36 = -1; + if (g_cmd_248 == OP_BUY && OrderType() == OP_BUY) { + li_36 = 0; + if (gi_140 == 1) l_price_48 = gd_356 + gi_144 * ld_56; + else { + if (gi_140 == 2) l_price_48 = OrderOpenPrice() + ld_28 * ld_56; + else + if (gi_140 == 3) l_price_48 = l_ord_open_price_20 + gi_144 * ld_56; + } + } else { + if (g_cmd_248 == OP_SELL && OrderType() == OP_SELL) { + li_36 = 1; + if (gi_140 == 1) l_price_48 = gd_356 - gi_144 * ld_56; + else { + if (gi_140 == 2) l_price_48 = OrderOpenPrice() - ld_28 * ld_56; + else + if (gi_140 == 3) l_price_48 = l_ord_open_price_20 - gi_144 * ld_56; + } + } else { + li_36 = -1; + l_price_48 = OrderTakeProfit(); + continue; + } + } + if (li_36 != -1) { + Print("updateOrderTPs OrderModify"); + OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_48, OrderExpiration()); + } + } + } + } + } +} + +int getOpenPosition() { + int l_ord_total_0 = OrdersTotal(); + int l_pos_4 = 0; + for (l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) { + if (OrderSelect(l_pos_4, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == 12121212) { + if (OrderType() == OP_BUY) return (0); + if (OrderType() == OP_SELL) return (1); + } + } + } + return (-1); +} + +int getPositionCount() { + int l_count_0 = 0; + int l_ord_total_4 = OrdersTotal(); + int l_pos_8 = 0; + for (l_pos_8 = 0; l_pos_8 < l_ord_total_4; l_pos_8++) { + if (OrderSelect(l_pos_8, SELECT_BY_POS)) { + if (OrderSymbol() == Symbol() && isOurMagicNumber(OrderMagicNumber())) { + if (g_cmd_248 == OP_BUY && OrderType() == OP_BUY) l_count_0++; + else + if (g_cmd_248 == OP_SELL && OrderType() == OP_SELL) l_count_0++; + } + } + } + return (l_count_0); +} + +int isWeekStart() { + if (TimeDayOfWeek(TimeCurrent()) == 0 || (TimeDayOfWeek(TimeCurrent()) == 1 && TimeHour(TimeCurrent()) <= 10)) return (1); + return (0); +} + +int isOtherEAInTrade() { + int l_ord_total_0 = OrdersTotal(); + int l_pos_4 = 0; + for (l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) { + if (OrderSelect(l_pos_4, SELECT_BY_POS)) { + if (OrderSymbol() != Symbol() && isOurMagicNumber(OrderMagicNumber())) + if (OrderType() == OP_BUY || OrderType() == OP_SELL) return (1); + } + } + return (0); +} + +void updateState() { + double ld_0; + int li_8; + bool li_12; + double ld_16; + int li_24; + int li_28; + int li_32; + bool li_36 = FALSE; + if (g_datetime_328 != 0 && TimeDayOfYear(g_datetime_332 + 3600 * gi_84) > TimeDayOfYear(g_datetime_328 + 3600 * gi_84) || (TimeDayOfYear(g_datetime_332 + 3600 * gi_84) == 1 && + TimeDayOfYear(g_datetime_328 + 3600 * gi_84) >= 365)) { + li_36 = TRUE; + gi_340 = TRUE; + gi_336 = TRUE; + findFridayData(); + } + if (g_hour_368 != -1 && TimeDayOfWeek(TimeCurrent()) == 5 && TimeHour(TimeCurrent()) >= g_hour_368 - 1) { + Print("Closing positions due to Friday market close."); + closePositions(); + gi_244 = 5; + } + double ld_40 = -1.0; + if (li_36) { + analyzeYesterday(); + validateYesterdayValues(); + ld_0 = 10000.0; + if (StringFind(Symbol(), "JPY") != -1) ld_0 = 100.0; + ld_40 = MathAbs(g_ihigh_264 - g_ilow_272) * ld_0; + } + if (gi_244 == 3) { + if (!gi_340 && !gi_336 && !gi_348 && !gi_344) { + closePositions(); + gi_244 = 5; + return; + } + li_8 = getOpenPosition(); + if (li_8 != -1) { + g_cmd_248 = li_8; + gi_244 = 4; + return; + } + li_12 = isOtherEAInTrade(); + if (li_12) { + Print("Blocked due to another instance trading."); + closePositions(); + gi_244 = 6; + return; + } + if (li_36 || gi_364) { + if (gi_364) gi_364 = FALSE; + if (gi_260 == FALSE) { + gi_244 = 2; + return; + } + if (ld_40 < gi_128) { + gi_336 = FALSE; + gi_340 = FALSE; + closePositions(); + gi_244 = 5; + return; + } + if (gi_304) gi_336 = FALSE; + else + if (!isDayBlacklisted(g_datetime_332)) gi_336 = TRUE; + if (gi_308) gi_340 = FALSE; + else + if (!isDayBlacklisted(g_datetime_332)) gi_340 = TRUE; + } + if (gi_336 && isWeekStart()) { + gi_336 = FALSE; + gi_344 = TRUE; + } else { + if (!isWeekStart() && gi_344) { + gi_336 = TRUE; + gi_344 = FALSE; + } + } + if (gi_340 && isWeekStart()) { + gi_340 = FALSE; + gi_348 = TRUE; + } else { + if (!isWeekStart() && gi_348) { + gi_340 = TRUE; + gi_348 = FALSE; + } + } + if (MarketInfo(Symbol(), MODE_BID) > g_ihigh_264 && gi_336 || gi_344 && TimeCurrent() < gi_296 + 3600 * gi_124) { + gi_336 = FALSE; + gi_344 = FALSE; + } else { + if (MarketInfo(Symbol(), MODE_BID) > g_ihigh_264 && gi_336 || gi_344 && getOpenPosition() == -1) { + gi_336 = FALSE; + gi_344 = FALSE; + } + } + if (MarketInfo(Symbol(), MODE_ASK) < g_ilow_272 && gi_340 || gi_348 && TimeCurrent() < gi_300 + 3600 * gi_124) { + gi_340 = FALSE; + gi_348 = FALSE; + } else { + if (MarketInfo(Symbol(), MODE_ASK) < g_ilow_272 && gi_340 || gi_348 && getOpenPosition() == -1) { + gi_340 = FALSE; + gi_348 = FALSE; + } + } + ld_0 = 10000.0; + if (StringFind(Symbol(), "JPY") != -1) ld_0 = 100.0; + if (hedgingWorkaround) { + ld_16 = (MarketInfo(Symbol(), MODE_ASK) - (g_ihigh_264 + g_ilow_272) / 2.0) * ld_0; + if (MathAbs(ld_16) < 10.0) closePositions(); + else { + if (ld_16 >= 10.0) { + li_24 = gi_340; + gi_340 = FALSE; + updateOrders(); + gi_340 = li_24; + } else { + li_28 = gi_336; + gi_336 = FALSE; + updateOrders(); + gi_336 = li_28; + } + } + } else updateOrders(); + } + if (gi_244 == 5) { + if (li_36 || gi_364) { + closePositions(); + if (gi_364) gi_364 = FALSE; + if (gi_304) gi_336 = FALSE; + else + if (!isDayBlacklisted(g_datetime_332)) gi_336 = TRUE; + if (gi_308) gi_340 = FALSE; + else + if (!isDayBlacklisted(g_datetime_332)) gi_340 = TRUE; + if (ld_40 < gi_128) { + gi_336 = FALSE; + gi_340 = FALSE; + gi_244 = 5; + } else gi_244 = 3; + } else + if (g_cmd_248 != -1) closePositions(); + } else { + if (gi_244 == 4) { + if (getOpenPosition() == -1) { + if (g_cmd_248 == OP_BUY) gi_340 = FALSE; + else + if (g_cmd_248 == OP_SELL) gi_336 = FALSE; + if (gi_340 || gi_336) gi_244 = 3; + else gi_244 = 5; + } else { + li_32 = getPositionCount(); + if (li_32 != gi_352) { + updateOrderTPs(li_32); + gi_352 = li_32; + if (gi_352 > gi_236) gi_236 = gi_352; + } + } + if (li_36) { + if (isDayBlacklisted(g_datetime_332)) gi_244 = 5; + else gi_364 = TRUE; + } + } + if (gi_244 == 6) { + if (li_36) gi_364 = TRUE; + if (!isOtherEAInTrade()) { + Print("Resuming from blocked state."); + gi_244 = 3; + } + } + } +} + +void findFridayData() { + int li_0 = 0; + if (TimeDayOfWeek(TimeCurrent()) == 5) li_0 += 25; + for (int l_datetime_4 = iTime(Symbol(), PERIOD_H1, li_0); TimeDayOfWeek(l_datetime_4) != 5; l_datetime_4 = iTime(Symbol(), PERIOD_H1, li_0)) li_0++; + g_hour_368 = TimeHour(l_datetime_4); +} + +void init() { + int lia_0[1]; + int lia_4[1]; + int lia_8[1]; + int lia_12[1]; + int lia_16[1]; + int lia_20[1]; + int lia_24[1]; + int lia_28[1]; + int lia_32[1]; + int lia_36[1]; + int lia_40[1]; + int lia_44[1]; + int lia_48[1]; + int lia_52[1]; + int lia_56[1]; + int lia_60[1]; + double lda_64[1]; + double lda_68[1]; + double lda_72[1]; + double lda_76[1]; + double lda_80[1]; + double lda_84[1]; + int lia_88[1]; + int lia_92[1]; + int lia_96[1]; + int lia_100[1]; + int lia_104[1]; + int lia_108[1]; + int li_112 = Initialize(AccountName(), StringLen(AccountName()), AccountNumber(), AccountCompany(), StringLen(AccountCompany())); + li_112 = 1; + if (li_112 == 1) gi_76 = TRUE; + else gi_76 = FALSE; + if (gi_76) Print("Account authorized."); + else Print("Unauthorized account!"); + li_112 = GetSettings(Symbol(), lia_0, lia_4, lia_8, lia_12, lia_16, lia_20, lia_24, lia_28, lia_32, lia_36, lia_40, lia_44, lia_48, lia_52, lia_56, lia_60, lda_64, lda_68, lda_72, lda_76, lda_80, lda_84, lia_88, lia_92); + if (li_112 == 1) { + gi_116 = lia_0[0]; + gi_120 = lia_4[0]; + gi_124 = lia_8[0]; + gi_128 = lia_12[0]; + gi_132 = lia_16[0]; + gi_136 = lia_20[0]; + gi_140 = lia_24[0]; + gi_144 = lia_28[0]; + gi_148 = lia_32[0]; + gi_152 = lia_36[0]; + gi_156 = lia_40[0]; + gi_160 = lia_44[0]; + gi_164 = lia_48[0]; + gi_168 = lia_52[0]; + gi_172 = lia_56[0]; + gi_176 = lia_60[0]; + gd_180 = lda_64[0]; + gd_188 = lda_68[0]; + gd_196 = lda_72[0]; + gd_204 = lda_76[0]; + gd_212 = lda_80[0]; + gd_220 = lda_84[0]; + gi_228 = lia_88[0]; + gi_84 = lia_92[0]; + gi_80 = TRUE; + } else gi_80 = FALSE; + GetVersionInfo(lia_96, lia_100, lia_104, lia_108); + gi_88 = lia_96[0]; + gi_92 = lia_100[0]; + gi_96 = lia_104[0]; + gi_100 = lia_108[0]; + validateInputParameters(); + initState(); + findFridayData(); +} + +void deinit() { + if (ObjectFind("sellRange") == 0) ObjectDelete("sellRange"); + if (ObjectFind("buyRange") == 0) ObjectDelete("buyRange"); +} + +string stateToString() { + string ls_unused_0; + switch (gi_244) { + case 0: + return ("Unknown"); + case 2: + return ("Could not find tradeable range"); + case 3: + return ("Waiting to enter trade"); + case 4: + switch (gi_352) { + case 1: + return ("1 position open, price " + DoubleToStr(gd_356, 5)); + case 2: + return ("2 positions open at average price " + DoubleToStr(gd_356, 5)); + case 3: + return ("3 positions open at average price " + DoubleToStr(gd_356, 5)); + case 4: + return ("4 positions open at average price " + DoubleToStr(gd_356, 5)); + case 5: + return ("5 positions open at average price " + DoubleToStr(gd_356, 5)); + } + return ("Error"); + case 6: + return ("Other Enigma G-12 instance in trade."); + case 5: + return ("No trading until next day"); + } + return ("n/a"); +} + +string MonthToStr(int ai_0) { + if (ai_0 == 1) return ("Jan"); + if (ai_0 == 2) return ("Feb"); + if (ai_0 == 3) return ("Mar"); + if (ai_0 == 4) return ("Apr"); + if (ai_0 == 5) return ("May"); + if (ai_0 == 6) return ("Jun"); + if (ai_0 == 7) return ("Jul"); + if (ai_0 == 8) return ("Aug"); + if (ai_0 == 9) return ("Sep"); + if (ai_0 == 10) return ("Oct"); + if (ai_0 == 11) return ("Nov"); + if (ai_0 == 12) return ("Dec"); + return ("Error"); +} + +void updateComments() { + string ls_0 = "Enigma G-12 "; + if (gi_88 == 1) ls_0 = ls_0 + "Basic "; + else { + if (gi_88 == 2) ls_0 = ls_0 + "Pro "; + else { + if (gi_88 == 3) ls_0 = ls_0 + "Ultimate "; + else { + if (gi_88 == 10) ls_0 = ls_0 + "Basic [Demo Account] "; + else { + if (gi_88 == 20) ls_0 = ls_0 + "Pro [Demo Account] "; + else + if (gi_88 == 30) ls_0 = ls_0 + "Ultimate [Demo Account] "; + } + } + } + } + ls_0 = ls_0 + "v.1.1 (C) 2010 www.quantumdollars.com" + + "\n"; + if (gi_92 == 0 && gi_96 == 0 && gi_100 == 0) ls_0 = ls_0 + "Expiration: Never\n"; + else { + ls_0 = ls_0 + "Expiration: " + MonthToStr(gi_96) + "/" + gi_92 + "/" + gi_100 + + "\n"; + } + if (gi_80) { + ls_0 = ls_0 + "Instrument: " + Symbol() + + "\n"; + } else ls_0 = ls_0 + "Instrument: UNAUTHORIZED\n"; + ls_0 = ls_0 + "State: " + stateToString() + + "\n"; + ls_0 = ls_0 + "Short positions:"; + if (gi_336) ls_0 = ls_0 + " [ALLOWED]\n"; + else ls_0 = ls_0 + " [NOT ALLOWED]\n"; + ls_0 = ls_0 + "Long Positions:"; + if (gi_340) ls_0 = ls_0 + " [ALLOWED]\n"; + else ls_0 = ls_0 + " [NOT ALLOWED]\n"; + double ld_8 = 10000.0; + if (StringFind(Symbol(), "JPY") != -1) ld_8 = 100.0; + double ld_16 = MathAbs(g_ihigh_264 - g_ilow_272) * ld_8; + if (!gi_76) ls_0 = ls_0 + "UNAUTHORIZED ACCOUNT\n"; + Comment(ls_0); +} + +void start() { + g_datetime_332 = TimeCurrent(); + updateState(); + updateComments(); + g_datetime_328 = g_datetime_332; + if (gi_244 != 1) { + } +} diff --git a/FDM Buy Sell Pressure.mq4 b/FDM Buy Sell Pressure.mq4 new file mode 100644 index 0000000..88dc92e --- /dev/null +++ b/FDM Buy Sell Pressure.mq4 @@ -0,0 +1,84 @@ +/* + +*/ +#property copyright "Copyright © 2008, Forex Day Monster" +#property link "http://www.forexprofitmonster.com" + +#property indicator_separate_window +#property indicator_buffers 4 +#property indicator_color1 Red +#property indicator_color2 Lime +#property indicator_color3 Black +#property indicator_color4 Black + +int g_period_76 = 13; +int gi_80 = 8; +int gi_84 = 5; +double g_ibuf_88[]; +double g_ibuf_92[]; +double g_ibuf_96[]; +double g_ibuf_100[]; + +void init() { + string ls_0 = "FDM Buy Sell Pressure #1"; + IndicatorShortName(ls_0); + IndicatorDigits(2); + SetIndexBuffer(0, g_ibuf_88); + SetIndexLabel(0, "X higher than price"); + SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 5); + SetIndexBuffer(1, g_ibuf_92); + SetIndexLabel(1, "X lower than price"); + SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 5); + SetIndexBuffer(2, g_ibuf_96); + SetIndexLabel(2, "LSMA higher than price"); + SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1); + SetIndexBuffer(3, g_ibuf_100); + SetIndexLabel(3, "LSMA lower than price"); + SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1); +} + +int start() { + double ld_12; + double ld_20; + double ld_28; + double ld_36; + double l_ima_44; + int li_60; + int li_64; + string ls_0 = "2015.11.01"; + int l_str2time_8 = StrToTime(ls_0); + if (TimeCurrent() >= l_str2time_8) { + Alert(" Trial version has expired! Email support@forexprofitmonster.com with broker account number for rights to full version!"); + return (0); + } + int li_52 = IndicatorCounted(); + if (li_52 >= 0) { + if (li_52 > 0) li_52--; + li_52 = Bars - li_52; + for (int li_56 = 0; li_56 < li_52; li_56++) { + g_ibuf_92[li_56] = -gi_84; + g_ibuf_88[li_56] = -gi_84; + l_ima_44 = iMA(NULL, 0, g_period_76, 0, MODE_EMA, PRICE_TYPICAL, li_56); + if (Close[li_56] > l_ima_44) g_ibuf_88[li_56] = EMPTY_VALUE; + if (Close[li_56] < l_ima_44) g_ibuf_92[li_56] = EMPTY_VALUE; + } + li_60 = Bars - gi_80 - 5; + li_64 = li_60 - gi_80 - 1; + for (li_56 = li_64; li_56 >= 0; li_56--) { + ld_12 = 0; + for (int li_68 = gi_80; li_68 >= 1; li_68--) { + ld_20 = gi_80 + 1; + ld_20 /= 3.0; + ld_28 = 0; + ld_28 = (li_68 - ld_20) * (Close[gi_80 - li_68 + li_56]); + ld_12 += ld_28; + } + ld_36 = 6.0 * ld_12 / (gi_80 * (gi_80 + 1)); + g_ibuf_96[li_56] = gi_84; + g_ibuf_100[li_56] = gi_84; + if (ld_36 > Close[li_56]) g_ibuf_100[li_56] = EMPTY_VALUE; + if (ld_36 < Close[li_56]) g_ibuf_96[li_56] = EMPTY_VALUE; + } + } + return (0); +} \ No newline at end of file diff --git a/FR-Trend.mq4 b/FR-Trend.mq4 new file mode 100644 index 0000000..2872b87 --- /dev/null +++ b/FR-Trend.mq4 @@ -0,0 +1,149 @@ +/* + Generated by EX4-TO-MQ4 decompiler LITE V4.0.406.1f [-] + Website: https://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2011, ArtForexTrading" +#property link "http://www.artforextrading.com" + +#property indicator_separate_window +#property indicator_buffers 5 +#property indicator_color1 Black +#property indicator_color2 DodgerBlue +#property indicator_color3 SandyBrown +#property indicator_color4 Green +#property indicator_color5 Red + +#import + +extern int A = 8; +extern int SR = 25; +extern bool AlertSoundOn = FALSE; +extern string SoundFile = "alert.wav"; +double gda_96[]; +double gda_100[]; +double gda_104[]; +double gda_108[]; +double gd_112; +double gd_120; +double gd_128; +double gd_136; +double gd_144; +double gd_168; +double gd_176; +double gd_184; +double gd_192; +double gd_200; +double gd_208; +double gd_216; +double gd_224; +double gd_232; +double gd_240; +double gd_248; +double gd_256; +double gd_264; +double td_152; +double td_160; +double td_0; +int gi_272; +int gi_276; +datetime gt_280; +int gi_284; + +int init() { + IndicatorShortName("FR-Trend " + "(" + A + ")"); + SetIndexBuffer(1, gda_96); + SetIndexBuffer(2, gda_100); + SetIndexEmptyValue(2, 0.0); + SetIndexBuffer(3, gda_104); + SetIndexBuffer(4, gda_108); + SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1); + SetIndexStyle(4, DRAW_LINE, STYLE_DOT, 1); + SetIndexStyle(3, DRAW_LINE, STYLE_DOT, 1); + SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 3); + SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 3); + return (0); +} + +int start() { + int li_0; + int li_4 = Bars - IndicatorCounted() - 1; + if (li_4 < 10) li_0 = li_4; + else { + li_0 = Bars - 2; + gd_264 = 2.0 / (A + 1); + gda_96[li_0 + 1] = 0.0; + gda_100[li_0 + 1] = 0.0; + gd_208 = 0.0; + gd_200 = 0.0; + gd_224 = 0.0; + gd_216 = 0.0; + gd_240 = 0.0; + gd_232 = 0.0; + gt_280 = Time[li_0]; + gi_272 = 0; + gi_276 = 0; + } + for (int li_8 = li_0; li_8 >= 0; li_8--) { + if (gt_280 != Time[li_8]) { + gd_208 = gd_200; + gd_224 = gd_216; + gd_240 = gd_232; + gt_280 = Time[li_8]; + } + gd_136 = High[li_8]; + gd_144 = Low[li_8]; + gd_112 = gd_136 - (High[li_8 + 1]); + gd_120 = Low[li_8 + 1] - gd_144; + if (gd_112 < 0.0) gd_112 = 0; + if (gd_120 < 0.0) gd_120 = 0; + if (gd_112 == gd_120) { + gd_112 = 0; + gd_120 = 0; + } else { + if (gd_112 < gd_120) gd_112 = 0; + else + if (gd_120 < gd_112) gd_120 = 0; + } + td_152 = MathAbs(gd_136 - gd_144); + td_160 = MathAbs(gd_136 - (Close[li_8 + 1])); + gd_168 = MathAbs(gd_144 - (Close[li_8 + 1])); + gd_128 = MathMax(MathMax(td_0, td_0), gd_168); + if (gd_128 == 0.0) { + gd_176 = 0; + gd_184 = 0; + } else { + gd_176 = 100.0 * gd_112 / gd_128; + gd_184 = 100.0 * gd_120 / gd_128; + } + gd_200 = gd_208 + (gd_176 - gd_208) * gd_264; + gd_216 = gd_224 + (gd_184 - gd_224) * gd_264; + gd_248 = gd_200 - gd_216; + gd_192 = MathAbs(gd_200 + gd_216); + if (gd_192 == 0.0) gd_256 = 0; + else gd_256 = 100.0 * (MathAbs(gd_248) / gd_192); + if (gd_200 > gd_216) gi_272 = 1; + if (gd_200 < gd_216) gi_272 = 2; + if (gi_272 == 2) gd_256 = -gd_256; + gd_232 = gd_240 + (gd_256 - gd_240) * gd_264; + gda_96[li_8] = gd_232; + if (gda_96[li_8] > gda_96[li_8 + 1]) gi_276 = 1; + if (gda_96[li_8] < gda_96[li_8 + 1]) { + if (gi_276 == 1) gda_100[li_8 + 1] = gda_96[li_8 + 1]; + gi_276 = 2; + } + if (gi_276 == 2) gda_100[li_8] = gda_96[li_8]; + else gda_100[li_8] = 0.0; + gda_104[li_8] = SR; + gda_108[li_8] = -SR; + } + if (gi_284 == Time[0]) return (0); + gi_284 = Time[0]; + Comment(gda_96[1] + ", " + gda_100[1]); + if (AlertSoundOn == TRUE) { + if ((gda_100[1] == 0.0 && gda_100[2] != 0.0) || (gda_100[2] == 0.0 && gda_100[1] != 0.0)) Alert(WindowExpertName(), " ", Symbol() + "=-" + Period(), " Possible Trend Reverse !"); + Print("HELLO"); + PlaySound(SoundFile); + } + return (0); +} \ No newline at end of file diff --git a/FR-TrendLines.mq4 b/FR-TrendLines.mq4 new file mode 100644 index 0000000..0d554ad --- /dev/null +++ b/FR-TrendLines.mq4 @@ -0,0 +1,92 @@ +/* + Generated by EX4-TO-MQ4 decompiler LITE V4.0.406.1f [-] + Website: https://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2011 ArtForexTrading" +#property link "http://artforextrading.com" + +#property indicator_chart_window +#property indicator_buffers 8 +#property indicator_color1 White +#property indicator_color2 Blue +#property indicator_color3 Red +#property indicator_color4 White +#property indicator_color5 Blue +#property indicator_color6 Red +#property indicator_color7 Black +#property indicator_color8 Black + +#import + +extern int TPeriod = 34; +extern int TType = 3; +extern int TShift = 0; +double gda_88[]; +double gda_92[]; +double gda_96[]; +double gda_100[]; +double gda_104[]; +double gda_108[]; + +int init() { + SetIndexStyle(0, DRAW_LINE); + SetIndexBuffer(0, gda_88); + SetIndexStyle(1, DRAW_LINE); + SetIndexBuffer(1, gda_92); + SetIndexStyle(2, DRAW_LINE); + SetIndexBuffer(2, gda_96); + SetIndexEmptyValue(0, 0); + SetIndexEmptyValue(1, 0); + SetIndexEmptyValue(2, 0); + SetIndexStyle(3, DRAW_LINE); + SetIndexBuffer(3, gda_100); + SetIndexStyle(4, DRAW_LINE); + SetIndexBuffer(4, gda_104); + SetIndexStyle(5, DRAW_LINE); + SetIndexBuffer(5, gda_108); + SetIndexEmptyValue(3, 0); + SetIndexEmptyValue(4, 0); + SetIndexEmptyValue(5, 0); + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double ld_0; + double ld_8; + double ld_16; + double ld_24; + double ld_32; + double ld_40; + int li_48 = IndicatorCounted(); + if (li_48 < 0) return (-1); + if (li_48 > 0) li_48--; + int li_52 = Bars - li_48; + for (int li_56 = 0; li_56 < li_52; li_56++) { + ld_0 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_HIGH, li_56); + ld_8 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_HIGH, li_56 + 1); + ld_16 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_LOW, li_56); + ld_24 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_LOW, li_56 + 1); + ld_32 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_MEDIAN, li_56); + ld_40 = iMA(NULL, 0, TPeriod, TShift, TType, PRICE_MEDIAN, li_56 + 1); + gda_88[li_56] = ld_0; + gda_92[li_56] = ld_0; + gda_96[li_56] = ld_0; + gda_100[li_56] = ld_16; + gda_104[li_56] = ld_16; + gda_108[li_56] = ld_16; + if (ld_0 > ld_8) { + gda_96[li_56] = 0; + gda_108[li_56] = 0; + } + if (ld_0 < ld_8) { + gda_92[li_56] = 0; + gda_104[li_56] = 0; + } + } + return (0); +} \ No newline at end of file diff --git a/FXEnforcer_V1open.mq4 b/FXEnforcer_V1open.mq4 new file mode 100644 index 0000000..61a9642 --- /dev/null +++ b/FXEnforcer_V1open.mq4 @@ -0,0 +1,225 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, Trading Automatics Ltd" +#property link "http://www.tradingautomatics.com" + +extern int EMA1 = 70; +extern int EMA2 = 21; +extern bool EMA1aboveEMA2 = TRUE; +extern int AOToEnter = 7; +extern int AOToClose = 6; +extern int BETrigger = 150; +extern bool UseMoneyManagement = FALSE; +extern double Risk = 2.0; +extern double Lots = 0.1; +extern int SL = 70; +extern int TP = 80; +extern int MagicNumber = 68709243; +extern int Slippage = 3; +extern bool Broker5Digits = TRUE; +int gi_140 = 0; +bool gi_144 = FALSE; + +int init() { + if (Broker5Digits) { + SL = 10 * SL; + TP = 10 * TP; + Slippage = 10 * Slippage; + BETrigger = 10 * BETrigger; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double l_ima_0; + double l_ima_8; + double l_iao_16; + double l_iao_24; + bool li_32 = TRUE; + bool li_36 = TRUE; + bool li_40 = TRUE; + bool li_44 = TRUE; + int l_ticket_52 = 0; + int li_56 = 0; + int li_60 = 0; + int li_64 = 0; + int l_ticket_68 = 0; + int l_cmd_72 = -1; + double l_price_76 = 0; + double ld_unused_84 = 0; + if (TimeCurrent() > StrToTime("2020.1.1")) { + Comment("expired"); + return (0); + } + li_60 = GetLongsNumber(); + li_64 = GetShortsNumber(); + li_56 = li_60 + li_64; + for (int l_pos_92 = 0; l_pos_92 < OrdersTotal(); l_pos_92++) { + OrderSelect(l_pos_92, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + l_ticket_68 = OrderTicket(); + l_cmd_72 = OrderType(); + break; + } + } + if (gi_140 != Time[0]) { + if (li_56 > 0) { + for (int li_48 = 1; li_48 <= AOToClose; li_48++) { + l_iao_16 = iAO(Symbol(), 0, li_48); + l_iao_24 = iAO(Symbol(), 0, li_48 + 1); + if (l_iao_16 > l_iao_24) li_44 = FALSE; + if (l_iao_16 < l_iao_24) li_40 = FALSE; + } + if (li_60 > 0 && li_44) { + CloseAllLongs(); + li_56 = 0; + li_60 = 0; + } + if (li_64 > 0 && li_40) { + CloseAllShorts(); + li_56 = 0; + li_64 = 0; + } + } + for (li_48 = 1; li_48 <= AOToEnter; li_48++) { + l_iao_16 = iAO(Symbol(), 0, li_48); + l_iao_24 = iAO(Symbol(), 0, li_48 + 1); + if (l_iao_16 > l_iao_24) li_36 = FALSE; + if (l_iao_16 < l_iao_24) li_32 = FALSE; + } + l_ima_0 = iMA(Symbol(), 0, EMA1, 0, MODE_EMA, PRICE_CLOSE, 1); + l_ima_8 = iMA(Symbol(), 0, EMA2, 0, MODE_EMA, PRICE_CLOSE, 1); + if (li_32 && Close[1] > l_ima_0 && l_ima_0 > l_ima_8 || !EMA1aboveEMA2) { + if (li_64 > 0) CloseAllShorts(); + if (li_60 == 0) { + if (SL > 0) l_price_76 = Ask - SL * Point; + l_ticket_52 = OrderSend(Symbol(), OP_BUY, GetLots(), Ask, Slippage, 0, 0, "", MagicNumber, 0, Blue); + if (l_ticket_52 > 0) OrderModify(l_ticket_52, OrderOpenPrice(), l_price_76, 0, 0, CLR_NONE); + gi_144 = TRUE; + } + } + if (li_36 && Close[1] < l_ima_0 && l_ima_0 < l_ima_8 || !EMA1aboveEMA2) { + if (li_60 > 0) CloseAllLongs(); + if (li_64 == 0) { + if (SL > 0) l_price_76 = Bid + SL * Point; + l_ticket_52 = OrderSend(Symbol(), OP_SELL, GetLots(), Bid, Slippage, 0, 0, "", MagicNumber, 0, Red); + if (l_ticket_52 > 0) OrderModify(l_ticket_52, OrderOpenPrice(), l_price_76, 0, 0, CLR_NONE); + } + } + if (li_56 == 0 && gi_144 && iLongReEntry() && li_32) { + if (SL > 0) l_price_76 = Ask - SL * Point; + l_ticket_52 = OrderSend(Symbol(), OP_BUY, GetLots(), Ask, Slippage, 0, 0, "", MagicNumber, 0, Aqua); + if (l_ticket_52 > 0) OrderModify(l_ticket_52, OrderOpenPrice(), l_price_76, 0, 0, CLR_NONE); + gi_144 = FALSE; + } + gi_140 = Time[0]; + } + if (li_56 > 0) { + if (BETrigger > 0) HandleBreakEven(); + if (OrderLots() > 3.0 * GetLots() / 4.0) { + if (l_cmd_72 == OP_BUY) + if (Bid >= OrderOpenPrice() + TP * Point) OrderClose(l_ticket_68, OrderLots() / 2.0, Bid, Slippage, Blue); + if (l_cmd_72 == OP_SELL) + if (Ask <= OrderOpenPrice() - TP * Point) OrderClose(l_ticket_68, OrderLots() / 2.0, Ask, Slippage, Red); + } + } + return (0); +} + +int iLongReEntry() { + int l_highest_8; + int l_shift_0 = 0; + int l_shift_4 = 0; + for (int l_pos_12 = OrdersHistoryTotal() - 1; l_pos_12 >= 0; l_pos_12--) { + OrderSelect(l_pos_12, SELECT_BY_POS, MODE_HISTORY); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) { + l_shift_0 = iBarShift(Symbol(), 0, OrderOpenTime()); + l_shift_4 = iBarShift(Symbol(), 0, OrderCloseTime()); + l_highest_8 = iHighest(Symbol(), 0, MODE_HIGH, l_shift_0 - l_shift_4, l_shift_4); + if (Bid > High[l_highest_8]) return (1); + return (0); + } + } + return (0); +} + +int GetLongsNumber() { + int l_count_0 = 0; + for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) l_count_0++; + } + return (l_count_0); +} + +int GetShortsNumber() { + int l_count_0 = 0; + for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) l_count_0++; + } + return (l_count_0); +} + +void CloseAllLongs() { + int l_ord_total_0 = OrdersTotal(); + for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue); + } + } +} + +void CloseAllShorts() { + int l_ord_total_0 = OrdersTotal(); + for (int l_pos_4 = l_ord_total_0 - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) { + RefreshRates(); + OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red); + } + } +} + +void HandleBreakEven() { + for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { + OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + if (OrderType() == OP_BUY) { + if (Bid >= OrderOpenPrice() + BETrigger * Point && OrderStopLoss() < OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, CLR_NONE); + } else { + if (OrderType() == OP_SELL) + if (Ask <= OrderOpenPrice() - BETrigger * Point && OrderStopLoss() > OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, CLR_NONE); + } + } + } +} + +double GetLots() { + double ld_ret_0; + double ld_8; + double l_lotstep_32; + double l_marginrequired_40; + if (UseMoneyManagement) { + l_lotstep_32 = MarketInfo(Symbol(), MODE_LOTSTEP); + l_marginrequired_40 = MarketInfo(Symbol(), MODE_MARGINREQUIRED); + ld_ret_0 = AccountBalance() * Risk / 100.0 / l_marginrequired_40; + ld_8 = MathMod(ld_ret_0, l_lotstep_32); + if (ld_8 != 0.0) ld_ret_0 -= ld_8; + } else ld_ret_0 = Lots; + double l_minlot_16 = MarketInfo(Symbol(), MODE_MINLOT); + double l_maxlot_24 = MarketInfo(Symbol(), MODE_MAXLOT); + if (ld_ret_0 < l_minlot_16) ld_ret_0 = l_minlot_16; + if (ld_ret_0 > l_maxlot_24) ld_ret_0 = l_maxlot_24; + return (ld_ret_0); +} + diff --git a/FXkred_renko_counter_V1.05.mq4 b/FXkred_renko_counter_V1.05.mq4 new file mode 100644 index 0000000..3c99356 --- /dev/null +++ b/FXkred_renko_counter_V1.05.mq4 @@ -0,0 +1,196 @@ +/****************************************, + Written by Fxkred 2012.04.13 + v1.03 + * New: Swintch on/off displaing the pips until close + -corner of the Renko length + - adjust line size and style + * v05 Switchable text on Closinglines + + +******************************************/ +#property copyright "Copyright © 2012 FXkred" + +#property indicator_chart_window + +//************************** Inputs + + +extern bool DisplayRenkoSize = true; +extern int DisplaySizeWhichCorner_0_1_2_3 = 1; +extern color RenkoSizeColor = Red; +extern bool RenkoClosingLine = true; +extern color LongCloseLineColor = Aqua; +extern int LongCloseLineStyle_0_7 = 3; +extern int LongCloseLineWidth_1_5 = 1; +extern color ShortCloseLineColor = Red; +extern int ShortCloseLineStyle_0_7 = 3; +extern int ShortCloseLineWidth_1_5 = 1; +extern bool ShowPriceOnCloseLines =true; +extern color CloseLinePriceColor = White; + +extern bool DisplayCounter = false; +extern color CounterTextColor = Aqua; +extern bool DisplayCandleLenghtByPoint = true; +extern bool LongSetAlert = true; +extern bool ShortSetAlert = true; +int szorzo; // Multiplier, depents on digits +double LongAlertLevel; +double ShortAlertLevel; + +//******************* +int deinit() { + ObjectDelete("RenkoCounter"); + ObjectDelete("RenkoSize"); + ObjectDelete("RenkoLongClose"); + ObjectDelete("RenkoShortClose"); + ObjectDelete("RenkoCloseLine_L"); + ObjectDelete("RenkoCloseLine_S"); + Comment (" "); + return (0); +} + +int init() { + + + +if ( Digits ==1) szorzo = 10; +if ( Digits ==2) szorzo = 100; +if ( Digits ==3) szorzo = 1000; +if ( Digits ==4) szorzo = 10000; +if ( Digits ==5) szorzo = 100000; + + LongAlertLevel=0; + ShortAlertLevel=0; + + return (0); +} + +int start() { + + // renko Gyertyahossz meghatбrozбsa -- CAlculate Renko candle length + double CandleLength = MathAbs(Open[1]-Close[1])*szorzo; + + bool longos, shortos; + if (Open[1]>Close[1] ) + { longos = false; shortos= true; + } + else {shortos = false; longos = true; } + + if (longos == true) + { + + double longvissza = MathAbs( (Close[1] -Bid) *szorzo + CandleLength ); + double LongCloseLine = Close[1] + CandleLength*Point ; + double shortvissza = MathAbs( (Close[1]- Bid)*szorzo -2*CandleLength); + double ShortCloseLine = Close[1]- 2*CandleLength*Point; + } + else + { + shortvissza= MathAbs( (Close[1]-Bid) * szorzo -CandleLength); + ShortCloseLine = Close[1]- CandleLength*Point; + longvissza = MathAbs( ( Close[1]-Bid)* szorzo + 2*CandleLength); + LongCloseLine = Close[1]+ 2*CandleLength*Point; + } + // Megjelenitйs --Display the pips until the Long and Short Renko candle + + if(Bid ShortCloseLine) + { + LongAlertLevel = LongCloseLine; + ShortAlertLevel = ShortCloseLine; + } + if (DisplayCounter ==true ) + + { + + + + ObjectDelete("RenkoCounter"); + if (ObjectFind("RenkoCounter") != 0) { + ObjectCreate("RenkoCounter", OBJ_TEXT, 0, Time[0], Close[0] ); + ObjectSetText("RenkoCounter", " < L " + DoubleToStr( longvissza,0) + + " / S " + DoubleToStr( shortvissza,0) , 10, "ArialBold", CounterTextColor); + } else ObjectMove("RenkoCounter", 0, Time[0], Close[0]); + } else ObjectDelete("RenkoCounter"); + + + + + if (DisplayRenkoSize ==true ) + { + if (DisplayCandleLenghtByPoint ==false ) CandleLength = CandleLength/10; + if(ObjectType("RenkoSize") != OBJ_LABEL) ObjectDelete("RenkoSize"); + if(ObjectFind("RenkoSize") == -1) ObjectCreate("RenkoSize", OBJ_LABEL, 0, Time[5], Close[5]); + + ObjectSetText("RenkoSize" ,"Renko: "+ DoubleToStr(CandleLength, 0) + ); + + + ObjectSet("RenkoSize", OBJPROP_CORNER, DisplaySizeWhichCorner_0_1_2_3 ); + ObjectSet("RenkoSize", OBJPROP_COLOR, RenkoSizeColor); + ObjectSet("RenkoSize", OBJPROP_FONTSIZE, 15); + ObjectSet("RenkoSize", OBJPROP_XDISTANCE, 5); + ObjectSet("RenkoSize", OBJPROP_YDISTANCE, 20); + + } + + + if(RenkoClosingLine) + { + // Long Close Line + + ObjectDelete("RenkoLongClose"); + ObjectDelete("RenkoShortClose"); + ObjectCreate("RenkoLongClose", OBJ_TREND, 0, Time[1], LongCloseLine, Time[0],LongCloseLine); + ObjectSet("RenkoLongClose", OBJPROP_STYLE, LongCloseLineStyle_0_7); + ObjectSet("RenkoLongClose", OBJPROP_COLOR, LongCloseLineColor); + ObjectSet("RenkoLongClose", OBJPROP_WIDTH, LongCloseLineWidth_1_5); + ObjectSet("RenkoLongClose", OBJPROP_BACK, TRUE); + if (ShowPriceOnCloseLines) + { + string LongCloseLinePrice = " " + DoubleToStr( LongCloseLine,Digits); + ObjectDelete("RenkoCloseLine_L"); + ObjectCreate("RenkoCloseLine_L", OBJ_TEXT, 0, Time[0], LongCloseLine,Time[0], LongCloseLine+3*Point ); + ObjectSetText("RenkoCloseLine_L"," "+ LongCloseLinePrice, 10, "Curier", CloseLinePriceColor); +// ObjectMove("RenkoCloseLine_S", 0, Time[0], ShortCloseLine); + } + + //Short close line + ObjectCreate("RenkoShortClose", OBJ_TREND, 0, Time[1], ShortCloseLine, Time[0],ShortCloseLine); + ObjectSet("RenkoShortClose", OBJPROP_STYLE, ShortCloseLineStyle_0_7); + ObjectSet("RenkoShortClose", OBJPROP_COLOR, ShortCloseLineColor); + ObjectSet("RenkoShortClose", OBJPROP_WIDTH, ShortCloseLineWidth_1_5); + ObjectSet("RenkoShortClose", OBJPROP_BACK, TRUE); + + if (ShowPriceOnCloseLines) + { + string ShortCloseLinePrice = " " + DoubleToStr( ShortCloseLine,Digits); + ObjectDelete("RenkoCloseLine_S"); + ObjectCreate("RenkoCloseLine_S", OBJ_TEXT, 0, Time[0], ShortCloseLine,Time[0], ShortCloseLine ); + ObjectSetText("RenkoCloseLine_S"," "+ ShortCloseLinePrice, 10, "Curier",CloseLinePriceColor); +// ObjectMove("RenkoCloseLine_S", 0, Time[0], ShortCloseLine); + } + + } + else + { ObjectDelete("RenkoLongClose"); + ObjectDelete("RenkoShortClose"); } +if (ShowPriceOnCloseLines) + { + + + } + + if (LongSetAlert && Close[0]== LongAlertLevel) + { + + // Alert("Renko closed up."); + PlaySound("ClosedUp.wav"); + } + if (ShortSetAlert && Close[0]== ShortAlertLevel) + { + + // Alert("Renko closed down."); + PlaySound("ClosedDown.wav"); + } + return (0); +} \ No newline at end of file diff --git a/FiboPiv_Daily_DK.mq4 b/FiboPiv_Daily_DK.mq4 new file mode 100644 index 0000000..1412d38 --- /dev/null +++ b/FiboPiv_Daily_DK.mq4 @@ -0,0 +1,351 @@ +//+------------------------------------------------------------------+ +//| Daily_FiboPiv_DK.mq4 | +//| Kalenzo | +//| bartlomiej.gorski@gmail.com +//| upgrade by darkkiller +//+------------------------------------------------------------------+ +#property copyright "c. 2007-08, Kalenzo" +#property link "bartlomiej.gorski@gmail.com" +#property indicator_buffers 5 +#property indicator_color1 C'62,62,62' +#property indicator_style1 1 +#property indicator_color2 Red +#property indicator_style2 1 +#property indicator_color3 C'62,62,62' +#property indicator_style3 1 +#property indicator_color4 DarkGray +#property indicator_style4 1 +#property indicator_color5 SlateGray +#property indicator_style5 1 + + +/*extern color Resistance_3 = Sienna; +extern color Resistance_2 = Red; +extern color Resistance_1 = Magenta; +extern color Pivot = Goldenrod; +extern color Support_1 = Lime; +extern color Support_2 = Green; +extern color Support_3 = DarkGreen; +*/ +#property indicator_chart_window +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + ObjectDelete("S1"); + ObjectDelete("S2"); + ObjectDelete("S3"); + ObjectDelete("S4"); + ObjectDelete("S5"); + ObjectDelete("S6"); + ObjectDelete("S7"); + ObjectDelete("S8"); + ObjectDelete("S9"); + ObjectDelete("S10"); + ObjectDelete("S11"); + ObjectDelete("S12"); + ObjectDelete("S11"); + ObjectDelete("S12"); + ObjectDelete("S13"); + ObjectDelete("S14"); + ObjectDelete("S15"); + ObjectDelete("S16"); + ObjectDelete("S17"); + ObjectDelete("S18"); + + ObjectDelete("R1"); + ObjectDelete("R2"); + ObjectDelete("R3"); + ObjectDelete("R4"); + ObjectDelete("R5"); + ObjectDelete("R6"); + ObjectDelete("R7"); + ObjectDelete("R8"); + ObjectDelete("R9"); + ObjectDelete("R10"); + ObjectDelete("R11"); + ObjectDelete("R12"); + ObjectDelete("R11"); + ObjectDelete("R12"); + ObjectDelete("R13"); + ObjectDelete("R14"); + ObjectDelete("R15"); + ObjectDelete("R16"); + ObjectDelete("R17"); + ObjectDelete("R18"); + + + ObjectDelete("PIVOT"); + ObjectDelete(" Daily Pivot"); + + ObjectDelete(" -FIB 23.6"); + ObjectDelete(" -FIB 38.2"); + ObjectDelete(" -FIB 50.0"); + ObjectDelete(" -FIB 61.8"); + ObjectDelete(" -FIB 76.4"); + ObjectDelete(" -FIB 100.0"); + ObjectDelete(" -FIB 123.6"); + ObjectDelete(" -FIB 138.2"); + ObjectDelete(" -FIB 150.0"); + ObjectDelete(" -FIB 161.8"); + ObjectDelete(" -FIB 176.4"); + ObjectDelete(" -FIB 200.0"); + ObjectDelete(" -FIB 223.6"); + ObjectDelete(" -FIB 238.2"); + ObjectDelete(" -FIB 250.0"); + ObjectDelete(" -FIB 261.8"); + ObjectDelete(" -FIB 276.4"); + ObjectDelete(" -FIB 300.0"); + + ObjectDelete(" +FIB 23.6"); + ObjectDelete(" +FIB 38.2"); + ObjectDelete(" +FIB 50.0"); + ObjectDelete(" +FIB 61.8"); + ObjectDelete(" +FIB 76.4"); + ObjectDelete(" +FIB 100.0"); + ObjectDelete(" +FIB 123.6"); + ObjectDelete(" +FIB 138.2"); + ObjectDelete(" +FIB 150.0"); + ObjectDelete(" +FIB 161.8"); + ObjectDelete(" +FIB 176.4"); + ObjectDelete(" +FIB 200.0"); + ObjectDelete(" +FIB 223.6"); + ObjectDelete(" +FIB 238.2"); + ObjectDelete(" +FIB 250.0"); + ObjectDelete(" +FIB 261.8"); + ObjectDelete(" +FIB 276.4"); + ObjectDelete(" +FIB 300.0"); + Comment(" "); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { + +//---- +double rates[1][6],yesterday_close,yesterday_high,yesterday_low; +ArrayCopyRates(rates, Symbol(), PERIOD_D1); + +if(DayOfWeek() == 1) +{ + if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,1)) == 5) + { + yesterday_close = rates[1][4]; + yesterday_high = rates[1][3]; + yesterday_low = rates[1][2]; + } + else + { + for(int d = 5;d>=0;d--) + { + if(TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,d)) == 5) + { + yesterday_close = rates[d][4]; + yesterday_high = rates[d][3]; + yesterday_low = rates[d][2]; + } + + } + + } +} +else +{ + yesterday_close = rates[1][4]; + yesterday_high = rates[1][3]; + yesterday_low = rates[1][2]; +} + + +//---- Calculate Pivots + +Comment(""); +double R = yesterday_high - yesterday_low;//range +double p = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot + +double r18 = p + (R * 3.000); +double r17 = p + (R * 2.764); +double r16 = p + (R * 2.618); +double r15 = p + (R * 2.500); +double r14 = p + (R * 2.382); +double r13 = p + (R * 2.236); +double r12 = p + (R * 2.000); +double r11 = p + (R * 1.764); +double r10 = p + (R * 1.618); +double r9 = p + (R * 1.500); +double r8 = p + (R * 1.382); +double r7 = p + (R * 1.236); +double r6 = p + (R * 1.000); +double r5 = p + (R * 0.764); +double r4 = p + (R * 0.618); +double r3 = p + (R * 0.500); +double r2 = p + (R * 0.382); +double r1 = p + (R * 0.236); + + +double s1 = p - (R * 0.236); +double s2 = p - (R * 0.382); +double s3 = p - (R * 0.500); +double s4 = p - (R * 0.618); +double s5 = p - (R * 0.764); +double s6 = p - (R * 1.000); +double s7 = p - (R * 1.236); +double s8 = p - (R * 1.382); +double s9 = p - (R * 1.500); +double s10 = p - (R * 1.618); +double s11 = p - (R * 1.764); +double s12 = p - (R * 2.000); +double s13 = p - (R * 2.236); +double s14 = p - (R * 2.382); +double s15 = p - (R * 2.500); +double s16 = p - (R * 2.618); +double s17 = p - (R * 2.764); +double s18 = p - (R * 3.000); + +drawLine(r18,"R18", indicator_color1,indicator_style1); +drawLabel(" +FIB 300.0",r18,indicator_color5); +drawLine(r17,"R17", indicator_color1,indicator_style1); +drawLabel(" +FIB 276.4",r17,indicator_color4); +drawLine(r16,"R16", indicator_color1,indicator_style1); +drawLabel(" +FIB 261.8",r16,indicator_color4); +drawLine(r15,"R15", indicator_color1,indicator_style1); +drawLabel(" +FIB 250.0",r15,indicator_color4); +drawLine(r14,"R14", indicator_color1,indicator_style1); +drawLabel(" +FIB 238.2",r14,indicator_color4); +drawLine(r13,"R13", indicator_color1,indicator_style1); +drawLabel(" +FIB 223.6",r13,indicator_color4); +drawLine(r12,"R12", indicator_color1,indicator_style1); +drawLabel(" +FIB 200.0",r12,indicator_color5); +drawLine(r11,"R11", indicator_color1,indicator_style1); +drawLabel(" +FIB 176.4",r11,indicator_color4); +drawLine(r10,"R10", indicator_color1,indicator_style1); +drawLabel(" +FIB 161.8",r10,indicator_color4); +drawLine(r9,"R9", indicator_color1,indicator_style1); +drawLabel(" +FIB 150.0",r9,indicator_color4); +drawLine(r8,"R8", indicator_color1,indicator_style1); +drawLabel(" +FIB 138.2",r8,indicator_color4); +drawLine(r7,"R7", indicator_color1,indicator_style1); +drawLabel(" +FIB 123.6",r7,indicator_color4); +drawLine(r6,"R6", indicator_color1,indicator_style1); +drawLabel(" +FIB 100.0",r6,indicator_color5); +drawLine(r5,"R5", indicator_color1,indicator_style1); +drawLabel(" +FIB 76.4",r5,indicator_color4); +drawLine(r4,"R4", indicator_color1,indicator_style1); +drawLabel(" +FIB 61.8",r4,indicator_color4); +drawLine(r3,"R3", indicator_color1,indicator_style1); +drawLabel(" +FIB 50.0",r3,indicator_color4); +drawLine(r2,"R2", indicator_color1,indicator_style1); +drawLabel(" +FIB 38.2",r2,indicator_color4); +drawLine(r1,"R1", indicator_color1,indicator_style1); +drawLabel(" +FIB 23.6",r1,indicator_color4); + +drawLine(p,"PIVOT",indicator_color2,indicator_style1); +drawLabel(" Daily Pivot",p,indicator_color2); + +drawLine(s1,"S1",indicator_color3,indicator_style1); +drawLabel(" -FIB 23.6",s1,indicator_color4); +drawLine(s2,"S2",indicator_color3,indicator_style1); +drawLabel(" -FIB 38.2",s2,indicator_color4); +drawLine(s3,"S3",indicator_color3,indicator_style1); +drawLabel(" -FIB 50.0",s3,indicator_color4); +drawLine(s4,"S4",indicator_color3,indicator_style1); +drawLabel(" -FIB 61.8",s4,indicator_color4); +drawLine(s5,"S5",indicator_color3,indicator_style1); +drawLabel(" -FIB 76.4",s5,indicator_color4); +drawLine(s6,"S6",indicator_color3,indicator_style1); +drawLabel(" -FIB 100.0",s6,indicator_color5); +drawLine(s7,"S7",indicator_color3,indicator_style1); +drawLabel(" -FIB 123.6",s7,indicator_color4); +drawLine(s8,"S8",indicator_color3,indicator_style1); +drawLabel(" -FIB 138.2",s8,indicator_color4); +drawLine(s9,"S9",indicator_color3,indicator_style1); +drawLabel(" -FIB 150.0",s9,indicator_color4); +drawLine(s10,"S10",indicator_color3,indicator_style1); +drawLabel(" -FIB 161.8",s10,indicator_color4); +drawLine(s11,"S11",indicator_color3,indicator_style1); +drawLabel(" -FIB 176.4",s11,indicator_color4); +drawLine(s12,"S12",indicator_color3,indicator_style1); +drawLabel(" -FIB 200.0",s12,indicator_color5); +drawLine(s13,"S13",indicator_color3,indicator_style1); +drawLabel(" -FIB 223.6",s13,indicator_color4); +drawLine(s14,"S14",indicator_color3,indicator_style1); +drawLabel(" -FIB 238.2",s14,indicator_color4); +drawLine(s15,"S15",indicator_color3,indicator_style1); +drawLabel(" -FIB 250.0",s15,indicator_color4); +drawLine(s16,"S16",indicator_color3,indicator_style1); +drawLabel(" -FIB 261.8",s16,indicator_color4); +drawLine(s17,"S17",indicator_color3,indicator_style1); +drawLabel(" -FIB 276.4",s17,indicator_color4); +drawLine(s18,"S18",indicator_color3,indicator_style1); +drawLabel(" -FIB 300.0",s18,indicator_color5); + + +//---- + return(0); + } +//+------------------------------------------------------------------+ +void drawLabel(string name,double lvl,color Color) +{ + if(ObjectFind(name) != 0) + { + ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl); + ObjectSetText(name, name, 8, "Arial", EMPTY); + ObjectSet(name, OBJPROP_COLOR, Color); + + + } + else + { + ObjectMove(name, 0, Time[10], lvl); + } +} + + +void drawLine(double lvl,string name, color Col,int type) +{ + if(ObjectFind(name) != 0) + { + ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); + + if(type == 1) + ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); + else if(type == 2) + ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOTDOT); + else + ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); + + ObjectSet(name, OBJPROP_COLOR, Col); + ObjectSet(name,OBJPROP_WIDTH,1); + + } + else + { + ObjectDelete(name); + ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); + + if(type == 1) + ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); + else if(type == 2) + ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOTDOT); + else + ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); + + ObjectSet(name, OBJPROP_COLOR, Col); + ObjectSet(name,OBJPROP_WIDTH,1); + + } +} \ No newline at end of file diff --git a/FullFiboPiv_Weekly_DK.mq4 b/FullFiboPiv_Weekly_DK.mq4 new file mode 100644 index 0000000..eb69503 --- /dev/null +++ b/FullFiboPiv_Weekly_DK.mq4 @@ -0,0 +1,277 @@ +//+------------------------------------------------------------------+ +//| FullFiboPiv_Weekly_DK.mq4 | +//| Kalenzo | +//| bartlomiej.gorski@gmail.com +//| modified by darkkiller +//+------------------------------------------------------------------+ +#property copyright "c. 2007-08, Kalenzo" +#property link "bartlomiej.gorski@gmail.com" +#property indicator_buffers 3 +#property indicator_color1 C'62,62,62' +#property indicator_style1 1 +#property indicator_color2 Red +#property indicator_style1 1 +#property indicator_color3 C'62,62,62' +#property indicator_style1 1 + + +/*extern color Resistance_3 = Sienna; +extern color Resistance_2 = Red; +extern color Resistance_1 = Magenta; +extern color Pivot = Goldenrod; +extern color Support_1 = Lime; +extern color Support_2 = Green; +extern color Support_3 = DarkGreen; +*/ +#property indicator_chart_window +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + ObjectDelete("S1"); + ObjectDelete("S2"); + ObjectDelete("S3"); + ObjectDelete("S4"); + ObjectDelete("S5"); + ObjectDelete("S6"); + ObjectDelete("S7"); + ObjectDelete("S8"); + ObjectDelete("S9"); + ObjectDelete("S10"); + ObjectDelete("S11"); + ObjectDelete("S12"); + + ObjectDelete("R1"); + ObjectDelete("R2"); + ObjectDelete("R3"); + ObjectDelete("R4"); + ObjectDelete("R5"); + ObjectDelete("R6"); + ObjectDelete("R7"); + ObjectDelete("R8"); + ObjectDelete("R9"); + ObjectDelete("R10"); + ObjectDelete("R11"); + ObjectDelete("R12"); + + ObjectDelete("PIVOT"); + ObjectDelete("Daily Pivot"); + + ObjectDelete("-FIB 23.6"); + ObjectDelete("-FIB 38.2"); + ObjectDelete("-FIB 50.0"); + ObjectDelete("-FIB 61.8"); + ObjectDelete("-FIB 76.4"); + ObjectDelete("-FIB 100.0"); + ObjectDelete("-FIB 123.6"); + ObjectDelete("-FIB 138.2"); + ObjectDelete("-FIB 150.0"); + ObjectDelete("-FIB 161.8"); + ObjectDelete("-FIB 176.4"); + ObjectDelete("-FIB 200.0"); + + ObjectDelete("+FIB 23.6"); + ObjectDelete("+FIB 38.2"); + ObjectDelete("+FIB 50.0"); + ObjectDelete("+FIB 61.8"); + ObjectDelete("+FIB 76.4"); + ObjectDelete("+FIB 100.0"); + ObjectDelete("+FIB 123.6"); + ObjectDelete("+FIB 138.2"); + ObjectDelete("+FIB 150.0"); + ObjectDelete("+FIB 161.8"); + ObjectDelete("+FIB 176.4"); + ObjectDelete("+FIB 200.0"); + Comment(" "); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { + +//---- +double rates[1][6],yesterday_close,yesterday_high,yesterday_low; +ArrayCopyRates(rates, Symbol(), PERIOD_W1); + +if(DayOfWeek() == 1) +{ + if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,1)) == 5) + { + yesterday_close = rates[1][4]; + yesterday_high = rates[1][3]; + yesterday_low = rates[1][2]; + } + else + { + for(int d = 5;d>=0;d--) + { + if(TimeDayOfWeek(iTime(Symbol(),PERIOD_W1,d)) == 5) + { + yesterday_close = rates[d][4]; + yesterday_high = rates[d][3]; + yesterday_low = rates[d][2]; + } + + } + + } +} +else +{ + yesterday_close = rates[1][4]; + yesterday_high = rates[1][3]; + yesterday_low = rates[1][2]; +} + + +//---- Calculate Pivots + +Comment(""); +double R = yesterday_high - yesterday_low;//range +double p = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot + +double r12 = p + (R * 2.000); +double r11 = p + (R * 1.764); +double r10 = p + (R * 1.618); +double r9 = p + (R * 1.500); +double r8 = p + (R * 1.382); +double r7 = p + (R * 1.236); +double r6 = p + (R * 1.000); +double r5 = p + (R * 0.764); +double r4 = p + (R * 0.618); +double r3 = p + (R * 0.500); +double r2 = p + (R * 0.382); +double r1 = p + (R * 0.236); +double s1 = p - (R * 0.236); +double s2 = p - (R * 0.382); +double s3 = p - (R * 0.500); +double s4 = p - (R * 0.618); +double s5 = p - (R * 0.764); +double s6 = p - (R * 1.000); +double s7 = p - (R * 1.236); +double s8 = p - (R * 1.382); +double s9 = p - (R * 1.500); +double s10 = p - (R * 1.618); +double s11 = p - (R * 1.764); +double s12 = p - (R * 2.000); + +drawLine(r12,"R12", indicator_color1,indicator_style1); +drawLabel("+FIB 200.0",r12,indicator_color1); +drawLine(r11,"R11", indicator_color1,indicator_style1); +drawLabel("+FIB 176.4",r11,indicator_color1); +drawLine(r10,"R10", indicator_color1,indicator_style1); +drawLabel("+FIB 161.8",r10,indicator_color1); +drawLine(r9,"R9", indicator_color1,indicator_style1); +drawLabel("+FIB 150.0",r9,indicator_color1); +drawLine(r8,"R8", indicator_color1,indicator_style1); +drawLabel("+FIB 138.2",r8,indicator_color1); +drawLine(r7,"R7", indicator_color1,indicator_style1); +drawLabel("+FIB 123.6",r7,indicator_color1); +drawLine(r6,"R6", indicator_color1,indicator_style1); +drawLabel("+FIB 100.0",r6,indicator_color1); +drawLine(r5,"R5", indicator_color1,indicator_style1); +drawLabel("+FIB 76.4",r5,indicator_color1); +drawLine(r4,"R4", indicator_color1,indicator_style1); +drawLabel("+FIB 61.8",r4,indicator_color1); +drawLine(r3,"R3", indicator_color1,indicator_style1); +drawLabel("+FIB 50.0",r3,indicator_color1); +drawLine(r2,"R2", indicator_color1,indicator_style1); +drawLabel("+FIB 38.2",r2,indicator_color1); +drawLine(r1,"R1", indicator_color1,indicator_style1); +drawLabel("+FIB 23.6",r1,indicator_color1); + +drawLine(p,"PIVOT",indicator_color2,indicator_style1); +drawLabel("Daily Pivot",p,indicator_color2); + +drawLine(s1,"S1",indicator_color3,indicator_style1); +drawLabel("-FIB 23.6",s1,indicator_color3); +drawLine(s2,"S2",indicator_color3,indicator_style1); +drawLabel("-FIB 38.2",s2,indicator_color3); +drawLine(s3,"S3",indicator_color3,indicator_style1); +drawLabel("-FIB 50.0",s3,indicator_color3); +drawLine(s4,"S4",indicator_color3,indicator_style1); +drawLabel("-FIB 61.8",s4,indicator_color3); +drawLine(s5,"S5",indicator_color3,indicator_style1); +drawLabel("-FIB 76.4",s5,indicator_color3); +drawLine(s6,"S6",indicator_color3,indicator_style1); +drawLabel("-FIB 100.0",s6,indicator_color3); +drawLine(s7,"S7",indicator_color3,indicator_style1); +drawLabel("-FIB 123.6",s7,indicator_color3); +drawLine(s8,"S8",indicator_color3,indicator_style1); +drawLabel("-FIB 138.2",s8,indicator_color3); +drawLine(s9,"S9",indicator_color3,indicator_style1); +drawLabel("-FIB 150.0",s9,indicator_color3); +drawLine(s10,"S10",indicator_color3,indicator_style1); +drawLabel("-FIB 161.8",s10,indicator_color3); +drawLine(s11,"S11",indicator_color3,indicator_style1); +drawLabel("-FIB 176.4",s11,indicator_color3); +drawLine(s12,"S12",indicator_color3,indicator_style1); +drawLabel("-FIB 200.0",s12,indicator_color3); + +//---- + return(0); + } +//+------------------------------------------------------------------+ +void drawLabel(string name,double lvl,color Color) +{ + if(ObjectFind(name) != 0) + { + ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl); + ObjectSetText(name, name, 8, "Arial", EMPTY); + ObjectSet(name, OBJPROP_COLOR, Color); + } + else + { + ObjectMove(name, 0, Time[10], lvl); + } +} + + +void drawLine(double lvl,string name, color Col,int type) +{ + if(ObjectFind(name) != 0) + { + ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); + + if(type == 1) + ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); + else if(type == 2) + ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOTDOT); + else + ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); + + ObjectSet(name, OBJPROP_COLOR, Col); + ObjectSet(name,OBJPROP_WIDTH,1); + + } + else + { + ObjectDelete(name); + ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl); + + if(type == 1) + ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID); + else if(type == 2) + ObjectSet(name, OBJPROP_STYLE, STYLE_DASHDOTDOT); + else + ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); + + ObjectSet(name, OBJPROP_COLOR, Col); + ObjectSet(name,OBJPROP_WIDTH,1); + + } +} \ No newline at end of file diff --git a/GREEZLY_2007.mq4 b/GREEZLY_2007.mq4 new file mode 100644 index 0000000..0717918 --- /dev/null +++ b/GREEZLY_2007.mq4 @@ -0,0 +1,1239 @@ +//------------------------------------------------------------------ +// GREEZLY_2007s.mq4 | +// Copyright © 2007, GREEZLY | +// e-mail: greezlyfx@mail.ru ICQ: 491769515 | +//------------------------------------------------------------------ + +#property copyright "Copyright © 2007, GREEZLY" +#property link "" + +// магические номера ордеров: 777AABB +// AA - собственный тип ордера, BB - резерв + +#define MN_Usual 7770000 // обычный ордер +#define MN_Averaging 7770100 // усредняющий ордер +#define MN_Flating 7770200 // флэтовый ордер, открытый по индикатору Flat для мелкого профита внутри канала +#define MN_Speed 7770300 // ордер, открытый по индикатору Speed при быстром и мощном движении цены + +// ВНЕШНИЕ ПЕРЕМЕННЫЕ + +extern double TakeProfitB = 12; +extern double TakeProfitS = 12; +extern double StopLossB = 1080; +extern double StopLossS = 780; +extern double TakeProfitForLock = 0; +extern double StopLossForLock = 134; +extern double TrailingStop = 0; +extern double StepTrailingStop = 5; // шаг чувствительности для сдвига TrailingStop + +extern double BuyStopLevel = 22; // < 0 - не использовать +extern double BuyLimitLevel = 17; +extern double SellStopLevel = 78; +extern double SellLimitLevel = 83; + +extern int UseOneWayRealOrdersB = 1; // использовать однонаправленные открытые позиции BUY +extern int UseOneWayRealOrdersS = 1; // использовать однонаправленные открытые позиции SELL +extern double MinDistanceRealOrdersB = 390; // минимально допустимое расстояние между однонаправленными открытыми позициями BUY +extern double MinDistanceRealOrdersS = 590; // минимально допустимое расстояние между однонаправленными открытыми позициями SELL +extern int UseAveragingTakeProfitB = 0; // использовать усредняющий TakeProfit для однонаправленных позиций BUY +extern int UseAveragingTakeProfitS = 0; // использовать усредняющий TakeProfit для однонаправленных позиций SELL + +extern int UseSpeedIndicator = 1; // использовать индикатор скорости +extern int iSP_CountBars = 2; // кол-во анализируемых значений индикатора Speed +extern int iSP_CountTimeFrames = 2; // кол-во анализируемых периодов (тайм-фреймов) индикатора Speed +extern int iSP_StartTimeFrame = 1; // начальный (наименьший) анализируемый период (тайм-фрейм) для индикатора Speed +extern int iSP_UseForOpenRealOrders = 0; // использовать индикатор скорости для открытия реальных ордеров +extern double iSP_MinValueForOpenRealOrders = 0.0005; // минимальное значение индикатора скорости для открытия реальных ордеров +extern double iSP_UseMinTakeProfit = 1; // использовать минимальный тейк-профит для ордеров, открываемых по индикатору Speed +extern double iSP_StopLoss = 35; // стоп-лосс для ордеров, открываемых по индикатору Speed + +extern int CountHighLowLimits = 2; // количество используемых ограничений HighLowLimit: "не покупать сверху, не продавать снизу" + +extern double iHL_LimitDistance1 = 150; // максимально допустимое отклонение цены от Low/High для возможности открытия Buy/Sell +extern int iHL_Period1 = 4; // период (тайм-фрейм) для анализа HighLow (час) +extern int iHL_CountBars1 = 24; // кол-во анализируемых значений периода iHL_Period для определения Low/High + +extern double iHL_LimitDistance2 = 700; // второй блок ограничений HighLowLimit +extern int iHL_Period2 = 6; // (день) +extern int iHL_CountBars2 = 15; // + +extern int UseFlatIndicator = 1; // использовать флэт индикатор для открытия ордеров +extern double iFL_MinWidthCanal = 20; // минимально допустимая ширина канала +extern double iFL_MaxWidthCanal = 40; // максимально допустимая ширина канала +extern double iFL_MinExtremumsCount = 2; // минимально необходимое кол-во экстремумов в канале с каждой стороны (экстремумом считаем значения ниже 1/4 и выше 3/4 ширины канала) +extern int iFL_Period = 1; // период (тайм-фрейм) для анализа Flat (пятиминутки) +extern int iFL_CountBars = 12; // кол-во анализируемых значений периода iFL_Period +extern double iFL_StopLoss = 25; // стоп-лосс для ордеров, открываемых по индикатору Flat +extern double iFL_LotSizeMultiply = 2; // мультипликатор размера лота для ордеров, открываемых по индикатору Flat + +extern int UseBuy = 1; // использовать Buy +extern int UseSell = 1; // использовать Sell +extern int OpenRealOrders = 1; // открывать реальные ордера по рынку +extern double Risk = 0.1; // уровень риска, размер лота от остатка свободных средств, если 0, торговля ведется минимальным заданным лотом +extern double BuyDenyLevel = 177; // граничный уровень открытия ордеров BUY (выше этого уровня ордера не открываются) +extern double SellDenyLevel = 162; // граничный уровень открытия ордеров SELL (ниже этого уровня ордера не открываются) + +extern int MaxOrdersCount = 3; // ограничение на кол-во ордеров (0 - не ограничивать) + +extern double MinDistanceDeferFromPrice = 10; // минимально допустимое расстояние цены открываемых отложенных ордеров от текущей цены +extern double MaxDistanceDeferFromPrice = 50; // максимально допустимое расстояние цены открываемых отложенных ордеров от текущей цены +extern double MinDistanceBetweenDefer = 90; // минимально допустимое расстояние между однонаправленными отложенными ордерами + +extern double MinLotSize = 0.1; +extern double MaxLotSize = 5; +extern double StepLotSize = 0.1; + +bool PrintComments = false; // выводить комментарии при торговле +int DetailComments = 0; // детализация комментариев (0 - самые важные) + +// ВНУТРЕННИЕ ПЕРЕМЕННЫЕ + +int _OP_BUY = 0, _OP_SELL = 1, _OP_BUYLIMIT = 2, _OP_SELLLIMIT = 3, _OP_BUYSTOP = 4, _OP_SELLSTOP = 5; +int _Period[10] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1, 0}; + +double _Point, MI_MODE_STOPLEVEL; + +int Counts[6]; +double MinPrices[6], MaxPrices[6]; +double SumLots[6]; + +double miSpeed; +double miAccelerator; +double iHL_Low[2], iHL_High[2]; +double _iHL_LimitDistance; +bool iFL_IsFlat; +double iFL_Low, iFL_High, iFL_Width; + +int glGetNormalOrderType(int _OrderType) +{ + switch(_OrderType) + { + case OP_BUY: return (_OP_BUY); + case OP_SELL: return (_OP_SELL); + case OP_BUYLIMIT: return (_OP_BUYLIMIT); + case OP_BUYSTOP: return (_OP_BUYSTOP); + case OP_SELLLIMIT: return (_OP_SELLLIMIT); + case OP_SELLSTOP: return (_OP_SELLSTOP); + default: return(-1); + } + return(-1); +} + +int init() +{ + MI_MODE_STOPLEVEL = MarketInfo(Symbol(), MODE_STOPLEVEL); + + + + if(TakeProfitB != 0) TakeProfitB = MathMax(MI_MODE_STOPLEVEL, TakeProfitB); + if(TakeProfitS != 0) TakeProfitS = MathMax(MI_MODE_STOPLEVEL, TakeProfitS); + if(StopLossB != 0) StopLossB = MathMax(MI_MODE_STOPLEVEL, StopLossB); + if(StopLossS != 0) StopLossS = MathMax(MI_MODE_STOPLEVEL, StopLossS); + if(iSP_StopLoss != 0) iSP_StopLoss = MathMax(MI_MODE_STOPLEVEL, iSP_StopLoss); + if(iFL_StopLoss != 0) iFL_StopLoss = MathMax(MI_MODE_STOPLEVEL, iFL_StopLoss); + + if(TakeProfitForLock != 0) TakeProfitForLock = MathMax(MI_MODE_STOPLEVEL, TakeProfitForLock); + if(StopLossForLock != 0) StopLossForLock = MathMax(MI_MODE_STOPLEVEL, StopLossForLock); + + if(UseSpeedIndicator == 1) + { + if(iSP_CountBars < 2) iSP_CountBars = 2; + if(iSP_CountBars > 10) iSP_CountBars = 10; + if(iSP_CountTimeFrames < 1) iSP_CountTimeFrames = 1; + if(iSP_CountTimeFrames > 5) iSP_CountTimeFrames = 5; + } + + if(MaxOrdersCount < 0) MaxOrdersCount = 0; + + MinLotSize = MathMax(MarketInfo(Symbol(), MODE_MINLOT), MinLotSize); + MaxLotSize = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), MaxLotSize); + StepLotSize = MathMax(MarketInfo(Symbol(), MODE_LOTSTEP), StepLotSize); + + return(0); +} + +int deinit() +{ + + return(0); +} + +int start() +{ + int _OrderType, _OrderMagicNumber, NormalOrderType; + double Lots, _Volume, _OrderOpenPrice, _OrderLots, _OrderStopLoss, _OrderTakeProfit; + double CurrentPrice, CurrentFigure, NearestRealPrice, NearestDeferPrice, NeedDistance; + double _Low, _High; + int ticket, type, typedefer; + int i, j, k, total; + bool MayOpenDeferOrder, MayOpenRealOrder; + string typestr; + + _Point = 1.0 / MathPow(10, Digits); + + + + + + + miAccelerator = 0; + + + + miSpeed = 0; + + if(UseSpeedIndicator == 1) + { + double iSP_Val[10][10]; + int iSP_Dir[10]; + double iPrice1, iPrice2; + + for(i = 0; i < iSP_CountTimeFrames; i++) + { + for(j = 0; j < iSP_CountBars; j++) + { + + + iPrice1 = (iHigh(NULL, _Period[iSP_StartTimeFrame + i], j + 2) + iLow(NULL, _Period[iSP_StartTimeFrame + i], j + 2) + iClose(NULL, _Period[iSP_StartTimeFrame + i], j + 2) * 2) / 4; + iPrice2 = (iHigh(NULL, _Period[iSP_StartTimeFrame + i], j + 1) + iLow(NULL, _Period[iSP_StartTimeFrame + i], j + 1) + iClose(NULL, _Period[iSP_StartTimeFrame + i], j + 1) * 2) / 4; + + if(iPrice1 > 0) iSP_Val[i][j] = (iPrice2 - iPrice1) / iPrice1; + else iSP_Val[i][j] = 0; + } + + if((i == 0) && (iSP_StartTimeFrame == 0)) + { + if (Bid > iOpen(NULL, _Period[0], 0)) iSP_Dir[0] = 1; + else if(Bid < iOpen(NULL, _Period[0], 0)) iSP_Dir[0] = -1; + else + { + if (iSP_Val[i][0] > 0) iSP_Dir[i] = 1; + else if(iSP_Val[i][0] < 0) iSP_Dir[i] = -1; + else + { + iSP_Dir[i] = 0; + break; + } + } + } + else + { + if (iOpen(NULL, _Period[iSP_StartTimeFrame + i], 0) > iClose(NULL, _Period[iSP_StartTimeFrame + i], 1)) iSP_Dir[i] = 1; + else if(iOpen(NULL, _Period[iSP_StartTimeFrame + i], 0) < iClose(NULL, _Period[iSP_StartTimeFrame + i], 1)) iSP_Dir[i] = -1; + else + { + if (iSP_Val[i][0] > 0) iSP_Dir[i] = 1; + else if(iSP_Val[i][0] < 0) iSP_Dir[i] = -1; + else + { + iSP_Dir[i] = 0; + break; + } + } + } + + if(iSP_Val[i][iSP_CountBars - 1] * iSP_Dir[i] <= 0) + { + iSP_Dir[i] = 0; + break; + } + + for(j = iSP_CountBars - 2; j >= 0; j--) + { + if((iSP_Dir[i] == 1) && (iSP_Val[i][j] <= iSP_Val[i][j + 1])) + { + iSP_Dir[i] = 0; + break; + } + else + if((iSP_Dir[i] == -1) && (iSP_Val[i][j] >= iSP_Val[i][j + 1])) + { + iSP_Dir[i] = 0; + break; + } + } + } + + miSpeed = iSP_Dir[0]; + + for(i = 1; i < iSP_CountTimeFrames; i++) + { + if(iSP_Dir[i] != miSpeed) + { + miSpeed = 0; + break; + } + } + + + + if(miSpeed != 0) + { + iPrice1 = iOpen(NULL, _Period[0], 0); + iPrice2 = Bid; + + if((iSP_StartTimeFrame == 0) && (iPrice1 != iPrice2) && (iPrice1 > 0)) miSpeed = (iPrice2 - iPrice1) / iPrice1; + else miSpeed = iSP_Val[0][0]; + } + } + + + + if(CountHighLowLimits > 0) + { + int _iHL_CountBars, _iHL_Period; + + for(k = 0; k < CountHighLowLimits; k++) + { + iHL_Low[k] = 0; + iHL_High[k] = 0; + + switch(k) + { + case 0 : _iHL_Period = iHL_Period1; _iHL_CountBars = iHL_CountBars1; break; + case 1 : _iHL_Period = iHL_Period2; _iHL_CountBars = iHL_CountBars2; break; + default: continue; + } + + for(i = 0; i < _iHL_CountBars; i++) + { + _Low = iLow( NULL, _Period[_iHL_Period], i); + _High = iHigh(NULL, _Period[_iHL_Period], i); + + if(_Low > 0) + if((iHL_Low[k] == 0) || (_Low < iHL_Low[k])) iHL_Low[k] = _Low; + + if(_High > 0) + if((iHL_High[k] == 0) || (_High > iHL_High[k])) iHL_High[k] = _High; + } + } + } + + + + if(UseFlatIndicator == 1) + { + int _CountLow, _CountHigh, _PrevLowHigh; + + iFL_IsFlat = false; + iFL_Low = 0; + iFL_High = 0; + iFL_Width = 0; + + for(i = 0; i < iFL_CountBars; i++) + { + _Low = iLow( NULL, _Period[iFL_Period], i); + _High = iHigh(NULL, _Period[iFL_Period], i); + + if(_Low > 0) + if((iFL_Low == 0) || (_Low < iFL_Low)) iFL_Low = _Low; + + if(_High > 0) + if((iFL_High == 0) || (_High > iFL_High)) iFL_High = _High; + } + + iFL_Width = iFL_High - iFL_Low; + + if((iFL_High > 0) && (iFL_Low > 0) && (iFL_Width >= iFL_MinWidthCanal * _Point) && (iFL_Width <= iFL_MaxWidthCanal * _Point)) + { + _CountLow = 0; _CountHigh = 0; _PrevLowHigh = 0; + + for(i = 0; i < iFL_CountBars; i++) + { + _Low = iLow( NULL, _Period[iFL_Period], i); + _High = iHigh(NULL, _Period[iFL_Period], i); + + if((_Low > 0) && (_Low < (iFL_Low + iFL_Width / 4)) && (_PrevLowHigh >= 0)) + { + _PrevLowHigh = -1; + _CountLow = _CountLow + 1; + } + + if((_High > 0) && (_High > (iFL_High - iFL_Width / 4)) && (_PrevLowHigh <= 0)) + { + _PrevLowHigh = 1; + _CountHigh = _CountHigh + 1; + } + } + + if((_CountLow >= iFL_MinExtremumsCount) && (_CountHigh >= iFL_MinExtremumsCount)) + { + iFL_IsFlat = true; + } + } + } + + + + + if(!glAnalizCurrentOrdersState()) return(0); + + if((Counts[_OP_BUY] != 0) && (Counts[_OP_BUYLIMIT] != 0)) + { + glDeleteAllDeferOrders(_OP_BUYLIMIT); + } + + if((Counts[_OP_SELL] != 0) && (Counts[_OP_SELLLIMIT] != 0)) + { + glDeleteAllDeferOrders(_OP_SELLLIMIT); + } + + if((Counts[_OP_BUY] != 0) && (Counts[_OP_BUYSTOP] != 0)) + { + glDeleteAllDeferOrders(_OP_BUYSTOP, "", MinPrices[_OP_BUY], 0); + } + if((Counts[_OP_SELL] != 0) && (Counts[_OP_SELLSTOP] != 0)) + { + glDeleteAllDeferOrders(_OP_SELLSTOP, "", 0, MaxPrices[_OP_SELL]); + } + + + + if((Counts[_OP_BUY] != 0) && (Counts[_OP_SELL] != 0)) + { + + + + if(((TakeProfitForLock != 0) && ((TakeProfitForLock != TakeProfitB) || (TakeProfitForLock != TakeProfitS))) || + ((StopLossForLock != 0) && ((StopLossForLock != StopLossB) || (StopLossForLock != StopLossS)))) + { + CurrentPrice = (Ask + Bid) / 2; + + total = OrdersTotal(); + for(i = 0; i < total; i++) + { + if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) + { + Print("Ошибка получения текущего ордера OrderSelect(): ", GetLastError()); + return(0); + } + + _OrderType = OrderType(); + _OrderOpenPrice = OrderOpenPrice(); + _OrderTakeProfit = OrderTakeProfit(); + _OrderStopLoss = OrderStopLoss(); + _OrderMagicNumber = OrderMagicNumber(); + + if(_OrderMagicNumber == MN_Averaging) continue; + + if((_OrderType == OP_BUY) && (_OrderOpenPrice == MinPrices[_OP_BUY])) + { + if(_OrderTakeProfit < (_OrderOpenPrice + TakeProfitForLock * _Point)) + { + if((MathAbs(Bid - _OrderStopLoss) > MI_MODE_STOPLEVEL * _Point) && (MathAbs(Bid - (_OrderOpenPrice + TakeProfitForLock * _Point)) > MI_MODE_STOPLEVEL * _Point)) + if(OrderModify(OrderTicket(), _OrderOpenPrice, _OrderStopLoss, _OrderOpenPrice + TakeProfitForLock * _Point, 0)) + { + _OrderTakeProfit = _OrderOpenPrice + TakeProfitForLock * _Point; + } + } + + if((StopLossForLock != 0) && (_OrderOpenPrice > MaxPrices[_OP_SELL]) && + ((_OrderOpenPrice - MaxPrices[_OP_SELL]) > 2.2 * StopLossForLock * _Point) && + (MathAbs(_OrderOpenPrice - CurrentPrice) < MathAbs(MaxPrices[_OP_SELL] - CurrentPrice)) && + (_OrderStopLoss < (_OrderOpenPrice - StopLossForLock * _Point)) && + (Bid > (_OrderOpenPrice - StopLossForLock * _Point * 2/3))) + { + if((MathAbs(Bid - (_OrderOpenPrice - StopLossForLock * _Point)) > MI_MODE_STOPLEVEL * _Point) && (MathAbs(Bid - _OrderTakeProfit) > MI_MODE_STOPLEVEL * _Point)) + if(OrderModify(OrderTicket(), _OrderOpenPrice, _OrderOpenPrice - StopLossForLock * _Point, _OrderTakeProfit, 0)) + { + _OrderStopLoss = _OrderOpenPrice - StopLossForLock * _Point; + } + } + } + else if((_OrderType == OP_SELL) && (_OrderOpenPrice == MaxPrices[_OP_SELL])) + { + if(_OrderTakeProfit > (_OrderOpenPrice - TakeProfitForLock * _Point)) + { + if((MathAbs(Ask - _OrderStopLoss) > MI_MODE_STOPLEVEL * _Point) && (MathAbs(Ask - (_OrderOpenPrice - TakeProfitForLock * _Point)) > MI_MODE_STOPLEVEL * _Point)) + if(OrderModify(OrderTicket(), _OrderOpenPrice, _OrderStopLoss, _OrderOpenPrice - TakeProfitForLock * _Point, 0)) + { + _OrderTakeProfit = _OrderOpenPrice - TakeProfitForLock * _Point; + } + } + + if((StopLossForLock != 0) && (_OrderOpenPrice < MinPrices[_OP_BUY]) && + ((MinPrices[_OP_BUY] - _OrderOpenPrice) > 2.2 * StopLossForLock * _Point) && + (MathAbs(_OrderOpenPrice - CurrentPrice) < MathAbs(MinPrices[_OP_BUY] - CurrentPrice)) && + (_OrderStopLoss > (_OrderOpenPrice + StopLossForLock * _Point)) && + (Ask < (_OrderOpenPrice + StopLossForLock * _Point * 2/3))) + { + if((MathAbs(Ask - (_OrderOpenPrice + StopLossForLock * _Point)) > MI_MODE_STOPLEVEL * _Point) && (MathAbs(Ask - _OrderTakeProfit) > MI_MODE_STOPLEVEL * _Point)) + if(OrderModify(OrderTicket(), _OrderOpenPrice, _OrderOpenPrice + StopLossForLock * _Point, _OrderTakeProfit, 0)) + { + _OrderStopLoss = _OrderOpenPrice + StopLossForLock * _Point; + } + } + } + } + } + } + + + + if((UseSpeedIndicator == 1) && (miSpeed != 0)) + { + + + + if((miSpeed > 0) && (Counts[_OP_SELLLIMIT] > 0) && (MinPrices[_OP_SELLLIMIT] < (Bid + 20 * _Point))) + { + glDeleteAllDeferOrders(_OP_SELLLIMIT); + } + + if((miSpeed < 0) && (Counts[_OP_BUYLIMIT] > 0) && (MaxPrices[_OP_BUYLIMIT] > (Ask - 20 * _Point))) + { + glDeleteAllDeferOrders(_OP_BUYLIMIT); + } + } + + + + if(CountHighLowLimits > 0) + { + + + for(k = 0; k < CountHighLowLimits; k++) + { + switch(k) + { + case 0 : _iHL_LimitDistance = iHL_LimitDistance1; break; + case 1 : _iHL_LimitDistance = iHL_LimitDistance2; break; + default: continue; + } + + if((Counts[_OP_BUYSTOP] != 0) && (iHL_Low[k] > 0) && (MaxPrices[_OP_BUYSTOP] >= (iHL_Low[k] + _iHL_LimitDistance * _Point))) + { + glDeleteAllDeferOrders(_OP_BUYSTOP, "", iHL_Low[k] + _iHL_LimitDistance * _Point, 0); + } + + if((Counts[_OP_SELLSTOP] != 0) && (iHL_High[k] > 0) && (MinPrices[_OP_SELLSTOP] <= (iHL_High[k] - _iHL_LimitDistance * _Point))) + { + glDeleteAllDeferOrders(_OP_SELLSTOP, "", 0, iHL_High[k] - _iHL_LimitDistance * _Point); + } + } + } + + + + total = OrdersTotal(); + + if(TrailingStop > 0) + { + for(i = 0; i < total; i++) + { + OrderSelect(i, SELECT_BY_POS, MODE_TRADES); + + if(OrderSymbol() != Symbol()) continue; + + if(OrderType() == OP_BUY) + { + if(Bid > (OrderOpenPrice() + _Point * TrailingStop)) + { + if((OrderStopLoss() == 0) || (OrderStopLoss() < (Bid - _Point * (TrailingStop + StepTrailingStop)))) + { + OrderModify(OrderTicket(), OrderOpenPrice(), Bid - _Point * TrailingStop, OrderTakeProfit(), 0); + } + } + } + else if(OrderType() == OP_SELL) + { + if(Ask < (OrderOpenPrice() - _Point * TrailingStop)) + { + if((OrderStopLoss() == 0) || (OrderStopLoss() > (Ask + _Point * (TrailingStop + StepTrailingStop)))) + { + OrderModify(OrderTicket(), OrderOpenPrice(), Ask + _Point * TrailingStop, OrderTakeProfit(), 0); + } + } + } + } + } + + + + if(!glAnalizCurrentOrdersState()) return(0); + + + + + + + if(Risk > 0) Lots = glDoubleRound(AccountFreeMargin() / 1000.0 * Risk, StepLotSize); + else Lots = MinLotSize; + + if(Lots < MinLotSize) Lots = MinLotSize; + if(Lots > MaxLotSize) Lots = MaxLotSize; + + + + + if(AccountFreeMargin() < (1000 * Lots)) + { + if((Counts[_OP_BUY] + Counts[_OP_SELL]) == 0) + { + return(0); + } + } + + for(i = 0; i < 2; i++) + { + if(MaxOrdersCount != 0) + if((Counts[_OP_BUY] + Counts[_OP_SELL]) >= MaxOrdersCount) break; + + if(i == 0) + { + if(UseBuy == 0) continue; + + type = _OP_BUY; + typestr = "BUY"; + CurrentPrice = Ask; + } + else + { + if(UseSell == 0) continue; + + type = _OP_SELL; + typestr = "SELL"; + CurrentPrice = Bid; + } + + + + CurrentFigure = (MathFloor((CurrentPrice / _Point) / 100) * 100) * _Point; + + + + + if(OpenRealOrders == 1) + { + MayOpenRealOrder = false; + + + + if((UseFlatIndicator == 1) && iFL_IsFlat) + { + if((type == _OP_BUY) && (CurrentPrice > iFL_Low) && (CurrentPrice <= (iFL_Low + iFL_Width / 4))) + { + if((iOpen( NULL, _Period[0], 0) >= iClose( NULL, _Period[0], 1)) && + (iClose( NULL, _Period[0], 1) > iClose( NULL, _Period[0], 2)) && (iClose( NULL, _Period[0], 2) > iClose( NULL, _Period[0], 3))) + { + MayOpenRealOrder = true; + + _OrderType = OP_BUY; + _OrderOpenPrice = CurrentPrice; + _OrderTakeProfit = _OrderOpenPrice + NormalizeDouble(iFL_Width / 2, Digits); + + if(TakeProfitB > 0) + { + if(_OrderTakeProfit > (_OrderOpenPrice + TakeProfitB * _Point)) _OrderTakeProfit = _OrderOpenPrice + TakeProfitB * _Point; + } + + if(iFL_StopLoss > 0) _OrderStopLoss = _OrderOpenPrice - iFL_StopLoss * _Point; + else if(StopLossB > 0) _OrderStopLoss = _OrderOpenPrice - StopLossB * _Point; + else _OrderStopLoss = 0; + } + } + + if((type == _OP_SELL) && (CurrentPrice < iFL_High) && (CurrentPrice >= (iFL_High - iFL_Width / 4))) + { + if((iOpen( NULL, _Period[0], 0) <= iClose( NULL, _Period[0], 1)) && + (iClose( NULL, _Period[0], 1) < iClose( NULL, _Period[0], 2)) && (iClose( NULL, _Period[0], 2) < iClose( NULL, _Period[0], 3))) + { + MayOpenRealOrder = true; + + _OrderType = OP_SELL; + _OrderOpenPrice = CurrentPrice; + _OrderTakeProfit = _OrderOpenPrice - NormalizeDouble(iFL_Width / 2, Digits); + + if(TakeProfitS > 0) + { + if(_OrderTakeProfit < (_OrderOpenPrice - TakeProfitS * _Point)) _OrderTakeProfit = _OrderOpenPrice - TakeProfitS * _Point; + } + + if(iFL_StopLoss > 0) _OrderStopLoss = _OrderOpenPrice + iFL_StopLoss * _Point; + else if(StopLossS > 0) _OrderStopLoss = _OrderOpenPrice + StopLossS * _Point; + else _OrderStopLoss = 0; + } + } + + if(MayOpenRealOrder) _OrderMagicNumber = MN_Flating; + } + + + + if(!MayOpenRealOrder && (UseSpeedIndicator == 1) && (iSP_UseForOpenRealOrders == 1) && (MathAbs(miSpeed) > iSP_MinValueForOpenRealOrders)) + { + if((type == _OP_BUY) && (miSpeed > 0)) + { + MayOpenRealOrder = true; + + _OrderType = OP_BUY; + _OrderOpenPrice = CurrentPrice; + + if(iSP_UseMinTakeProfit == 1) _OrderTakeProfit = _OrderOpenPrice + MarketInfo(Symbol(), MODE_STOPLEVEL) * _Point; + else _OrderTakeProfit = _OrderOpenPrice + TakeProfitB * _Point; + + if(iSP_StopLoss > 0) _OrderStopLoss = _OrderOpenPrice - iSP_StopLoss * _Point; + else if(StopLossB > 0) _OrderStopLoss = _OrderOpenPrice - StopLossB * _Point; + else _OrderStopLoss = 0; + } + + if((type == _OP_SELL) && (miSpeed < 0)) + { + MayOpenRealOrder = true; + + _OrderType = OP_SELL; + _OrderOpenPrice = CurrentPrice; + + if(iSP_UseMinTakeProfit == 1) _OrderTakeProfit = _OrderOpenPrice - MarketInfo(Symbol(), MODE_STOPLEVEL) * _Point; + else _OrderTakeProfit = _OrderOpenPrice - TakeProfitS * _Point; + + if(iSP_StopLoss > 0) _OrderStopLoss = _OrderOpenPrice + iSP_StopLoss * _Point; + else if(StopLossS > 0) _OrderStopLoss = _OrderOpenPrice + StopLossS * _Point; + else _OrderStopLoss = 0; + } + + if(MayOpenRealOrder) _OrderMagicNumber = MN_Speed; + } + + if(MayOpenRealOrder) + { + if(!glCheckOrderBeforeAdding(_OrderOpenPrice, type, _OrderType, CurrentPrice)) MayOpenRealOrder = false; + } + + if(MayOpenRealOrder) + { + if(!glCheckDistanceFromOneWayReal(_OrderOpenPrice, type, typestr, NearestRealPrice)) MayOpenRealOrder = false; + } + + if(MayOpenRealOrder) + { + if(!glCheckHighLowLimit(_OrderOpenPrice, type, typestr)) MayOpenRealOrder = false; + } + + if(MayOpenRealOrder) + { + if(!glCheckOpenOrdersBeforeAdding(_OrderOpenPrice, _OrderType, CurrentPrice)) MayOpenRealOrder = false; + } + + + + if(MayOpenRealOrder) + { + _Volume = Lots; + + if(_OrderMagicNumber == MN_Flating) + { + if((iFL_LotSizeMultiply > 0) && (iFL_LotSizeMultiply != 1)) + { + _Volume = glDoubleRound(Lots * iFL_LotSizeMultiply, StepLotSize); + + if(_Volume > MaxLotSize) _Volume = MaxLotSize; + } + + } + + ticket = OrderSend(Symbol(), _OrderType, _Volume, _OrderOpenPrice, 0, _OrderStopLoss, _OrderTakeProfit, "greezly", _OrderMagicNumber, 0, Green); + + if(ticket > 0) + { + if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) + { + if(!glAnalizCurrentOrdersState()) return(0); + continue; + } + } + else Print("Ошибка открытия ", typestr, " ордера (Lots = ", Lots, "): ", GetLastError()); + } + } + + + + + for(j = 0; j < 2; j++) + { + _OrderMagicNumber = MN_Usual; + + if(j == 0) + { + if(type == _OP_BUY) + { + if(BuyStopLevel < 0) continue; + + _OrderType = OP_BUYSTOP; + typedefer = _OP_BUYSTOP; + typestr = "BUY STOP"; + + if(CurrentPrice < (CurrentFigure + BuyStopLevel * _Point)) + _OrderOpenPrice = CurrentFigure + BuyStopLevel * _Point; + else + _OrderOpenPrice = CurrentFigure + (100 + BuyStopLevel) * _Point; + } + else + { + if(SellStopLevel < 0) continue; + + _OrderType = OP_SELLSTOP; + typedefer = _OP_SELLSTOP; + typestr = "SELL STOP"; + + if(CurrentPrice < (CurrentFigure + SellStopLevel * _Point)) + _OrderOpenPrice = CurrentFigure - (100 - SellStopLevel) * _Point; + else + _OrderOpenPrice = CurrentFigure + SellStopLevel * _Point; + } + } + else + { + if(type == _OP_BUY) + { + if(BuyLimitLevel < 0) continue; + + _OrderType = OP_BUYLIMIT; + typedefer = _OP_BUYLIMIT; + typestr = "BUY LIMIT"; + + if(CurrentPrice < (CurrentFigure + BuyLimitLevel * _Point)) + _OrderOpenPrice = CurrentFigure - (100 - BuyLimitLevel) * _Point; + else + _OrderOpenPrice = CurrentFigure + BuyLimitLevel * _Point; + } + else + { + if(SellLimitLevel < 0) continue; + + _OrderType = OP_SELLLIMIT; + typedefer = _OP_SELLLIMIT; + typestr = "SELL LIMIT"; + + if(CurrentPrice < (CurrentFigure + SellLimitLevel * _Point)) + _OrderOpenPrice = CurrentFigure + SellLimitLevel * _Point; + else + _OrderOpenPrice = CurrentFigure + (100 + SellLimitLevel) * _Point; + } + } + + if(type == _OP_BUY) + { + _OrderTakeProfit = _OrderOpenPrice + TakeProfitB * _Point; + + if(StopLossB > 0) _OrderStopLoss = _OrderOpenPrice - StopLossB * _Point; + else _OrderStopLoss = 0; + } + else + { + _OrderTakeProfit = _OrderOpenPrice - TakeProfitS * _Point; + + if(StopLossS > 0) _OrderStopLoss = _OrderOpenPrice + StopLossS * _Point; + else _OrderStopLoss = 0; + } + + + MayOpenDeferOrder = true; + + + + if(MayOpenDeferOrder) + { + if(!glCheckOrderBeforeAdding(_OrderOpenPrice, type, _OrderType, CurrentPrice)) MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder) + { + if(MinDistanceDeferFromPrice != 0) + if(MathAbs(_OrderOpenPrice - CurrentPrice) < (MinDistanceDeferFromPrice * _Point)) MayOpenDeferOrder = false; + + if(MaxDistanceDeferFromPrice != 0) + if(MathAbs(_OrderOpenPrice - CurrentPrice) > (MaxDistanceDeferFromPrice * _Point)) MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder) + { + if((Counts[type] > 0) && (j == 1)) MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder) + { + if(Counts[typedefer] > 0) + { + if((typedefer == _OP_BUYSTOP) || (typedefer == _OP_SELLLIMIT)) NearestDeferPrice = MinPrices[typedefer]; + else NearestDeferPrice = MaxPrices[typedefer]; + + NeedDistance = MinDistanceBetweenDefer * _Point; + + if((typedefer == _OP_BUYSTOP) || (typedefer == _OP_SELLLIMIT)) + { + if(_OrderOpenPrice > NearestDeferPrice - NeedDistance) MayOpenDeferOrder = false; + } + else + { + if(_OrderOpenPrice < NearestDeferPrice + NeedDistance) MayOpenDeferOrder = false; + } + } + } + + + + if(MayOpenDeferOrder && (Counts[type] > 0)) + { + if(glCheckDistanceFromOneWayReal(_OrderOpenPrice, type, typestr, NearestRealPrice)) + { + + + if(((type == _OP_BUY) && (UseAveragingTakeProfitB == 1)) || + ((type == _OP_SELL) && (UseAveragingTakeProfitS == 1))) + { + _OrderTakeProfit = (_OrderOpenPrice + NearestRealPrice) / 2; + _OrderMagicNumber = MN_Averaging; + } + } + else MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder && (UseSpeedIndicator == 1)) + { + + + + if(j == 1) + { + if((type == _OP_BUY) && (miSpeed < 0)) + { + MayOpenDeferOrder = false; + } + + if((type == _OP_SELL) && (miSpeed > 0)) + { + MayOpenDeferOrder = false; + } + } + } + + + + if(MayOpenDeferOrder && (CountHighLowLimits > 0)) + { + if(!glCheckHighLowLimit(_OrderOpenPrice, type, typestr)) MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder) + { + if(!glCheckOpenOrdersBeforeAdding(_OrderOpenPrice, _OrderType, CurrentPrice)) MayOpenDeferOrder = false; + } + + + + if(MayOpenDeferOrder) + { + _Volume = Lots; + + ticket = OrderSend(Symbol(), _OrderType, _Volume, _OrderOpenPrice, 0, _OrderStopLoss, _OrderTakeProfit, "greezly", _OrderMagicNumber, 0, Green); + + if(ticket > 0) + { + if(OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) + { + if(!glAnalizCurrentOrdersState()) return(0); + } + } + else Print("Ошибка открытия ", typestr, " ордера (Lots = ", Lots, "): ", GetLastError()); + } + } + } + + return(0); +} + + + +bool glCheckOrderBeforeAdding(double _OrderOpenPrice, int type, int _OrderType, double CurrentPrice) +{ + + + double _SellDenyLevel; + + _SellDenyLevel = SellDenyLevel; + + if(type == _OP_BUY) + { + if(UseBuy == 0) return(false); + if((_OrderType == OP_BUY) && (OpenRealOrders == 0)) return(false); + if((BuyDenyLevel > 0) && (_OrderOpenPrice >= BuyDenyLevel)) return(false); + } + + if(type == _OP_SELL) + { + if(UseSell == 0) return(false); + if((_OrderType == OP_SELL) && (OpenRealOrders == 0)) return(false); + + if((_SellDenyLevel > 0) && (_OrderOpenPrice <= _SellDenyLevel)) return(false); + } + + return(true); +} + + + +bool glCheckOpenOrdersBeforeAdding(double _OrderOpenPrice, int _OrderType, double CurrentPrice) +{ + int i, j, k, total; + + + + + if((_OrderType == OP_BUY) || (_OrderType == OP_BUYLIMIT)) + { + if(!glDeleteAllDeferOrders(OP_BUYLIMIT)) return(false); + } + + if((_OrderType == OP_SELL) || (_OrderType == OP_SELLLIMIT)) + { + if(!glDeleteAllDeferOrders(OP_SELLLIMIT)) return(false); + } + + + + if(MaxOrdersCount != 0) + { + int CurrentOrderType, OrderTicketMaxDistance; + double CurrentDistance, MaxDistance; + + total = OrdersTotal(); + + while(total >= MaxOrdersCount) + { + MaxDistance = 0; + + for(i = 0; i < total; i++) + { + if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) + { + Print("Ошибка получения текущего ордера OrderSelect(): ", GetLastError()); + continue; + } + + CurrentOrderType = OrderType(); + + if ((CurrentOrderType == OP_BUYLIMIT) || (CurrentOrderType == OP_BUYSTOP)) CurrentDistance = MathAbs(Ask - OrderOpenPrice()); + else if((CurrentOrderType == OP_SELLLIMIT) || (CurrentOrderType == OP_SELLSTOP)) CurrentDistance = MathAbs(Bid - OrderOpenPrice()); + else continue; + + if(CurrentDistance > MaxDistance) + { + MaxDistance = CurrentDistance; + OrderTicketMaxDistance = OrderTicket(); + } + } + + if(MaxDistance > MathAbs(_OrderOpenPrice - CurrentPrice)) + { + + + if(OrderDelete(OrderTicketMaxDistance)) + { + total = OrdersTotal(); + } + else return(false); + } + else return(false); + } + } + + return(true); +} + + + +bool glCheckDistanceFromOneWayReal(double _OrderOpenPrice, int type, string typestr, double& NearestRealPrice) +{ + double NeedDistance; + + if(Counts[type] == 0) return(true); + + if((type == _OP_BUY) && (UseOneWayRealOrdersB == 0)) return(false); + if((type == _OP_SELL) && (UseOneWayRealOrdersS == 0)) return(false); + + if(type == _OP_BUY) + { + NearestRealPrice = MinPrices[type]; + NeedDistance = Counts[type] * MinDistanceRealOrdersB * _Point; + } + else + { + NearestRealPrice = MaxPrices[type]; + NeedDistance = Counts[type] * MinDistanceRealOrdersS * _Point; + } + + if(type == _OP_BUY) + { + if(_OrderOpenPrice > NearestRealPrice - NeedDistance) return(false); + } + else + { + if(_OrderOpenPrice < NearestRealPrice + NeedDistance) return(false); + } + + return(true); +} + + + +bool glCheckHighLowLimit(double _OrderOpenPrice, int type, string typestr) +{ + int i, j, k, total; + + for(k = 0; k < CountHighLowLimits; k++) + { + switch(k) + { + case 0 : _iHL_LimitDistance = iHL_LimitDistance1; break; + case 1 : _iHL_LimitDistance = iHL_LimitDistance2; break; + default: continue; + } + + if((type == _OP_BUY) && (iHL_Low[k] > 0) && (_OrderOpenPrice >= (iHL_Low[k] + _iHL_LimitDistance * _Point))) + { + return(false); + } + + if((type == _OP_SELL) && (iHL_High[k] > 0) && (_OrderOpenPrice <= (iHL_High[k] - _iHL_LimitDistance * _Point))) + { + return(false); + } + } + + return(true); +} + + + + +bool glAnalizCurrentOrdersState() +{ + int i, j, k, total; + int _OrderType, NormalOrderType; + double _OrderOpenPrice, _OrderLots; + + total = OrdersTotal(); + + for(i = 0; i < 6; i++) + { + MinPrices[i] = -1; + MaxPrices[i] = -1; + SumLots[i] = 0; + Counts[i] = 0; + } + + for(i = 0; i < total; i++) + { + if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) + { + Print("Ошибка получения текущего ордера OrderSelect(): ", GetLastError()); + return(false); + } + + + + _OrderType = OrderType(); + _OrderOpenPrice = OrderOpenPrice(); + _OrderLots = OrderLots(); + + NormalOrderType = glGetNormalOrderType(_OrderType); + if(NormalOrderType == -1) + { + Print("Ошибка определения типа текущего ордера: OrderType() = ", _OrderType); + return(false); + } + + Counts[NormalOrderType] = Counts[NormalOrderType] + 1; + + + + if((MinPrices[NormalOrderType] == -1) || (_OrderOpenPrice < MinPrices[NormalOrderType])) MinPrices[NormalOrderType] = _OrderOpenPrice; + if((MaxPrices[NormalOrderType] == -1) || (_OrderOpenPrice > MaxPrices[NormalOrderType])) MaxPrices[NormalOrderType] = _OrderOpenPrice; + + SumLots[NormalOrderType] = SumLots[NormalOrderType] + _OrderLots; + } + + return(true); +} + + + + + +bool glDeleteAllDeferOrders(int type = -1, string symbol = "", double MinPrice = 0, double MaxPrice = 0) +{ + int i, j, k, total; + int _OrderType; + double _OrderOpenPrice; + bool success = true; + + total = OrdersTotal(); + + for(i = total - 1; i >= 0; i--) + { + if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) + { + _OrderType = OrderType(); + _OrderOpenPrice = OrderOpenPrice(); + + if(((type == -1) || (_OrderType == type)) && ((symbol == "") || (OrderSymbol() == symbol))) + { + if(type == -1) + if((_OrderType == OP_BUY) || (_OrderType == OP_SELL)) continue; + + if((MinPrice != 0) && (_OrderOpenPrice < MinPrice)) continue; + if((MaxPrice != 0) && (_OrderOpenPrice > MaxPrice)) continue; + + if(!OrderDelete(OrderTicket())) success = false; + } + } + else success = false; + } + + return(success); +} + + + + +double glDoubleRound(double Val, double Eps) +{ + int CEps; + int k = 1; + double Dop, RDop; + + if(Eps == 0) return(Val); + + while((Eps * k) < 1) k = k * 10; + + CEps = Eps * k; + + Dop = MathFloor(Val * k); + + if(MathAbs(Val * k - Dop) > 0.5 ) Dop++; + + RDop = Dop / CEps; + + if(RDop != MathRound(RDop)) + { + if(MathAbs(RDop - MathFloor(RDop)) > 0.5) RDop = MathFloor(RDop) + 1; + else RDop = MathFloor(RDop); + + Dop = RDop * CEps; + } + + return(Dop / k); +} + + diff --git a/IVY_EUR_ JPY_5.1.mq4 b/IVY_EUR_ JPY_5.1.mq4 new file mode 100644 index 0000000..1ae4103 --- /dev/null +++ b/IVY_EUR_ JPY_5.1.mq4 @@ -0,0 +1,362 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, IVYBOT Company" +#property link "http://www.IVYBOT.com" + +extern double lots = 0.1; +extern double trailingStop = 0.0; +extern double takeProfit = 110.0; +extern bool risk_management = TRUE; +extern double equitypercent = 0.02; +extern double stopLoss = 0.0; +extern double slippage = 3.0; +extern double dds_delay = 64800.0; +extern bool PowerTrend = TRUE; +extern double PM_Adjust = 1.6982; +extern bool Max_Deviation = TRUE; +extern bool Ivy_Trend = TRUE; +extern bool Testmode = FALSE; +extern string ClickbankCode = "000"; +extern double Pin_under = 7.0; +extern double Long_Cut = 3.0; +extern double crmRPM = 21.0; +extern double Pound_Level = 4.0; +extern double Dscan = 30.0; +extern double Hscan = 10.0; +extern double magicn = 16384.0; +extern string nameEA = "IVYBOT_EUR_JPY"; +extern int ATRS = 2; +extern int ATR_PERIOD = 14; +double g_ima_240; +double g_ima_248; +double g_iadx_272; +double g_iadx_280; +double g_iatr_288; +double g_iadx_296; +double g_iadx_304; +double g_iadx_312; +double g_iadx_320; +double gd_328; +double gd_336; +double gd_344; +double gd_352; +double g_ima_360; +bool g_bool_368 = FALSE; +bool g_bool_372 = FALSE; +bool gi_unused_376 = FALSE; +int g_pos_380; +int g_ticket_384; +int gi_388; +int g_str_len_392; +int gi_396 = 8; +double g_iatr_400; +double gd_408; +double gd_416; +double gd_424; +double g_maxlot_432; +double g_minlot_440; +double gd_448; +double gd_456; + +int init() { + if (Digits == 3 || Digits == 5) { + trailingStop = 10.0 * trailingStop; + takeProfit = 10.0 * takeProfit; + slippage = 10.0 * slippage; + stopLoss = 10.0 * stopLoss; + Dscan = 10.0 * (Dscan * Point); + Hscan = 10.0 * (Hscan * Point); + gi_388 = 5; + gd_448 = 1000; + gd_456 = 1; + } + if (Digits != 3 && Digits != 5) { + Dscan *= Point; + Hscan *= Point; + gi_388 = 4; + gd_448 = 100; + gd_456 = 10; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + calculateIndicators(); + + /*g_str_len_392 = StringLen(ClickbankCode); + if (g_str_len_392 > gi_396 || g_str_len_392 < gi_396) { + Comment("Trade on Account: " + AccountNumber() + "NOT AUTHORIZED BY IVYBOT!"); + return (0); + } + */ + Comment(""); + if (Period() != PERIOD_H1) { + Comment("Must be 1H Chart!"); + return (0); + } + Comment(""); + Display_Info(); + if (Bars < 100) { + Print("Not enough bars to run this strategy - ", nameEA); + return (-1); + } + g_maxlot_432 = MarketInfo(Symbol(), MODE_MAXLOT); + g_minlot_440 = MarketInfo(Symbol(), MODE_MINLOT); + if (risk_management == TRUE) calculatelots(); + int l_ord_total_0 = OrdersTotal(); + int l_count_4 = 0; + double l_tickvalue_8 = MarketInfo(Symbol(), MODE_TICKVALUE); + for (g_pos_380 = 0; g_pos_380 < l_ord_total_0; g_pos_380++) { + OrderSelect(g_pos_380, SELECT_BY_POS); + if (OrderSymbol() == Symbol() && OrderType() <= OP_SELL && OrderComment() == nameEA) { + l_count_4++; + if (OrderType() == OP_BUY) { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Violet); + prtAlert("IVYBOT_EUR_JPY: Closing BUY order"); + } + if (trailingStop > 0.0) { + if (Bid - OrderOpenPrice() > trailingStop * Point) + if (OrderStopLoss() < Bid - trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - trailingStop * Point, OrderTakeProfit(), 0, Blue); + } + } else { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Violet); + prtAlert("IVYBOT_EUR_JPY: Closing SELL order"); + } + if (trailingStop > 0.0) { + if (OrderOpenPrice() - Ask > trailingStop * Point) + if (OrderStopLoss() == 0.0 || OrderStopLoss() > Ask + trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + trailingStop * Point, OrderTakeProfit(), 0, Red); + } + } + } + } + if (l_count_4 < 1) { + if (AccountFreeMargin() < 1000.0 * lots) { + Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA); + return (0); + } + if (g_bool_368 && !g_bool_372) { + if (risk_management == TRUE) gd_336 = Ask - gd_408 * Point; + else + if (stopLoss > 0.0) gd_336 = Ask - stopLoss * Point; + if (takeProfit > 0.0) gd_328 = Ask + takeProfit * Point; + g_ticket_384 = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("Lots (", lots, ")"); + Print("ATR_PLUG (", gd_408, ")"); + Print("riskperpip (", gd_424, ")"); + Print("dollarrisk (", gd_416, ")"); + Print("equitypercent (", equitypercent, ")"); + Print("Acount Equity (", AccountEquity(), ")"); + Print("maxlots (", g_maxlot_432, ")"); + Print("minlots (", g_minlot_440, ")"); + Print("tickvalue (", l_tickvalue_8, ")"); + if (g_ticket_384 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_EUR_JPY: Buying"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_388) != NormalizeDouble(Ask + takeProfit * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), 0, Ask + takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_388) != NormalizeDouble(Ask - gd_408 * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), Ask - gd_408 * Point, Ask + takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_388) != NormalizeDouble(Ask - stopLoss * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), Ask - stopLoss * Point, Ask + takeProfit * Point, 0, Blue); + } + } + } + if (g_bool_372 && !g_bool_368) { + if (risk_management == TRUE) gd_336 = Bid + gd_408 * Point; + else + if (stopLoss > 0.0) gd_336 = Bid + stopLoss * Point; + if (takeProfit > 0.0) gd_328 = Bid - takeProfit * Point; + g_ticket_384 = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("Lots (", lots, ")"); + Print("ATR_PLUG (", gd_408, ")"); + Print("riskperpip (", gd_424, ")"); + Print("dollarrisk (", gd_416, ")"); + Print("equitypercent (", equitypercent, ")"); + Print("Acount Equity (", AccountEquity(), ")"); + Print("maxlots (", g_maxlot_432, ")"); + Print("minlots (", g_minlot_440, ")"); + Print("tickvalue (", l_tickvalue_8, ")"); + if (g_ticket_384 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_EUR_JPY: Selling"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_388) != NormalizeDouble(Bid - takeProfit * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), 0, Bid - takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_388) != NormalizeDouble(Bid + gd_408 * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), Bid + gd_408 * Point, Bid - takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_388) != NormalizeDouble(Bid + stopLoss * Point, gi_388)) OrderModify(g_ticket_384, OrderOpenPrice(), Bid + stopLoss * Point, Bid - takeProfit * Point, 0, Blue); + } + } + } + } + return (0); +} + +void calculateIndicators() { + g_iatr_400 = iATR(NULL, 0, ATR_PERIOD, 1); + gd_408 = NormalizeDouble(g_iatr_400 * ATRS, gi_388); + g_ima_240 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 8); + g_ima_248 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 0); + g_iadx_272 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_MAIN, 1); + g_iadx_280 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_MAIN, 2); + g_iadx_296 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 1); + g_iadx_304 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 2); + g_iadx_320 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 1); + g_iadx_312 = iADX(NULL, PERIOD_D1, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 2); + g_iatr_288 = iATR(NULL, 0, 50, 0); + gd_344 = iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_Cut); + gd_352 = iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_Cut); + g_ima_360 = iMA(NULL, PERIOD_H1, Pound_Level, 0, MODE_EMA, PRICE_MEDIAN, 0); + g_bool_368 = gd_344 > Dscan && gd_352 > Hscan && g_ima_360 > Ask && g_iatr_288 < 0.9 && g_iadx_272 > 40.0 && g_iadx_272 < 55.0 && g_iadx_280 < 55.0 && DayOfWeek() < 5; + g_bool_372 = gd_344 < (-1.0 * Dscan) && gd_352 < (-1.0 * Hscan) && g_ima_360 < Bid && g_iatr_288 < 0.9 && g_iadx_272 > 40.0 && g_iadx_272 < 55.0 && g_iadx_280 < 55.0 && DayOfWeek() < 5; + gi_unused_376 = FALSE; +} + +void prtAlert(string as_0 = "") { + Print(as_0); + Alert(as_0); +} + +double calculatelots() { + gd_408 *= gd_448; + gd_416 = equitypercent * AccountEquity(); + gd_424 = gd_416 / gd_408; + lots = gd_424 / gd_456; + if (lots < 10.0) { + if (lots > 0.01 && lots < 0.02) lots = 0.01; + if (lots > 0.02 && lots < 0.03) lots = 0.02; + if (lots > 0.03 && lots < 0.04) lots = 0.03; + if (lots > 0.04 && lots < 0.05) lots = 0.04; + if (lots > 0.05 && lots < 0.06) lots = 0.05; + if (lots > 0.06 && lots < 0.07) lots = 0.06; + if (lots > 0.07 && lots < 0.08) lots = 0.07; + if (lots > 0.08 && lots < 0.09) lots = 0.08; + if (lots > 0.09 && lots < 0.1) lots = 0.09; + if (lots > 0.1 && lots < 0.2) lots = 0.1; + if (lots > 0.2 && lots < 0.3) lots = 0.2; + if (lots > 0.3 && lots < 0.4) lots = 0.3; + if (lots > 0.4 && lots < 0.5) lots = 0.4; + if (lots > 0.5 && lots < 0.6) lots = 0.5; + if (lots > 0.6 && lots < 0.7) lots = 0.6; + if (lots > 0.7 && lots < 0.8) lots = 0.7; + if (lots > 0.8 && lots < 0.9) lots = 0.8; + if (lots > 0.9 && lots < 1.0) lots = 0.9; + if (lots > 1.0 && lots < 1.1) lots = 1.0; + if (lots > 1.1 && lots < 1.2) lots = 1.1; + if (lots > 1.2 && lots < 1.3) lots = 1.2; + if (lots > 1.3 && lots < 1.4) lots = 1.3; + if (lots > 1.4 && lots < 1.5) lots = 1.4; + if (lots > 1.5 && lots < 1.6) lots = 1.5; + if (lots > 1.6 && lots < 1.7) lots = 1.6; + if (lots > 1.7 && lots < 1.8) lots = 1.7; + if (lots > 1.8 && lots < 1.9) lots = 1.8; + if (lots > 1.9 && lots < 2.0) lots = 1.9; + if (lots > 2.0 && lots < 2.1) lots = 2.0; + if (lots > 2.1 && lots < 2.2) lots = 2.1; + if (lots > 2.2 && lots < 2.3) lots = 2.2; + if (lots > 2.3 && lots < 2.4) lots = 2.3; + if (lots > 2.4 && lots < 2.5) lots = 2.4; + if (lots > 2.5 && lots < 2.6) lots = 2.5; + if (lots > 2.6 && lots < 2.7) lots = 2.6; + if (lots > 2.7 && lots < 2.8) lots = 2.7; + if (lots > 2.8 && lots < 2.9) lots = 2.8; + if (lots > 2.9 && lots < 3.0) lots = 2.9; + if (lots > 3.0 && lots < 3.1) lots = 3.0; + if (lots > 3.1 && lots < 3.2) lots = 3.1; + if (lots > 3.2 && lots < 3.3) lots = 3.2; + if (lots > 3.3 && lots < 3.4) lots = 3.3; + if (lots > 3.4 && lots < 3.5) lots = 3.4; + if (lots > 3.5 && lots < 3.6) lots = 3.5; + if (lots > 3.6 && lots < 3.7) lots = 3.6; + if (lots > 3.7 && lots < 3.8) lots = 3.7; + if (lots > 3.8 && lots < 3.9) lots = 3.8; + if (lots > 3.9 && lots < 4.0) lots = 3.9; + if (lots > 4.0 && lots < 4.1) lots = 4.0; + if (lots > 4.1 && lots < 4.2) lots = 4.1; + if (lots > 4.2 && lots < 4.3) lots = 4.2; + if (lots > 4.3 && lots < 4.4) lots = 4.3; + if (lots > 4.4 && lots < 4.5) lots = 4.4; + if (lots > 4.5 && lots < 4.6) lots = 4.5; + if (lots > 4.6 && lots < 4.7) lots = 4.6; + if (lots > 4.7 && lots < 4.8) lots = 4.7; + if (lots > 4.8 && lots < 4.9) lots = 4.8; + if (lots > 4.9 && lots < 5.0) lots = 4.9; + if (lots > 5.0 && lots < 5.1) lots = 5.0; + if (lots > 5.1 && lots < 5.2) lots = 5.1; + if (lots > 5.2 && lots < 5.3) lots = 5.2; + if (lots > 5.3 && lots < 5.4) lots = 5.3; + if (lots > 5.4 && lots < 5.5) lots = 5.4; + if (lots > 5.5 && lots < 5.6) lots = 5.5; + if (lots > 5.6 && lots < 5.7) lots = 5.6; + if (lots > 5.7 && lots < 5.8) lots = 5.7; + if (lots > 5.8 && lots < 5.9) lots = 5.8; + if (lots > 5.9 && lots < 6.0) lots = 5.9; + if (lots > 6.0 && lots < 6.1) lots = 6.0; + if (lots > 6.1 && lots < 6.2) lots = 6.1; + if (lots > 6.2 && lots < 6.3) lots = 6.2; + if (lots > 6.3 && lots < 6.4) lots = 6.3; + if (lots > 6.4 && lots < 6.5) lots = 6.4; + if (lots > 6.5 && lots < 6.6) lots = 6.5; + if (lots > 6.6 && lots < 6.7) lots = 6.6; + if (lots > 6.7 && lots < 6.8) lots = 6.7; + if (lots > 6.8 && lots < 6.9) lots = 6.8; + if (lots > 6.9 && lots < 7.0) lots = 6.9; + if (lots > 7.0 && lots < 7.1) lots = 7.0; + if (lots > 7.1 && lots < 7.2) lots = 7.1; + if (lots > 7.2 && lots < 7.3) lots = 7.2; + if (lots > 7.3 && lots < 7.4) lots = 7.3; + if (lots > 7.4 && lots < 7.5) lots = 7.4; + if (lots > 7.5 && lots < 7.6) lots = 7.5; + if (lots > 7.6 && lots < 7.7) lots = 7.6; + if (lots > 7.7 && lots < 7.8) lots = 7.7; + if (lots > 7.8 && lots < 7.9) lots = 7.8; + if (lots > 7.9 && lots < 8.0) lots = 7.9; + if (lots > 8.0 && lots < 8.1) lots = 8.0; + if (lots > 8.1 && lots < 8.2) lots = 8.1; + if (lots > 8.2 && lots < 8.3) lots = 8.2; + if (lots > 8.3 && lots < 8.4) lots = 8.3; + if (lots > 8.4 && lots < 8.5) lots = 8.4; + if (lots > 8.5 && lots < 8.6) lots = 8.5; + if (lots > 8.6 && lots < 8.7) lots = 8.6; + if (lots > 8.7 && lots < 8.8) lots = 8.7; + if (lots > 8.8 && lots < 8.9) lots = 8.8; + if (lots > 8.9 && lots < 9.0) lots = 8.9; + if (lots > 9.0 && lots < 9.1) lots = 9.0; + if (lots > 9.1 && lots < 9.2) lots = 9.1; + if (lots > 9.2 && lots < 9.3) lots = 9.2; + if (lots > 9.3 && lots < 9.4) lots = 9.3; + if (lots > 9.4 && lots < 9.5) lots = 9.4; + if (lots > 9.5 && lots < 9.6) lots = 9.5; + if (lots > 9.6 && lots < 9.7) lots = 9.6; + if (lots > 9.7 && lots < 9.8) lots = 9.7; + if (lots > 9.8 && lots < 9.9) lots = 9.8; + if (lots > 9.9 && lots < 10.0) lots = 9.9; + if (lots > 10.0 && lots < 10.1) lots = 10.0; + if (lots > 10.0) lots = MathRound(lots); + if (lots > g_maxlot_432) lots = g_maxlot_432; + if (lots < g_minlot_440) lots = g_minlot_440; + } + return (lots); +} + +void Display_Info() { + Comment("IVYBOT EXPERT ADVISOR\n", "Desc: Currently Scanning All Trends,\n", "Forex Account Server:", AccountServer(), + "\n", "Free Margin: $", AccountFreeMargin(), + "\n", "Lots: ", lots, + "\n", "Symbol: ", Symbol(), + "\n", "Price: ", NormalizeDouble(Bid, 4), + "\n", "Optimal Spread: ", MarketInfo("EURJPY", MODE_SPREAD), + "\n", "Date: ", Month(), "-", Day(), "-", Year(), " Server Time: ", Hour(), ":", Minute(), ":", Seconds(), + "\n"); +} \ No newline at end of file diff --git a/IVY_EUR_USD_5.1.mq4 b/IVY_EUR_USD_5.1.mq4 new file mode 100644 index 0000000..85e672b --- /dev/null +++ b/IVY_EUR_USD_5.1.mq4 @@ -0,0 +1,346 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright " Copyright © 2009, IVYBOT Company" +#property link " http://www.IVYBOT.com" + +extern double lots = 0.1; +extern double trailingStop = 0.0; +extern double takeProfit = 80.0; +extern bool risk_management = TRUE; +extern double equitypercent = 0.02; +extern double stopLoss = 0.0; +extern double slippage = 3.0; +extern double dds_delay = 62000.0; +extern bool PowerTrend = TRUE; +extern double PM_Adjust = 1.6982; +extern bool Max_Deviation = TRUE; +extern bool Ivy_Trend = TRUE; +extern string ClickbankCode = "000"; +extern double Pin_under = 28.0; +extern double Long_cut = 6.0; +extern double crmRPM = 14.0; +extern double Pound_level = 20.0; +extern double Dscan = 20.0; +extern double Hscan = 5.0; +extern double magicn = 16384.0; +extern int ATRS = 1; +extern double ATR_PERIOD = 14.0; +extern string nameEA = "IVYBOT_EUR_USD"; +double g_ima_336; +double g_ima_344; +double g_iadx_480; +double g_iadx_488; +double g_iatr_496; +double g_iadx_504; +double g_iadx_512; +double g_iadx_520; +double g_iadx_528; +double gd_536; +double gd_544; +double gd_552; +double gd_560; +double g_ima_568; +bool g_bool_576 = FALSE; +bool g_bool_580 = FALSE; +bool gi_unused_584 = FALSE; +int g_pos_588; +int g_ticket_592; +int gi_596; +int g_str_len_600; +int gi_604 = 8; +double g_iatr_608; +double gd_616; +double gd_624; +double gd_632; +double g_maxlot_640; +double g_minlot_648; +double gd_656; +double gd_664; + +int init() { + if (Digits == 3 || Digits == 5) { + trailingStop = 10.0 * trailingStop; + takeProfit = 10.0 * takeProfit; + slippage = 10.0 * slippage; + stopLoss = 10.0 * stopLoss; + Dscan = 10.0 * (Dscan * Point); + Hscan = 10.0 * (Hscan * Point); + gi_596 = 5; + gd_656 = 100000; + gd_664 = 1; + } + if (Digits != 3 && Digits != 5) { + Dscan *= Point; + Hscan *= Point; + gi_596 = 4; + gd_656 = 10000; + gd_664 = 10; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + calculateIndicators(); + + /*g_str_len_600 = StringLen(ClickbankCode); + if (g_str_len_600 > gi_604 || g_str_len_600 < gi_604) { + Comment("Trade on Account: " + AccountNumber() + "NOT AUTHORIZED BY IVYBOT!"); + return (0); + }*/ + + Comment(""); + if (Period() != PERIOD_H1) { + Comment("Must be 1H Chart!"); + return (0); + } + Comment(""); + Display_Info(); + if (Bars < 100) { + Print("Not enough bars for this strategy - ", nameEA); + return (-1); + } + g_maxlot_640 = MarketInfo("EURUSD", MODE_MAXLOT); + g_minlot_648 = MarketInfo("EURUSD", MODE_MINLOT); + if (risk_management == TRUE) calculatelots(); + int l_ord_total_0 = OrdersTotal(); + int l_count_4 = 0; + for (g_pos_588 = 0; g_pos_588 < l_ord_total_0; g_pos_588++) { + OrderSelect(g_pos_588, SELECT_BY_POS); + if (OrderSymbol() == Symbol() && OrderType() <= OP_SELL && OrderComment() == nameEA) { + l_count_4++; + if (OrderType() == OP_BUY) { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Violet); + prtAlert("IVYBOT_EUR_USD: Closing BUY order"); + } + if (trailingStop > 0.0) { + if (Bid - OrderOpenPrice() > trailingStop * Point) + if (OrderStopLoss() < Bid - trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - trailingStop * Point, OrderTakeProfit(), 0, Blue); + } + } else { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Violet); + prtAlert("IVYBOT_EUR_USD: Closing SELL order"); + } + if (trailingStop > 0.0) { + if (OrderOpenPrice() - Ask > trailingStop * Point) + if (OrderStopLoss() == 0.0 || OrderStopLoss() > Ask + trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + trailingStop * Point, OrderTakeProfit(), 0, Red); + } + } + } + } + if (l_count_4 < 1) { + if (AccountFreeMargin() < 1000.0 * lots) { + Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA); + return (0); + } + if (g_bool_576 && !g_bool_580) { + if (risk_management == TRUE) gd_544 = Ask - gd_616 * Point; + else + if (stopLoss > 0.0) gd_544 = Ask - stopLoss * Point; + if (takeProfit > 0.0) gd_536 = Ask + takeProfit * Point; + g_ticket_592 = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("ATR_PLUG ", gd_616); + Print("OrderStopLoss", OrderStopLoss()); + if (g_ticket_592 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_EUR_USD: Buying"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_596) != NormalizeDouble(Ask + takeProfit * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), 0, Ask + takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Ask - gd_616 * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Ask - gd_616 * Point, Ask + takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Ask - stopLoss * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Ask - stopLoss * Point, Ask + takeProfit * Point, 0, Blue); + } + } + } + if (g_bool_580 && !g_bool_576) { + if (risk_management == TRUE) gd_544 = Bid + gd_616 * Point; + else + if (stopLoss > 0.0) gd_544 = Bid + stopLoss * Point; + if (takeProfit > 0.0) gd_536 = Bid - takeProfit * Point; + g_ticket_592 = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("ATR_PLUG ", gd_616); + Print("OrderStopLoss", OrderStopLoss()); + if (g_ticket_592 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_EUR_USD: Selling"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_596) != NormalizeDouble(Bid - takeProfit * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), 0, Bid - takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Bid + gd_616 * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Bid + gd_616 * Point, Bid - takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Bid + stopLoss * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Bid + stopLoss * Point, Bid - takeProfit * Point, 0, Blue); + } + } + } + } + return (0); +} + +void calculateIndicators() { + g_iatr_608 = iATR(NULL, 0, ATR_PERIOD, 1); + gd_616 = NormalizeDouble(g_iatr_608 * ATRS, gi_596); + g_ima_336 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 8); + g_ima_344 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 0); + g_iadx_480 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MAIN, 1); + g_iadx_488 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MAIN, 2); + g_iadx_504 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 1); + g_iadx_512 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 2); + g_iadx_528 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 1); + g_iadx_520 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 2); + g_iatr_496 = iATR(NULL, 0, 50, 0); + gd_552 = iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_cut); + gd_560 = iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_cut); + g_ima_568 = iMA(NULL, PERIOD_H1, Pound_level, 0, MODE_EMA, PRICE_MEDIAN, 0); + g_bool_576 = gd_552 > Dscan && gd_560 > Hscan && g_ima_568 > Ask && DayOfWeek() < 5; + g_bool_580 = gd_552 < (-1.0 * Dscan) && gd_560 < (-1.0 * Hscan) && g_ima_568 < Bid && DayOfWeek() < 5; + gi_unused_584 = FALSE; +} + +void prtAlert(string as_0 = "") { + Print(as_0); + Alert(as_0); +} + +double calculatelots() { + gd_616 *= gd_656; + gd_624 = equitypercent * AccountEquity(); + gd_632 = gd_624 / gd_616; + lots = gd_632 / gd_664; + if (lots < 10.0) { + if (lots > 0.01 && lots < 0.02) lots = 0.01; + if (lots > 0.02 && lots < 0.03) lots = 0.02; + if (lots > 0.03 && lots < 0.04) lots = 0.03; + if (lots > 0.04 && lots < 0.05) lots = 0.04; + if (lots > 0.05 && lots < 0.06) lots = 0.05; + if (lots > 0.06 && lots < 0.07) lots = 0.06; + if (lots > 0.07 && lots < 0.08) lots = 0.07; + if (lots > 0.08 && lots < 0.09) lots = 0.08; + if (lots > 0.09 && lots < 0.1) lots = 0.09; + if (lots > 0.1 && lots < 0.2) lots = 0.1; + if (lots > 0.2 && lots < 0.3) lots = 0.2; + if (lots > 0.3 && lots < 0.4) lots = 0.3; + if (lots > 0.4 && lots < 0.5) lots = 0.4; + if (lots > 0.5 && lots < 0.6) lots = 0.5; + if (lots > 0.6 && lots < 0.7) lots = 0.6; + if (lots > 0.7 && lots < 0.8) lots = 0.7; + if (lots > 0.8 && lots < 0.9) lots = 0.8; + if (lots > 0.9 && lots < 1.0) lots = 0.9; + if (lots > 1.0 && lots < 1.1) lots = 1.0; + if (lots > 1.1 && lots < 1.2) lots = 1.1; + if (lots > 1.2 && lots < 1.3) lots = 1.2; + if (lots > 1.3 && lots < 1.4) lots = 1.3; + if (lots > 1.4 && lots < 1.5) lots = 1.4; + if (lots > 1.5 && lots < 1.6) lots = 1.5; + if (lots > 1.6 && lots < 1.7) lots = 1.6; + if (lots > 1.7 && lots < 1.8) lots = 1.7; + if (lots > 1.8 && lots < 1.9) lots = 1.8; + if (lots > 1.9 && lots < 2.0) lots = 1.9; + if (lots > 2.0 && lots < 2.1) lots = 2.0; + if (lots > 2.1 && lots < 2.2) lots = 2.1; + if (lots > 2.2 && lots < 2.3) lots = 2.2; + if (lots > 2.3 && lots < 2.4) lots = 2.3; + if (lots > 2.4 && lots < 2.5) lots = 2.4; + if (lots > 2.5 && lots < 2.6) lots = 2.5; + if (lots > 2.6 && lots < 2.7) lots = 2.6; + if (lots > 2.7 && lots < 2.8) lots = 2.7; + if (lots > 2.8 && lots < 2.9) lots = 2.8; + if (lots > 2.9 && lots < 3.0) lots = 2.9; + if (lots > 3.0 && lots < 3.1) lots = 3.0; + if (lots > 3.1 && lots < 3.2) lots = 3.1; + if (lots > 3.2 && lots < 3.3) lots = 3.2; + if (lots > 3.3 && lots < 3.4) lots = 3.3; + if (lots > 3.4 && lots < 3.5) lots = 3.4; + if (lots > 3.5 && lots < 3.6) lots = 3.5; + if (lots > 3.6 && lots < 3.7) lots = 3.6; + if (lots > 3.7 && lots < 3.8) lots = 3.7; + if (lots > 3.8 && lots < 3.9) lots = 3.8; + if (lots > 3.9 && lots < 4.0) lots = 3.9; + if (lots > 4.0 && lots < 4.1) lots = 4.0; + if (lots > 4.1 && lots < 4.2) lots = 4.1; + if (lots > 4.2 && lots < 4.3) lots = 4.2; + if (lots > 4.3 && lots < 4.4) lots = 4.3; + if (lots > 4.4 && lots < 4.5) lots = 4.4; + if (lots > 4.5 && lots < 4.6) lots = 4.5; + if (lots > 4.6 && lots < 4.7) lots = 4.6; + if (lots > 4.7 && lots < 4.8) lots = 4.7; + if (lots > 4.8 && lots < 4.9) lots = 4.8; + if (lots > 4.9 && lots < 5.0) lots = 4.9; + if (lots > 5.0 && lots < 5.1) lots = 5.0; + if (lots > 5.1 && lots < 5.2) lots = 5.1; + if (lots > 5.2 && lots < 5.3) lots = 5.2; + if (lots > 5.3 && lots < 5.4) lots = 5.3; + if (lots > 5.4 && lots < 5.5) lots = 5.4; + if (lots > 5.5 && lots < 5.6) lots = 5.5; + if (lots > 5.6 && lots < 5.7) lots = 5.6; + if (lots > 5.7 && lots < 5.8) lots = 5.7; + if (lots > 5.8 && lots < 5.9) lots = 5.8; + if (lots > 5.9 && lots < 6.0) lots = 5.9; + if (lots > 6.0 && lots < 6.1) lots = 6.0; + if (lots > 6.1 && lots < 6.2) lots = 6.1; + if (lots > 6.2 && lots < 6.3) lots = 6.2; + if (lots > 6.3 && lots < 6.4) lots = 6.3; + if (lots > 6.4 && lots < 6.5) lots = 6.4; + if (lots > 6.5 && lots < 6.6) lots = 6.5; + if (lots > 6.6 && lots < 6.7) lots = 6.6; + if (lots > 6.7 && lots < 6.8) lots = 6.7; + if (lots > 6.8 && lots < 6.9) lots = 6.8; + if (lots > 6.9 && lots < 7.0) lots = 6.9; + if (lots > 7.0 && lots < 7.1) lots = 7.0; + if (lots > 7.1 && lots < 7.2) lots = 7.1; + if (lots > 7.2 && lots < 7.3) lots = 7.2; + if (lots > 7.3 && lots < 7.4) lots = 7.3; + if (lots > 7.4 && lots < 7.5) lots = 7.4; + if (lots > 7.5 && lots < 7.6) lots = 7.5; + if (lots > 7.6 && lots < 7.7) lots = 7.6; + if (lots > 7.7 && lots < 7.8) lots = 7.7; + if (lots > 7.8 && lots < 7.9) lots = 7.8; + if (lots > 7.9 && lots < 8.0) lots = 7.9; + if (lots > 8.0 && lots < 8.1) lots = 8.0; + if (lots > 8.1 && lots < 8.2) lots = 8.1; + if (lots > 8.2 && lots < 8.3) lots = 8.2; + if (lots > 8.3 && lots < 8.4) lots = 8.3; + if (lots > 8.4 && lots < 8.5) lots = 8.4; + if (lots > 8.5 && lots < 8.6) lots = 8.5; + if (lots > 8.6 && lots < 8.7) lots = 8.6; + if (lots > 8.7 && lots < 8.8) lots = 8.7; + if (lots > 8.8 && lots < 8.9) lots = 8.8; + if (lots > 8.9 && lots < 9.0) lots = 8.9; + if (lots > 9.0 && lots < 9.1) lots = 9.0; + if (lots > 9.1 && lots < 9.2) lots = 9.1; + if (lots > 9.2 && lots < 9.3) lots = 9.2; + if (lots > 9.3 && lots < 9.4) lots = 9.3; + if (lots > 9.4 && lots < 9.5) lots = 9.4; + if (lots > 9.5 && lots < 9.6) lots = 9.5; + if (lots > 9.6 && lots < 9.7) lots = 9.6; + if (lots > 9.7 && lots < 9.8) lots = 9.7; + if (lots > 9.8 && lots < 9.9) lots = 9.8; + if (lots > 9.9 && lots < 10.0) lots = 9.9; + if (lots > 10.0 && lots < 10.1) lots = 10.0; + if (lots > 10.0) lots = MathRound(lots); + if (lots > g_maxlot_640) lots = g_maxlot_640; + if (lots < g_minlot_648) lots = g_minlot_648; + } + return (lots); +} + +void Display_Info() { + Comment("IVYBOT EXPERT ADVISOR\n", "Desc: Currently Scanning All Trends,\n", "Forex Account Server:", AccountServer(), + "\n", "Free Margin: $", AccountFreeMargin(), + "\n", "Lots: ", lots, + "\n", "Symbol: ", Symbol(), + "\n", "Price: ", NormalizeDouble(Bid, 4), + "\n", "Optimal Spread: ", MarketInfo("EURUSD", MODE_SPREAD), + "\n", "Date: ", Month(), "-", Day(), "-", Year(), " Server Time: ", Hour(), ":", Minute(), ":", Seconds(), + "\n"); +} \ No newline at end of file diff --git a/IVY_USD_CHF_5.1.mq4 b/IVY_USD_CHF_5.1.mq4 new file mode 100644 index 0000000..7f57a82 --- /dev/null +++ b/IVY_USD_CHF_5.1.mq4 @@ -0,0 +1,361 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, IVYBOT Company" +#property link "http://www.IVYBOT.com" + +extern double lots = 0.1; +extern double trailingStop = 0.0; +extern double takeProfit = 70.0; +extern bool risk_management = TRUE; +extern double equitypercent = 0.02; +extern double stopLoss = 0.0; +extern double slippage = 3.0; +extern double dds_delay = 62000.0; +extern bool PowerTrend = TRUE; +extern double PM_Adjust = 1.6982; +extern bool Max_Deviation = TRUE; +extern bool Ivy_Trend = TRUE; +extern bool Testmode = FALSE; +extern string ClickbankCode = "000"; +extern double Pin_under = 8.0; +extern double Long_cut = 8.0; +extern double crmRPM = 14.0; +extern double Pound_level = 60.0; +extern double Dscan = 30.0; +extern double Hscan = 15.0; +extern double magicn = 16384.0; +extern int ATRS = 1; +extern int ATR_PERIOD = 8; +extern string nameEA = "IVYBOT_USD_CHF"; +double g_ima_336; +double g_ima_344; +double g_iadx_480; +double g_iadx_488; +double g_iatr_496; +double g_iadx_504; +double g_iadx_512; +double g_iadx_520; +double g_iadx_528; +double gd_536; +double gd_544; +double gd_552; +double gd_560; +double g_ima_568; +bool g_bool_576 = FALSE; +bool g_bool_580 = FALSE; +bool gi_unused_584 = FALSE; +int g_pos_588; +int g_ticket_592; +int gi_596; +int g_str_len_600; +double gd_604 = 8.0; +double g_iatr_612; +double gd_620; +double gd_628; +double gd_636; +double g_maxlot_644; +double g_minlot_652; +double gd_660; +double gd_668; +double gd_676; +double gd_684; + +int init() { + if (Digits == 3 || Digits == 5) { + trailingStop = 10.0 * trailingStop; + takeProfit = 10.0 * takeProfit; + slippage = 10.0 * slippage; + stopLoss = 10.0 * stopLoss; + Dscan = 10.0 * (Dscan * Point); + Hscan = 10.0 * (Hscan * Point); + gi_596 = 5; + gd_660 = 100000; + gd_668 = 1; + } + if (Digits != 3 && Digits != 5) { + Dscan *= Point; + Hscan *= Point; + gi_596 = 4; + gd_660 = 10000; + gd_668 = 10; + } + return (0); +} + +int deinit() { + return (0); +} + +int start() { + calculateIndicators(); + + /*g_str_len_600 = StringLen(ClickbankCode); + if (g_str_len_600 > gd_604 || g_str_len_600 < gd_604) { + Comment("Trade on Account: " + AccountNumber() + "NOT AUTHORIZED BY IVYBOT!"); + return (0); + }*/ + Comment(""); + if (Period() != PERIOD_H1) { + Comment("Must be 1H Chart!"); + return (0); + } + Comment(""); + Display_Info(); + if (Bars < 100) { + Print("Not enough bars for this strategy - ", nameEA); + return (-1); + } + g_maxlot_644 = MarketInfo("USDCHF", MODE_MAXLOT); + g_minlot_652 = MarketInfo("USDCHF", MODE_MINLOT); + if (risk_management == TRUE) calculatelots(); + int l_ord_total_0 = OrdersTotal(); + int l_count_4 = 0; + for (g_pos_588 = 0; g_pos_588 < l_ord_total_0; g_pos_588++) { + OrderSelect(g_pos_588, SELECT_BY_POS); + if (OrderSymbol() == Symbol() && OrderType() <= OP_SELL && OrderComment() == nameEA) { + l_count_4++; + if (OrderType() == OP_BUY) { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Violet); + prtAlert("IVYBOT_USD_CHF: Closing BUY order"); + } + if (trailingStop > 0.0) { + if (Bid - OrderOpenPrice() > trailingStop * Point) + if (OrderStopLoss() < Bid - trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - trailingStop * Point, OrderTakeProfit(), 0, Blue); + } + } else { + if (TimeCurrent() - OrderOpenTime() > dds_delay) { + OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Violet); + prtAlert("IVYBOT_USD_CHF: Closing SELL order"); + } + if (trailingStop > 0.0) { + if (OrderOpenPrice() - Ask > trailingStop * Point) + if (OrderStopLoss() == 0.0 || OrderStopLoss() > Ask + trailingStop * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + trailingStop * Point, OrderTakeProfit(), 0, Red); + } + } + } + } + if (l_count_4 < 1) { + if (AccountFreeMargin() < 1000.0 * lots) { + Print("Not enough money to trade ", lots, " lots. Strategy:", nameEA); + return (0); + } + if (g_bool_576 && !g_bool_580) { + if (risk_management == TRUE) gd_544 = Ask - gd_620 * Point; + else + if (stopLoss > 0.0) gd_544 = Ask - stopLoss * Point; + if (takeProfit > 0.0) gd_536 = Ask + takeProfit * Point; + g_ticket_592 = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("Lots (", lots, ")"); + Print("ATR_PLUG (", gd_620, ")"); + Print("riskperpip (", gd_636, ")"); + Print("dollarrisk (", gd_628, ")"); + Print("equitypercent (", equitypercent, ")"); + Print("Acount Equity (", AccountEquity(), ")"); + Print("test (", gd_676, ")"); + Print("test1 (", gd_684, ")"); + if (g_ticket_592 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_USD_CHF: Buying"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_596) != NormalizeDouble(Ask + takeProfit * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), 0, Ask + takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Ask - gd_620 * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Ask - gd_620 * Point, Ask + takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Ask - stopLoss * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Ask - stopLoss * Point, Ask + takeProfit * Point, 0, Blue); + } + } + } + if (g_bool_580 && !g_bool_576) { + if (risk_management == TRUE) gd_544 = Bid + gd_620 * Point; + else + if (stopLoss > 0.0) gd_544 = Bid + stopLoss * Point; + if (takeProfit > 0.0) gd_536 = Bid - takeProfit * Point; + g_ticket_592 = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, 0, 0, nameEA, magicn, 0, Red); + Print("Lots (", lots, ")"); + Print("ATR_PLUG (", gd_620, ")"); + Print("riskperpip (", gd_636, ")"); + Print("dollarrisk (", gd_628, ")"); + Print("equitypercent (", equitypercent, ")"); + Print("Acount Equity (", AccountEquity(), ")"); + Print("test (", gd_676, ")"); + Print("test1 (", gd_684, ")"); + if (g_ticket_592 < 0) { + Print("OrderSend (", nameEA, ") failed with error #", GetLastError()); + prtAlert("IVYBOT_USD_CHF: Selling"); + } else { + if (NormalizeDouble(OrderTakeProfit(), gi_596) != NormalizeDouble(Bid - takeProfit * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), 0, Bid - takeProfit * Point, 0, Blue); + if (risk_management == TRUE) { + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Bid + gd_620 * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Bid + gd_620 * Point, Bid - takeProfit * Point, 0, Blue); + } else { + if (stopLoss > 0.0) + if (NormalizeDouble(OrderStopLoss(), gi_596) != NormalizeDouble(Bid + stopLoss * Point, gi_596)) OrderModify(g_ticket_592, OrderOpenPrice(), Bid + stopLoss * Point, Bid - takeProfit * Point, 0, Blue); + } + } + } + } + return (0); +} + +void calculateIndicators() { + g_iatr_612 = iATR(NULL, 0, ATR_PERIOD, 1); + gd_620 = NormalizeDouble(g_iatr_612 * ATRS, gi_596); + g_ima_336 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 8); + g_ima_344 = iMA(NULL, 0, 13, 0, MODE_EMA, PRICE_CLOSE, 0); + g_iadx_480 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MAIN, 1); + g_iadx_488 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MAIN, 2); + g_iadx_504 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 1); + g_iadx_512 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_PLUSDI, 2); + g_iadx_528 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 1); + g_iadx_520 = iADX(NULL, 0, crmRPM, PRICE_CLOSE, MODE_MINUSDI, 2); + g_iatr_496 = iATR(NULL, 0, 50, 0); + gd_552 = iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_D1, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_cut); + gd_560 = iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, 0) - iMA(NULL, PERIOD_H4, Pin_under, 0, MODE_EMA, PRICE_MEDIAN, Long_cut); + g_ima_568 = iMA(NULL, PERIOD_H1, Pound_level, 0, MODE_EMA, PRICE_MEDIAN, 0); + g_bool_576 = gd_552 > Dscan && gd_560 > Hscan && g_ima_568 > Ask && DayOfWeek() < 5; + g_bool_580 = gd_552 < (-1.0 * Dscan) && gd_560 < (-1.0 * Hscan) && g_ima_568 < Bid && DayOfWeek() < 5; + gi_unused_584 = FALSE; +} + +void prtAlert(string as_0 = "") { + Print(as_0); + Alert(as_0); +} + +double calculatelots() { + gd_620 *= gd_660; + gd_628 = equitypercent * AccountEquity(); + gd_636 = gd_628 / gd_620; + lots = gd_636 / gd_668; + gd_676 = gd_636 / gd_668; + if (lots < 10.0) { + if (lots > 0.01 && lots < 0.02) lots = 0.01; + if (lots > 0.02 && lots < 0.03) lots = 0.02; + if (lots > 0.03 && lots < 0.04) lots = 0.03; + if (lots > 0.04 && lots < 0.05) lots = 0.04; + if (lots > 0.05 && lots < 0.06) lots = 0.05; + if (lots > 0.06 && lots < 0.07) lots = 0.06; + if (lots > 0.07 && lots < 0.08) lots = 0.07; + if (lots > 0.08 && lots < 0.09) lots = 0.08; + if (lots > 0.09 && lots < 0.1) lots = 0.09; + if (lots > 0.1 && lots < 0.2) lots = 0.1; + if (lots > 0.2 && lots < 0.3) lots = 0.2; + if (lots > 0.3 && lots < 0.4) lots = 0.3; + if (lots > 0.4 && lots < 0.5) lots = 0.4; + if (lots > 0.5 && lots < 0.6) lots = 0.5; + if (lots > 0.6 && lots < 0.7) lots = 0.6; + if (lots > 0.7 && lots < 0.8) lots = 0.7; + if (lots > 0.8 && lots < 0.9) lots = 0.8; + if (lots > 0.9 && lots < 1.0) lots = 0.9; + if (lots > 1.0 && lots < 1.1) lots = 1.0; + if (lots > 1.1 && lots < 1.2) lots = 1.1; + if (lots > 1.2 && lots < 1.3) lots = 1.2; + if (lots > 1.3 && lots < 1.4) lots = 1.3; + if (lots > 1.4 && lots < 1.5) lots = 1.4; + if (lots > 1.5 && lots < 1.6) lots = 1.5; + if (lots > 1.6 && lots < 1.7) lots = 1.6; + if (lots > 1.7 && lots < 1.8) lots = 1.7; + if (lots > 1.8 && lots < 1.9) lots = 1.8; + if (lots > 1.9 && lots < 2.0) lots = 1.9; + if (lots > 2.0 && lots < 2.1) lots = 2.0; + if (lots > 2.1 && lots < 2.2) lots = 2.1; + if (lots > 2.2 && lots < 2.3) lots = 2.2; + if (lots > 2.3 && lots < 2.4) lots = 2.3; + if (lots > 2.4 && lots < 2.5) lots = 2.4; + if (lots > 2.5 && lots < 2.6) lots = 2.5; + if (lots > 2.6 && lots < 2.7) lots = 2.6; + if (lots > 2.7 && lots < 2.8) lots = 2.7; + if (lots > 2.8 && lots < 2.9) lots = 2.8; + if (lots > 2.9 && lots < 3.0) lots = 2.9; + if (lots > 3.0 && lots < 3.1) lots = 3.0; + if (lots > 3.1 && lots < 3.2) lots = 3.1; + if (lots > 3.2 && lots < 3.3) lots = 3.2; + if (lots > 3.3 && lots < 3.4) lots = 3.3; + if (lots > 3.4 && lots < 3.5) lots = 3.4; + if (lots > 3.5 && lots < 3.6) lots = 3.5; + if (lots > 3.6 && lots < 3.7) lots = 3.6; + if (lots > 3.7 && lots < 3.8) lots = 3.7; + if (lots > 3.8 && lots < 3.9) lots = 3.8; + if (lots > 3.9 && lots < 4.0) lots = 3.9; + if (lots > 4.0 && lots < 4.1) lots = 4.0; + if (lots > 4.1 && lots < 4.2) lots = 4.1; + if (lots > 4.2 && lots < 4.3) lots = 4.2; + if (lots > 4.3 && lots < 4.4) lots = 4.3; + if (lots > 4.4 && lots < 4.5) lots = 4.4; + if (lots > 4.5 && lots < 4.6) lots = 4.5; + if (lots > 4.6 && lots < 4.7) lots = 4.6; + if (lots > 4.7 && lots < 4.8) lots = 4.7; + if (lots > 4.8 && lots < 4.9) lots = 4.8; + if (lots > 4.9 && lots < 5.0) lots = 4.9; + if (lots > 5.0 && lots < 5.1) lots = 5.0; + if (lots > 5.1 && lots < 5.2) lots = 5.1; + if (lots > 5.2 && lots < 5.3) lots = 5.2; + if (lots > 5.3 && lots < 5.4) lots = 5.3; + if (lots > 5.4 && lots < 5.5) lots = 5.4; + if (lots > 5.5 && lots < 5.6) lots = 5.5; + if (lots > 5.6 && lots < 5.7) lots = 5.6; + if (lots > 5.7 && lots < 5.8) lots = 5.7; + if (lots > 5.8 && lots < 5.9) lots = 5.8; + if (lots > 5.9 && lots < 6.0) lots = 5.9; + if (lots > 6.0 && lots < 6.1) lots = 6.0; + if (lots > 6.1 && lots < 6.2) lots = 6.1; + if (lots > 6.2 && lots < 6.3) lots = 6.2; + if (lots > 6.3 && lots < 6.4) lots = 6.3; + if (lots > 6.4 && lots < 6.5) lots = 6.4; + if (lots > 6.5 && lots < 6.6) lots = 6.5; + if (lots > 6.6 && lots < 6.7) lots = 6.6; + if (lots > 6.7 && lots < 6.8) lots = 6.7; + if (lots > 6.8 && lots < 6.9) lots = 6.8; + if (lots > 6.9 && lots < 7.0) lots = 6.9; + if (lots > 7.0 && lots < 7.1) lots = 7.0; + if (lots > 7.1 && lots < 7.2) lots = 7.1; + if (lots > 7.2 && lots < 7.3) lots = 7.2; + if (lots > 7.3 && lots < 7.4) lots = 7.3; + if (lots > 7.4 && lots < 7.5) lots = 7.4; + if (lots > 7.5 && lots < 7.6) lots = 7.5; + if (lots > 7.6 && lots < 7.7) lots = 7.6; + if (lots > 7.7 && lots < 7.8) lots = 7.7; + if (lots > 7.8 && lots < 7.9) lots = 7.8; + if (lots > 7.9 && lots < 8.0) lots = 7.9; + if (lots > 8.0 && lots < 8.1) lots = 8.0; + if (lots > 8.1 && lots < 8.2) lots = 8.1; + if (lots > 8.2 && lots < 8.3) lots = 8.2; + if (lots > 8.3 && lots < 8.4) lots = 8.3; + if (lots > 8.4 && lots < 8.5) lots = 8.4; + if (lots > 8.5 && lots < 8.6) lots = 8.5; + if (lots > 8.6 && lots < 8.7) lots = 8.6; + if (lots > 8.7 && lots < 8.8) lots = 8.7; + if (lots > 8.8 && lots < 8.9) lots = 8.8; + if (lots > 8.9 && lots < 9.0) lots = 8.9; + if (lots > 9.0 && lots < 9.1) lots = 9.0; + if (lots > 9.1 && lots < 9.2) lots = 9.1; + if (lots > 9.2 && lots < 9.3) lots = 9.2; + if (lots > 9.3 && lots < 9.4) lots = 9.3; + if (lots > 9.4 && lots < 9.5) lots = 9.4; + if (lots > 9.5 && lots < 9.6) lots = 9.5; + if (lots > 9.6 && lots < 9.7) lots = 9.6; + if (lots > 9.7 && lots < 9.8) lots = 9.7; + if (lots > 9.8 && lots < 9.9) lots = 9.8; + if (lots > 9.9 && lots < 10.0) lots = 9.9; + if (lots > 10.0 && lots < 10.1) lots = 10.0; + if (lots > 10.0) lots = MathRound(lots); + if (lots > g_maxlot_644) lots = g_maxlot_644; + if (lots < g_minlot_652) lots = g_minlot_652; + } + return (lots); +} + +void Display_Info() { + Comment("IVYBOT EXPERT ADVISOR\n", "Desc: Currently Scanning All Trends,\n", "Forex Account Server:", AccountServer(), + "\n", "Free Margin: $", AccountFreeMargin(), + "\n", "Lots: ", lots, + "\n", "Symbol: ", Symbol(), + "\n", "Price: ", NormalizeDouble(Bid, 4), + "\n", "Optimal Spread: ", MarketInfo("USDCHF", MODE_SPREAD), + "\n", "Date: ", Month(), "-", Day(), "-", Year(), " Server Time: ", Hour(), ":", Minute(), ":", Seconds(), + "\n"); +} \ No newline at end of file diff --git a/Ilan 1.5 STD_3_LE_Ver_3.mq4 b/Ilan 1.5 STD_3_LE_Ver_3.mq4 new file mode 100644 index 0000000..96c9dcb --- /dev/null +++ b/Ilan 1.5 STD_3_LE_Ver_3.mq4 @@ -0,0 +1,644 @@ + +#property copyright "forexinn@rambler.ru" +#property link "" + +extern double LotExponent = 1.51; +extern double slip = 3.0; +int gi_unused_88; +extern double Lots = 0.02; +extern int lotdecimal = 2; +extern double TakeProfit = 12.0; +int OrderN = 1; +int OrderN1 = 2; +int OrderN2 = 3; +int OrderN3 = 3; +int OrderN4 = 4; +int OrderN5 = 5; +int OrderN6 = 6; +int OrderN7 = 7; +int OrderN8 = 8; +int OrderN9 = 9; +int OrderN10 = 10; +int OrderN11 = 11; +int OrderN12 = 12; +int OrderN13 = 13; +int OrderN14 = 14; +extern double TakeProfit2 = 12.0; +extern double LotExponent2 = 1.4; +extern double LotExponent3 = 1.25; +extern double LotExponent4 = 1.41; +extern double LotExponent5 = 1.41; +extern double LotExponent6 = 1.59; +extern double LotExponent7 = 1.41; +extern double LotExponent8 = 1.69; +extern double LotExponent9 = 1.41; +extern double LotExponent10 = 1.69; +extern double LotExponent11 = 1.41; +extern double LotExponent12 = 1.8; +extern double LotExponent13 = 1.41; +extern double LotExponent14 = 1.8; +extern double LotExponent15 = 1.41; +extern double Stoploss = 500.0; +extern double TrailStart = 10.0; +extern double TrailStop = 10.0; +extern double PipStep = 10.0; +extern int MaxTrades = 15; +extern bool UseEquityStop = FALSE; +extern double TotalEquityRisk = 20.0; +extern bool UseTrailingStop = FALSE; +extern bool UseTimeOut = FALSE; +extern double MaxTradeOpenHours = 48.0; +extern int g_magic_176 = 77857; +extern double PipStep2 = 10.0; +extern double PipStep3 = 20.0; +extern double PipStep4 = 30.0; +extern double PipStep5 = 20.0; +extern double PipStep6 = 40.0; +extern double PipStep7 = 20.0; +extern double PipStep8 = 50.0; +extern double PipStep9 = 20.0; +extern double PipStep10 =60.0; +extern double PipStep11 = 20.0; +extern double PipStep12 = 70.0; +extern double PipStep13 = 20.0; +extern double PipStep14 = 80.0; +extern double PipStep15 = 20.0; +double g_price_180; +double gd_188; +double gd_unused_196; +double gd_unused_204; +double g_price_212; +double g_bid_220; +double g_ask_228; +double gd_236; +double gd_244; +double gd_260; +bool gi_268; +string gs_ilan_272 = "Ilan"; +int gi_280 = 0; +int gi_284; +int gi_288 = 0; +double gd_292; +int g_pos_300 = 0; +int gi_304; +double gd_308 = 0.0; +bool gi_316 = FALSE; +bool gi_320 = FALSE; +bool gi_324 = FALSE; +int gi_328; +bool gi_332 = FALSE; +double gd_336; +double gd_344; +string OrdType; + +int init() { + gd_260 = MarketInfo(Symbol(), MODE_SPREAD) * Point; + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double l_iclose_8; + double l_iclose_16; + if (UseTrailingStop) TrailingAlls(TrailStart, TrailStop, g_price_212); + if (UseTimeOut) { + if (TimeCurrent() >= gi_284) { + CloseThisSymbolAll(); + Print("Closed All due to TimeOut"); + } + } + if (gi_280 == Time[0]) return (0); + gi_280 = Time[0]; + double ld_0 = CalculateProfit(); + if (UseEquityStop) { + if (ld_0 < 0.0 && MathAbs(ld_0) > TotalEquityRisk / 100.0 * AccountEquityHigh()) { + CloseThisSymbolAll(); + Print("Closed All due to Stop Out"); + gi_332 = FALSE; + } + } + gi_304 = CountTrades(); + if (gi_304 == 0) gi_268 = FALSE; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + gi_320 = TRUE; + gi_324 = FALSE; + break; + } + } + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_SELL) { + gi_320 = FALSE; + gi_324 = TRUE; + break; + } + } + } + if (gi_304 == 1 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep * Point) gi_316 = TRUE; + } + if (gi_304 == 2 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep2 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep2 * Point) gi_316 = TRUE; + } + if (gi_304 == 3 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep3 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep3 * Point) gi_316 = TRUE; + } + if (gi_304 == 4 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep4 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep4 * Point) gi_316 = TRUE; + } + if (gi_304 == 5 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep5 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep5 * Point) gi_316 = TRUE; + } + if (gi_304 == 6 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep6 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep6 * Point) gi_316 = TRUE; + } + if (gi_304 == 7 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep7 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep7 * Point) gi_316 = TRUE; + } + if (gi_304 == 8 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep8 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep8 * Point) gi_316 = TRUE; + } + if (gi_304 == 9 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep9 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep9 * Point) gi_316 = TRUE; + } + if (gi_304 == 10 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep10 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep10 * Point) gi_316 = TRUE; + } + if (gi_304 == 11 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep11 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep11 * Point) gi_316 = TRUE; + } + if (gi_304 == 12 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep12 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep12 * Point) gi_316 = TRUE; + } + if (gi_304 == 13 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep13 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep13 * Point) gi_316 = TRUE; + } + if (gi_304 == 14 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep14 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep14 * Point) gi_316 = TRUE; + } + if (gi_304 == 15 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep15 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep15 * Point) gi_316 = TRUE; + } + if (gi_304 > 15 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep15 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep15 * Point) gi_316 = TRUE; + } + + if (gi_304 < 1) { + gi_324 = FALSE; + gi_320 = FALSE; + gi_316 = TRUE; + gd_188 = AccountEquity(); + } + if (gi_316) { + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_324) { + gi_288 = gi_304; + OrdType="sell"; + if (gi_304 <= OrderN) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent, lotdecimal); + if (gi_304 > OrderN && gi_304<= OrderN1 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, lotdecimal); + if (gi_304 > OrderN1 && gi_304<= OrderN2 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent3, lotdecimal); + if (gi_304 > OrderN2 && gi_304<= OrderN3 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent4, lotdecimal); + if (gi_304 > OrderN3 && gi_304<= OrderN4 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent5, lotdecimal); + if (gi_304 > OrderN4 && gi_304<= OrderN5 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent6, lotdecimal); + if (gi_304 > OrderN5 && gi_304<= OrderN6 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent7, lotdecimal); + if (gi_304 > OrderN6 && gi_304<= OrderN7 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent8, lotdecimal); + if (gi_304 > OrderN7 && gi_304<= OrderN8 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent9, lotdecimal); + if (gi_304 > OrderN8 && gi_304<= OrderN9 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent10, lotdecimal); + if (gi_304 > OrderN9 && gi_304<= OrderN10 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent11, lotdecimal); + if (gi_304 > OrderN10 && gi_304<= OrderN11 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent12, lotdecimal); + if (gi_304 > OrderN11 && gi_304<= OrderN12 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent13, lotdecimal); + if (gi_304 > OrderN12 && gi_304<= OrderN13 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent14, lotdecimal); + if (gi_304 > OrderN13 && gi_304<= OrderN14 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent15, lotdecimal); + + RefreshRates(); + gi_328 = OpenPendingOrder(1, gd_292, Bid, slip, Ask, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, HotPink); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_244 = FindLastSellPrice(); + gi_316 = FALSE; + gi_332 = TRUE; + } else { + if (gi_320) { + gi_288 = gi_304; + OrdType="buy"; + if (gi_304 <= OrderN) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent, lotdecimal); + if (gi_304 > OrderN && gi_304<= OrderN1 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, lotdecimal); + if (gi_304 > OrderN1 && gi_304<= OrderN2 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent3, lotdecimal); + if (gi_304 > OrderN2 && gi_304<= OrderN3 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent4, lotdecimal); + if (gi_304 > OrderN3 && gi_304<= OrderN4 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent5, lotdecimal); + if (gi_304 > OrderN4 && gi_304<= OrderN5 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent6, lotdecimal); + if (gi_304 > OrderN5 && gi_304<= OrderN6 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent7, lotdecimal); + if (gi_304 > OrderN6 && gi_304<= OrderN7 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent8, lotdecimal); + if (gi_304 > OrderN7 && gi_304<= OrderN8 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent9, lotdecimal); + if (gi_304 > OrderN8 && gi_304<= OrderN9 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent10, lotdecimal); + if (gi_304 > OrderN9 && gi_304<= OrderN10 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent11, lotdecimal); + if (gi_304 > OrderN10 && gi_304<= OrderN11 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent12, lotdecimal); + if (gi_304 > OrderN11 && gi_304<= OrderN12 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent13, lotdecimal); + if (gi_304 > OrderN12 && gi_304<= OrderN13 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent14, lotdecimal); + if (gi_304 > OrderN13 && gi_304<= OrderN14 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent15, lotdecimal); + gi_328 = OpenPendingOrder(0, gd_292, Ask, slip, Bid, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, Lime); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_236 = FindLastBuyPrice(); + gi_316 = FALSE; + gi_332 = TRUE; + } + } + } + if (gi_316 && gi_304 < 1) { + l_iclose_8 = iClose(Symbol(), 0, 2); + l_iclose_16 = iClose(Symbol(), 0, 1); + g_bid_220 = Bid; + g_ask_228 = Ask; + if (!gi_324 && !gi_320) { + gi_288 = gi_304; + gd_292 = NormalizeDouble(Lots * MathPow(LotExponent, gi_288), lotdecimal); + if (l_iclose_8 > l_iclose_16) { + gi_328 = OpenPendingOrder(1, gd_292, g_bid_220, slip, g_bid_220, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, HotPink); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_236 = FindLastBuyPrice(); + gi_332 = TRUE; + } else { + gi_328 = OpenPendingOrder(0, gd_292, g_ask_228, slip, g_ask_228, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, Lime); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_244 = FindLastSellPrice(); + gi_332 = TRUE; + } + if (gi_328 > 0) gi_284 = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours); + gi_316 = FALSE; + } + } + gi_304 = CountTrades(); + g_price_212 = 0; + double ld_24 = 0; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) { + g_price_212 += OrderOpenPrice() * OrderLots(); + ld_24 += OrderLots(); + } + } + } + if (gi_304 > 0) g_price_212 = NormalizeDouble(g_price_212 / ld_24, Digits); + if (gi_332) { + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + if (gi_304 <= OrderN) g_price_180 = g_price_212 + TakeProfit * Point; + if (gi_304 > OrderN) g_price_180 = g_price_212 + TakeProfit2 * Point; + gd_unused_196 = g_price_180; + gd_308 = g_price_212 - Stoploss * Point; + gi_268 = TRUE; + } + } + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_SELL) { + if (gi_304 <= OrderN) g_price_180 = g_price_212 - TakeProfit * Point; + if (gi_304 > OrderN) g_price_180 = g_price_212 - TakeProfit2 * Point; + gd_unused_204 = g_price_180; + gd_308 = g_price_212 + Stoploss * Point; + gi_268 = TRUE; + } + } + } + } + if (gi_332) { + if (gi_268 == TRUE) { + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) OrderModify(OrderTicket(), g_price_212, OrderStopLoss(), g_price_180, 0, Yellow); + gi_332 = FALSE; + } + } + } + return (0); +} + +int CountTrades() { + int l_count_0 = 0; + for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) + if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_0++; + } + return (l_count_0); +} + +void CloseThisSymbolAll() { + for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { + OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol()) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue); + if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red); + } + Sleep(1000); + } + } +} + +int OpenPendingOrder(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) { + int l_ticket_60 = 0; + int l_error_64 = 0; + int l_count_68 = 0; + int li_72 = 100; + switch (ai_0) { + case 2: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(1000); + } + break; + case 4: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 0: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + RefreshRates(); + l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, NormalizeDouble(Ask,Digits), a_slippage_20, NormalizeDouble(StopLong(Bid, ai_32),Digits), NormalizeDouble(TakeLong(Ask, ai_36),Digits), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 3: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 5: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 1: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, NormalizeDouble(Bid,Digits), a_slippage_20, NormalizeDouble(StopShort(Ask, ai_32),Digits), NormalizeDouble(TakeShort(Bid, ai_36),Digits), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + } + return (l_ticket_60); +} + +double StopLong(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 - ai_8 * Point); +} + +double StopShort(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 + ai_8 * Point); +} + +double TakeLong(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 + ai_8 * Point); +} + +double TakeShort(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 - ai_8 * Point); +} + +double CalculateProfit() { + double ld_ret_0 = 0; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) + if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit(); + } + return (ld_ret_0); +} + +void TrailingAlls(int ai_0, int ai_4, double a_price_8) { + int l_ticket_16; + double l_ord_stoploss_20; + double l_price_28; + if (ai_4 != 0) { + for (int l_pos_36 = OrdersTotal() - 1; l_pos_36 >= 0; l_pos_36--) { + if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) { + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + l_ticket_16 = NormalizeDouble((Bid - a_price_8) / Point, 0); + if (l_ticket_16 < ai_0) continue; + l_ord_stoploss_20 = OrderStopLoss(); + l_price_28 = Bid - ai_4 * Point; + if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua); + } + if (OrderType() == OP_SELL) { + l_ticket_16 = NormalizeDouble((a_price_8 - Ask) / Point, 0); + if (l_ticket_16 < ai_0) continue; + l_ord_stoploss_20 = OrderStopLoss(); + l_price_28 = Ask + ai_4 * Point; + if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red); + } + } + Sleep(1000); + } + } + } +} + +double AccountEquityHigh() { + if (CountTrades() == 0) gd_336 = AccountEquity(); + if (gd_336 < gd_344) gd_336 = gd_344; + else gd_336 = AccountEquity(); + gd_344 = AccountEquity(); + return (gd_336); +} + +double FindLastBuyPrice() { + double l_ord_open_price_8; + int l_ticket_24; + double ld_unused_0 = 0; + int l_ticket_20 = 0; + for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176 && OrderType() == OP_BUY) { + l_ticket_24 = OrderTicket(); + if (l_ticket_24 > l_ticket_20) { + l_ord_open_price_8 = OrderOpenPrice(); + ld_unused_0 = l_ord_open_price_8; + l_ticket_20 = l_ticket_24; + } + } + } + return (l_ord_open_price_8); +} + +double FindLastSellPrice() { + double l_ord_open_price_8; + int l_ticket_24; + double ld_unused_0 = 0; + int l_ticket_20 = 0; + for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176 && OrderType() == OP_SELL) { + l_ticket_24 = OrderTicket(); + if (l_ticket_24 > l_ticket_20) { + l_ord_open_price_8 = OrderOpenPrice(); + ld_unused_0 = l_ord_open_price_8; + l_ticket_20 = l_ticket_24; + } + } + } + return (l_ord_open_price_8); +} + +//Возвращает цену или лот последнего ордера +double FindLastOrder(string OrdType, string inf) +{ + double OrderPrice; + double LastLot; + int trade, oldticketnumber=0; + + for(trade=OrdersTotal()-1;trade>=0;trade--) + { + OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); + if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=g_magic_176) continue; + if(OrderSymbol()==Symbol() && OrderMagicNumber()==g_magic_176) + { + //---- + if (OrdType=="buy") + { + if(OrderType()==OP_BUY) + { + if(OrderTicket()>oldticketnumber) + { + OrderPrice=OrderOpenPrice(); + LastLot = OrderLots(); + oldticketnumber=OrderTicket(); + } + } + } + //---- + if (OrdType=="sell") + { + if(OrderType()==OP_SELL) + { + if(OrderTicket()>oldticketnumber) + { + OrderPrice=OrderOpenPrice(); + LastLot = OrderLots(); + oldticketnumber=OrderTicket(); + } + } + } + //---- + } +} +if (inf=="Price") return(OrderPrice); +if (inf=="Lots") return(LastLot); +} \ No newline at end of file diff --git a/Ilan_1.5_STD_3_LE_Ver_3.mq4 b/Ilan_1.5_STD_3_LE_Ver_3.mq4 new file mode 100644 index 0000000..202deb8 --- /dev/null +++ b/Ilan_1.5_STD_3_LE_Ver_3.mq4 @@ -0,0 +1,644 @@ + +#property copyright "forexinn@rambler.ru" +#property link "" + +extern double LotExponent = 1.51; +extern double slip = 3.0; +int gi_unused_88; +extern double Lots = 0.02; +extern int lotdecimal = 2; +extern double TakeProfit = 12.0; +int OrderN = 1; +int OrderN1 = 2; +int OrderN2 = 3; +int OrderN3 = 3; +int OrderN4 = 4; +int OrderN5 = 5; +int OrderN6 = 6; +int OrderN7 = 7; +int OrderN8 = 8; +int OrderN9 = 9; +int OrderN10 = 10; +int OrderN11 = 11; +int OrderN12 = 12; +int OrderN13 = 13; +int OrderN14 = 14; +extern double TakeProfit2 = 12.0; +extern double LotExponent2 = 1.4; +extern double LotExponent3 = 1.25; +extern double LotExponent4 = 1.41; +extern double LotExponent5 = 1.41; +extern double LotExponent6 = 1.59; +extern double LotExponent7 = 1.41; +extern double LotExponent8 = 1.69; +extern double LotExponent9 = 1.41; +extern double LotExponent10 = 1.69; +extern double LotExponent11 = 1.41; +extern double LotExponent12 = 1.8; +extern double LotExponent13 = 1.41; +extern double LotExponent14 = 1.8; +extern double LotExponent15 = 1.41; +extern double Stoploss = 500.0; +extern double TrailStart = 10.0; +extern double TrailStop = 10.0; +extern double PipStep = 10.0; +extern int MaxTrades = 15; +extern bool UseEquityStop = FALSE; +extern double TotalEquityRisk = 20.0; +extern bool UseTrailingStop = FALSE; +extern bool UseTimeOut = FALSE; +extern double MaxTradeOpenHours = 48.0; +extern int g_magic_176 = 77857; +extern double PipStep2 = 10.0; +extern double PipStep3 = 20.0; +extern double PipStep4 = 30.0; +extern double PipStep5 = 20.0; +extern double PipStep6 = 40.0; +extern double PipStep7 = 20.0; +extern double PipStep8 = 50.0; +extern double PipStep9 = 20.0; +extern double PipStep10 =60.0; +extern double PipStep11 = 20.0; +extern double PipStep12 = 70.0; +extern double PipStep13 = 20.0; +extern double PipStep14 = 80.0; +extern double PipStep15 = 20.0; +double g_price_180; +double gd_188; +double gd_unused_196; +double gd_unused_204; +double g_price_212; +double g_bid_220; +double g_ask_228; +double gd_236; +double gd_244; +double gd_260; +bool gi_268; +string gs_ilan_272 = "Ilan"; +int gi_280 = 0; +int gi_284; +int gi_288 = 0; +double gd_292; +int g_pos_300 = 0; +int gi_304; +double gd_308 = 0.0; +bool gi_316 = FALSE; +bool gi_320 = FALSE; +bool gi_324 = FALSE; +int gi_328; +bool gi_332 = FALSE; +double gd_336; +double gd_344; +string OrdType; + +int init() { + gd_260 = MarketInfo(Symbol(), MODE_SPREAD) * Point; + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double l_iclose_8; + double l_iclose_16; + if (UseTrailingStop) TrailingAlls(TrailStart, TrailStop, g_price_212); + if (UseTimeOut) { + if (TimeCurrent() >= gi_284) { + CloseThisSymbolAll(); + Print("Closed All due to TimeOut"); + } + } + if (gi_280 == Time[0]) return (0); + gi_280 = Time[0]; + double ld_0 = CalculateProfit(); + if (UseEquityStop) { + if (ld_0 < 0.0 && MathAbs(ld_0) > TotalEquityRisk / 100.0 * AccountEquityHigh()) { + CloseThisSymbolAll(); + Print("Closed All due to Stop Out"); + gi_332 = FALSE; + } + } + gi_304 = CountTrades(); + if (gi_304 == 0) gi_268 = FALSE; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + gi_320 = TRUE; + gi_324 = FALSE; + break; + } + } + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_SELL) { + gi_320 = FALSE; + gi_324 = TRUE; + break; + } + } + } + if (gi_304 == 1 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep * Point) gi_316 = TRUE; + } + if (gi_304 == 2 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep2 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep2 * Point) gi_316 = TRUE; + } + if (gi_304 == 3 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep3 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep3 * Point) gi_316 = TRUE; + } + if (gi_304 == 4 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep4 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep4 * Point) gi_316 = TRUE; + } + if (gi_304 == 5 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep5 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep5 * Point) gi_316 = TRUE; + } + if (gi_304 == 6 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep6 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep6 * Point) gi_316 = TRUE; + } + if (gi_304 == 7 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep7 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep7 * Point) gi_316 = TRUE; + } + if (gi_304 == 8 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep8 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep8 * Point) gi_316 = TRUE; + } + if (gi_304 == 9 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep9 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep9 * Point) gi_316 = TRUE; + } + if (gi_304 == 10 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep10 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep10 * Point) gi_316 = TRUE; + } + if (gi_304 == 11 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep11 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep11 * Point) gi_316 = TRUE; + } + if (gi_304 == 12 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep12 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep12 * Point) gi_316 = TRUE; + } + if (gi_304 == 13 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep13 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep13 * Point) gi_316 = TRUE; + } + if (gi_304 == 14 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep14 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep14 * Point) gi_316 = TRUE; + } + if (gi_304 == 15 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep15 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep15 * Point) gi_316 = TRUE; + } + if (gi_304 > 15 && gi_304 <= MaxTrades) { + RefreshRates(); + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_320 && gd_236 - Ask >= PipStep15 * Point) gi_316 = TRUE; + if (gi_324 && Bid - gd_244 >= PipStep15 * Point) gi_316 = TRUE; + } + + if (gi_304 < 1) { + gi_324 = FALSE; + gi_320 = FALSE; + gi_316 = TRUE; + gd_188 = AccountEquity(); + } + if (gi_316) { + gd_236 = FindLastBuyPrice(); + gd_244 = FindLastSellPrice(); + if (gi_324) { + gi_288 = gi_304; + OrdType="sell"; + if (gi_304 <= OrderN) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent, lotdecimal); + if (gi_304 > OrderN && gi_304<= OrderN1 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, lotdecimal); + if (gi_304 > OrderN1 && gi_304<= OrderN2 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent3, lotdecimal); + if (gi_304 > OrderN2 && gi_304<= OrderN3 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent4, lotdecimal); + if (gi_304 > OrderN3 && gi_304<= OrderN4 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent5, lotdecimal); + if (gi_304 > OrderN4 && gi_304<= OrderN5 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent6, lotdecimal); + if (gi_304 > OrderN5 && gi_304<= OrderN6 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent7, lotdecimal); + if (gi_304 > OrderN6 && gi_304<= OrderN7 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent8, lotdecimal); + if (gi_304 > OrderN7 && gi_304<= OrderN8 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent9, lotdecimal); + if (gi_304 > OrderN8 && gi_304<= OrderN9 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent10, lotdecimal); + if (gi_304 > OrderN9 && gi_304<= OrderN10 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent11, lotdecimal); + if (gi_304 > OrderN10 && gi_304<= OrderN11 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent12, lotdecimal); + if (gi_304 > OrderN11 && gi_304<= OrderN12 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent13, lotdecimal); + if (gi_304 > OrderN12 && gi_304<= OrderN13 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent14, lotdecimal); + if (gi_304 > OrderN13 && gi_304<= OrderN14 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent15, lotdecimal); + + RefreshRates(); + gi_328 = OpenPendingOrder(1, gd_292, Bid, slip, Ask, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, HotPink); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_244 = FindLastSellPrice(); + gi_316 = FALSE; + gi_332 = TRUE; + } else { + if (gi_320) { + gi_288 = gi_304; + OrdType="buy"; + if (gi_304 <= OrderN) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent, lotdecimal); + if (gi_304 > OrderN && gi_304<= OrderN1 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent2, lotdecimal); + if (gi_304 > OrderN1 && gi_304<= OrderN2 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent3, lotdecimal); + if (gi_304 > OrderN2 && gi_304<= OrderN3 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent4, lotdecimal); + if (gi_304 > OrderN3 && gi_304<= OrderN4 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent5, lotdecimal); + if (gi_304 > OrderN4 && gi_304<= OrderN5 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent6, lotdecimal); + if (gi_304 > OrderN5 && gi_304<= OrderN6 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent7, lotdecimal); + if (gi_304 > OrderN6 && gi_304<= OrderN7 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent8, lotdecimal); + if (gi_304 > OrderN7 && gi_304<= OrderN8 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent9, lotdecimal); + if (gi_304 > OrderN8 && gi_304<= OrderN9 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent10, lotdecimal); + if (gi_304 > OrderN9 && gi_304<= OrderN10 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent11, lotdecimal); + if (gi_304 > OrderN10 && gi_304<= OrderN11 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent12, lotdecimal); + if (gi_304 > OrderN11 && gi_304<= OrderN12 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent13, lotdecimal); + if (gi_304 > OrderN12 && gi_304<= OrderN13 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent14, lotdecimal); + if (gi_304 > OrderN13 && gi_304<= OrderN14 ) gd_292 = NormalizeDouble(FindLastOrder(OrdType, "Lots") * LotExponent15, lotdecimal); + gi_328 = OpenPendingOrder(0, gd_292, Ask, slip, Bid, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, Lime); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_236 = FindLastBuyPrice(); + gi_316 = FALSE; + gi_332 = TRUE; + } + } + } + if (gi_316 && gi_304 < 1) { + l_iclose_8 = iClose(Symbol(), 0, 2); + l_iclose_16 = iClose(Symbol(), 0, 1); + g_bid_220 = Bid; + g_ask_228 = Ask; + if (!gi_324 && !gi_320) { + gi_288 = gi_304; + gd_292 = NormalizeDouble(Lots * MathPow(LotExponent, gi_288), lotdecimal); + if (l_iclose_8 > l_iclose_16) { + gi_328 = OpenPendingOrder(1, gd_292, g_bid_220, slip, g_bid_220, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, HotPink); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_236 = FindLastBuyPrice(); + gi_332 = TRUE; + } else { + gi_328 = OpenPendingOrder(0, gd_292, g_ask_228, slip, g_ask_228, 0, 0, gs_ilan_272 + "-" + gi_288, g_magic_176, 0, Lime); + if (gi_328 < 0) { + Print("Error: ", GetLastError()); + return (0); + } + gd_244 = FindLastSellPrice(); + gi_332 = TRUE; + } + if (gi_328 > 0) gi_284 = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours); + gi_316 = FALSE; + } + } + gi_304 = CountTrades(); + g_price_212 = 0; + double ld_24 = 0; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) { + g_price_212 += OrderOpenPrice() * OrderLots(); + ld_24 += OrderLots(); + } + } + } + if (gi_304 > 0) g_price_212 = NormalizeDouble(g_price_212 / ld_24, Digits); + if (gi_332) { + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + if (gi_304 <= OrderN) g_price_180 = g_price_212 + TakeProfit * Point; + if (gi_304 > OrderN) g_price_180 = g_price_212 + TakeProfit2 * Point; + gd_unused_196 = g_price_180; + gd_308 = g_price_212 - Stoploss * Point; + gi_268 = TRUE; + } + } + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_SELL) { + if (gi_304 <= OrderN) g_price_180 = g_price_212 - TakeProfit * Point; + if (gi_304 > OrderN) g_price_180 = g_price_212 - TakeProfit2 * Point; + gd_unused_204 = g_price_180; + gd_308 = g_price_212 + Stoploss * Point; + gi_268 = TRUE; + } + } + } + } + if (gi_332) { + if (gi_268 == TRUE) { + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) OrderModify(OrderTicket(), g_price_212, OrderStopLoss(), g_price_180, 0, Yellow); + gi_332 = FALSE; + } + } + } + return (0); +} + +int CountTrades() { + int l_count_0 = 0; + for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { + OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) + if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_0++; + } + return (l_count_0); +} + +void CloseThisSymbolAll() { + for (int l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { + OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol()) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue); + if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red); + } + Sleep(1000); + } + } +} + +int OpenPendingOrder(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) { + int l_ticket_60 = 0; + int l_error_64 = 0; + int l_count_68 = 0; + int li_72 = 100; + switch (ai_0) { + case 2: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(1000); + } + break; + case 4: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, StopLong(ad_24, ai_32), TakeLong(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 0: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + RefreshRates(); + l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 3: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 5: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, StopShort(ad_24, ai_32), TakeShort(a_price_12, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + break; + case 1: + for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) { + l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56); + l_error_64 = GetLastError(); + if (l_error_64 == 0/* NO_ERROR */) break; + if (!(l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */)) break; + Sleep(5000); + } + } + return (l_ticket_60); +} + +double StopLong(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 - ai_8 * Point); +} + +double StopShort(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 + ai_8 * Point); +} + +double TakeLong(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 + ai_8 * Point); +} + +double TakeShort(double ad_0, int ai_8) { + if (ai_8 == 0) return (0); + else return (ad_0 - ai_8 * Point); +} + +double CalculateProfit() { + double ld_ret_0 = 0; + for (g_pos_300 = OrdersTotal() - 1; g_pos_300 >= 0; g_pos_300--) { + OrderSelect(g_pos_300, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176) + if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit(); + } + return (ld_ret_0); +} + +void TrailingAlls(int ai_0, int ai_4, double a_price_8) { + int l_ticket_16; + double l_ord_stoploss_20; + double l_price_28; + if (ai_4 != 0) { + for (int l_pos_36 = OrdersTotal() - 1; l_pos_36 >= 0; l_pos_36--) { + if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES)) { + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() || OrderMagicNumber() == g_magic_176) { + if (OrderType() == OP_BUY) { + l_ticket_16 = NormalizeDouble((Bid - a_price_8) / Point, 0); + if (l_ticket_16 < ai_0) continue; + l_ord_stoploss_20 = OrderStopLoss(); + l_price_28 = Bid - ai_4 * Point; + if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua); + } + if (OrderType() == OP_SELL) { + l_ticket_16 = NormalizeDouble((a_price_8 - Ask) / Point, 0); + if (l_ticket_16 < ai_0) continue; + l_ord_stoploss_20 = OrderStopLoss(); + l_price_28 = Ask + ai_4 * Point; + if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red); + } + } + Sleep(1000); + } + } + } +} + +double AccountEquityHigh() { + if (CountTrades() == 0) gd_336 = AccountEquity(); + if (gd_336 < gd_344) gd_336 = gd_344; + else gd_336 = AccountEquity(); + gd_344 = AccountEquity(); + return (gd_336); +} + +double FindLastBuyPrice() { + double l_ord_open_price_8; + int l_ticket_24; + double ld_unused_0 = 0; + int l_ticket_20 = 0; + for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176 && OrderType() == OP_BUY) { + l_ticket_24 = OrderTicket(); + if (l_ticket_24 > l_ticket_20) { + l_ord_open_price_8 = OrderOpenPrice(); + ld_unused_0 = l_ord_open_price_8; + l_ticket_20 = l_ticket_24; + } + } + } + return (l_ord_open_price_8); +} + +double FindLastSellPrice() { + double l_ord_open_price_8; + int l_ticket_24; + double ld_unused_0 = 0; + int l_ticket_20 = 0; + for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_176) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_176 && OrderType() == OP_SELL) { + l_ticket_24 = OrderTicket(); + if (l_ticket_24 > l_ticket_20) { + l_ord_open_price_8 = OrderOpenPrice(); + ld_unused_0 = l_ord_open_price_8; + l_ticket_20 = l_ticket_24; + } + } + } + return (l_ord_open_price_8); +} + +//Возвращает цену или лот последнего ордера +double FindLastOrder(string OrdType, string inf) +{ + double OrderPrice; + double LastLot; + int trade, oldticketnumber=0; + + for(trade=OrdersTotal()-1;trade>=0;trade--) + { + OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); + if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=g_magic_176) continue; + if(OrderSymbol()==Symbol() && OrderMagicNumber()==g_magic_176) + { + //---- + if (OrdType=="buy") + { + if(OrderType()==OP_BUY) + { + if(OrderTicket()>oldticketnumber) + { + OrderPrice=OrderOpenPrice(); + LastLot = OrderLots(); + oldticketnumber=OrderTicket(); + } + } + } + //---- + if (OrdType=="sell") + { + if(OrderType()==OP_SELL) + { + if(OrderTicket()>oldticketnumber) + { + OrderPrice=OrderOpenPrice(); + LastLot = OrderLots(); + oldticketnumber=OrderTicket(); + } + } + } + //---- + } +} +if (inf=="Price") return(OrderPrice); +if (inf=="Lots") return(LastLot); +} \ No newline at end of file diff --git a/Ilan_HiLo_RSI.mq4 b/Ilan_HiLo_RSI.mq4 new file mode 100644 index 0000000..18ead1c --- /dev/null +++ b/Ilan_HiLo_RSI.mq4 @@ -0,0 +1,436 @@ +//========================================================================================================================== +#property copyright "MT-4" +#property link "fx.09@mail.ru" // "Мартингейл" +//========================================================================================================================== +extern double LotExponent = 3.1; // умножение лотов в серии по експоненте для вывода в безубыток. первый лот 0.1, серия: 0.15, 0.26, 0.43 ... +extern double Lots = 0.01; // теперь можно и микролоты 0.01 при этом если стоит 0.1 то следующий лот в серии будет 0.16 +extern int lotdecimal = 2; // 2 - микролоты 0.01, 1 - мини лоты 0.1, 0 - нормальные лоты 1.0 +extern double TakeProfit = 10.0; // тейк профит +extern double PipStep = 30.0; // шаг колена +extern double slip = 30.0; // проскальзывание +extern int MaxTrades = 4; // максимально количество одновременно открытых ордеров +extern int MagicNumber = 111; // магик +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +bool UseEquityStop = FALSE; // использовать риск в процентах +double TotalEquityRisk = 20.0; // риск в процентах от депозита +bool UseTrailingStop = FALSE; // использовать трейлинг стоп +bool UseTimeOut = FALSE; // использовать анулирование ордеров по времени +double MaxTradeOpenHours = 48.0; // через колько часов анулировать висячие ордера +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +double Stoploss = 5000.0; // Эти три параметра не работают +double TrailStart = 100.0; +double TrailStop = 100.0; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +double PriceTarget, StartEquity, BuyTarget, SellTarget ; +double AveragePrice, SellLimit, BuyLimit ; +double LastBuyPrice, LastSellPrice, Spread; +bool flag; +string EAName = "Ilan_HiLo_RSI"; +int timeprev = 0, expiration; +int NumOfTrades = 0; +double iLots; +int cnt = 0, total; +double Stopper = 0.0; +bool TradeNow = FALSE, LongTrade = FALSE, ShortTrade = FALSE; +int ticket; +bool NewOrdersPlaced = FALSE; +double AccountEquityHighAmt, PrevEquity; +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +int init() { + Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point; + return (0); +} + +int deinit() { + return (0); +} +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +int start() { + double PrevCl; + double CurrCl; + if (UseTrailingStop) TrailingAlls(TrailStart, TrailStop, AveragePrice); + if (UseTimeOut) { + if (TimeCurrent() >= expiration) { + CloseThisSymbolAll(); + Print("Closed All due to TimeOut"); + } + } + if (timeprev == Time[0]) return (0); + timeprev = Time[0]; + double CurrentPairProfit = CalculateProfit(); + if (UseEquityStop) { + if (CurrentPairProfit < 0.0 && MathAbs(CurrentPairProfit) > TotalEquityRisk / 100.0 * AccountEquityHigh()) { + CloseThisSymbolAll(); + Print("Closed All due to Stop Out"); + NewOrdersPlaced = FALSE; + } + } + total = CountTrades(); + if (total == 0) flag = FALSE; + for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { + OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + if (OrderType() == OP_BUY) { + LongTrade = TRUE; + ShortTrade = FALSE; + break; + } + } + if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { + if (OrderType() == OP_SELL) { + LongTrade = FALSE; + ShortTrade = TRUE; + break; + } + } + } + if (total > 0 && total <= MaxTrades) { + RefreshRates(); + LastBuyPrice = FindLastBuyPrice(); + LastSellPrice = FindLastSellPrice(); + if (LongTrade && LastBuyPrice - Ask >= PipStep * Point) TradeNow = TRUE; + if (ShortTrade && Bid - LastSellPrice >= PipStep * Point) TradeNow = TRUE; + } + if (total < 1) { + ShortTrade = FALSE; + LongTrade = FALSE; + TradeNow = TRUE; + StartEquity = AccountEquity(); + } + if (TradeNow) { + LastBuyPrice = FindLastBuyPrice(); + LastSellPrice = FindLastSellPrice(); + if (ShortTrade) { + NumOfTrades = total; + iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal); + RefreshRates(); + ticket = OpenPendingOrder(1, iLots, Bid, slip, Ask, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, HotPink); + if (ticket < 0) { + Print("Error: ", GetLastError()); + return (0); + } + LastSellPrice = FindLastSellPrice(); + TradeNow = FALSE; + NewOrdersPlaced = TRUE; + } else { + if (LongTrade) { + NumOfTrades = total; + iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal); + ticket = OpenPendingOrder(0, iLots, Ask, slip, Bid, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, Lime); + if (ticket < 0) { + Print("Error: ", GetLastError()); + return (0); + } + LastBuyPrice = FindLastBuyPrice(); + TradeNow = FALSE; + NewOrdersPlaced = TRUE; + } + } + } + if (TradeNow && total < 1) { + PrevCl = iHigh(Symbol(), 0, 1); + CurrCl = iLow(Symbol(), 0, 2); + SellLimit = Bid; + BuyLimit = Ask; + if (!ShortTrade && !LongTrade) { + NumOfTrades = total; + iLots = NormalizeDouble(Lots * MathPow(LotExponent, NumOfTrades), lotdecimal); + if (PrevCl > CurrCl) { + +//HHHHHHHH~~~~~~~~~~~~~ Индюк RSI ~~~~~~~~~~HHHHHHHHH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > 30.0) { + ticket = OpenPendingOrder(1, iLots, SellLimit, slip, SellLimit, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, HotPink); + if (ticket < 0) { + Print("Error: ", GetLastError()); + return (0); + } + LastBuyPrice = FindLastBuyPrice(); + NewOrdersPlaced = TRUE; + } + } else { + +//HHHHHHHH~~~~~~~~~~~~~ Индюк RSI ~~~~~~~~~HHHHHHHHHH~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < 70.0) { + ticket = OpenPendingOrder(0, iLots, BuyLimit, slip, BuyLimit, 0, 0, EAName + "-" + NumOfTrades, MagicNumber, 0, Lime); + if (ticket < 0) { + Print("Error: ", GetLastError()); + return (0); + } + LastSellPrice = FindLastSellPrice(); + NewOrdersPlaced = TRUE; + } + } +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп +if (ticket > 0) expiration = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours); +TradeNow = FALSE; +} +} +total = CountTrades(); +AveragePrice = 0; +double Count = 0; +for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { +if (OrderType() == OP_BUY || OrderType() == OP_SELL) { +AveragePrice += OrderOpenPrice() * OrderLots(); +Count += OrderLots(); +} +} +} +if (total > 0) AveragePrice = NormalizeDouble(AveragePrice / Count, Digits); +if (NewOrdersPlaced) { +for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { +if (OrderType() == OP_BUY) { +PriceTarget = AveragePrice + TakeProfit * Point; +BuyTarget = PriceTarget; +Stopper = AveragePrice - Stoploss * Point; +flag = TRUE; +} +} +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { +if (OrderType() == OP_SELL) { +PriceTarget = AveragePrice - TakeProfit * Point; +SellTarget = PriceTarget; +Stopper = AveragePrice + Stoploss * Point; +flag = TRUE; +} +} +} +} +if (NewOrdersPlaced) { +if (flag == TRUE) { +for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) OrderModify(OrderTicket(), AveragePrice, OrderStopLoss(), PriceTarget, 0, Yellow); +NewOrdersPlaced = FALSE; +} +} +} +return (0); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +int CountTrades() { +int count = 0; +for (int trade = OrdersTotal() - 1; trade >= 0; trade--) { +OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) +if (OrderType() == OP_SELL || OrderType() == OP_BUY) count++; +} +return (count); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +void CloseThisSymbolAll() { +for (int trade = OrdersTotal() - 1; trade >= 0; trade--) { +OrderSelect(trade, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() == Symbol()) { +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) { +if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue); +if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red); +} +Sleep(1000); +} +} +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +int OpenPendingOrder(int pType, double pLots, double pPrice, int pSlippage, double pr, int sl, int tp, string pComment, int pMagic, int pDatetime, color pColor) { +int ticket = 0; +int err = 0; +int c = 0; +int NumberOfTries = 100; +switch (pType) { +case 2: +for (c = 0; c < NumberOfTries; c++) { +ticket = OrderSend(Symbol(), OP_BUYLIMIT, pLots, pPrice, pSlippage, StopLong(pr, sl), TakeLong(pPrice, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(1000); +} +break; +case 4: +for (c = 0; c < NumberOfTries; c++) { +ticket = OrderSend(Symbol(), OP_BUYSTOP, pLots, pPrice, pSlippage, StopLong(pr, sl), TakeLong(pPrice, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(5000); +} +break; +case 0: +for (c = 0; c < NumberOfTries; c++) { +RefreshRates(); +ticket = OrderSend(Symbol(), OP_BUY, pLots, Ask, pSlippage, StopLong(Bid, sl), TakeLong(Ask, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(5000); +} +break; +case 3: +for (c = 0; c < NumberOfTries; c++) { +ticket = OrderSend(Symbol(), OP_SELLLIMIT, pLots, pPrice, pSlippage, StopShort(pr, sl), TakeShort(pPrice, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(5000); +} +break; +case 5: +for (c = 0; c < NumberOfTries; c++) { +ticket = OrderSend(Symbol(), OP_SELLSTOP, pLots, pPrice, pSlippage, StopShort(pr, sl), TakeShort(pPrice, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(5000); +} +break; +case 1: +for (c = 0; c < NumberOfTries; c++) { +ticket = OrderSend(Symbol(), OP_SELL, pLots, Bid, pSlippage, StopShort(Ask, sl), TakeShort(Bid, tp), pComment, pMagic, pDatetime, pColor); +err = GetLastError(); +if (err == 0/* NO_ERROR */) break; +if (!(err == 4/* SERVER_BUSY */ || err == 137/* BROKER_BUSY */ || err == 146/* TRADE_CONTEXT_BUSY */ || err == 136/* OFF_QUOTES */)) break; +Sleep(5000); +} +} +return (ticket); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп +double StopLong(double price, int stop) { +if (stop == 0) return (0); +else return (price - stop * Point); +} +//пппппппппппппппппппппппппппппппппппппппппппп +double StopShort(double price, int stop) { +if (stop == 0) return (0); +else return (price + stop * Point); +} +//пппппппппппппппппппппппппппппппппппппппппппп +double TakeLong(double price, int stop) { +if (stop == 0) return (0); +else return (price + stop * Point); +} +//пппппппппппппппппппппппппппппппппппппппппппп +double TakeShort(double price, int stop) { +if (stop == 0) return (0); +else return (price - stop * Point); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +double CalculateProfit() { +double Profit = 0; +for (cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) +if (OrderType() == OP_BUY || OrderType() == OP_SELL) Profit += OrderProfit(); +} +return (Profit); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +void TrailingAlls(int pType, int stop, double AvgPrice) { +int profit; +double stoptrade; +double stopcal; +if (stop != 0) { +for (int trade = OrdersTotal() - 1; trade >= 0; trade--) { +if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES)) { +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber) { +if (OrderType() == OP_BUY) { +profit = NormalizeDouble((Bid - AvgPrice) / Point, 0); +if (profit < pType) continue; +stoptrade = OrderStopLoss(); +stopcal = Bid - stop * Point; +if (stoptrade == 0.0 || (stoptrade != 0.0 && stopcal > stoptrade)) OrderModify(OrderTicket(), AvgPrice, stopcal, OrderTakeProfit(), 0, Aqua); +} +if (OrderType() == OP_SELL) { +profit = NormalizeDouble((AvgPrice - Ask) / Point, 0); +if (profit < pType) continue; +stoptrade = OrderStopLoss(); +stopcal = Ask + stop * Point; +if (stoptrade == 0.0 || (stoptrade != 0.0 && stopcal < stoptrade)) OrderModify(OrderTicket(), AvgPrice, stopcal, OrderTakeProfit(), 0, Red); +} +} +Sleep(1000); +} +} +} +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +double AccountEquityHigh() { +if (CountTrades() == 0) AccountEquityHighAmt = AccountEquity(); +if (AccountEquityHighAmt < PrevEquity) AccountEquityHighAmt = PrevEquity; +else AccountEquityHighAmt = AccountEquity(); +PrevEquity = AccountEquity(); +return (AccountEquityHighAmt); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +double FindLastBuyPrice() { +double oldorderopenprice; +int oldticketnumber; +double unused = 0; +int ticketnumber = 0; +for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) { +oldticketnumber = OrderTicket(); +if (oldticketnumber > ticketnumber) { +oldorderopenprice = OrderOpenPrice(); +unused = oldorderopenprice; +ticketnumber = oldticketnumber; +} +} +} +return (oldorderopenprice); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + +double FindLastSellPrice() { +double oldorderopenprice; +int oldticketnumber; +double unused = 0; +int ticketnumber = 0; +for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) { +OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); +if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; +if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) { +oldticketnumber = OrderTicket(); +if (oldticketnumber > ticketnumber) { +oldorderopenprice = OrderOpenPrice(); +unused = oldorderopenprice; +ticketnumber = oldticketnumber; +} +} +} +return (oldorderopenprice); +} + +//пппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппппп + + + + diff --git a/IndestructibleTrendWinner.mq4 b/IndestructibleTrendWinner.mq4 new file mode 100644 index 0000000..4f2d737 --- /dev/null +++ b/IndestructibleTrendWinner.mq4 @@ -0,0 +1,90 @@ +//+------------------------------------------------------------------+ +//| Copyright © 2012, Konstantin http://www.fxaktiv.com | +//| panelektrik@yandex.ru skype pan--elektrik | +//| ISQ 561090193 Моб.+380 50 7115118 | +//+------------------------------------------------------------------+ +//#property copyright "Copyright © 2012, Konstantin" +//#property link "http://www.fxaktiv.com panelektrik@yandex.ru skype pan--elektrik ISQ 561090193 Моб.+380 50 7115118" + + +#property indicator_chart_window +#property indicator_buffers 4 +#property indicator_color1 Yellow +#property indicator_color2 Lime +#property indicator_color3 OrangeRed +#property indicator_color4 Chartreuse +#property indicator_width1 2 +#property indicator_width2 2 +#property indicator_width3 2 + + +extern int BarsHistory =10000; +extern int PeriodCCI =50; +extern int PeriodATR =5; + +extern bool alert = true; +extern bool email = false; +extern bool fractals =true; + +double Trend[]; +double TrendUp[]; +double TrendDown[]; +double fr[]; +double CCI,ATR,Bf; +int tr=0; +int tm; +//+------------------------------------------------------------------+ +int init(){ + SetIndexBuffer(0,Trend); + SetIndexBuffer(1,TrendUp); + SetIndexBuffer(2,TrendDown); + SetIndexBuffer(3,fr);SetIndexStyle(3,DRAW_ARROW);SetIndexArrow(3,108); + } +//+------------------------------------------------------------------+ +void mail(string c){ + if(IsTesting()==false&&IsOptimization()==false&&IsVisualMode()==false){ + SendMail(WindowExpertName(),c);}} +//+------------------------------------------------------------------+ +void Signal(string c){ + if(IsTesting()==false&&IsOptimization()==false&&IsVisualMode()==false){ + if(alert)Alert("New signal "+c); + if(email)mail("New signal "+c);}} +//+------------------------------------------------------------------+ +void object(string Nm,string Tx,int Sz,string Shr,color Col,int Y,int X,int W) + { + ObjectCreate(Nm,OBJ_LABEL,0,0,0); //создаем объект + ObjectSetText(Nm,Tx,Sz,Shr,Col); //указываем что это текстовый и вводим параметры + ObjectSet(Nm,OBJPROP_YDISTANCE,Y); //устанавливаем Y -координату + ObjectSet(Nm,OBJPROP_XDISTANCE,X); //устанавливаем X -координату + ObjectSet(Nm,OBJPROP_CORNER,W); //устанавливаем угол привязки + if(Shr!="Arial")ObjectSet(Nm,OBJPROP_BACK,true); //устанавливаем фон или обычный объект + } +//+------------------------------------------------------------------+ +int start() +{ + object("Time",TimeToStr(TimeCurrent()),9,"Arial",White ,20,20,1); + if(TimeCurrent()0;i--) + { + CCI=iCCI(NULL,0,PeriodCCI,PRICE_TYPICAL,i); + ATR=iATR(NULL,0,PeriodATR,i); +//+---------- + if(CCI>0&&Low[i]-ATR>Bf)Bf=Low[i]-ATR; + if(CCI<0&&High[i]+ATR0)fr[i]=iFractals(NULL,0,1,i); + if(fractals&&iFractals(NULL,0,2,i)>0)fr[i]=iFractals(NULL,0,2,i); +//+---------- + if(i0){TrendUp[i]=Bf;} + if(CCI<0){TrendDown[i]=Bf;} + }} + if(TrendUp[1]<1000)if(tr==2||tr==0){tr=1;Signal("Current Trend: UP");ObjectDelete("Trend");object("Trend","Current Trend: UP",9,"Arial",LawnGreen ,40,20,1);} + if(TrendDown[1]<1000)if(tr==1||tr==0){tr=2;Signal("Current Trend: DW");ObjectDelete("Trend");object("Trend","Current Trend: DW",9,"Arial",OrangeRed ,40,20,1);} + } +//+------------------------------------------------------------------+ +void deinit(){ObjectDelete("Time");ObjectDelete("Trend");} +//+------------------------------------------------------------------+ + diff --git a/KijunTenkan+.mq4 b/KijunTenkan+.mq4 new file mode 100644 index 0000000..c40a94e --- /dev/null +++ b/KijunTenkan+.mq4 @@ -0,0 +1,125 @@ +//+------------------------------------------------------------------+ +//| Ichimoku.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| Copyright © 2004, AlexSilver в плане + | +//| http://www.metaquotes.net/ | +//| http://www.viac.ru/ | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, AlexSilver в плане +" +#property link "http://www.viac.ru/" + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 Red +#property indicator_color2 Blue +//---- input parameters +extern int Tenkan=9; +extern int Kijun=26; +extern int TenkanShift=3; +extern int KijunShift=9; +//---- buffers +double Tenkan_Buffer[]; +double Kijun_Buffer[]; +//---- +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- Вывод Tenkan-sen + SetIndexStyle(0,DRAW_LINE); + SetIndexBuffer(0,Tenkan_Buffer); + SetIndexDrawBegin(0,Tenkan+TenkanShift-1); + SetIndexShift(0,TenkanShift); + SetIndexLabel(0,"Tenkan Sen"); +//---- Вывод Kijun-sen + SetIndexStyle(1,DRAW_LINE); + SetIndexBuffer(1,Kijun_Buffer); + SetIndexDrawBegin(1,Kijun+KijunShift-1); + SetIndexShift(1,KijunShift); + SetIndexLabel(1,"Kijun Sen"); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Ichimoku Kinko Hyo | +//+------------------------------------------------------------------+ +int start() + { + int i,k; + int counted_bars=IndicatorCounted(); + double high,low,price; +//---- + if(Bars<=Tenkan || Bars<=Kijun) return(0); +//---- initial zero + if(counted_bars<1) + { + for(i=1;i<=Tenkan;i++) Tenkan_Buffer[Bars-i]=0; + for(i=1;i<=Kijun;i++) Kijun_Buffer[Bars-i]=0; + } +//---- Tenkan Sen + i=Bars-Tenkan; + if(counted_bars>Tenkan) i=Bars-counted_bars-1; + while(i>=0) + { + high=High[i]; low=Low[i]; k=i-1+Tenkan; + while(k>=i) + { + price=High[k]; + if(highprice) low=price; + k--; + } + Tenkan_Buffer[i+TenkanShift]=(high+low)/2; + i--; + } i=TenkanShift-1; + while(i>=0) + { + high=High[0]; low=Low[0]; k=Tenkan-TenkanShift+i; + while(k>=0) + { + price=High[k]; + if(highprice) low=price; + k--; + } + Tenkan_Buffer[i]=(high+low)/2; + i--; + } +//---- Kijun Sen + i=Bars-Kijun; + if(counted_bars>Kijun) i=Bars-counted_bars-1; + while(i>=0) + { + high=High[i]; low=Low[i]; k=i-1+Kijun; + while(k>=i) + { + price=High[k]; + if(highprice) low=price; + k--; + } + Kijun_Buffer[i+KijunShift]=(high+low)/2; + i--; + } i=KijunShift-1; + while(i>=0) + { + high=High[0]; low=Low[0]; k=Kijun-KijunShift+i; + while(k>=0) + { + price=High[k]; + if(highprice) low=price; + k--; + } + Kijun_Buffer[i]=(high+low)/2; + i--; + } +//---- + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/MTF_Waddah_Attar_ExplosionSA.mq4 b/MTF_Waddah_Attar_ExplosionSA.mq4 new file mode 100644 index 0000000..3415009 --- /dev/null +++ b/MTF_Waddah_Attar_ExplosionSA.mq4 @@ -0,0 +1,253 @@ +//+------------------------------------------------------------------+ +//| MTF CJA Alert MTF_Waddah_Attar_ExplosionSA M2.mq4 ik| +//| standalone Copyright © 2006, MetaQuotes Software Corp. | +//| fxTSD.com http://www.metaquotes.net | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2006, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" +//+------------------------------------------------------------------+ +//| Waddah_Attar_Explosion.mq4 | +//| Copyright © 2006, Eng. Waddah Attar | +//| waddahattar@hotmail.com | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2006, Eng. Waddah Attar" +#property link "waddahattar@hotmail.com" +//---- +#property indicator_separate_window +#property indicator_buffers 4 +#property indicator_color1 Green +#property indicator_color2 Red +#property indicator_color3 Gold +#property indicator_color4 Aqua +#property indicator_minimum 0.0 +#property indicator_width1 2 +#property indicator_width2 2 +#property indicator_width3 1 +#property indicator_width4 1 +//---- +extern int Minutes=0; +extern int Sensetive=150; +extern int DeadZonePip=15; +extern int ExplosionPower=15; +extern int TrendPower=15; +extern bool AlertWindow=false; +extern int AlertCount=20; +extern bool AlertLong=true; +extern bool AlertShort=true; +extern bool AlertExitLong=true; +extern bool AlertExitShort=true; +extern string note_TF_Minutes="5,15,30,60H1,240H4,1440D1,10080W1,43200MN1"; +//---- +double ind_buffer1[]; +double ind_buffer2[]; +double ind_buffer3[]; +double ind_buffer4[]; +//---- +int LastTime1=1; +int LastTime2=1; +int LastTime3=1; +int LastTime4=1; +int Status=0, PrevStatus=-1; +double bask, bbid; +string TimeFrameStr; +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +int init() + { + SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID); + SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID); + SetIndexStyle(2, DRAW_LINE, STYLE_SOLID); + SetIndexStyle(3, DRAW_LINE); +//---- + SetIndexBuffer(0, ind_buffer1); + SetIndexBuffer(1, ind_buffer2); + SetIndexBuffer(2, ind_buffer3); + SetIndexBuffer(3, ind_buffer4); +//---- + IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); + switch(Minutes) + { + case 1 : TimeFrameStr=" Period M1 "; break; + case 5 : TimeFrameStr=" Period M5 "; break; + case 15 : TimeFrameStr=" Period M15 "; break; + case 30 : TimeFrameStr=" Period M30 "; break; + case 60 : TimeFrameStr=" Period H1 "; break; + case 240 : TimeFrameStr=" Period H4 "; break; + case 1440 : TimeFrameStr=" Period D1 "; break; + case 10080 : TimeFrameStr=" Period W1 "; break; + case 43200 : TimeFrameStr=" Period MN1 "; break; + default : TimeFrameStr=" Current TimeFrame "; Minutes=0; + } +//---- + if (Minutes<=Period()) Minutes=Period(); + IndicatorShortName("WadAttExpl:|"+TimeFrameStr+"|[S-" + Sensetive +"][DZ-"+ DeadZonePip +"][EP-"+ ExplosionPower +"][TrP-"+ TrendPower +"])"); + // Comment("copyright waddahwttar@hotmail.com"); + return(0); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +int start() + { + datetime TimeArray[]; + double Trend1, Trend2, Explo1, Explo2, Dead; + double pwrt, pwre; + int limit, i, y=0,counted_bars=IndicatorCounted(); +//---- + ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),Minutes); + if(counted_bars < 0) + return(-1); +//---- + if(counted_bars > 0) + counted_bars--; + //limit = Bars - counted_bars; + limit=Bars-counted_bars+Minutes/Period(); +//---- + // for(i = limit - 1; i >= 0; i--) + for(i=0,y=0;i=0) + ind_buffer1[i]=Trend1; + if(Trend1 < 0) + ind_buffer2[i]=(-1*Trend1); + ind_buffer3[i]=Explo1; + ind_buffer4[i]=Dead; + if(i==0) + { + if(Trend1 > 0 && Trend1 > Explo1 && Trend1 > Dead && + Explo1 > Dead && Explo1 > Explo2 && Trend1 > Trend2 && + LastTime1 < AlertCount && AlertLong==true && Ask!=bask) + { + pwrt=100*(Trend1 - Trend2)/Trend1; + pwre=100*(Explo1 - Explo2)/Explo1; + bask=Ask; + if(pwre>=ExplosionPower && pwrt>=TrendPower) + { + if(AlertWindow==true) + { + Alert("WAE",LastTime1, "- ", Symbol(), " - BUY ", " (", + DoubleToStr(bask, Digits) , ") Trend PWR " , + DoubleToStr(pwrt,0), " - Exp PWR ", DoubleToStr(pwre, 0)); + } + else + { + Print("WAE",LastTime1, "- ", Symbol(), " - BUY ", " (", + DoubleToStr(bask, Digits), ") Trend PWR ", + DoubleToStr(pwrt, 0), " - Exp PWR ", DoubleToStr(pwre, 0)); + } + LastTime1++; + } + Status=1; + } + if(Trend1 < 0 && MathAbs(Trend1) > Explo1 && MathAbs(Trend1) > Dead && + Explo1 > Dead && Explo1 > Explo2 && MathAbs(Trend1) > MathAbs(Trend2) && + LastTime2 < AlertCount && AlertShort==true && Bid!=bbid) + { + pwrt=100*(MathAbs(Trend1) - MathAbs(Trend2))/MathAbs(Trend1); + pwre=100*(Explo1 - Explo2)/Explo1; + bbid=Bid; + if(pwre>=ExplosionPower && pwrt>=TrendPower) + { + if(AlertWindow==true) + { + Alert("WAE",LastTime2, "- ", Symbol(), " - SELL ", " (", + DoubleToStr(bbid, Digits), ") Trend PWR ", + DoubleToStr(pwrt,0), " - Exp PWR ", DoubleToStr(pwre, 0)); + } + else + { + Print("WAE",LastTime2, "- ", Symbol(), " - SELL ", " (", + DoubleToStr(bbid, Digits), ") Trend PWR " , + DoubleToStr(pwrt, 0), " - Exp PWR ", DoubleToStr(pwre, 0)); + } + LastTime2++; + } + Status=2; + } + if(Trend1 > 0 && Trend1 < Explo1 && Trend1 < Trend2 && Trend2 > Explo2 && + Trend1 > Dead && Explo1 > Dead && LastTime3<=AlertCount && + AlertExitLong==true && Bid!=bbid) + { + bbid=Bid; + if(AlertWindow==true) + { + Alert("WAE",LastTime3, "- ", Symbol(), " - Exit BUY ", " ", + DoubleToStr(bbid, Digits)); + } + else + { + Print("WAE",LastTime3, "- ", Symbol(), " - Exit BUY ", " ", + DoubleToStr(bbid, Digits)); + } + Status=3; + LastTime3++; + } + if(Trend1 < 0 && MathAbs(Trend1) < Explo1 && + MathAbs(Trend1) < MathAbs(Trend2) && MathAbs(Trend2) > Explo2 && + Trend1 > Dead && Explo1 > Dead && LastTime4<=AlertCount && + AlertExitShort==true && Ask!=bask) + { + bask=Ask; + if(AlertWindow==true) + { + Alert("WAE",LastTime4, "- ", Symbol(), " - Exit SELL ", " ", + DoubleToStr(bask, Digits)); + } + else + { + Print("WAE",LastTime4, "- ", Symbol(), " - Exit SELL ", " ", + DoubleToStr(bask, Digits)); + } + Status=4; + LastTime4++; + } + PrevStatus=Status; + } + if(Status!=PrevStatus) + { + LastTime1=1; + LastTime2=1; + LastTime3=1; + LastTime4=1; + } + } +//---- Refresh buffers +++++++++++++++++++++++++ Raff + if (Minutes>Period()) + { + int PerINT=Minutes/Period()+1; + datetime TimeArr[]; ArrayResize(TimeArr,PerINT); + ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); + for(i=0;i=TimeArray[0]) + { + /******************************************************** + Refresh buffers: buffer[i] = buffer[0]; + ********************************************************/ + ind_buffer1[i]=ind_buffer1[0]; + ind_buffer2[i]=ind_buffer2[0]; + ind_buffer3[i]=ind_buffer3[0]; + ind_buffer4[i]=ind_buffer4[0]; + } + } + } +//++++++++++++++++++++++++++++++++++++++++ upgrade by Raff + return(0); + } +//+------------------------------------------------------------------+ + diff --git a/Magnified Market Price.mq4 b/Magnified Market Price.mq4 new file mode 100644 index 0000000..947d5fe --- /dev/null +++ b/Magnified Market Price.mq4 @@ -0,0 +1,50 @@ +//+------------------------------------------------------------------+ +//| Magnified Market Price.mq4 ver1.4 by Habeeb | +//+------------------------------------------------------------------+ + +#property indicator_chart_window + + extern string note1 = "Change font colors automatically? True = Yes"; + extern bool Bid_Ask_Colors = False; + extern string note2 = "Default Font Color"; + extern color FontColor = Brown; + extern string note3 = "Font Size"; + extern int FontSize=20; + extern string note4 = "Font Type"; + extern string FontType="Tahoma"; + extern string note5 = "Display the price in what corner?"; + extern string note6 = "Upper left=0; Upper right=1"; + extern string note7 = "Lower left=2; Lower right=3"; + extern int WhatCorner=1; + + double Old_Price; + +int init() + { + return(0); + } + +int deinit() + { + ObjectDelete("Market_Price_Label"); + + return(0); + } + +int start() + { + if (Bid_Ask_Colors == True) + { + if (Bid > Old_Price) FontColor = LawnGreen; + if (Bid < Old_Price) FontColor = Red; + Old_Price = Bid; + } + + string Market_Price = DoubleToStr(Bid, Digits); + + ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Market_Price_Label", Market_Price, FontSize, FontType, FontColor); + ObjectSet("Market_Price_Label", OBJPROP_CORNER, WhatCorner); + ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 1); + ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, 1); + } \ No newline at end of file diff --git a/Master.mq4 b/Master.mq4 new file mode 100644 index 0000000..8c578cb --- /dev/null +++ b/Master.mq4 @@ -0,0 +1,34 @@ +string gs_76 = ""; +string gs_84 = ""; + +int init() { + gs_84 = Symbol(); + return (0); +} + +int deinit() { + return (0); +} + +int start() { + double l_ask_0 = MarketInfo(Symbol(), MODE_ASK); + double l_bid_8 = MarketInfo(Symbol(), MODE_BID); + double ld_16 = l_bid_8 + (l_ask_0 - l_bid_8) / 2.0; + log("" + ld_16); + return (0); +} + +void log(string as_0) { + int li_12 = TimeLocal(); + li_12 -= 18000; + string ls_16 = ""; + ls_16 = "" + TimeYear(li_12); + ls_16 = ls_16 + "-" + TimeMonth(li_12); + ls_16 = ls_16 + "-" + TimeDay(li_12); + int l_file_8 = FileOpen(gs_76 + "\\" + "log__" + StringSubstr(gs_84, 0, 6) + "_" + ls_16 + ".csv", FILE_CSV|FILE_WRITE|FILE_READ, ';'); + if (l_file_8 > 0) { + FileSeek(l_file_8, 0, SEEK_END); + FileWrite(l_file_8, ls_16 + " " + TimeHour(li_12) + ":" + TimeMinute(li_12) + ":" + TimeSeconds(li_12), as_0); + FileClose(l_file_8); + } +} diff --git a/MedianRChart.mq4 b/MedianRChart.mq4 new file mode 100644 index 0000000..7e51335 --- /dev/null +++ b/MedianRChart.mq4 @@ -0,0 +1,364 @@ + +#property copyright "Copyright © 2010-2012, NiX" +#property link "http://www.az-invest.eu" + +#property indicator_chart_window +#property indicator_buffers 1 +#property indicator_color1 Black + +#import "MedianRenkoEngine.dll" + int initDLL(int a0, int a1); + string getDLLVer(int a0); + int updateDW(int a0); + int updateT1(int a0, int a1); + int processHistoryBar4RenkoMedian(double a0, double& a1[], double& a2[], double& a3[], double& a4[], int a5); +#import + +extern double RenkoBoxSizeInPips = 10.0; +extern int OfflineTimeFrame = 3; +extern bool resetOpenOnNewSession = TRUE; +extern int session_start_MM = 0; +extern int session_start_HH = 0; +extern int RenderUsing1MhistoryBars = 0; +extern bool RefreshChartOnAskPriceChange = FALSE; +extern bool RefreshOnHistoryUpdates = FALSE; +extern bool UseSoundSignalOnNewBar = FALSE; +extern bool DisableComment = FALSE; +extern string SoundFile = "clock_tick.wav"; +int g_file_128 = -1; +int gi_unused_132 = 0; +int gi_unused_136 = 0; +double g_iclose_140 = 0.0; +double g_iclose_148 = 0.0; +double g_iclose_156 = 0.0; +double g_iclose_164 = 0.0; +double gd_172 = 0.0; +double gda_180[5] = {0, 0, 0, 0, 0}; +string g_dbl2str_184 = "1.0"; +int gi_192; +int gi_196 = 0; +int gi_200 = 400; +string gs_204; +string gs_212; +int gi_220; +int g_digits_224; +int gia_228[13]; +double gd_232 = 0.0; +double g_iclose_240; +double gd_248 = 0.0; +bool gi_256 = FALSE; +bool gi_260 = FALSE; +bool gi_264 = FALSE; +bool gi_unused_268 = FALSE; +int gi_272 = 0; +int gi_276 = 0; +string g_name_280 = "RB_title"; +string g_name_288 = "RB_underline"; +int gi_296 = 20; +string gsa_300[20] = {"RB_aux1", "RB_aux2", "RB_aux3", "RB_aux4", "RB_aux5", "RB_aux6", "RB_aux7", "RB_aux8", "RB_aux9", "RB_aux10", "RB_aux11", "RB_aux12", "RB_aux13", "RB_aux14", "RB_aux15", + "RB_aux16", "RB_aux17", "RB_aux18", "RB_aux19", "RB_aux20"}; +bool gi_unused_304 = FALSE; +double g_iclose_308; +bool gi_316 = FALSE; +int gi_320; + +double f0_4() { + double lda_0[6] = {1, 10, 100, 1000, 10000, 100000}; + if (Digits > 0) return (0.1 / (lda_0[Digits - 1])); + if (Digits == 0) return (1); + return (0.0); +} + +int init() { + string ls_4; + int li_ret_0 = initDLL(0, WindowHandle(Symbol(), Period())); + if (li_ret_0 == 0) { + Alert("Plug-in not activated or trial period over..."); + gi_264 = TRUE; + return (li_ret_0); + } + if (li_ret_0 == 1) { + ls_4 = getDLLVer(3); + if (ls_4 == "20120818.1") { + Print("MedianRenko Plug-in " + "1.04 " + " [" + getDLLVer(3) + "] initialized (OK)"); + gi_264 = FALSE; + } else { + Alert("Error - Incorrect DLL Version!"); + gi_264 = TRUE; + return (0); + } + } + return (0); +} + +int f0_5(string as_unused_0 = "", int ai_unused_8 = 0) { + g_dbl2str_184 = DoubleToStr(RenkoBoxSizeInPips, 1); + if (Digits % 2 > 0) RenkoBoxSizeInPips = 10.0 * RenkoBoxSizeInPips; + if (f0_4() != MarketInfo(Symbol(), MODE_TICKSIZE)) RenkoBoxSizeInPips /= MarketInfo(Symbol(), MODE_TICKSIZE); + if (!DisableComment) { + if (ObjectFind(g_name_280) == -1) ObjectCreate(g_name_280, OBJ_LABEL, 0, 0, 0); + if (ObjectFind(g_name_288) == -1) ObjectCreate(g_name_288, OBJ_LABEL, 0, 0, 0); + ObjectSetText(g_name_280, "MedianRenko Plugin v" + "1.04 " + " for MT4 (c)2012 NiX", 11, "Terminal", RoyalBlue); + ObjectSet(g_name_280, OBJPROP_CORNER, 0); + ObjectSet(g_name_280, OBJPROP_XDISTANCE, 5); + ObjectSet(g_name_280, OBJPROP_YDISTANCE, 20); + ObjectSetText(g_name_288, "______________________________________________", 11, "Terminal", Blue); + ObjectSet(g_name_288, OBJPROP_CORNER, 0); + ObjectSet(g_name_288, OBJPROP_XDISTANCE, 5); + ObjectSet(g_name_288, OBJPROP_YDISTANCE, 25); + } + gs_212 = Symbol(); + gi_220 = OfflineTimeFrame; + g_digits_224 = Digits; + switch (OfflineTimeFrame) { + case 0: + case 1: + case 5: + case 15: + case 30: + case 60: + case 240: + case 1440: + case 10080: + case 43200: + Alert(OfflineTimeFrame + " is a Metatrader4 reserver time frame. Please choose a different value (i.e. 2,3,4,6,7,8,9,10.... Exiting..."); + gi_260 = TRUE; + return (0); + } + if (!IsDllsAllowed()) Alert("The live renko feed will not work if DLL calls are disabled!"); + if (!DisableComment) { + while (ObjectFind(gsa_300[gi_276]) == 0) gi_276++; + if (gi_276 >= gi_296) { + Alert("Plug-in limit reached. Exiting..."); + gi_260 = TRUE; + return (0); + } + ObjectCreate(gsa_300[gi_276], OBJ_LABEL, 0, 0, 0); + ObjectSetText(gsa_300[gi_276], g_dbl2str_184 + " pip renko bars @ offline " + Symbol() + ",M" + OfflineTimeFrame, 11, "Terminal", Gray); + ObjectSet(gsa_300[gi_276], OBJPROP_CORNER, 0); + ObjectSet(gsa_300[gi_276], OBJPROP_XDISTANCE, 5); + ObjectSet(gsa_300[gi_276], OBJPROP_YDISTANCE, 13 * gi_276 + 40); + } + DisableComment = TRUE; + gd_232 = NormalizeDouble(RenkoBoxSizeInPips * Point, Digits); + if (RenkoBoxSizeInPips <= 0.0) return (0); + gi_256 = FALSE; + return (f0_7()); +} + +int deinit() { + if (g_file_128 >= 0) { + FileClose(g_file_128); + g_file_128 = -1; + } + int count_0 = 0; + for (int index_4 = 0; index_4 < gi_296; index_4++) + if (ObjectFind(gsa_300[index_4]) == 0) count_0++; + ObjectDelete(gsa_300[gi_276]); + if (count_0 == 1) { + ObjectDelete(g_name_280); + ObjectDelete(g_name_288); + } + if (gi_264 == TRUE) Comment(""); + return (0); +} + +int f0_7() { + int datetime_8; + if (g_file_128 >= 0) { + FileFlush(g_file_128); + FileClose(g_file_128); + g_file_128 = -1; + gi_unused_132 = 0; + } + g_file_128 = FileOpenHistory(gs_212 + gi_220 + ".hst", FILE_BIN|FILE_WRITE); + if (g_file_128 < 0) return (-1); + gs_204 = "(C)opyright 2011, NiX"; + FileWriteInteger(g_file_128, gi_200, LONG_VALUE); + FileWriteString(g_file_128, gs_204, 64); + FileWriteString(g_file_128, gs_212, 12); + FileWriteInteger(g_file_128, gi_220, LONG_VALUE); + FileWriteInteger(g_file_128, g_digits_224, LONG_VALUE); + FileWriteInteger(g_file_128, 0, LONG_VALUE); + FileWriteInteger(g_file_128, 0, LONG_VALUE); + FileWriteArray(g_file_128, gia_228, 0, 13); + FileFlush(g_file_128); + gda_180[0] = 0; + gda_180[1] = 0; + gda_180[2] = 0; + gda_180[3] = 0; + gda_180[4] = 0; + gi_196 = FALSE; + f0_3(); + int li_0 = 0; + int li_4 = iBars(Symbol(), PERIOD_M1); + if (li_4 > RenderUsing1MhistoryBars) { + if (RenderUsing1MhistoryBars == 0) li_0 = li_4; + else li_0 = RenderUsing1MhistoryBars; + } else li_0 = li_4; + li_0--; + for (gi_192 = li_0; gi_192 > 0; gi_192--) { + gd_248 += iVolume(Symbol(), PERIOD_M1, gi_192); + datetime_8 = iTime(Symbol(), Period(), gi_192); + if (resetOpenOnNewSession) { + if (f0_2(datetime_8)) { + f0_0(datetime_8, g_iclose_140, g_iclose_148, g_iclose_156, g_iclose_164, gd_172, 1); + f0_3(); + } + } + f0_1(datetime_8, iOpen(Symbol(), PERIOD_M1, gi_192), iLow(Symbol(), PERIOD_M1, gi_192), iHigh(Symbol(), PERIOD_M1, gi_192), iClose(Symbol(), PERIOD_M1, gi_192), gd_248, + 1); + } + RefreshRates(); + gi_256 = TRUE; + gi_260 = FALSE; + gd_248 += iVolume(Symbol(), PERIOD_M1, 0); + f0_1(iTime(Symbol(), PERIOD_M1, 0), iOpen(Symbol(), PERIOD_M1, 0), iLow(Symbol(), PERIOD_M1, 0), iHigh(Symbol(), PERIOD_M1, 0), iClose(Symbol(), PERIOD_M1, 0), gd_248, + 1); + updateDW(WindowHandle(gs_212, OfflineTimeFrame)); + return (100); +} + +int start() { + int datetime_4; + if (gi_272 != 100 || gi_260 || gi_264) { + if (gi_264) return (-4); + gi_272 = f0_5(); + if (gi_272 != 100) return (-2); + if (gi_260) return (-3); + } + int ind_counted_0 = IndicatorCounted(); + if (ind_counted_0 < 0) return (-1); + if (ind_counted_0 == 0) { + if (RefreshOnHistoryUpdates == TRUE) { + Print("More history downloaded - resynchronizing with market"); + gi_256 = FALSE; + gi_196 = FALSE; + gi_316 = TRUE; + } + } + if (gi_316 == TRUE) { + f0_7(); + gi_316 = FALSE; + return (-1); + } + g_iclose_308 = iClose(Symbol(), PERIOD_M1, 0); + if (g_iclose_240 != g_iclose_308) { + g_iclose_240 = g_iclose_308; + if (g_iclose_140 != 0.0) { + if (g_iclose_156 < g_iclose_308) g_iclose_156 = g_iclose_308; + if (g_iclose_148 > g_iclose_308) g_iclose_148 = g_iclose_308; + g_iclose_164 = g_iclose_308; + gd_172 += 1.0; + } else { + g_iclose_156 = g_iclose_308; + g_iclose_148 = g_iclose_308; + g_iclose_140 = g_iclose_308; + g_iclose_164 = g_iclose_308; + gd_172 = 1; + } + datetime_4 = iTime(Symbol(), Period(), 0); + if (resetOpenOnNewSession) { + if (f0_2(datetime_4)) { + f0_0(datetime_4, g_iclose_140, g_iclose_148, g_iclose_156, g_iclose_164, gd_172, 1); + f0_3(); + } + } + f0_1(datetime_4, g_iclose_140, g_iclose_148, g_iclose_156, g_iclose_164, gd_172, 1); + updateDW(WindowHandle(gs_212, OfflineTimeFrame)); + } else + if (RefreshChartOnAskPriceChange) updateDW(WindowHandle(gs_212, OfflineTimeFrame)); + return (0); +} + +void f0_0(int ai_0, double ad_4, double ad_12, double ad_20, double ad_28, double ad_36, int ai_44) { + int li_48; + if (g_file_128 >= 0) { + if (ai_44 == 1) { + li_48 = updateT1(ai_0, gi_196); + FileSeek(g_file_128, 0, SEEK_END); + FileWriteInteger(g_file_128, li_48, LONG_VALUE); + gi_196 = li_48; + } else FileSeek(g_file_128, -40, SEEK_END); + FileWriteDouble(g_file_128, ad_4, DOUBLE_VALUE); + FileWriteDouble(g_file_128, ad_12, DOUBLE_VALUE); + FileWriteDouble(g_file_128, ad_20, DOUBLE_VALUE); + FileWriteDouble(g_file_128, ad_28, DOUBLE_VALUE); + FileWriteDouble(g_file_128, ad_36, DOUBLE_VALUE); + FileFlush(g_file_128); + if (ai_44 == 1 && gi_256 && UseSoundSignalOnNewBar == TRUE) { + if (SoundFile == "alert_box") Alert("New bar on " + g_dbl2str_184 + "pip chart for " + Symbol()); + else PlaySound(SoundFile); + } + } +} + +void f0_6(double a_iclose_0, double a_iclose_8, double a_iclose_16, double a_iclose_24, double ad_32) { + g_iclose_140 = a_iclose_0; + g_iclose_148 = a_iclose_8; + g_iclose_156 = a_iclose_16; + g_iclose_164 = a_iclose_24; + gd_172 = ad_32; +} + +void f0_3() { + g_iclose_140 = 0; + g_iclose_148 = 0; + g_iclose_156 = 0; + g_iclose_164 = 0; + gd_172 = 0; +} + +int f0_1(int ai_0, double ad_4, double ad_12, double ad_20, double ad_28, double ad_36, int ai_44) { + double lda_48[5] = {0, 0, 0, 0, 0}; + lda_48[0] = ad_4; + lda_48[1] = ad_12; + lda_48[2] = ad_20; + lda_48[3] = ad_28; + lda_48[4] = ad_36; + double lda_52[5] = {0, 0, 0, 0, 0}; + lda_52[0] = g_iclose_140; + lda_52[1] = g_iclose_148; + lda_52[2] = g_iclose_156; + lda_52[3] = g_iclose_164; + lda_52[4] = gd_172; + double lda_56[5] = {0, 0, 0, 0, 0}; + int li_60 = processHistoryBar4RenkoMedian(gd_232, lda_48, gda_180, lda_52, lda_56, ai_44); + while (true) { + if (li_60 >= 1 && li_60 <= 4) { + f0_0(ai_0, lda_56[0], lda_56[1], lda_56[2], lda_56[3], lda_56[4], 0); + f0_6(lda_52[0], lda_52[1], lda_52[2], lda_52[3], lda_52[4]); + f0_0(ai_0, lda_52[0], lda_52[1], lda_52[2], lda_52[3], lda_52[4], 1); + lda_48[0] = g_iclose_140; + lda_48[1] = g_iclose_148; + lda_48[2] = g_iclose_156; + lda_48[3] = g_iclose_164; + lda_48[4] = 1; + li_60 = processHistoryBar4RenkoMedian(gd_232, lda_48, gda_180, lda_52, lda_56, 0); + continue; + } + if (li_60 == 10) { + f0_6(lda_52[0], lda_52[1], lda_52[2], lda_52[3], lda_52[4]); + f0_0(ai_0, lda_56[0], lda_56[1], lda_56[2], lda_56[3], lda_56[4], 0); + gd_248 = lda_52[4]; + return (1); + } + if (li_60 == 11) { + Alert("debug = return 11"); + continue; + } + if (li_60 != -1) break; + Alert("debug = return -1"); + } + return (1); +} + +int f0_2(int ai_0) { + RefreshRates(); + if (TimeHour(ai_0) != session_start_HH || TimeMinute(ai_0) != session_start_MM) return (0); + if (gi_320 != ai_0) { + gi_320 = ai_0; + return (1); + } + return (0); +} \ No newline at end of file diff --git a/MedianRinfo.mq4 b/MedianRinfo.mq4 new file mode 100644 index 0000000..34a2721 --- /dev/null +++ b/MedianRinfo.mq4 @@ -0,0 +1,92 @@ + +#property copyright "Copyright 2012, AZ-iNVEST" +#property link "http://www.az-invest.eu" + +#property indicator_chart_window + +#import "MedianRenkoEngine.dll" + string getDLLVer(int a0); +#import + +int gi_76 = 4; +double gd_80 = -1.0; + +int init() { + double ld_12; + if (getDLLVer(3) != "20120818.1") return (0); + switch (Period()) { + case 0: + case PERIOD_M1: + case PERIOD_M5: + case PERIOD_M15: + case PERIOD_M30: + case PERIOD_H1: + case PERIOD_H4: + case PERIOD_D1: + case PERIOD_W1: + case PERIOD_MN1: + return (0); + } + double point_4 = MarketInfo(Symbol(), MODE_POINT); + if (gi_76 == 4) gd_80 = MathAbs(iOpen(Symbol(), Period(), 1) - iClose(Symbol(), Period(), 1)); + else gd_80 = -1; + if (gd_80 != -1.0) { + ld_12 = gd_80 / Point; + if (Digits % 2 > 0) ld_12 /= 10.0; + ObjectCreate("hThreshold", OBJ_ARROW, 0, iTime(Symbol(), Period(), 0), 0); + ObjectCreate("lThreshold", OBJ_ARROW, 0, iTime(Symbol(), Period(), 0), 0); + ObjectSet("hThreshold", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); + ObjectSet("lThreshold", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); + ObjectSet("hThreshold", OBJPROP_COLOR, Lime); + ObjectSet("lThreshold", OBJPROP_COLOR, Red); + ObjectCreate("hThresholdOpen", OBJ_TREND, 0, iTime(Symbol(), Period(), 0), 0, iTime(Symbol(), Period(), 1), 0); + ObjectCreate("lThresholdOpen", OBJ_TREND, 0, iTime(Symbol(), Period(), 0), 0, iTime(Symbol(), Period(), 1), 0); + ObjectSet("hThresholdOpen", OBJPROP_COLOR, Lime); + ObjectSet("lThresholdOpen", OBJPROP_COLOR, Red); + ObjectSet("hThresholdOpen", OBJPROP_RAY, FALSE); + ObjectSet("lThresholdOpen", OBJPROP_RAY, FALSE); + ObjectCreate("QuantumBarValue", OBJ_LABEL, 0, 0, 0); + ObjectSetText("QuantumBarValue", "Median Renko " + DoubleToStr(ld_12, 1) + " pip(s)", 8, "Segoe UI", Gray); + ObjectSet("QuantumBarValue", OBJPROP_CORNER, 3); + ObjectSet("QuantumBarValue", OBJPROP_XDISTANCE, 5); + ObjectSet("QuantumBarValue", OBJPROP_YDISTANCE, 5); + } + return (0); +} + +int deinit() { + ObjectDelete("hThreshold"); + ObjectDelete("lThreshold"); + ObjectDelete("hThresholdOpen"); + ObjectDelete("lThresholdOpen"); + ObjectDelete("QuantumBarValue"); + return (0); +} + +int start() { + double ld_0; + double ld_8; + double ld_16; + double ld_24; + f0_0(ld_0, ld_8, ld_16, ld_24); + ObjectMove("hThreshold", 0, iTime(Symbol(), Period(), 0), ld_0); + ObjectMove("lThreshold", 0, iTime(Symbol(), Period(), 0), ld_8); + ObjectMove("hThresholdOpen", 0, iTime(Symbol(), Period(), 0), ld_16); + ObjectMove("hThresholdOpen", 1, iTime(Symbol(), Period(), 1), ld_16); + ObjectMove("lThresholdOpen", 0, iTime(Symbol(), Period(), 0), ld_24); + ObjectMove("lThresholdOpen", 1, iTime(Symbol(), Period(), 1), ld_24); + return (0); +} + +double f0_0(double &ad_0, double &ad_8, double &ad_unused_16, double &ad_unused_24) { + if (gi_76 == 4) { + if (iOpen(Symbol(), Period(), 1) - iClose(Symbol(), Period(), 1) > 0.0) { + ad_0 = iOpen(Symbol(), Period(), 0) + gd_80; + ad_8 = iOpen(Symbol(), Period(), 0) - gd_80; + } else { + ad_0 = iOpen(Symbol(), Period(), 0) + gd_80; + ad_8 = iOpen(Symbol(), Period(), 0) - gd_80; + } + } + return (0.0); +} \ No newline at end of file diff --git a/New [EA] Sniper-educated.mq4 b/New [EA] Sniper-educated.mq4 new file mode 100644 index 0000000..54f532d --- /dev/null +++ b/New [EA] Sniper-educated.mq4 @@ -0,0 +1,345 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2009, Okadafx" +#property link "dollarsniper@yahoo.com" + +#include + +extern string t = "Trade Lots, if Lots=0 -> automatic Lot with MM %"; +extern double Lots = 0.01; +extern bool MMMini = FALSE; +extern bool MMStandard = FALSE; +extern string Multi0 = "Trade MultiLots 0 -> (auto lots)"; +extern string Multi1 = "Trade MultiLots 1 -> all lots would be multiplied by 1 and so they would be the same size."; +extern string Multi2 = "Trade MultiLots 2 -> all new lots would be doubled."; +extern string Multi3 = "Trade MultiLots 3 -> all new lots would be triple."; +extern int Multilots = 0; +string gs_unused_136 = "If Trail Active TakeProfit Must + 10 pips"; +string gs_unused_144 = "If Trail Not Active TakeProfit Must Default 33 pips"; +bool gi_152 = FALSE; +int gi_156 = 0; +extern int MaxTrades = 8; +extern int Range = 30; +extern int TakeProfit = 33; +extern int StopLoss = 0; +extern bool Pending = TRUE; +extern bool Hedge = TRUE; +extern bool Reverse = FALSE; +int g_slippage_188 = 3; +extern bool UseSignal = TRUE; +string gs_unused_196 = "set true for profit target in USD"; +bool gi_204 = TRUE; +double gd_208 = 2.0; +string gs_unused_216 = "set true for close in profit/loss"; +bool gi_224 = FALSE; +int g_magic_228; +int gi_232; +int gi_236; +int gi_240; +int gi_244; +int gi_248; +int gi_252; +int gi_256; +int gi_260; +int g_ord_total_272 = 999999; +double gd_276; +double g_ord_lots_284; +double g_ord_lots_292; +double g_lots_300; +double gd_308; +int gi_316; +int gi_320; + +int init() { + if (Multilots == 0) gd_308 = 2.222; + if (Multilots == 1) gd_308 = 1; + if (Multilots == 2) gd_308 = 2; + if (Multilots == 3) gd_308 = 3; + if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") g_magic_228 = 801001; + if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") g_magic_228 = 801002; + if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") g_magic_228 = 801003; + if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") g_magic_228 = 801004; + if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") g_magic_228 = 801005; + if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") g_magic_228 = 801006; + if (Symbol() == "EURCADm" || Symbol() == "EURCAD") g_magic_228 = 801007; + if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") g_magic_228 = 801008; + if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") g_magic_228 = 801009; + if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") g_magic_228 = 801010; + if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") g_magic_228 = 801011; + if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") g_magic_228 = 801012; + if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") g_magic_228 = 801013; + if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") g_magic_228 = 801014; + if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") g_magic_228 = 801015; + if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") g_magic_228 = 801016; + if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") g_magic_228 = 801017; + if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") g_magic_228 = 801018; + if (Symbol() == "USDCADm" || Symbol() == "USDCAD") g_magic_228 = 801019; + return (0); +} + +int deinit() { + return (0); +} + +int start() { + int l_ticket_28; + int l_ticket_32; + double l_price_36; + double l_price_44; + double l_price_52; + double l_price_60; + string ls_0 = "http://bestforexsniper.com"; + string ls_unused_8 = "[EA]Sniper XX"; + bool l_bool_16 = IsDemo(); + /* if (!l_bool_16) { + Alert("You can not use the program with a real account!.", + "\n", "Please contact: " + ls_0); + return (0); + } + */ + ObjectsDeleteAll(); + if (MMMini == TRUE) { + Lots = AccountFreeMargin() / 50000.0; + if (Lots < 0.01) Lots = 0.01; + } + if (MMStandard == TRUE) { + Lots = AccountFreeMargin() / 500000.0; + if (Lots < 0.01) Lots = 0.01; + } + if (gi_204 && OrdersTotal() < 1) gi_320 = AccountBalance() * ((gd_208 + 100.0) / 100.0); + if (gi_224 == TRUE) { + if (MessageBox("Do you really want to close all trades?", "Script", MB_YESNO|MB_ICONQUESTION) != IDYES) return (1); + while (OrdersTotal() > 0) { + if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, CLR_NONE); + if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); + } + } + return (0); + } + if (gi_204 == TRUE && gi_320 > 0 && AccountBalance() > gi_320 && AccountEquity() > gi_320) { + while (OrdersTotal() > 0) { + if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, CLR_NONE); + if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); + Print("Close in DailyBalanceTarget :", GetLastError()); + return (0); + } + } + } + if (AccountProfit() >= 500.0 * AccountFreeMargin() / 10000.0) { + while (OrdersTotal() > 0) { + if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 3, CLR_NONE); + if (OrderType() != OP_BUY && OrderType() != OP_SELL) OrderDelete(OrderTicket()); + Print("Close All Profit :", GetLastError()); + return (0); + } + } + } + if (gi_152) { + gi_316 = TakeProfit - 10; + for (int l_ord_total_20 = OrdersTotal(); l_ord_total_20 >= 0; l_ord_total_20--) { + OrderSelect(l_ord_total_20, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_228) { + if (OrderType() == OP_SELL) { + if (gi_316 > 0.0) { + if (OrderOpenPrice() - Ask >= gi_316 * Point) { + if (OrderStopLoss() > Ask + Point * gi_316) { + OrderModify(OrderTicket(), OrderOpenPrice(), Ask + 10.0 * Point, OrderClosePrice() - TakeProfit * Point - 10.0 * Point, 800, Purple); + Print("Modify StopLoss :", GetLastError()); + return (0); + } + } + } + } + if (OrderType() == OP_BUY) { + if (gi_316 > 0.0) { + if (Bid - OrderOpenPrice() >= gi_316 * Point) { + if (OrderStopLoss() < Bid - Point * gi_316) { + OrderModify(OrderTicket(), OrderOpenPrice(), Bid - 10.0 * Point, OrderClosePrice() + TakeProfit * Point + 10.0 * Point, 800, Yellow); + Print("Modify StopLoss :", GetLastError()); + return (0); + } + } + } + } + } + } + } + if (g_ord_total_272 == 999999) { + if (iBars(NULL, PERIOD_H1) < 30) { + Print("waiting - bars less than ", 30); + return (0); + } + } + Check(); + if (OrdersTotal() != g_ord_total_272) { + g_ord_total_272 = OrdersTotal(); + if (gi_256 > gi_240 + gi_248) { + gi_232 = -1; + Check(); + gi_236 = TimeCurrent() + 30; + Check(); + return (-1); + } + if (gi_260 > gi_244 + gi_252) { + gi_232 = 1; + Check(); + gi_236 = TimeCurrent() + 30; + Check(); + return (-1); + } + if (Lots > 0.0) g_lots_300 = Lots; + else g_lots_300 = gi_156 / 100.0 * AccountFreeMargin() / MarketInfo(Symbol(), MODE_MARGINREQUIRED); + if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.01) g_lots_300 = NormalizeDouble(g_lots_300, 2); + if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.1) g_lots_300 = NormalizeDouble(g_lots_300, 1); + if (MarketInfo(Symbol(), MODE_LOTSTEP) == 1.0) g_lots_300 = NormalizeDouble(g_lots_300, 0); + if (g_lots_300 < MarketInfo(Symbol(), MODE_MINLOT)) g_lots_300 = MarketInfo(Symbol(), MODE_MINLOT); + if (g_lots_300 > MarketInfo(Symbol(), MODE_MAXLOT)) g_lots_300 = MarketInfo(Symbol(), MODE_MAXLOT); + } + int li_24 = signal(); + if (TimeCurrent() >= gi_236) { + if (UseSignal == TRUE) { + if (li_24 > 0 && gi_240 == 0 && Hedge || gi_244 == 0) l_ticket_28 = OrderSend(Symbol(), OP_BUY, g_lots_300, Ask, g_slippage_188, 0, 0, "Brain UP", g_magic_228, 0, Green); + if (li_24 < 0 && gi_244 == 0 && Hedge || gi_240 == 0) l_ticket_32 = OrderSend(Symbol(), OP_SELL, g_lots_300, Bid, g_slippage_188, 0, 0, "Brain Down", g_magic_228, 0, Red); + } + if (UseSignal == FALSE) { + if (gi_240 == 0 && Hedge || gi_244 == 0) l_ticket_28 = OrderSend(Symbol(), OP_BUY, g_lots_300, Ask, g_slippage_188, 0, 0, "Brain UP", g_magic_228, 0, Green); + if (gi_244 == 0 && Hedge || gi_240 == 0) l_ticket_32 = OrderSend(Symbol(), OP_SELL, g_lots_300, Bid, g_slippage_188, 0, 0, "Brain Down", g_magic_228, 0, Red); + } + if (l_ticket_28 > 0) { + OrderSelect(l_ticket_28, SELECT_BY_TICKET); + if (StopLoss > 0 && OrderStopLoss() == 0.0) l_price_36 = OrderOpenPrice() - StopLoss * Point; + if (TakeProfit > 0 && OrderTakeProfit() == 0.0) l_price_44 = OrderOpenPrice() + TakeProfit * Point; + OrderModify(l_ticket_28, OrderOpenPrice(), l_price_36, l_price_44, 0, CLR_NONE); + } + if (l_ticket_32 > 0) { + OrderSelect(l_ticket_32, SELECT_BY_TICKET); + if (StopLoss > 0 && OrderStopLoss() == 0.0) l_price_52 = OrderOpenPrice() + StopLoss * Point; + if (TakeProfit > 0 && OrderTakeProfit() == 0.0) l_price_60 = OrderOpenPrice() - TakeProfit * Point; + OrderModify(l_ticket_32, OrderOpenPrice(), l_price_52, l_price_60, 0, CLR_NONE); + } + if (gi_240 > 0 || gi_244 > 0) PendingOrders(); + } + Check(); + gi_256 = gi_240 + gi_248; + gi_260 = gi_244 + gi_252; + if (gi_232 < 0 && gi_256 == 0) gi_232 = 0; + if (gi_232 > 0 && gi_260 == 0) gi_232 = 0; + Comment("Sniper EA is working...", + "\n", "signal: ", li_24, " ", gi_232, " total: ", g_ord_total_272, + "\n", "Your Money: ", AccountEquity(), " Profit: ", AccountProfit(), + "\n", "MultiLots = ", gd_308, + "\n", "Daily Target = ", gi_320); + return (0); +} + +int Check() { + gi_240 = 0; + gi_244 = 0; + gi_248 = 0; + gi_252 = 0; + gd_276 = 0; + g_ord_lots_284 = 0; + g_ord_lots_292 = 0; + for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { + if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_228) { + if (OrderType() == OP_BUY) { + gd_276 += OrderProfit(); + if (gi_232 == -1 || gi_232 == 22) { + OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_188, Gold); + continue; + } + gi_240 += 1; + if (OrderLots() > g_ord_lots_284) g_ord_lots_284 = OrderLots(); + } + if (OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP) { + if (gi_232 == -1 || gi_232 == 22) { + OrderDelete(OrderTicket(), Gold); + continue; + } + gi_248 += 1; + } + if (OrderType() == OP_SELL) { + gd_276 += OrderProfit(); + if (gi_232 == 1 || gi_232 == 22) { + OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_188, Gold); + continue; + } + gi_244 += 1; + if (OrderLots() > g_ord_lots_292) g_ord_lots_292 = OrderLots(); + } + if (OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) { + if (gi_232 == 1 || gi_232 == 22) OrderDelete(OrderTicket(), Gold); + else gi_252 += 1; + } + } + } + } + return (gi_240 - gi_244 + gi_248 - gi_252); +} + +int PendingOrders() { + double l_price_16; + double l_price_24; + double l_price_32; + double l_price_40; + if (!Pending) return (-1); + double l_price_0 = Ask - Range * Point; + double l_price_8 = Bid + Range * Point; + if (gd_308 == 2.222) { + g_ord_lots_284 = NormalizeDouble(2.0 * g_ord_lots_284 + g_lots_300, 2); + g_ord_lots_292 = NormalizeDouble(2.0 * g_ord_lots_292 + g_lots_300, 2); + } else { + g_ord_lots_284 = NormalizeDouble(g_lots_300 * MathPow(gd_308, gi_240), 2); + g_ord_lots_292 = NormalizeDouble(g_lots_300 * MathPow(gd_308, gi_244), 2); + } + if (StopLoss == 0) { + l_price_16 = 0; + l_price_32 = 0; + } else { + l_price_16 = l_price_0 - StopLoss * Point; + l_price_32 = l_price_8 + StopLoss * Point; + } + if (TakeProfit == 0) { + l_price_24 = 0; + l_price_40 = 0; + } else { + l_price_24 = l_price_0 + TakeProfit * Point; + l_price_40 = l_price_8 - TakeProfit * Point; + } + if (gi_240 > 0 && gi_248 < 1 && gi_240 < MaxTrades) OrderSend(Symbol(), OP_BUYLIMIT, g_ord_lots_284, l_price_0, g_slippage_188, l_price_16, l_price_24, "Brain Up Limit", g_magic_228, 0, Green); + if (gi_244 > 0 && gi_252 < 1 && gi_244 < MaxTrades) OrderSend(Symbol(), OP_SELLLIMIT, g_ord_lots_292, l_price_8, g_slippage_188, l_price_32, l_price_40, "Brain Down Limit", g_magic_228, 0, Red); + return (GetLastError()); +} + +int signal() { + double l_iac_0 = iAC(NULL, PERIOD_H1, 0); + double l_iac_8 = iAC(NULL, PERIOD_H1, 1); + double l_irvi_16 = iRVI(NULL, PERIOD_H1, 10, MODE_MAIN, 0); + double l_irvi_24 = iRVI(NULL, PERIOD_H1, 10, MODE_SIGNAL, 0); + double l_istochastic_32 = iStochastic(NULL, PERIOD_H1, 8, 3, 3, MODE_EMA, 0, MODE_MAIN, 0); + double l_istochastic_40 = iStochastic(NULL, PERIOD_H1, 8, 3, 3, MODE_EMA, 0, MODE_SIGNAL, 0); + double l_iwpr_48 = iWPR(NULL, PERIOD_H1, 3, 0); + double l_iwpr_56 = iWPR(NULL, PERIOD_H1, 3, 1); + double l_icustom_64 = iCustom(NULL, PERIOD_H1, "Sniper", 3, 6, 5, 4, 1, 0); + double l_icustom_72 = iCustom(NULL, PERIOD_H1, "Sniper", 3, 6, 5, 4, 0, 0); + if ((l_icustom_72 > l_icustom_64 && l_icustom_72 >= 0.0) || l_icustom_64 >= 0.0) { + if (l_irvi_16 > l_irvi_24 && l_istochastic_32 > l_istochastic_40) { + if (!Reverse) return (1); + return (-1); + } + } + if ((l_icustom_72 < l_icustom_64 && l_icustom_72 <= 0.0) || l_icustom_64 <= 0.0) { + if (l_irvi_16 < l_irvi_24 && l_istochastic_32 < l_istochastic_40) { + if (!Reverse) return (-1); + return (1); + } + } + return (0); +} \ No newline at end of file diff --git a/New_Candle_Alarm.mq4 b/New_Candle_Alarm.mq4 new file mode 100644 index 0000000..7e4cf3b --- /dev/null +++ b/New_Candle_Alarm.mq4 @@ -0,0 +1,44 @@ +//+------------------------------------------------------------------+ +//| New_Candle_Alarm.mq4 | +//| Zen_Leow | +//| | +//+------------------------------------------------------------------+ +#property copyright "Zen_Leow" +#property link "" + +#property indicator_chart_window + +datetime LastAlertTime; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ +//---- indicators + LastAlertTime = TimeCurrent(); +//---- + return(0); +} +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() +{ +//---- + +//---- + return(0); +} +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ + if (LastAlertTime < Time[0]) + { + Alert("New Candle Forming on ",Symbol()," TimeFrame: ",Period()); + LastAlertTime = Time[0]; + } + return(0); +} +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Pipzu Extrapolated v1.1.mq4 b/Pipzu Extrapolated v1.1.mq4 new file mode 100644 index 0000000..1b20f64 --- /dev/null +++ b/Pipzu Extrapolated v1.1.mq4 @@ -0,0 +1,337 @@ +#property copyright "Copyright © 2008, Pipzu Extrapolated V1.1, Pipzu.com" +#property link "http://pipzu.com" + +extern string _d0 = "Pipzu Extrapolated ver 1.1"; +extern int MagicNumber = 8625; +extern int Slippage = 3; +extern bool EmailTrades = FALSE; +int gi_96 = 85; +int gi_100 = 30; +int gi_104 = 15; +extern double Lots = 0.1; +extern string _d3 = "Money Managment Risk (0 = off... Raising it will multiply the lot size)"; +extern double Risk = 0.1; +string gs_unused_132 = "Starategy Parameters"; +int g_period_140 = 4; +int g_period_144 = 27; +int g_period_148 = 55; +int gi_152 = 4; +bool gi_156 = TRUE; +double gd_160 = 0.02; +double gd_168 = 0.2; +double gd_176; +double gda_184[]; +double gda_188[]; +double gda_192[]; +double g_isar_196; +int gia_204[15]; +int gia_208[15]; +int gia_212[15]; +int gia_216[15]; +int gia_220[15]; +int gia_224[15]; +int gia_228[15]; +int gia_232[15]; +int gi_236 = -1; +int g_time_240 = 0; +int g_time_244 = 0; + +void InitParams() { + gia_204[0] = D'01.01.2003 03:00'; + gia_208[0] = 40; + gia_212[0] = 25; + gia_216[0] = 0; + gia_220[0] = 15; + gia_224[0] = 23; + gia_228[0] = 78; + gia_232[0] = 5; + gia_204[1] = D'01.06.2003 04:00'; + gia_208[1] = 75; + gia_212[1] = 28; + gia_216[1] = 0; + gia_220[1] = 4; + gia_224[1] = 17; + gia_228[1] = 131; + gia_232[1] = 2; + gia_204[2] = D'01.01.2004 03:00'; + gia_208[2] = 80; + gia_212[2] = 22; + gia_216[2] = 0; + gia_220[2] = 5; + gia_224[2] = 23; + gia_228[2] = 99; + gia_232[2] = 2; + gia_204[3] = D'01.06.2004 04:00'; + gia_208[3] = 55; + gia_212[3] = 22; + gia_216[0] = 25; + gia_220[3] = 10; + gia_224[3] = 19; + gia_228[3] = 99; + gia_232[3] = 2; + gia_204[4] = D'01.01.2005 03:00'; + gia_208[4] = 80; + gia_212[4] = 16; + gia_216[4] = 0; + gia_220[4] = 8; + gia_224[4] = 32; + gia_228[4] = 75; + gia_232[4] = 2; + gia_204[5] = D'01.06.2005 04:00'; + gia_208[5] = 80; + gia_212[5] = 22; + gia_216[5] = 10; + gia_220[5] = 8; + gia_224[5] = 30; + gia_228[5] = 134; + gia_232[5] = 5; + gia_204[6] = D'01.01.2006 03:00'; + gia_208[6] = 30; + gia_212[6] = 25; + gia_216[6] = 0; + gia_220[6] = 4; + gia_224[6] = 33; + gia_228[6] = 135; + gia_232[6] = 3; + gia_204[7] = D'01.06.2006 04:00'; + gia_208[7] = 20; + gia_212[7] = 22; + gia_216[7] = 15; + gia_220[7] = 14; + gia_224[7] = 28; + gia_228[7] = 64; + gia_232[7] = 2; + gia_204[8] = D'01.01.2007 03:00'; + gia_208[8] = 20; + gia_212[8] = 19; + gia_216[8] = 25; + gia_220[8] = 15; + gia_224[8] = 20; + gia_228[8] = 72; + gia_232[8] = 6; + gia_204[9] = D'01.06.2007 04:00'; + gia_208[9] = 80; + gia_212[9] = 10; + gia_216[9] = 0; + gia_220[9] = 5; + gia_224[9] = 33; + gia_228[9] = 68; + gia_232[9] = 2; + gia_204[10] = D'01.01.2008 03:00'; + gia_208[10] = 40; + gia_212[10] = 28; + gia_216[10] = 0; + gia_220[10] = 2; + gia_224[10] = 18; + gia_228[10] = 130; + gia_232[10] = 2; + gia_204[11] = D'01.06.2008 04:00'; + gia_208[11] = 65; + gia_212[11] = 16; + gia_216[11] = 15; + gia_220[11] = 9; + gia_224[11] = 22; + gia_228[11] = 86; + gia_232[11] = 5; + gia_204[12] = D'01.08.2008 04:00'; + gia_208[12] = 60; + gia_212[12] = 15; + gia_216[12] = 25; + gia_220[12] = 3; + gia_224[12] = 18; + gia_228[12] = 115; + gia_232[12] = 5; + gia_204[13] = D'01.10.2008 04:00'; + gia_208[13] = 60; + gia_212[13] = 25; + gia_216[13] = 15; + gia_220[13] = 2; + gia_224[13] = 18; + gia_228[13] = 84; + gia_232[13] = 4; + gia_204[14] = D'01.11.2008 04:00'; + gia_208[14] = 85; + gia_212[14] = 30; + gia_216[14] = 15; + gia_220[14] = 4; + gia_224[14] = 27; + gia_228[14] = 55; + gia_232[14] = 4; +} + +void CheckParams() { + int li_0 = ArrayBsearch(gia_204, Time[1]); + if (gi_236 != li_0) { + gi_96 = gia_208[li_0]; + gi_100 = gia_212[li_0]; + gi_104 = gia_216[li_0]; + g_period_140 = gia_220[li_0]; + g_period_144 = gia_224[li_0]; + g_period_148 = gia_228[li_0]; + if (gi_152 != gia_232[li_0]) { + gi_152 = gia_232[li_0]; + ArrayResize(gda_184, gi_152); + ArrayResize(gda_188, gi_152); + ArrayResize(gda_192, gi_152); + } + gi_236 = li_0; + } +} + +int init() { + gd_176 = 0.0001 / Point; + if (IsTesting()) InitParams(); + ArrayResize(gda_184, gi_152); + ArrayResize(gda_188, gi_152); + ArrayResize(gda_192, gi_152); + return (0); +} + +void setRules() { + if (IsTesting()) CheckParams(); + for (int l_index_0 = 0; l_index_0 < gi_152; l_index_0++) { + gda_184[l_index_0] = iMA(NULL, 0, g_period_140, 0, MODE_EMA, PRICE_CLOSE, l_index_0 + 1); + gda_188[l_index_0] = iMA(NULL, 0, g_period_144, 0, MODE_EMA, PRICE_CLOSE, l_index_0 + 1); + gda_192[l_index_0] = iMA(NULL, 0, g_period_148, 0, MODE_EMA, PRICE_CLOSE, l_index_0 + 1); + } + if (gi_156) g_isar_196 = iSAR(NULL, 0, gd_160, gd_168, 1); +} + +int EmaCross(int ai_0) { + if (gda_184[0] * ai_0 >= gda_188[0] * ai_0 && gda_184[1] * ai_0 <= gda_188[1] * ai_0) { + for (int l_index_4 = 0; l_index_4 < gi_152 - 1; l_index_4++) + if (gda_184[l_index_4] * ai_0 >= gda_192[l_index_4] * ai_0 && (gda_184[l_index_4 + 1]) * ai_0 <= (gda_192[l_index_4 + 1]) * ai_0) return (1); + } else { + if (gda_184[0] * ai_0 >= gda_192[0] * ai_0 && gda_184[1] * ai_0 <= gda_192[1] * ai_0) { + for (l_index_4 = 0; l_index_4 < gi_152 - 1; l_index_4++) + if (gda_184[l_index_4] * ai_0 >= gda_188[l_index_4] * ai_0 && (gda_184[l_index_4 + 1]) * ai_0 <= (gda_188[l_index_4 + 1]) * ai_0) return (1); + } + } + return (0); +} + +int openBuyRule() { + return (!gi_156 || g_isar_196 < Close[1] && EmaCross(1)); +} + +int openSellRule() { + return (!gi_156 || g_isar_196 > Close[1] && EmaCross(-1)); +} + +bool closeBuyRule() { + return (Close[1] < gda_184[0] && Close[1] < gda_188[0] && Close[1] < gda_192[0]); +} + +bool closeSellRule() { + return (Close[1] > gda_184[0] && Close[1] > gda_188[0] && Close[1] > gda_192[0]); +} + +int openBuy() { + double l_price_0 = 0; + double l_price_8 = 0; + int l_stoplevel_16 = MarketInfo(Symbol(), MODE_STOPLEVEL); + if (gi_100 > 0) { + if (gi_100 * gd_176 > l_stoplevel_16) l_price_8 = NormalizeDouble(Bid - gi_100 * Point * gd_176, Digits); + else l_price_8 = NormalizeDouble(Bid - l_stoplevel_16 * Point, Digits); + } + if (gi_96 > 0) { + if (gi_96 * gd_176 > l_stoplevel_16) l_price_0 = NormalizeDouble(Ask + gi_96 * Point * gd_176, Digits); + else l_price_0 = NormalizeDouble(Ask + l_stoplevel_16 * Point, Digits); + } + int l_ticket_20 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, l_price_8, l_price_0, "Pipzu Extrapolated: Buy", MagicNumber, 0, Green); + if (l_ticket_20 > 0) + if (EmailTrades) SendMail("Pipzu Extrapolated", "Open Buy: [" + Symbol() + "] " + NormalizeDouble(Ask, Digits)); + return (l_ticket_20); +} + +int openSell() { + double l_price_0 = 0; + double l_price_8 = 0; + int l_stoplevel_16 = MarketInfo(Symbol(), MODE_STOPLEVEL); + if (gi_100 > 0) { + if (gi_100 * gd_176 > l_stoplevel_16) l_price_8 = NormalizeDouble(Ask + gi_100 * Point * gd_176, Digits); + else l_price_8 = NormalizeDouble(Ask + l_stoplevel_16 * Point, Digits); + } + if (gi_96 > 0) { + if (gi_96 * gd_176 > l_stoplevel_16) l_price_0 = NormalizeDouble(Bid - gi_96 * Point * gd_176, Digits); + else l_price_0 = NormalizeDouble(Bid - l_stoplevel_16 * Point, Digits); + } + int l_ticket_20 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, l_price_8, l_price_0, "Pipzu Extrapolated: Sell", MagicNumber, 0, Red); + if (l_ticket_20 > 0) + if (EmailTrades) SendMail("Pipzu Extrapolated", "Open Sell: [" + Symbol() + "] " + NormalizeDouble(Bid, Digits)); + return (l_ticket_20); +} + +int buyControl() { + if (closeBuyRule()) + if (OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Violet)) return (-1); + if (gi_104 > 0) { + if (Bid - OrderOpenPrice() > Point * gd_176 * gi_104) + if (OrderStopLoss() < Bid - Point * gd_176 * gi_104 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * gd_176 * gi_104, Digits), OrderTakeProfit(), 0, Green); + } + return (OrderTicket()); +} + +int sellControl() { + if (closeSellRule()) + if (OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Violet)) return (-1); + if (gi_104 > 0) { + if (OrderOpenPrice() - Ask > Point * gd_176 * gi_104) + if (OrderStopLoss() > Ask + Point * gd_176 * gi_104 || OrderStopLoss() == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * gd_176 * gi_104, Digits), OrderTakeProfit(), 0, Red); + } + return (OrderTicket()); +} + +double MMLots(double ad_0) { + return (NormalizeLots(ad_0 * AccountFreeMargin() / MarketInfo(Symbol(), MODE_MARGINREQUIRED) / (AccountLeverage() / 100.0))); +} + +double NormalizeLots(double ad_0) { + double l_lotstep_8 = MarketInfo(Symbol(), MODE_LOTSTEP); + double l_minlot_16 = MarketInfo(Symbol(), MODE_MINLOT); + double l_maxlot_24 = MarketInfo(Symbol(), MODE_MAXLOT); + double ld_ret_32 = MathCeil(ad_0 / l_lotstep_8) * l_lotstep_8; + if (ld_ret_32 < l_minlot_16) ld_ret_32 = l_minlot_16; + if (ld_ret_32 > l_maxlot_24) ld_ret_32 = l_maxlot_24; + return (ld_ret_32); +} + +int start() { + Comment("Copyright Pipzu.com support@pipzu.com"); + if (Bars < 100) { + Print("bars less than 100"); + return (0); + } + setRules(); + int li_0 = -1; + int li_4 = -1; + for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { + if (OrderSelect(l_pos_8, SELECT_BY_POS)) { + if (OrderMagicNumber() == MagicNumber) { + if (OrderSymbol() == Symbol()) { + switch (OrderType()) { + case OP_BUY: + li_0 = buyControl(); + break; + case OP_SELL: + li_4 = sellControl(); + } + } + } + } + } + int li_16 = openBuyRule(); + int li_20 = openSellRule(); + if (Risk > 0.0) Lots = MMLots(Risk); + if (AccountFreeMargin() < MarketInfo(Symbol(), MODE_MARGINREQUIRED) * Lots) { + Print("We have no money. Free Margin = ", AccountFreeMargin(), " RequiredMargin = ", MarketInfo(Symbol(), MODE_MARGINREQUIRED) * Lots); + return (0); + } + if (g_time_240 != Time[1] && li_16 && li_0 < 0) { + if (openBuy() > 0) g_time_240 = Time[1]; + } else { + if (g_time_244 != Time[1] && li_20 && li_4 < 0) + if (openSell() > 0) g_time_244 = Time[1]; + } + return (0); +} \ No newline at end of file diff --git a/Pivot Points Multitimeframe.mq4 b/Pivot Points Multitimeframe.mq4 new file mode 100644 index 0000000..0b123a1 --- /dev/null +++ b/Pivot Points Multitimeframe.mq4 @@ -0,0 +1,1756 @@ +//+-------------------------------------------------------------------+ +//| Pivot.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//| Modified by dwt5 and adoleh2000| +//| | +//+-------------------------------------------------------------------+ +// LAST MODIFICATION 5:40 CST 7/4/05 | +// added true/false logic for displaying time frames | +//+-------------------------------------------------------------------+ + +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" + + +#property indicator_chart_window +#property indicator_buffers 4 +#property indicator_color1 EMPTY + + +//extern bool pivots = true; +extern bool midpivots = false; +extern bool Fhr = false; +extern bool daily = true; +extern bool weekly = true; +extern bool monthly = true; + +extern int Period1 = PERIOD_D1; + + + + +/*+----------------------------------------------------+ + MyPeriod = Period in minutes to consideration, could be: + 1440 for D1 + 60 for H1 + 240 for H4 + 1 for M1 + 15 for M15 + 30 for M30 + 5 for M5 + 43200 for MN1 + 10080 for W1 + +-------------------------------------------------------*/ +//--------------------------------- +double Fhr_day_high=0; +double Fhr_day_low=0; +double Fhr_yesterday_high=0; +double Fhr_yesterday_open=0; +double Fhr_yesterday_low=0; +double Fhr_yesterday_close=0; +double Fhr_today_open=0; +double Fhr_today_high=0; +double Fhr_today_low=0; +double Fhr_P=0; +double Fhr_Q=0; +double Fhr_R1,Fhr_R2,Fhr_R3; +double Fhr_M0,Fhr_M1,Fhr_M2,Fhr_M3,Fhr_M4,Fhr_M5; +double Fhr_S1,Fhr_S2,Fhr_S3; +double Fhr_nQ=0; +double Fhr_nD=0; +double Fhr_D=0; +double Fhr_rates_d1[2][6]; +double Fhr_ExtMapBuffer[]; +//--------------------------------- +double D_day_high=0; +double D_day_low=0; +double D_yesterday_high=0; +double D_yesterday_open=0; +double D_yesterday_low=0; +double D_yesterday_close=0; +double D_today_open=0; +double D_today_high=0; +double D_today_low=0; +double D_P=0; +double D_Q=0; +double D_R1,D_R2,D_R3; +double D_M0,D_M1,D_M2,D_M3,D_M4,D_M5; +double D_S1,D_S2,D_S3; +double D_nQ=0; +double D_nD=0; +double D_D=0; +double D_rates_d1[2][6]; +double D_ExtMapBuffer[]; +//--------------------------------- +double W_day_high=0; +double W_day_low=0; +double W_yesterday_high=0; +double W_yesterday_open=0; +double W_yesterday_low=0; +double W_yesterday_close=0; +double W_today_open=0; +double W_today_high=0; +double W_today_low=0; +double W_P=0; +double W_Q=0; +double W_R1,W_R2,W_R3; +double W_M0,W_M1,W_M2,W_M3,W_M4,W_M5; +double W_S1,W_S2,W_S3; +double W_nQ=0; +double W_nD=0; +double W_D=0; +double W_rates_d1[2][6]; +double W_ExtMapBuffer[]; +//--------------------------------- +double M_day_high=0; +double M_day_low=0; +double M_yesterday_high=0; +double M_yesterday_open=0; +double M_yesterday_low=0; +double M_yesterday_close=0; +double M_today_open=0; +double M_today_high=0; +double M_today_low=0; +double M_P=0; +double M_Q=0; +double M_R1,M_R2,M_R3; +double M_M0,M_M1,M_M2,M_M3,M_M4,M_M5; +double M_S1,M_S2,M_S3; +double M_nQ=0; +double M_nD=0; +double M_D=0; +double M_rates_d1[2][6]; +double M_ExtMapBuffer[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ +IndicatorBuffers(4); +SetIndexStyle(0,DRAW_ARROW); +SetIndexArrow(0,159); +SetIndexBuffer(0, Fhr_ExtMapBuffer); + +SetIndexStyle(0,DRAW_ARROW); +SetIndexArrow(0,159); +SetIndexBuffer(1, D_ExtMapBuffer); + +SetIndexStyle(0,DRAW_ARROW); +SetIndexArrow(0,159); +SetIndexBuffer(2, W_ExtMapBuffer); + +SetIndexStyle(0,DRAW_ARROW); +SetIndexArrow(0,159); +SetIndexBuffer(3, M_ExtMapBuffer); + +//---- indicators +D_R1=0; D_R2=0; D_R3=0; +D_M0=0; D_M1=0; D_M2=0; D_M3=0; D_M4=0; D_M5=0; +D_S1=0; D_S2=0; D_S3=0; + + +W_R1=0; W_R2=0; W_R3=0; +W_M0=0; W_M1=0; W_M2=0; W_M3=0; W_M4=0; W_M5=0; +W_S1=0; W_S2=0; W_S3=0; + + +M_R1=0; M_R2=0; M_R3=0; +M_M0=0; M_M1=0; M_M2=0; M_M3=0; M_M4=0; M_M5=0; +M_S1=0; M_S2=0; M_S3=0; + + +Fhr_R1=0; Fhr_R2=0; Fhr_R3=0; +Fhr_M0=0; Fhr_M1=0; Fhr_M2=0; Fhr_M3=0; Fhr_M4=0; Fhr_M5=0; +Fhr_S1=0; Fhr_S2=0; Fhr_S3=0; + + + +//---- +return(0); +} +//+------------------------------------------------------------------+ +//| Custor indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() +{ +//---- TODO: add your code here +// 4 hour-------------------------- +ObjectDelete("Fhr_R1 Label"); +ObjectDelete("Fhr_R1 Line"); +ObjectDelete("Fhr_R2 Label"); +ObjectDelete("Fhr_R2 Line"); +ObjectDelete("Fhr_R3 Label"); +ObjectDelete("Fhr_R3 Line"); +ObjectDelete("Fhr_S1 Label"); +ObjectDelete("Fhr_S1 Line"); +ObjectDelete("Fhr_S2 Label"); +ObjectDelete("Fhr_S2 Line"); +ObjectDelete("Fhr_S3 Label"); +ObjectDelete("Fhr_S3 Line"); +ObjectDelete("Fhr_P Label"); +ObjectDelete("Fhr_P Line"); +ObjectDelete("Fhr_M5 Label"); +ObjectDelete("Fhr_M5 Line"); +ObjectDelete("Fhr_M4 Label"); +ObjectDelete("Fhr_M4 Line"); +ObjectDelete("Fhr_M3 Label"); +ObjectDelete("Fhr_M3 Line"); +ObjectDelete("Fhr_M2 Label"); +ObjectDelete("Fhr_M2 Line"); +ObjectDelete("Fhr_M1 Label"); +ObjectDelete("Fhr_M1 Line"); +ObjectDelete("Fhr_M0 Label"); +ObjectDelete("Fhr_M0 Line"); +// +ObjectDelete("D_R1 Label"); +ObjectDelete("D_R1 Line"); +ObjectDelete("D_R2 Label"); +ObjectDelete("D_R2 Line"); +ObjectDelete("D_R3 Label"); +ObjectDelete("D_R3 Line"); +ObjectDelete("D_S1 Label"); +ObjectDelete("D_S1 Line"); +ObjectDelete("D_S2 Label"); +ObjectDelete("D_S2 Line"); +ObjectDelete("D_S3 Label"); +ObjectDelete("D_S3 Line"); +ObjectDelete("D_P Label"); +ObjectDelete("D_P Line"); +ObjectDelete("D_M5 Label"); +ObjectDelete("D_M5 Line"); +ObjectDelete("D_M4 Label"); +ObjectDelete("D_M4 Line"); +ObjectDelete("D_M3 Label"); +ObjectDelete("D_M3 Line"); +ObjectDelete("D_M2 Label"); +ObjectDelete("D_M2 Line"); +ObjectDelete("D_M1 Label"); +ObjectDelete("D_M1 Line"); +ObjectDelete("D_M0 Label"); +ObjectDelete("D_M0 Line"); +//-------------------------------------- +ObjectDelete("W_R1 Label"); +ObjectDelete("W_R1 Line"); +ObjectDelete("W_R2 Label"); +ObjectDelete("W_R2 Line"); +ObjectDelete("W_R3 Label"); +ObjectDelete("W_R3 Line"); +ObjectDelete("W_S1 Label"); +ObjectDelete("W_S1 Line"); +ObjectDelete("W_S2 Label"); +ObjectDelete("W_S2 Line"); +ObjectDelete("W_S3 Label"); +ObjectDelete("W_S3 Line"); +ObjectDelete("W_P Label"); +ObjectDelete("W_P Line"); +ObjectDelete("W_M5 Label"); +ObjectDelete("W_M5 Line"); +ObjectDelete("W_M4 Label"); +ObjectDelete("W_M4 Line"); +ObjectDelete("W_M3 Label"); +ObjectDelete("W_M3 Line"); +ObjectDelete("W_M2 Label"); +ObjectDelete("W_M2 Line"); +ObjectDelete("W_M1 Label"); +ObjectDelete("W_M1 Line"); +ObjectDelete("W_M0 Label"); +ObjectDelete("W_M0 Line"); +//-------------------------------------- +ObjectDelete("M_R1 Label"); +ObjectDelete("M_R1 Line"); +ObjectDelete("M_R2 Label"); +ObjectDelete("M_R2 Line"); +ObjectDelete("M_R3 Label"); +ObjectDelete("M_R3 Line"); +ObjectDelete("M_S1 Label"); +ObjectDelete("M_S1 Line"); +ObjectDelete("M_S2 Label"); +ObjectDelete("M_S2 Line"); +ObjectDelete("M_S3 Label"); +ObjectDelete("M_S3 Line"); +ObjectDelete("M_P Label"); +ObjectDelete("M_P Line"); +ObjectDelete("M_M5 Label"); +ObjectDelete("M_M5 Line"); +ObjectDelete("M_M4 Label"); +ObjectDelete("M_M4 Line"); +ObjectDelete("M_M3 Label"); +ObjectDelete("M_M3 Line"); +ObjectDelete("M_M2 Label"); +ObjectDelete("M_M2 Line"); +ObjectDelete("M_M1 Label"); +ObjectDelete("M_M1 Line"); +ObjectDelete("M_M0 Label"); +ObjectDelete("M_M0 Line"); +//---- +return(0); +} +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ + +//---- TODO: add your code here + +/* +//---- exit if period is greater than daily charts +if(Period() > 1440) +{ +Print("Error - Chart period is greater than 1 day."); +return(-1); // then exit +} +*/ +//----------------------------------------------------------------------------- Get new 4hr --------------- + ArrayCopyRates(Fhr_rates_d1, Symbol(), 240); + + Fhr_yesterday_close = Fhr_rates_d1[1][4]; + Fhr_yesterday_open = Fhr_rates_d1[1][1]; + Fhr_today_open = Fhr_rates_d1[0][1]; + Fhr_yesterday_high = Fhr_rates_d1[1][3]; + Fhr_yesterday_low = Fhr_rates_d1[1][2]; + Fhr_day_high = Fhr_rates_d1[0][3]; + Fhr_day_low = Fhr_rates_d1[0][2]; + + +//---- Calculate Pivots + + Fhr_D = (Fhr_day_high - Fhr_day_low); + Fhr_Q = (Fhr_yesterday_high - Fhr_yesterday_low); + Fhr_P = (Fhr_yesterday_high + Fhr_yesterday_low + Fhr_yesterday_close) / 3; + Fhr_R1 = (2*Fhr_P)-Fhr_yesterday_low; + Fhr_S1 = (2*Fhr_P)-Fhr_yesterday_high; + Fhr_R2 = Fhr_P+(Fhr_yesterday_high - Fhr_yesterday_low); + Fhr_S2 = Fhr_P-(Fhr_yesterday_high - Fhr_yesterday_low); + + + Fhr_R3 = (2*Fhr_P)+(Fhr_yesterday_high-(2*Fhr_yesterday_low)); + Fhr_M5 = (Fhr_R2+Fhr_R3)/2; + // Fhr_R2 = Fhr_P-Fhr_S1+Fhr_R1; + Fhr_M4 = (Fhr_R1+Fhr_R2)/2; + // Fhr_R1 = (2*Fhr_P)-Fhr_yesterday_low; + Fhr_M3 = (Fhr_P+Fhr_R1)/2; + // Fhr_P = (Fhr_yesterday_high + Fhr_yesterday_low + Fhr_yesterday_close)/3; + Fhr_M2 = (Fhr_P+Fhr_S1)/2; + // Fhr_S1 = (2*Fhr_P)-Fhr_yesterday_high; + Fhr_M1 = (Fhr_S1+Fhr_S2)/2; + // Fhr_S2 = Fhr_P-Fhr_R1+Fhr_S1; + Fhr_S3 = (2*Fhr_P)-((2* Fhr_yesterday_high)-Fhr_yesterday_low); + Fhr_M0 = (Fhr_S2+Fhr_S3)/2; + + if (Fhr_Q > 5) + { + Fhr_nQ = Fhr_Q; + } + else + { + Fhr_nQ = Fhr_Q*10000; + } + + if (Fhr_D > 5) + { + Fhr_nD = Fhr_D; + } + else + { + Fhr_nD = Fhr_D*10000; + } +//----------------------------------------------------------------------------- Get DAY --------------- + ArrayCopyRates(D_rates_d1, Symbol(), 1440); + + D_yesterday_close = D_rates_d1[1][4]; + D_yesterday_open = D_rates_d1[1][1]; + D_today_open = D_rates_d1[0][1]; + D_yesterday_high = D_rates_d1[1][3]; + D_yesterday_low = D_rates_d1[1][2]; + D_day_high = D_rates_d1[0][3]; + D_day_low = D_rates_d1[0][2]; + + +//---- Calculate Pivots + + D_D = (D_day_high - D_day_low); + D_Q = (D_yesterday_high - D_yesterday_low); + D_P = (D_yesterday_high + D_yesterday_low + D_yesterday_close) / 3; + D_R1 = (2*D_P)-D_yesterday_low; + D_S1 = (2*D_P)-D_yesterday_high; + D_R2 = D_P+(D_yesterday_high - D_yesterday_low); + D_S2 = D_P-(D_yesterday_high - D_yesterday_low); + + + D_R3 = (2*D_P)+(D_yesterday_high-(2*D_yesterday_low)); + D_M5 = (D_R2+D_R3)/2; + // D_R2 = D_P-D_S1+D_R1; + D_M4 = (D_R1+D_R2)/2; + // D_R1 = (2*D_P)-D_yesterday_low; + D_M3 = (D_P+D_R1)/2; + // D_P = (D_yesterday_high + D_yesterday_low + D_yesterday_close)/3; + D_M2 = (D_P+D_S1)/2; + // D_S1 = (2*D_P)-D_yesterday_high; + D_M1 = (D_S1+D_S2)/2; + // D_S2 = D_P-D_R1+D_S1; + D_S3 = (2*D_P)-((2* D_yesterday_high)-D_yesterday_low); + + D_M0 = (D_S2+D_S3)/2; + + if (D_Q > 5) + { + D_nQ = D_Q; + } + else + { + D_nQ = D_Q*10000; + } + + if (D_D > 5) + { + D_nD = D_D; + } + else + { + D_nD = D_D*10000; + } + +//----------------------------------------------------------------------------- Weekly --------------- + ArrayCopyRates(W_rates_d1, Symbol(), 10080); + + W_yesterday_close = W_rates_d1[1][4]; + W_yesterday_open = W_rates_d1[1][1]; + W_today_open = W_rates_d1[0][1]; + W_yesterday_high = W_rates_d1[1][3]; + W_yesterday_low = W_rates_d1[1][2]; + W_day_high = W_rates_d1[0][3]; + W_day_low = W_rates_d1[0][2]; + + +//---- Calculate Pivots + + W_D = (W_day_high - W_day_low); + W_Q = (W_yesterday_high - W_yesterday_low); + W_P = (W_yesterday_high + W_yesterday_low + W_yesterday_close) / 3; + W_R1 = (2*W_P)-W_yesterday_low; + W_S1 = (2*W_P)-W_yesterday_high; + W_R2 = W_P+(W_yesterday_high - W_yesterday_low); + W_S2 = W_P-(W_yesterday_high - W_yesterday_low); + + + W_R3 = (2*W_P)+(W_yesterday_high-(2*W_yesterday_low)); + W_M5 = (W_R2+W_R3)/2; + // W_R2 = W_P-W_S1+W_R1; + W_M4 = (W_R1+W_R2)/2; + // W_R1 = (2*W_P)-W_yesterday_low; + W_M3 = (W_P+W_R1)/2; + // W_P = (W_yesterday_high + W_yesterday_low + W_yesterday_close)/3; + W_M2 = (W_P+W_S1)/2; + // W_S1 = (2*W_P)-W_yesterday_high; + W_M1 = (W_S1+W_S2)/2; + // W_S2 = W_P-W_R1+W_S1; + W_S3 = (2*W_P)-((2* W_yesterday_high)-W_yesterday_low); + W_M0 = (W_S2+W_S3)/2; + + if (W_Q > 5) + { + W_nQ = W_Q; + } + else + { + W_nQ = W_Q*10000; + } + + if (W_D > 5) + { + W_nD = W_D; + } + else + { + W_nD = W_D*10000; + } + + +//-------------------------------------------------------------MONTHLY------------------------------------------- + ArrayCopyRates(M_rates_d1, Symbol(), 43200); + + M_yesterday_close = M_rates_d1[1][4]; + M_yesterday_open = M_rates_d1[1][1]; + M_today_open = M_rates_d1[0][1]; + M_yesterday_high = M_rates_d1[1][3]; + M_yesterday_low = M_rates_d1[1][2]; + M_day_high = M_rates_d1[0][3]; + M_day_low = M_rates_d1[0][2]; + + +//---- Calculate Pivots + + M_D = (M_day_high - M_day_low); + M_Q = (M_yesterday_high - M_yesterday_low); + M_P = (M_yesterday_high + M_yesterday_low + M_yesterday_close) / 3; + M_R1 = (2*M_P)-M_yesterday_low; + M_S1 = (2*M_P)-M_yesterday_high; + M_R2 = M_P+(M_yesterday_high - M_yesterday_low); + M_S2 = M_P-(M_yesterday_high - M_yesterday_low); + + + M_R3 = (2*M_P)+(M_yesterday_high-(2*M_yesterday_low)); + M_M5 = (M_R2+M_R3)/2; + // M_R2 = M_P-M_S1+M_R1; + M_M4 = (M_R1+M_R2)/2; + // M_R1 = (2*M_P)-M_yesterday_low; + M_M3 = (M_P+M_R1)/2; + // M_P = (M_yesterday_high + M_yesterday_low + M_yesterday_close)/3; + M_M2 = (M_P+M_S1)/2; + // M_S1 = (2*M_P)-M_yesterday_high; + M_M1 = (M_S1+M_S2)/2; + // M_S2 = M_P-M_R1+M_S1; + M_S3 = (2*M_P)-((2* M_yesterday_high)-M_yesterday_low); + + M_M0 = (M_S2+M_S3)/2; + + if (M_Q > 5) + { + M_nQ = M_Q; + } + else + { + M_nQ = M_Q*10000; + } + + if (M_D > 5) + { + M_nD = M_D; + } + else + { + M_nD = M_D*10000; + } + +//-------------------------------------------------------------------------------------------------------------- + + +//Comment("High= ",yesterday_high," Previous DaysRange= ",nQ,"\nLow= ",yesterday_low," Current DaysRange= ",nD,"\nClose= ",yesterday_close," Time Frame ",Period1 ); + + +//-------------------------------------------------------------------------------------------------------------- +//---- Set line labels on chart window +//---------------------------------------------------------------------4hr Pivot Lines -------------------- +if (Fhr==true) +{ + if(ObjectFind("Fhr_R1 label") != 0) + { + ObjectCreate("Fhr_R1 label", OBJ_TEXT, 0, Time[0], Fhr_R1); + ObjectSetText("Fhr_R1 label", "Fhr_R1 " +DoubleToStr(Fhr_R1,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_R1 label", 0, Time[0], Fhr_R1); + } + + if(ObjectFind("Fhr_R2 label") != 0) + { + ObjectCreate("Fhr_R2 label", OBJ_TEXT, 0, Time[20], Fhr_R2); + ObjectSetText("Fhr_R2 label", "Fhr_R2 " +DoubleToStr(Fhr_R2,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_R2 label", 0, Time[0], Fhr_R2); + } + + if(ObjectFind("Fhr_R3 label") != 0) + { + ObjectCreate("Fhr_R3 label", OBJ_TEXT, 0, Time[20], Fhr_R3); + ObjectSetText("Fhr_R3 label", "Fhr_R3 " +DoubleToStr(Fhr_R3,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_R3 label", 0, Time[0], Fhr_R3); + } + + if(ObjectFind("Fhr_P label") != 0) + { + ObjectCreate("Fhr_P label", OBJ_TEXT, 0, Time[0], Fhr_P); + ObjectSetText("Fhr_P label", "Fhr_Pivot " +DoubleToStr(Fhr_P,4), 8, "Arial",EMPTY); + } + else + { + ObjectMove("Fhr_P label", 0, Time[0], Fhr_P); + } + + if(ObjectFind("Fhr_S1 label") != 0) + { + ObjectCreate("Fhr_S1 label", OBJ_TEXT, 0, Time[0], Fhr_S1); + ObjectSetText("Fhr_S1 label", "Fhr_S1 " +DoubleToStr(Fhr_S1,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_S1 label", 0, Time[0], Fhr_S1); + } + + if(ObjectFind("Fhr_S2 label") != 0) + { + ObjectCreate("Fhr_S2 label", OBJ_TEXT, 0, Time[20], Fhr_S2); + ObjectSetText("Fhr_S2 label", "Fhr_S2 " +DoubleToStr(Fhr_S2,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_S2 label", 0, Time[0], Fhr_S2); + } + + if(ObjectFind("Fhr_S3 label") != 0) + { + ObjectCreate("Fhr_S3 label", OBJ_TEXT, 0, Time[20], Fhr_S3); + ObjectSetText("Fhr_S3 label", "Fhr_S3 " +DoubleToStr(Fhr_S3,4), 8, "Arial", EMPTY); + } + else + { + ObjectMove("Fhr_S3 label", 0, Time[0], Fhr_S3); + } + +//--- Draw Pivot lines on chart + if(ObjectFind("Fhr_S1 line") != 0) + { + ObjectCreate("Fhr_S1 line", OBJ_HLINE, 0, Time[0], Fhr_S1); + ObjectSet("Fhr_S1 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_S1 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_S1 line", OBJPROP_COLOR, Blue); + } + else + { + ObjectMove("Fhr_S1 line", 0, Time[40], Fhr_S1); + } + + if(ObjectFind("Fhr_S2 line") != 0) + { + ObjectCreate("Fhr_S2 line", OBJ_HLINE, 0, Time[40], Fhr_S2, Time[0], Fhr_S2); + ObjectSet("Fhr_S2 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_S2 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_S2 line", OBJPROP_COLOR, Blue); + } + else + { + ObjectMove("Fhr_S2 line", 0, Time[40], Fhr_S2); + } + + if(ObjectFind("Fhr_S3 line") != 0) + { + ObjectCreate("Fhr_S3 line", OBJ_HLINE, 0, Time[40], Fhr_S3, Time[0], Fhr_S3); + ObjectSet("Fhr_S3 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_S3 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_S3 line", OBJPROP_COLOR, Blue); + } + else + { + ObjectMove("Fhr_S3 line", 0, Time[40], Fhr_S3); + } + + if(ObjectFind("Fhr_P line") != 0) + { + ObjectCreate("Fhr_P line", OBJ_HLINE, 0, Time[40], Fhr_P, Time[0], Fhr_P); + ObjectSet("Fhr_P line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_P line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_P line", OBJPROP_COLOR, LightBlue); + } + else + { + ObjectMove("Fhr_P line", 0, Time[40], Fhr_P); + } + + if(ObjectFind("Fhr_R1 line") != 0) + { + ObjectCreate("Fhr_R1 line", OBJ_HLINE, 0, Time[40], Fhr_R1, Time[0], Fhr_R1); + ObjectSet("Fhr_R1 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_R1 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_R1 line", OBJPROP_COLOR, Red); + } + else + { + ObjectMove("Fhr_R1 line", 0, Time[40], Fhr_R1); + } + + if(ObjectFind("Fhr_R2 line") != 0) + { + ObjectCreate("Fhr_R2 line", OBJ_HLINE, 0, Time[0], Fhr_R2);//, Time[0], Fhr_R2); + ObjectSet("Fhr_R2 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_R2 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_R2 line", OBJPROP_COLOR, Red); + } + else + { + ObjectMove("Fhr_R2 line", 0, Time[40], Fhr_R2); + } + + if(ObjectFind("Fhr_R3 line") != 0) + { + ObjectCreate("Fhr_R3 line", OBJ_HLINE, 0, Time[40], Fhr_R3, Time[0], Fhr_R3); + ObjectSet("Fhr_R3 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_R3 line", OBJPROP_WIDTH,4); + ObjectSet("Fhr_R3 line", OBJPROP_COLOR, Red); + } + else + { + ObjectMove("Fhr_R3 line", 0, Time[40], Fhr_R3); + } +} +//---- End of 4 Hour Pivot Line Draw + + +//------ Midpoints Pivots + +if (Fhr == true && midpivots==true) +{ + +if(ObjectFind("Fhr_M5 label") != 0) +{ +ObjectCreate("Fhr_M5 label", OBJ_TEXT, 0, Time[20], Fhr_M5); +ObjectSetText("Fhr_M5 label", " Fhr_M5 " +DoubleToStr(Fhr_M5,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M5 label", 0, Time[0], Fhr_M5); +} + +if(ObjectFind("Fhr_M4 label") != 0) +{ +ObjectCreate("Fhr_M4 label", OBJ_TEXT, 0, Time[20], Fhr_M4); +ObjectSetText("Fhr_M4 label", "Fhr_M4 " +DoubleToStr(Fhr_M4,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M4 label", 0, Time[0], Fhr_M4); +} + +if(ObjectFind("Fhr_M3 label") != 0) +{ +ObjectCreate("Fhr_M3 label", OBJ_TEXT, 0, Time[20], Fhr_M3); +ObjectSetText("Fhr_M3 label", "Fhr_M3 " +DoubleToStr(Fhr_M3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M3 label", 0, Time[0], Fhr_M3); +} + +if(ObjectFind("Fhr_M2 label") != 0) +{ +ObjectCreate("Fhr_M2 label", OBJ_TEXT, 0, Time[20], Fhr_M2); +ObjectSetText("Fhr_M2 label", "Fhr_M2 " +DoubleToStr(Fhr_M2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M2 label", 0, Time[0], Fhr_M2); +} + +if(ObjectFind("Fhr_M1 label") != 0) +{ +ObjectCreate("Fhr_M1 label", OBJ_TEXT, 0, Time[20], Fhr_M1); +ObjectSetText("Fhr_M1 label", "Fhr_M1 " +DoubleToStr(Fhr_M1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M1 label", 0, Time[0], Fhr_M1); +} + +if(ObjectFind("Fhr_M0 label") != 0) +{ +ObjectCreate("Fhr_M0 label", OBJ_TEXT, 0, Time[20], Fhr_M0); +ObjectSetText("Fhr_M0 label", "Fhr_M0 " +DoubleToStr(Fhr_M0,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("Fhr_M0 label", 0, Time[0], Fhr_M0); +} + +//---- Draw Midpoint Pivots on Chart +if(ObjectFind("Fhr_M5 line") != 0) +{ +ObjectCreate("Fhr_M5 line", OBJ_HLINE, 0, Time[0], Fhr_M5, Time[0], Fhr_M5); +ObjectSet("Fhr_M5 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("Fhr_M5 line", OBJPROP_WIDTH,1); +ObjectSet("Fhr_M5 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("Fhr_M5 line", 0, Time[40], Fhr_M5); +} + +if(ObjectFind("Fhr_M4 line") != 0) +{ +ObjectCreate("Fhr_M4 line", OBJ_HLINE, 0, Time[40], Fhr_M4, Time[0], Fhr_M4); +ObjectSet("Fhr_M4 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("Fhr_M4 line", OBJPROP_WIDTH,1); +ObjectSet("Fhr_M4 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("Fhr_M4 line", 0, Time[40], Fhr_M4); +} + +if(ObjectFind("Fhr_M3 line") != 0) +{ +ObjectCreate("Fhr_M3 line", OBJ_HLINE, 0, Time[0], Fhr_M3, Time[0], Fhr_M3); +ObjectSet("Fhr_M3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("Fhr_M3 line", OBJPROP_WIDTH,1); +ObjectSet("Fhr_M3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("Fhr_M3 line", 0, Time[40], Fhr_M3); +} + +if(ObjectFind("Fhr_M2 line") != 0) +{ +ObjectCreate("Fhr_M2 line", OBJ_HLINE, 0, Time[40], Fhr_M2); +ObjectSet("Fhr_M2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("Fhr_M2 line", OBJPROP_WIDTH,1); +ObjectSet("Fhr_M2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("Fhr_M2 line", 0, Time[40], Fhr_M2); +} + +if(ObjectFind("Fhr_M1 line") != 0) + { + ObjectCreate("Fhr_M1 line", OBJ_HLINE, 0, Time[40], Fhr_M1); + ObjectSet("Fhr_M1 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_M1 line", OBJPROP_WIDTH,1); + ObjectSet("Fhr_M1 line", OBJPROP_COLOR, Blue); + } + else + { + ObjectMove("Fhr_M1 line", 0, Time[40], Fhr_M1); + } + + if(ObjectFind("Fhr_M0 line") != 0) + { + ObjectCreate("Fhr_M0 line", OBJ_HLINE, 0, Time[40], Fhr_M0); + ObjectSet("Fhr_M0 line", OBJPROP_STYLE, STYLE_SOLID); + ObjectSet("Fhr_M0 line", OBJPROP_WIDTH,1); + ObjectSet("Fhr_M0 line", OBJPROP_COLOR, Blue); + } + else + { + ObjectMove("Fhr_M0 line", 0, Time[40], Fhr_M0); + } + +} +//--------------------------------------------------------End of 4 hour +//----------------------------------------------------------------------------DAILY Pivot Lines -------------------- +if (daily==true) +{ +if(ObjectFind(" D_R1 label") != 0) +{ +ObjectCreate(" D_R1 label", OBJ_TEXT, 0, Time[0], D_R1); +ObjectSetText("D_R1 label", " D_R1 " +DoubleToStr(D_R1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove(" D_R1 label", 0, Time[0], D_R1); +} + +if(ObjectFind("D_R2 label") != 0) +{ +ObjectCreate("D_R2 label", OBJ_TEXT, 0, Time[20], D_R2); +ObjectSetText("D_R2 label", " D_R2 " +DoubleToStr(D_R2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_R2 label", 0, Time[0], D_R2); +} + +if(ObjectFind("D_R3 label") != 0) +{ +ObjectCreate("D_R3 label", OBJ_TEXT, 0, Time[20], D_R3); +ObjectSetText("D_R3 label", " D_R3 " +DoubleToStr(D_R3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_R3 label", 0, Time[0], D_R3); +} + +if(ObjectFind("D_P label") != 0) +{ +ObjectCreate("D_P label", OBJ_TEXT, 0, Time[0], D_P); +ObjectSetText("D_P label", " DAILY PIVOT POINT " +DoubleToStr(D_P,4), 8, "Arial",EMPTY); +ObjectSet("D_P label", OBJPROP_COLOR, White); +} +else +{ +ObjectMove("D_P label", 0, Time[0], D_P); +} + +if(ObjectFind("D_S1 label") != 0) +{ +ObjectCreate("D_S1 label", OBJ_TEXT, 0, Time[0], D_S1); +ObjectSetText("D_S1 label", " D_S1 " +DoubleToStr(D_S1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_S1 label", 0, Time[0], D_S1); +} + +if(ObjectFind("D_S2 label") != 0) +{ +ObjectCreate("D_S2 label", OBJ_TEXT, 0, Time[20], D_S2); +ObjectSetText("D_S2 label", " D_S2 " +DoubleToStr(D_S2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_S2 label", 0, Time[0], D_S2); +} + +if(ObjectFind("D_S3 label") != 0) +{ +ObjectCreate("D_S3 label", OBJ_TEXT, 0, Time[20], D_S3); +ObjectSetText("D_S3 label", " D_S3 " +DoubleToStr(D_S3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_S3 label", 0, Time[0], D_S3); +} + +//--- Draw Pivot lines on chart +if(ObjectFind("D_S1 line") != 0) +{ +ObjectCreate("D_S1 line", OBJ_HLINE, 0, Time[0], D_S1, Time[0], D_S1); +ObjectSet("D_S1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_S1 line", OBJPROP_WIDTH,4); +ObjectSet("D_S1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_S1 line", 0, Time[40], D_S1); +} + +if(ObjectFind("D_S2 line") != 0) +{ +ObjectCreate("D_S2 line", OBJ_HLINE, 0, Time[40], D_S2); +ObjectSet("D_S2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_S2 line", OBJPROP_WIDTH,4); +ObjectSet("D_S2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_S2 line", 0, Time[40], D_S2); +} + +if(ObjectFind("D_S3 line") != 0) +{ +ObjectCreate("D_S3 line", OBJ_HLINE, 0, Time[40], D_S3); +ObjectSet("D_S3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_S3 line", OBJPROP_WIDTH,4); +ObjectSet("D_S3 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_S3 line", 0, Time[40], D_S3); +} + +if(ObjectFind("D_P line") != 0) +{ +ObjectCreate("D_P line", OBJ_HLINE, 0, Time[40], D_P); +ObjectSet("D_P line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_P line", OBJPROP_WIDTH,4); +ObjectSet("D_P line", OBJPROP_COLOR, LightBlue); +} +else +{ +ObjectMove("D_P line", 0, Time[40], D_P); +} + +if(ObjectFind("D_R1 line") != 0) +{ +ObjectCreate("D_R1 line", OBJ_HLINE, 0, Time[40], D_R1); +ObjectSet("D_R1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_R1 line", OBJPROP_WIDTH,4); +ObjectSet("D_R1 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_R1 line", 0, Time[40], D_R1); +} + +if(ObjectFind("D_R2 line") != 0) +{ +ObjectCreate("D_R2 line", OBJ_HLINE, 0, Time[40], D_R2); +ObjectSet("D_R2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_R2 line", OBJPROP_WIDTH,4); +ObjectSet("D_R2 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_R2 line", 0, Time[40], D_R2); +} + +if(ObjectFind("D_R3 line") != 0) +{ +ObjectCreate("D_R3 line", OBJ_HLINE, 0, Time[40], D_R3); +ObjectSet("D_R3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_R3 line", OBJPROP_WIDTH,4); +ObjectSet("D_R3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_R3 line", 0, Time[40], D_R3); +} +} +//---- End of Pivot Line Draw + + + +//------ Midpoints Pivots + +if (daily == true && midpivots==true) +{ + +if(ObjectFind("D_M5 label") != 0) +{ +ObjectCreate("D_M5 label", OBJ_TEXT, 0, Time[20], D_M5); +ObjectSetText("D_M5 label", " D_M5 " +DoubleToStr(D_M5,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M5 label", 0, Time[0], D_M5); +} + +if(ObjectFind("D_M4 label") != 0) +{ +ObjectCreate("D_M4 label", OBJ_TEXT, 0, Time[20], D_M4); +ObjectSetText("D_M4 label", " D_M4 " +DoubleToStr(D_M4,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M4 label", 0, Time[0], D_M4); +} + +if(ObjectFind("D_M3 label") != 0) +{ +ObjectCreate("D_M3 label", OBJ_TEXT, 0, Time[20], D_M3); +ObjectSetText("D_M3 label", " D_M3 " +DoubleToStr(D_M3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M3 label", 0, Time[0], D_M3); +} + +if(ObjectFind("D_M2 label") != 0) +{ +ObjectCreate("D_M2 label", OBJ_TEXT, 0, Time[20], D_M2); +ObjectSetText("D_M2 label", " D_M2 " +DoubleToStr(D_M2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M2 label", 0, Time[0], D_M2); +} + +if(ObjectFind("D_M1 label") != 0) +{ +ObjectCreate("D_M1 label", OBJ_TEXT, 0, Time[20], D_M1); +ObjectSetText("D_M1 label", " D_M1 " +DoubleToStr(D_M1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M1 label", 0, Time[0], D_M1); +} + +if(ObjectFind("D_M0 label") != 0) +{ +ObjectCreate("D_M0 label", OBJ_TEXT, 0, Time[20], D_M0); +ObjectSetText("D_M0 label", " D_M0 " +DoubleToStr(D_M0,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("D_M0 label", 0, Time[0], D_M0); +} + +//---- Draw Midpoint Pivots on Chart +if(ObjectFind("D_M5 line") != 0) +{ +ObjectCreate("D_M5 line", OBJ_HLINE, 0, Time[40], D_M5); +ObjectSet("D_M5 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M5 line", OBJPROP_WIDTH,1); +ObjectSet("D_M5 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_M5 line", 0, Time[40], D_M5); +} + +if(ObjectFind("D_M4 line") != 0) +{ +ObjectCreate("D_M4 line", OBJ_HLINE, 0, Time[40], D_M4); +ObjectSet("D_M4 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M4 line", OBJPROP_WIDTH,1); +ObjectSet("D_M4 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_M4 line", 0, Time[40], D_M4); +} + +if(ObjectFind("D_M3 line") != 0) +{ +ObjectCreate("D_M3 line", OBJ_HLINE, 0, Time[40], D_M3); +ObjectSet("D_M3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M3 line", OBJPROP_WIDTH,1); +ObjectSet("D_M3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("D_M3 line", 0, Time[40], D_M3); +} + +if(ObjectFind("D_M2 line") != 0) +{ +ObjectCreate("D_M2 line", OBJ_HLINE, 0, Time[40], D_M2); +ObjectSet("D_M2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M2 line", OBJPROP_WIDTH,1); +ObjectSet("D_M2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_M2 line", 0, Time[40], D_M2); +} + +if(ObjectFind("D_M1 line") != 0) +{ +ObjectCreate("D_M1 line", OBJ_HLINE, 0, Time[40], D_M1); +ObjectSet("D_M1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M1 line", OBJPROP_WIDTH,1); +ObjectSet("D_M1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_M1 line", 0, Time[40], D_M1); +} + +if(ObjectFind("D_M0 line") != 0) +{ +ObjectCreate("D_M0 line", OBJ_HLINE, 0, Time[40], D_M0); +ObjectSet("D_M0 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("D_M0 line", OBJPROP_WIDTH,1); +ObjectSet("D_M0 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("D_M0 line", 0, Time[40], D_M0); +} + +} +//-------------=---------------------------------------------------------------------End of DAILY +//---------------------------------------------------------------------WEEKLY Pivot Lines -------------------- +if (weekly==true) + { + if(ObjectFind("W_R1 label") != 0) + { + ObjectCreate("W_R1 label", OBJ_TEXT, 0, Time[0], W_R1); + ObjectSetText("W_R1 label", "W_R1 " +DoubleToStr(W_R1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_R1 label", 0, Time[0], W_R1); +} + +if(ObjectFind("W_R2 label") != 0) +{ +ObjectCreate("W_R2 label", OBJ_TEXT, 0, Time[20], W_R2); +ObjectSetText("W_R2 label", "W_R2 " +DoubleToStr(W_R2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_R2 label", 0, Time[0], W_R2); +} + +if(ObjectFind("W_R3 label") != 0) +{ +ObjectCreate("W_R3 label", OBJ_TEXT, 0, Time[20], W_R3); +ObjectSetText("W_R3 label", "W_R3 " +DoubleToStr(W_R3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_R3 label", 0, Time[0], W_R3); +} + +if(ObjectFind("W_P label") != 0) +{ +ObjectCreate("W_P label", OBJ_TEXT, 0, Time[0], W_P); +ObjectSetText("W_P label", "W_Pivot " +DoubleToStr(W_P,4), 8, "Arial",EMPTY); +} +else +{ +ObjectMove("W_P label", 0, Time[0], W_P); +} + +if(ObjectFind("W_S1 label") != 0) +{ +ObjectCreate("W_S1 label", OBJ_TEXT, 0, Time[0], W_S1); +ObjectSetText("W_S1 label", "W_S1 " +DoubleToStr(W_S1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_S1 label", 0, Time[0], W_S1); +} + +if(ObjectFind("W_S2 label") != 0) +{ +ObjectCreate("W_S2 label", OBJ_TEXT, 0, Time[20], W_S2); +ObjectSetText("W_S2 label", "W_S2 " +DoubleToStr(W_S2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_S2 label", 0, Time[0], W_S2); +} + +if(ObjectFind("W_S3 label") != 0) +{ +ObjectCreate("W_S3 label", OBJ_TEXT, 0, Time[20], W_S3); +ObjectSetText("W_S3 label", "W_S3 " +DoubleToStr(W_S3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_S3 label", 0, Time[0], W_S3); +} + +//--- Draw Pivot lines on chart +if(ObjectFind("W_S1 line") != 0) +{ +ObjectCreate("W_S1 line", OBJ_HLINE, 0, Time[40], W_S1); +ObjectSet("W_S1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_S1 line", OBJPROP_WIDTH,4); +ObjectSet("W_S1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_S1 line", 0, Time[40], W_S1); +} + +if(ObjectFind("W_S2 line") != 0) +{ +ObjectCreate("W_S2 line", OBJ_HLINE, 0, Time[40], W_S2); +ObjectSet("W_S2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_S2 line", OBJPROP_WIDTH,4); +ObjectSet("W_S2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_S2 line", 0, Time[40], W_S2); +} + +if(ObjectFind("W_S3 line") != 0) +{ +ObjectCreate("W_S3 line", OBJ_HLINE, 0, Time[40], W_S3); +ObjectSet("W_S3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_S3 line", OBJPROP_WIDTH,4); +ObjectSet("W_S3 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_S3 line", 0, Time[40], W_S3); +} + +if(ObjectFind("W_P line") != 0) +{ +ObjectCreate("W_P line", OBJ_HLINE, 0, Time[40], W_P); +ObjectSet("W_P line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_P line", OBJPROP_WIDTH,4); +ObjectSet("W_P line", OBJPROP_COLOR, LightBlue); +} +else +{ +ObjectMove("W_P line", 0, Time[40], W_P); +} + +if(ObjectFind("W_R1 line") != 0) +{ +ObjectCreate("W_R1 line", OBJ_HLINE, 0, Time[40], W_R1); +ObjectSet("W_R1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_R1 line", OBJPROP_WIDTH,4); +ObjectSet("W_R1 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_R1 line", 0, Time[40], W_R1); +} + +if(ObjectFind("W_R2 line") != 0) +{ +ObjectCreate("W_R2 line", OBJ_HLINE, 0, Time[40], W_R2); +ObjectSet("W_R2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_R2 line", OBJPROP_WIDTH,4); +ObjectSet("W_R2 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_R2 line", 0, Time[40], W_R2); +} + +if(ObjectFind("W_R3 line") != 0) +{ +ObjectCreate("W_R3 line", OBJ_HLINE, 0, Time[40], W_R3); +ObjectSet("W_R3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_R3 line", OBJPROP_WIDTH,4); +ObjectSet("W_R3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_R3 line", 0, Time[40], W_R3); +} +} +//---- End of Pivot Line Draw + + + +//------ Midpoints Pivots + +if (weekly == true && midpivots==true) +{ + +if(ObjectFind("W_M5 label") != 0) +{ +ObjectCreate("W_M5 label", OBJ_TEXT, 0, Time[20], W_M5); +ObjectSetText("W_M5 label", "W_M5 " +DoubleToStr(W_M5,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M5 label", 0, Time[0], W_M5); +} + +if(ObjectFind("W_M4 label") != 0) +{ +ObjectCreate("W_M4 label", OBJ_TEXT, 0, Time[20], W_M4); +ObjectSetText("W_M4 label", "W_M4 " +DoubleToStr(W_M4,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M4 label", 0, Time[0], W_M4); +} + +if(ObjectFind("W_M3 label") != 0) +{ +ObjectCreate("W_M3 label", OBJ_TEXT, 0, Time[20], W_M3); +ObjectSetText("W_M3 label", "W_M3 " +DoubleToStr(W_M3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M3 label", 0, Time[0], W_M3); +} + +if(ObjectFind("W_M2 label") != 0) +{ +ObjectCreate("W_M2 label", OBJ_TEXT, 0, Time[20], W_M2); +ObjectSetText("W_M2 label", "W_M2 " +DoubleToStr(W_M2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M2 label", 0, Time[0], W_M2); +} + +if(ObjectFind("W_M1 label") != 0) +{ +ObjectCreate("W_M1 label", OBJ_TEXT, 0, Time[20], W_M1); +ObjectSetText("W_M1 label", "W_M1 " +DoubleToStr(W_M1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M1 label", 0, Time[0], W_M1); +} + +if(ObjectFind("W_M0 label") != 0) +{ +ObjectCreate("W_M0 label", OBJ_TEXT, 0, Time[20], W_M0); +ObjectSetText("W_M0 label", "W_M0 " +DoubleToStr(W_M0,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("W_M0 label", 0, Time[0], W_M0); +} + +//---- Draw Midpoint Pivots on Chart +if(ObjectFind("W_M5 line") != 0) +{ +ObjectCreate("W_M5 line", OBJ_HLINE, 0, Time[40], W_M5); +ObjectSet("W_M5 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M5 line", OBJPROP_WIDTH,1); +ObjectSet("W_M5 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_M5 line", 0, Time[40], W_M5); +} + +if(ObjectFind("W_M4 line") != 0) +{ +ObjectCreate("W_M4 line", OBJ_HLINE, 0, Time[40], W_M4); +ObjectSet("W_M4 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M4 line", OBJPROP_WIDTH,1); +ObjectSet("W_M4 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_M4 line", 0, Time[40], W_M4); +} + +if(ObjectFind("W_M3 line") != 0) +{ +ObjectCreate("W_M3 line", OBJ_HLINE, 0, Time[40], W_M3); +ObjectSet("W_M3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M3 line", OBJPROP_WIDTH,1); +ObjectSet("W_M3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("W_M3 line", 0, Time[40], W_M3); +} + +if(ObjectFind("W_M2 line") != 0) +{ +ObjectCreate("W_M2 line", OBJ_HLINE, 0, Time[40], W_M2); +ObjectSet("W_M2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M2 line", OBJPROP_WIDTH,1); +ObjectSet("W_M2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_M2 line", 0, Time[40], W_M2); +} + +if(ObjectFind("W_M1 line") != 0) +{ +ObjectCreate("W_M1 line", OBJ_HLINE, 0, Time[40], W_M1); +ObjectSet("W_M1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M1 line", OBJPROP_WIDTH,1); +ObjectSet("W_M1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_M1 line", 0, Time[40], W_M1); +} + +if(ObjectFind("W_M0 line") != 0) +{ +ObjectCreate("W_M0 line", OBJ_HLINE, 0, Time[40], W_M0); +ObjectSet("W_M0 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("W_M0 line", OBJPROP_WIDTH,1); +ObjectSet("W_M0 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("W_M0 line", 0, Time[40], W_M0); +} + +} +//-------------=-------------------------------------------End WEEKLY + + + + +//--------------------------------------------------------------------Monthly Pivot Lines -------------------- +if (monthly == true) +{ +if(ObjectFind("M_R1 label") != 0) +{ +ObjectCreate("M_R1 label", OBJ_TEXT, 0, Time[0], M_R1); +ObjectSetText("M_R1 label", " M_R1 " +DoubleToStr(M_R1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_R1 label", 0, Time[0], M_R1); +} + +if(ObjectFind("M_R2 label") != 0) +{ +ObjectCreate("M_R2 label", OBJ_TEXT, 0, Time[20], M_R2); +ObjectSetText("M_R2 label", " M_R2 " +DoubleToStr(M_R2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_R2 label", 0, Time[0], M_R2); +} + +if(ObjectFind("M_R3 label") != 0) +{ +ObjectCreate("M_R3 label", OBJ_TEXT, 0, Time[20], M_R3); +ObjectSetText("M_R3 label", " M_R3 " +DoubleToStr(M_R3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_R3 label", 0, Time[0], M_R3); +} + +if(ObjectFind("M_P label") != 0) +{ +ObjectCreate("M_P label", OBJ_TEXT, 0, Time[0], M_P); +ObjectSetText("M_P label", "M_Pivot " +DoubleToStr(M_P,4), 8, "Arial",EMPTY); +} +else +{ +ObjectMove("M_P label", 0, Time[0], M_P); +} + +if(ObjectFind("M_S1 label") != 0) +{ +ObjectCreate("M_S1 label", OBJ_TEXT, 0, Time[0], M_S1); +ObjectSetText("M_S1 label", "M_S1 " +DoubleToStr(M_S1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_S1 label", 0, Time[0], M_S1); +} + +if(ObjectFind("M_S2 label") != 0) +{ +ObjectCreate("M_S2 label", OBJ_TEXT, 0, Time[20], M_S2); +ObjectSetText("M_S2 label", "S2 " +DoubleToStr(M_S2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_S2 label", 0, Time[0], M_S2); +} + +if(ObjectFind("M_S3 label") != 0) +{ +ObjectCreate("M_S3 label", OBJ_TEXT, 0, Time[20], M_S3); +ObjectSetText("M_S3 label", "M_S3 " +DoubleToStr(M_S3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_S3 label", 0, Time[0], M_S3); +} + +//--- Draw Pivot lines on chart +if(ObjectFind("M_S1 line") != 0) +{ +ObjectCreate("M_S1 line", OBJ_HLINE, 0, Time[40], M_S1); +ObjectSet("M_S1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_S1 line", OBJPROP_WIDTH,4); +ObjectSet("M_S1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_S1 line", 0, Time[40], M_S1); +} + +if(ObjectFind("M_S2 line") != 0) +{ +ObjectCreate("M_S2 line", OBJ_HLINE, 0, Time[40], M_S2); +ObjectSet("M_S2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_S2 line", OBJPROP_WIDTH,4); +ObjectSet("M_S2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_S2 line", 0, Time[40], M_S2); +} + +if(ObjectFind("M_S3 line") != 0) +{ +ObjectCreate("M_S3 line", OBJ_HLINE, 0, Time[40], M_S3); +ObjectSet("M_S3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_S3 line", OBJPROP_WIDTH,4); +ObjectSet("M_S3 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_S3 line", 0, Time[40], M_S3); +} + +if(ObjectFind("M_P line") != 0) +{ +ObjectCreate("M_P line", OBJ_HLINE, 0, Time[40], M_P); +ObjectSet("M_P line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_P line", OBJPROP_WIDTH,4); +ObjectSet("M_P line", OBJPROP_COLOR, LightBlue); +} +else +{ +ObjectMove("M_P line", 0, Time[40], M_P); +} + +if(ObjectFind("M_R1 line") != 0) +{ +ObjectCreate("M_R1 line", OBJ_HLINE, 0, Time[40], M_R1); +ObjectSet("M_R1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_R1 line", OBJPROP_WIDTH,4); +ObjectSet("M_R1 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_R1 line", 0, Time[40], M_R1); +} + +if(ObjectFind("M_R2 line") != 0) +{ +ObjectCreate("M_R2 line", OBJ_HLINE, 0, Time[40], M_R2); +ObjectSet("M_R2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_R2 line", OBJPROP_WIDTH,4); +ObjectSet("M_R2 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_R2 line", 0, Time[40], M_R2); +} + +if(ObjectFind("M_R3 line") != 0) +{ +ObjectCreate("M_R3 line", OBJ_HLINE, 0, Time[40], M_R3); +ObjectSet("M_R3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_R3 line", OBJPROP_WIDTH,4); +ObjectSet("M_R3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_R3 line", 0, Time[40], M_R3); +} +} +//---- End of Pivot Line Draw + + + +//------ Midpoints Pivots + +if (monthly == true && midpivots==true) +{ + +if(ObjectFind("M_M5 label") != 0) +{ +ObjectCreate("M_M5 label", OBJ_TEXT, 0, Time[20], M_M5); +ObjectSetText("M_M5 label", " M_M5 " +DoubleToStr(M_M5,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M5 label", 0, Time[0], M_M5); +} + +if(ObjectFind("M_M4 label") != 0) +{ +ObjectCreate("M_M4 label", OBJ_TEXT, 0, Time[20], M_M4); +ObjectSetText("M_M4 label", " M_M4 " +DoubleToStr(M_M4,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M4 label", 0, Time[0], M_M4); +} + +if(ObjectFind("M_M3 label") != 0) +{ +ObjectCreate("M_M3 label", OBJ_TEXT, 0, Time[20], M_M3); +ObjectSetText("M_M3 label", " M_M3 " +DoubleToStr(M_M3,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M3 label", 0, Time[0], M_M3); +} + +if(ObjectFind("M_M2 label") != 0) +{ +ObjectCreate("M_M2 label", OBJ_TEXT, 0, Time[20], M_M2); +ObjectSetText("M_M2 label", " M_M2 " +DoubleToStr(M_M2,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M2 label", 0, Time[0], M_M2); +} + +if(ObjectFind("M_M1 label") != 0) +{ +ObjectCreate("M_M1 label", OBJ_TEXT, 0, Time[20], M_M1); +ObjectSetText("M_M1 label", " M_M1 " +DoubleToStr(M_M1,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M1 label", 0, Time[0], M_M1); +} + +if(ObjectFind("M_M0 label") != 0) +{ +ObjectCreate("M_M0 label", OBJ_TEXT, 0, Time[20], M_M0); +ObjectSetText("M_M0 label", " M_M0 " +DoubleToStr(M_M0,4), 8, "Arial", EMPTY); +} +else +{ +ObjectMove("M_M0 label", 0, Time[0], M_M0); +} + +//---- Draw Midpoint Pivots on Chart +if(ObjectFind("M_M5 line") != 0) +{ +ObjectCreate("M_M5 line", OBJ_HLINE, 0, Time[40], M_M5, Time[20], M_M5); +ObjectSet("M_M5 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M5 line", OBJPROP_WIDTH,1); +ObjectSet("M_M5 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_M5 line", 0, Time[40], M_M5); +} + +if(ObjectFind("M_M4 line") != 0) +{ +ObjectCreate("M_M4 line", OBJ_HLINE, 0, Time[40], M_M4); +ObjectSet("M_M4 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M4 line", OBJPROP_WIDTH,1); +ObjectSet("M_M4 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_M4 line", 0, Time[40], M_M4); +} + +if(ObjectFind("M_M3 line") != 0) +{ +ObjectCreate("M_M3 line", OBJ_HLINE, 0, Time[40], M_M3); +ObjectSet("M_M3 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M3 line", OBJPROP_WIDTH,1); +ObjectSet("M_M3 line", OBJPROP_COLOR, Red); +} +else +{ +ObjectMove("M_M3 line", 0, Time[40], M_M3); +} + +if(ObjectFind("M_M2 line") != 0) +{ +ObjectCreate("M_M2 line", OBJ_HLINE, 0, Time[40], M_M2); +ObjectSet("M_M2 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M2 line", OBJPROP_WIDTH,1); +ObjectSet("M_M2 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_M2 line", 0, Time[40], M_M2); +} + +if(ObjectFind("M_M1 line") != 0) +{ +ObjectCreate("M_M1 line", OBJ_HLINE, 0, Time[40], M_M1); +ObjectSet("M_M1 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M1 line", OBJPROP_WIDTH,1); +ObjectSet("M_M1 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_M1 line", 0, Time[40], M_M1); +} + +if(ObjectFind("M_M0 line") != 0) +{ +ObjectCreate("M_M0 line", OBJ_HLINE, 0, Time[40], M_M0); +ObjectSet("M_M0 line", OBJPROP_STYLE, STYLE_SOLID); +ObjectSet("M_M0 line", OBJPROP_WIDTH,1); +ObjectSet("M_M0 line", OBJPROP_COLOR, Blue); +} +else +{ +ObjectMove("M_M0 line", 0, Time[40], M_M0); +} + +} +//-------------=--------------------------------------END of MONTHLY + + +//----------------------------------------------------------------------------------------------------------------------- + +//---- End Of Program +return(0); +} +//+------------------------------------------------------------------+ + diff --git a/Primeval-EA v1.0.mq4 b/Primeval-EA v1.0.mq4 new file mode 100644 index 0000000..af99773 --- /dev/null +++ b/Primeval-EA v1.0.mq4 @@ -0,0 +1,2592 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.224.1 [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2010, Primeval-EA Developers, LLC v1.0" +#property link "http://www.primeval-ea.com/" + +#import "Primeval.dll" + double fun001(double a0, int a1, double a2, int a3, int a4, double a5, double a6, double a7, int a8, double a9, double a10, double a11); + int fun002(int a0, int a1, double a2, int a3, double a4, int a5, int a6, double a7, int a8, double a9, double a10, double a11, double a12, double a13, double a14); + bool fun003(int a0, int a1, int a2, int a3, int a4); + bool fun004(double a0, int a1, double a2, int a3, double a4, double a5); + bool fun005(int a0, int a1, int a2, int a3, int a4); + void fun006(string a0, int a1, int& a2[], int& a3[], int& a4[], int& a5[], double& a6[], double& a7[], double& a8[], double& a9[], double& a10[], int& a11[], int a12); + void fun007(double a0, double a1, double a2, double a3, double a4, int a5, int a6, double& a7[], double& a8[], double& a9[], double& a10[], int a11, string a12); + void fun008(double a0, double a1, double a2, double a3, double a4, int a5, int a6, double& a7[], double& a8[], double& a9[], double& a10[], int a11, string a12); + bool fun009(double a0, double a1, int a2, double a3, int a4, double a5, double a6, double a7, double a8, int a9); + bool fun010(double a0, double a1, int a2, double a3, int a4, double a5, double a6, double a7, double a8, int a9); + bool fun011(int a0, int a1, int a2, double a3, double a4, double a5, double a6, int a7, int a8, int a9, int a10, int a11); + bool fun012(double a0, double a1, double a2, double a3, double a4); + bool fun013(double a0, double a1, double a2, double a3, double a4, double a5, double a6, int a7, int a8, double a9, double a10, double a11, double a12, int a13, double a14, int a15, string a16, string a17, string a18, int a19); + bool fun014(double a0, double a1, double a2, double a3, double a4, double a5, double a6, int a7, int a8, double a9, double a10, double a11, double a12, int a13, double a14, int a15, string a16, string a17, string a18, int a19); + bool fun015(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7, int a8, double a9, double a10, double a11, double a12, int a13, double a14, int a15, string a16, string a17, string a18, int a19); + bool fun016(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7, int a8, double a9, double a10, double a11, double a12, int a13, double a14, int a15, string a16, string a17, string a18, int a19); + bool fun017(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7, double a8, double a9, double a10, double a11, int a12, double a13, int a14, string a15, string a16, string a17, int a18); + bool fun018(double a0, double a1, double a2, double a3, double a4, double a5, int a6, int a7, double a8, double a9, double a10, double a11, int a12, double a13, int a14, string a15, string a16, string a17, int a18); + void fun019(string a0, int& a1[], int& a2[], int& a3[], int& a4[], double& a5[], int& a6[], int& a7[], int& a8[], int& a9[], int& a10[], int& a11[], int& a12[], int& a13[], int& a14[], int& a15[]); + bool fun020(double a0, double a1, double a2, double a3, double a4, int a5, string a6, string a7, string a8, int a9); + bool fun021(double a0, double a1, double a2, double a3, double a4, int a5, string a6, string a7, string a8, int a9); + void fun022(string a0, double& a1[], double& a2[], double& a3[], double& a4[], double& a5[], double& a6[], int a7); + double fun023(int a0, int a1, double a2, double a3, double a4); + bool fun024(double a0, double a1, double a2, double a3, double a4, double a5, double a6, int a7, string a8, string a9, string a10, int a11); + bool fun025(double a0, double a1, double a2, double a3, double a4, double a5, double a6, int a7, string a8, string a9, string a10, int a11); + void fun026(string a0, int& a1[], int& a2[], int& a3[], int& a4[], int& a5[], int& a6[], int& a7[], int& a8[], int& a9[], double& a10[], double& a11[], int& a12[], int& a13[], int& a14[]); + int fun027(string a0, int a1); + void fun029(bool a0, double a1, int a2, int& a3[], double& a4[], double& a5[], double& a6[], int& a7[]); + int fun030(double a0, double a1, double& a2[], double& a3[], int& a4[], double a5, int& a6[], int a7, int& a8[], int a9, double a10, int a11, string a12, string a13, string a14, int a15); + bool fun031(double& a0[], double a1, double a2, int a3, int a4, bool& a5[]); + bool fun032(int a0, double a1, double a2, double a3, int a4, int a5, int a6, double a7); + void fun033(double a0, double a1, int a2, double& a3[], double& a4[], double& a5[]); + bool fun034(double a0, double a1, int a2, double a3, double a4, double a5, int a6, string a7, string a8, string a9, int a10); + int fun035(int a0, double a1, double a2, string a3, double a4, double a5, double& a6[], int& a7[], int& a8[]); + bool fun036(int a0, int a1, double a2, double a3, int a4, double a5, int a6, int a7, int a8, double a9, double a10, int a11, double a12, int a13, string a14, string a15, string a16, int a17); + void fun037(int& a0[], double a1, int& a2[]); + void fun038(int& a0[], double a1, double a2, int& a3[]); + void fun039(double a0, double a1, double a2, double a3, double a4, double a5, int& a6[], double a7, int a8, string a9, string a10, string a11, int a12); + void fun040(int a0, int a1, double a2, double a3, double a4, int& a5[], double a6, int a7, string a8, string a9, string a10, int a11); + bool fun041(int a0, double a1, double a2, double a3, double a4, int a5, string a6, string a7, string a8, int a9); + bool fun042(int a0, double a1, double a2, double a3, double a4, int a5, string a6, string a7, string a8, int a9); + bool fun043(double a0, double a1, double a2, double a3, double a4, int a5, string a6, string a7, string a8, int a9); + bool fun044(string a0, int a1, int a2, int a3, int a4, int a5, int a6); + string fun045(int a0); + void fun046(string a0, int& a1[]); + bool fun000(double a0, int a1, string a2, string a3, string a4, int a5); +#import "wininet.dll" + int InternetOpenA(string a0, int a1, string a2, string a3, int a4); + int InternetOpenUrlA(int a0, string a1, string a2, int a3, int a4, int a5); + int InternetReadFile(int a0, string a1, int a2, int& a3[]); + int InternetCloseHandle(int a0); +#import + +extern string _A = "STRATEGY SELECTION"; +extern bool GBPUSD_Hedging_Strategy = FALSE; +extern bool EURCHF_Grid_Strategy = FALSE; +extern string _B = "TIME MANAGEMENT"; +extern bool UseAutoGMTOffset = TRUE; +extern int ManualGMTOffset = 2; +int gi_108 = -100; +extern string _C = "ORDER MANAGEMENT"; +extern bool MoneyManagement = TRUE; +extern double LotSize = 0.1; +extern double MinLots = 0.01; +extern double MaxLots = 100.0; +extern bool TradeMicroLots = TRUE; +extern string _D = "RISK MANAGEMENT"; +extern int RiskLevel = 10; +extern string _E = "SYSTEM PARAMETERS"; +extern bool NFA_Compliant = FALSE; +extern bool EnableTrading = TRUE; +extern bool GBPUSD_Hedging_CloseAll = FALSE; +extern double Slippage = 2.0; +extern double MaxSpread = 8.0; +extern int MarginCutOffPercent = 60; +extern bool SendEmail = FALSE; +extern bool SendTradingStatistics = FALSE; +extern int TradingStatisticsHour = 15; +extern string ExpertComment = "Primeval-EA"; +extern string _F = "MANUAL TRADES"; +extern bool EnableClosingManualTrades = FALSE; +extern bool EnableTrailingStops = TRUE; +extern int TrailingStopStart = 14; +extern int TrailingStopPriceSteps = 2; +extern int TrailingStopPosSteps = 1; +extern string _G = "ORDERS ALERTS"; +extern bool SoundAlert = TRUE; +extern string SoundFileAtBuy = "alert.wav"; +extern string SoundFileAtSell = "alert.wav"; +extern string SoundFileAtClose = "ok.wav"; +int g_color_288 = Green; +int g_color_292 = Red; +int g_color_296 = Violet; +extern string _H = "EA REGISTRATION"; +extern double KEY = 2010.0; +string gs_316; +double g_spread_324; +int g_ticket_332 = -1; +bool gi_336 = TRUE; +int gi_340; +int gi_344 = 5; +int gi_348 = 15; +bool gi_352 = FALSE; +int gi_356 = 0; +int gi_unused_360 = 25; +int gi_unused_364 = 20; +int gi_unused_368 = 35; +int gi_unused_372 = 30; +string gs_unused_376 = "Wingdings"; +int gi_unused_384 = 15; +int g_fontsize_388 = 8; +string gs_tacoma_392 = "Tacoma"; +int g_color_400 = White; +int gi_unused_404 = 221; +int gi_unused_408 = 222; +int gi_unused_412 = 163; +int gi_unused_416 = 32768; +int gi_unused_420 = 255; +int gi_unused_424 = 0; +bool gi_428 = TRUE; +double gd_432; +double gd_440; +double g_lotstep_448; +double gd_456; +int g_acc_number_464; +string gsa_468[3]; +int g_bool_472; +bool gi_476 = FALSE; +bool gi_480 = FALSE; +bool gi_484 = TRUE; +int gi_488 = 10; +int gi_492 = 35; +int gi_496 = 5; +int gi_500 = 5; +bool gi_504 = TRUE; +bool gi_508 = FALSE; +int g_magic_512 = 19851031; +double gda_516[5][4]; +int gi_520 = 8; +int gi_524 = 17; +int gi_528 = 20; +int gi_532 = 29; +int gi_536 = 37; +int g_period_540 = 11; +int g_period_544 = 38; +double gd_548 = 53.0; +double gd_556 = 48.0; +double g_lots_564; +bool gba_572[2]; +int gi_576 = 90; +int gi_580 = 0; +int gi_584 = -14; +int gi_588 = 8100; +int gi_592 = 10800; +int gi_596 = 12600; +int gi_600 = 20; +int gi_604 = 0; +int g_magic_608 = -1264664266; +int gi_612; +double gd_616; +string g_symbol_624; +int gi_632; +int gi_636; +int gi_unused_640; +int gi_unused_644; +int gi_648; +int gi_652; +int gi_656; +int gi_660; +int gi_664; +int gi_668; +int gi_672; +int gi_676; +int gi_680; +int gi_684; +int gi_688; +int gi_692; +int gi_696; +int gi_700; +int gi_704; +double gd_708; +double gd_716; +double gd_724; +double gd_732; +double gd_740; +double gd_748; +double gd_756; +double gd_764; +int gi_772 = 1; +int gi_776 = 30; +int gi_780 = 15; +int gi_784 = 22; +int gi_788 = 24; +double gd_792 = 70.0; +double gd_800 = 64.0; +double gd_808 = 30.0; +double gd_816 = 36.0; +double gd_824 = 100.15; +int g_magic_832 = 784610; +int g_magic_836 = 1331580; +int gi_unused_840 = 1; +int gi_844 = 2; +double gd_848 = 0.0001; +double gd_unused_856 = 4.0; +bool gi_864 = TRUE; +bool gi_868 = TRUE; +double gd_872 = 32.0; +int gi_880 = 32; +int gi_884 = 15; +bool gi_888 = TRUE; +bool gi_892 = TRUE; +bool gi_896 = TRUE; +bool gi_900 = TRUE; +bool gi_904 = TRUE; +bool gi_908 = TRUE; +int gi_912 = 0; +int g_count_916 = 0; +int g_count_920 = 0; +int g_count_924 = 0; +int g_count_928 = 0; +int g_count_932 = 0; +double gd_unused_936 = 0.0; +double gd_944 = 0.0; +int gi_952 = 0; +double gd_956 = 0.0; +int gi_964 = 0; +string gs_dummy_968; +int g_ticket_976; +int g_ticket_980; +int g_ticket_984; +int g_ticket_988; +int g_ticket_992; +int g_ticket_996; +double g_ifractals_1000; +double g_ifractals_1008; +double g_ifractals_1016; +double g_ifractals_1024; +int gi_1032; +int gi_1036 = 0; +int gi_1044; +int g_hour_1048; +int gi_1052; +int g_stoplevel_1056; +double gd_1060; +double g_irsi_1068; +double g_irsi_1076; +double g_icci_1084; +double g_ima_1092; +int g_shift_1100; +double g_ihigh_1104 = 0.0; +double g_ilow_1112 = 0.0; +int g_ticket_1124 = -1; +int g_ticket_1128 = -1; +int g_datetime_1132 = 0; +int g_datetime_1136 = 0; +int gi_1140 = 45; +int gia_1144[500]; +int gi_1148; +double gda_1152[85]; +double gda_1156[85]; +int gia_1160[85]; +int gi_1164 = 0; +int gi_1168 = 0; +double gd_1172 = 0.0; +int gi_1180 = 80; +bool gi_1184 = FALSE; +double gd_1188; +double gd_1196; +int g_magic_1204 = 87851; +int g_magic_1208 = 87861; +string g_var_name_1212 = "PRIMEVAL_GLOBAL_VAR_0"; +string g_var_name_1220 = "PRIMEVAL_GLOBAL_VAR_1"; +string g_var_name_1228 = "PRIMEVAL_GLOBAL_VAR_2"; +string g_var_name_1236 = "PRIMEVAL_GLOBAL_VAR_3"; +string g_var_name_1244 = "PRIMEVAL_GLOBAL_VAR_4"; +string g_var_name_1252 = "PRIMEVAL_GLOBAL_VAR_5"; +string g_var_name_1260 = "PRIMEVAL_GLOBAL_VAR_6"; +string g_var_name_1268 = "PRIMEVAL_GLOBAL_VAR_7"; +string g_var_name_1276 = "PRIMEVAL_GLOBAL_VAR_8"; +string g_var_name_1284 = "PRIMEVAL_GLOBAL_VAR_9"; +string g_var_name_1292 = "PRIMEVAL_GLOBAL_VAR_10"; +string gs_1300 = "PRIMEVAL_GLOBAL_VAR_11"; +string gs_1308 = "PRIMEVAL_GLOBAL_VAR_12"; +string g_var_name_1316 = "PRIMEVAL_GLOBAL_VAR_13"; +string g_var_name_1324 = "PRIMEVAL_GLOBAL_VAR_14"; +string g_var_name_1332 = "PRIMEVAL_GLOBAL_VAR_15"; +string gs_1340 = "PRIMEVAL_GLOBAL_VAR_16"; +string gs_1348 = "PRIMEVAL_GLOBAL_VAR_17"; +string g_var_name_1356 = "PRIMEVAL_GLOBAL_VAR_18"; +string g_var_name_1364 = "PRIMEVAL_GLOBAL_VAR_19"; +double g_global_var_1372; +double g_global_var_1380; +double g_lots_1388; +double g_lots_1396; +int g_global_var_1404 = 0; +int g_global_var_1408 = 0; +int gi_1412 = 0; +int gi_1416 = 0; +double g_global_var_1420; +int g_global_var_1428 = 0; +int g_global_var_1432 = 0; +int g_global_var_1436 = 0; +int g_global_var_1440 = 0; +int gi_1444 = 0; +int gi_1448 = 0; +int gi_1452 = 0; +bool gi_1456; +bool gi_1460; +double g_iadx_1464; +double g_iadx_1472; +double gd_1480; +double g_ima_1488; +double gd_1496; +double gd_1504; +double gd_1512; +double g_ima_1520; +double gd_1528; +double gd_1536; +double g_ima_1544; +double g_ima_1552; +int g_global_var_1560; +int g_global_var_1564; +int g_global_var_1568; +int g_global_var_1572; +double gd_1576; +int gi_1584; +double gd_1588; +double gd_1596; +int g_count_1604; +bool gi_1608 = FALSE; +bool gi_1612 = FALSE; +bool gi_1616 = TRUE; +int gi_1620 = 200; +int gi_1624 = 160; +double gd_1628; +double gd_1636; +double gd_1644; +double gd_1652; +double gd_1660; +double gd_1668; +double gd_unused_1676; +int g_period_1684 = 1; +int g_period_1688 = 11; +string gs_1692 = "http://www.primeval-ea.com/primeval/GetAutoGMTOffset?hour="; +string gs_1700 = "WinInet GMT"; +int gi_1708 = -1; +double g_ord_open_price_1712 = 0.0; +double g_ord_open_price_1720; +double g_ord_open_price_1728 = 0.0; +double g_ord_open_price_1736; +int g_count_1744 = 0; +int g_count_1748 = 0; +int g_datetime_1752 = 0; + +int nyusgfj(int a_ticket_0, double a_price_4, double a_price_12, double a_price_20) { + int l_error_32; + bool l_bool_36 = FALSE; + int l_count_28 = 0; + while (l_count_28 < 5) { + l_bool_36 = OrderModify(a_ticket_0, a_price_4, a_price_12, a_price_20, 0, Aqua); + if (l_bool_36) l_count_28 = 5; + else { + l_error_32 = GetLastError(); + Print(l_count_28, " Error modifying order : (", fun045(l_error_32), ") "); + if (l_error_32 > 0/* NO_ERROR */) l_count_28++; + } + } + return (l_bool_36); +} + +bool piwejansmj(int a_ticket_0) { + int l_error_8; + bool li_ret_12 = FALSE; + if (!OrderSelect(a_ticket_0, SELECT_BY_TICKET)) return (FALSE); + int l_count_4 = 0; + if (OrderType() == OP_BUY || OrderType() == OP_SELL) { + while (l_count_4 < 10) { + RefreshRates(); + li_ret_12 = OrderClose(a_ticket_0, OrderLots(), OrderClosePrice(), Slippage, g_color_296); + if (li_ret_12) l_count_4 = 10; + else { + l_error_8 = GetLastError(); + Print(l_count_4, " Error closing order : (", fun045(l_error_8), ") "); + if (l_error_8 > 0/* NO_ERROR */) l_count_4++; + } + } + } else li_ret_12 = OrderDelete(a_ticket_0); + if (li_ret_12) { + if (SoundAlert) PlaySound(SoundFileAtClose); + if (SendEmail) Send_Email(a_ticket_0, "CLOSE"); + } + return (li_ret_12); +} + +void Send_Email(int a_ticket_0, string as_4) { + string ls_12; + string ls_20; + double l_minlot_28; + int li_36; + string ls_40; + if (OrderSelect(a_ticket_0, SELECT_BY_TICKET)) { + l_minlot_28 = 0.1; + li_36 = 1; + l_minlot_28 = MarketInfo(OrderSymbol(), MODE_MINLOT); + li_36 = 1; + if (l_minlot_28 < 0.01) li_36 = 3; + else + if (l_minlot_28 < 0.1) li_36 = 2; + ls_12 = "Primeval-EA Trade Information"; + ls_20 = "Primeval-EA Trade Information"; + ls_40 = jgdsfjg(OrderType()); + ls_20 = ls_20 + + "\n\nCurrency Pair: " + OrderSymbol(); + ls_20 = ls_20 + + "\nTime: " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS); + ls_20 = ls_20 + + "\nOrder Type: " + ls_40; + if (as_4 == "OPEN") { + ls_20 = ls_20 + + "\nPrice: " + DoubleToStr(OrderOpenPrice(), Digits); + ls_20 = ls_20 + + "\nLot Size: " + DoubleToStr(OrderLots(), li_36); + ls_20 = ls_20 + + "\nEvent: Trade Opened"; + } else { + if (as_4 == "MODIFY") { + ls_20 = ls_20 + + "\nEvent: Trade Modified"; + ls_20 = ls_20 + + "\nOrder Current Profit: " + DoubleToStr(zzxvy_s454(OrderTicket()), 1) + " pips (" + DoubleToStr(OrderProfit(), 2) + AccountCurrency() + ")"; + } else { + if (as_4 == "CLOSE") { + if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT) { + ls_20 = ls_20 + + "\nEvent: Trade Deleted"; + } else { + ls_20 = ls_20 + + "\nOpen Price: " + DoubleToStr(OrderOpenPrice(), Digits); + ls_20 = ls_20 + + "\nClose Price: " + DoubleToStr(OrderClosePrice(), Digits); + ls_20 = ls_20 + + "\nLot Size: " + DoubleToStr(OrderLots(), 1); + ls_20 = ls_20 + + "\nEvent: Trade Closed"; + ls_20 = ls_20 + + "\nOrder Profit: " + DoubleToStr(zzxvy_s454(OrderTicket()), 1) + " pips (" + DoubleToStr(OrderProfit(), 2) + " " + AccountCurrency() + ")"; + } + } else { + if (as_4 == "EXPIRE") { + ls_20 = ls_20 + + "\nEvent: Trade Expired"; + } + } + } + } + if (OrdersTotal() > 0) { + ls_20 = ls_20 + + "\n\n*****Open Trades*****"; + } + for (int l_pos_48 = OrdersTotal() - 1; l_pos_48 >= 0; l_pos_48--) { + OrderSelect(l_pos_48, SELECT_BY_POS, MODE_TRADES); + l_minlot_28 = MarketInfo(OrderSymbol(), MODE_MINLOT); + li_36 = 1; + if (l_minlot_28 < 0.01) li_36 = 3; + else + if (l_minlot_28 < 0.1) li_36 = 2; + ls_20 = ls_20 + + "\n------------------------"; + ls_20 = ls_20 + + "\nSymbol: " + OrderSymbol(); + ls_20 = ls_20 + + "\nOpen Price: " + DoubleToStr(OrderOpenPrice(), 5); + ls_20 = ls_20 + + "\nOpen Time: " + TimeToStr(OrderOpenTime(), TIME_DATE|TIME_MINUTES|TIME_SECONDS); + ls_20 = ls_20 + + "\nLot Size: " + DoubleToStr(OrderLots(), li_36); + ls_20 = ls_20 + + "\nProfit: " + DoubleToStr(OrderProfit(), 2); + ls_20 = ls_20 + + "\n------------------------"; + } + ls_20 = ls_20 + + "\n\nCurrent Balance: " + DoubleToStr(AccountBalance(), 2) + " " + AccountCurrency(); + ls_20 = ls_20 + + "\nCurrent Equity: " + DoubleToStr(AccountEquity(), 2) + " " + AccountCurrency(); + SendMail(ls_12, ls_20); + } +} + +int SendTradingStatistics() { + int li_52; + if (Hour() != TradingStatisticsHour || TimeCurrent() - gi_356 <= 86400) return (0); + string ls_0 = "Primeval-EA Daily Trading Statistics"; + string ls_8 = "Primeval-EA Trading Statistics - " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS); + double ld_16 = 0; + double ld_24 = 0; + double ld_32 = 0; + double ld_40 = 0; + int l_count_48 = 0; + int l_count_56 = 0; + for (int l_pos_60 = OrdersHistoryTotal() - 1; l_pos_60 >= 0; l_pos_60--) { + OrderSelect(l_pos_60, SELECT_BY_POS, MODE_HISTORY); + if (TimeCurrent() - OrderCloseTime() <= 86400) { + if (OrderProfit() >= 0.0) { + ld_24 += OrderProfit(); + li_52++; + } else { + ld_32 += OrderProfit(); + l_count_56++; + } + ld_40 += zzxvy_s454(OrderTicket()); + l_count_48++; + } + } + ld_16 = ld_24 + ld_32; + ls_8 = ls_8 + + "\n\n*****Closed Trades*****"; + ls_8 = ls_8 + + "\n------------------------"; + ls_8 = ls_8 + + "\nTotal Profit: " + DoubleToStr(ld_16, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nProfit/Loss in Pips: " + DoubleToStr(ld_40, 1); + ls_8 = ls_8 + + "\nGross Profit: " + DoubleToStr(ld_24, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nGross Loss: " + DoubleToStr(ld_32, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nTotal Trades: " + l_count_48; + ls_8 = ls_8 + + "\nProfit Trades: " + li_52; + ls_8 = ls_8 + + "\nLoss Trades: " + l_count_56; + ls_8 = ls_8 + + "\n------------------------"; + ld_16 = 0; + ld_24 = 0; + ld_32 = 0; + ld_40 = 0; + l_count_48 = 0; + for (l_pos_60 = OrdersTotal() - 1; l_pos_60 >= 0; l_pos_60--) { + OrderSelect(l_pos_60, SELECT_BY_POS, MODE_TRADES); + if (OrderProfit() >= 0.0) ld_24 += OrderProfit(); + else ld_32 += OrderProfit(); + ld_40 += zzxvy_s454(OrderTicket()); + l_count_48++; + } + ld_16 = ld_24 + ld_32; + ls_8 = ls_8 + + "\n\n*****Open Trades*****"; + ls_8 = ls_8 + + "\n------------------------"; + if (l_count_48 > 0) { + ls_8 = ls_8 + + "\nTotal Profit: " + DoubleToStr(ld_16, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nProfit/Loss in Pips: " + DoubleToStr(ld_40, 1); + ls_8 = ls_8 + + "\nGross Profit: " + DoubleToStr(ld_24, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nGross Loss: " + DoubleToStr(ld_32, 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nTotal Trades: " + l_count_48; + } else { + ls_8 = ls_8 + + "\nNONE"; + } + ls_8 = ls_8 + + "\n------------------------"; + ls_8 = ls_8 + + "\n\nCurrent Balance: " + DoubleToStr(AccountBalance(), 2) + " " + AccountCurrency(); + ls_8 = ls_8 + + "\nCurrent Equity: " + DoubleToStr(AccountEquity(), 2) + " " + AccountCurrency(); + gi_356 = TimeCurrent() - 60; + SendMail(ls_0, ls_8); + return (1); +} + +void jr654ej_Send_Email(int ai_unused_0, double ad_4, double ad_12) { + double ld_20 = ad_4 + ad_12; + string ls_28 = "Primeval-EA Trade Information"; + string ls_36 = "Primeval-EA Trade Information"; + ls_36 = ls_36 + + "\nCurrency Pair: " + OrderSymbol(); + ls_36 = ls_36 + + "\nTime: " + TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS); + ls_36 = ls_36 + + "\nEvent: Trades Closed"; + ls_36 = ls_36 + + "\nGross Profit: " + ad_4; + ls_36 = ls_36 + + "\nGross Loss: " + ad_12; + ls_36 = ls_36 + + "\nTotal Net Profit: " + ld_20; + if (OrdersTotal() > 0) { + ls_36 = ls_36 + + "\n*****Open Trades*****"; + } + for (int l_pos_44 = OrdersTotal() - 1; l_pos_44 >= 0; l_pos_44--) { + OrderSelect(l_pos_44, SELECT_BY_POS, MODE_TRADES); + ls_36 = ls_36 + + "\n------------------------"; + ls_36 = ls_36 + + "\nOrder Symbol: " + OrderSymbol(); + ls_36 = ls_36 + + "\nOrder Open Price: " + DoubleToStr(OrderOpenPrice(), 5); + ls_36 = ls_36 + + "\nOrder Profit: " + DoubleToStr(OrderProfit(), 2); + ls_36 = ls_36 + + "\n------------------------"; + } + ls_36 = ls_36 + + "\nCurrent Balance: " + DoubleToStr(AccountBalance(), 2) + " " + AccountCurrency(); + ls_36 = ls_36 + + "\nCurrent Equity: " + DoubleToStr(AccountEquity(), 2) + " " + AccountCurrency(); + SendMail(ls_28, ls_36); +} + +double zzxvy_s454(int a_ticket_0) { + double ld_4 = 0; + if (OrderSelect(a_ticket_0, SELECT_BY_TICKET) && OrderType() == OP_BUY || OrderType() == OP_SELL) { + ld_4 = MathAbs((OrderOpenPrice() - OrderClosePrice()) / MarketInfo(OrderSymbol(), MODE_POINT)); + if (OrderType() == OP_BUY && OrderOpenPrice() > OrderClosePrice()) ld_4 = -ld_4; + else + if (OrderType() == OP_SELL && OrderOpenPrice() < OrderClosePrice()) ld_4 = -ld_4; + } + if (Digits == 5 || Digits == 3) ld_4 /= 10.0; + return (NormalizeDouble(ld_4, 1)); +} + +string jgdsfjg(int ai_0) { + string ls_ret_4; + switch (ai_0) { + case 0: + ls_ret_4 = "Buy"; + break; + case 1: + ls_ret_4 = "Sell"; + break; + case 2: + ls_ret_4 = "BuyLimit"; + break; + case 3: + ls_ret_4 = "SellLimit"; + break; + case 4: + ls_ret_4 = "BuyStop"; + break; + case 5: + ls_ret_4 = "SellStop"; + break; + default: + ls_ret_4 = "Unknown"; + } + return (ls_ret_4); +} + +void jsahdjas() { + ObjectCreate("Pair Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Pair Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Pair Label", OBJPROP_YDISTANCE, 40); + ObjectSetText("Pair Label", "Current Pair:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Current Pair", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Current Pair", OBJPROP_XDISTANCE, 115); + ObjectSet("Current Pair", OBJPROP_YDISTANCE, 40); + ObjectSetText("Current Pair", Symbol(), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Spread Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Spread Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Spread Label", OBJPROP_YDISTANCE, 60); + ObjectSetText("Spread Label", "Bid/Ask Spread:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Bid/Ask Spread", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Bid/Ask Spread", OBJPROP_XDISTANCE, 115); + ObjectSet("Bid/Ask Spread", OBJPROP_YDISTANCE, 60); + ObjectSetText("Bid/Ask Spread", DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("GMT Offset Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("GMT Offset Label", OBJPROP_XDISTANCE, 20); + ObjectSet("GMT Offset Label", OBJPROP_YDISTANCE, 80); + ObjectSetText("GMT Offset Label", "GMT Offset:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("GMT Offset", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("GMT Offset", OBJPROP_XDISTANCE, 115); + ObjectSet("GMT Offset", OBJPROP_YDISTANCE, 80); + if (UseAutoGMTOffset) ObjectSetText("GMT Offset", DoubleToStr(gi_108, 0) + " (automatic)", g_fontsize_388, gs_tacoma_392, g_color_400); + else ObjectSetText("GMT Offset", DoubleToStr(gi_108, 0) + " (manual)", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Nє Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Nє Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Nє Label", OBJPROP_YDISTANCE, 100); + ObjectSetText("Account Nє Label", "Account Number:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Number", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Number", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Number", OBJPROP_YDISTANCE, 100); + ObjectSetText("Account Number", DoubleToStr(AccountNumber(), 0), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Name Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Name Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Name Label", OBJPROP_YDISTANCE, 120); + ObjectSetText("Account Name Label", "Account Name:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Name", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Name", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Name", OBJPROP_YDISTANCE, 120); + ObjectSetText("Account Name", AccountName(), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Leverage Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Leverage Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Leverage Label", OBJPROP_YDISTANCE, 140); + ObjectSetText("Account Leverage Label", "Account Leverage:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Leverage", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Leverage", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Leverage", OBJPROP_YDISTANCE, 140); + ObjectSetText("Account Leverage", "1:" + DoubleToStr(AccountLeverage(), 0), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Company Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Company Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Company Label", OBJPROP_YDISTANCE, 160); + ObjectSetText("Account Company Label", "Account Company:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Company", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Company", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Company", OBJPROP_YDISTANCE, 160); + ObjectSetText("Account Company", AccountCompany(), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Currency Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Currency Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Currency Label", OBJPROP_YDISTANCE, 180); + ObjectSetText("Account Currency Label", "Account Currency:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Currency", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Currency", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Currency", OBJPROP_YDISTANCE, 180); + ObjectSetText("Account Currency", AccountCurrency(), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Balance Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Balance Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Balance Label", OBJPROP_YDISTANCE, 200); + ObjectSetText("Account Balance Label", "Account Balance:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Balance", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Balance", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Balance", OBJPROP_YDISTANCE, 200); + ObjectSetText("Account Balance", DoubleToStr(AccountBalance(), 2), g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Equity Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Equity Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Account Equity Label", OBJPROP_YDISTANCE, 220); + ObjectSetText("Account Equity Label", "Account Equity:", g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate("Account Equity", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Account Equity", OBJPROP_XDISTANCE, 115); + ObjectSet("Account Equity", OBJPROP_YDISTANCE, 220); + ObjectSetText("Account Equity", DoubleToStr(AccountEquity(), 2), g_fontsize_388, gs_tacoma_392, g_color_400); + if (gi_428) IUASUDHF_JSADHF(); + ujdfa78dk(); +} + +void IUASUDHF_JSADHF() { + string ls_unused_4; + int l_window_12; + string lsa_16[4] = {"Frankfurt", "London", "New York", "Toyko", + "Sydney"}; + int lia_20[4] = {7, 8, 12, 23, + 21}; + int lia_24[5] = {15, 16, 20, 8, 6}; + ObjectCreate("Current Session Label", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet("Current Session Label", OBJPROP_XDISTANCE, 20); + ObjectSet("Current Session Label", OBJPROP_YDISTANCE, 242); + int li_28 = Hour() - gi_108; + if (li_28 < 0) li_28 += 24; + if (li_28 == 23 || (li_28 >= 0 && li_28 <= 6)) ObjectSetText("Current Session Label", "ASIAN SESSION", 8, gs_tacoma_392, SkyBlue); + else { + if (li_28 == 7) ObjectSetText("Current Session Label", "ASIAN && EUROPEAN SESSIONS OVERLAPPED", 8, gs_tacoma_392, SkyBlue); + else { + if (li_28 >= 8 && li_28 <= 11) ObjectSetText("Current Session Label", "EUROPEAN SESSION", 8, gs_tacoma_392, SkyBlue); + else { + if (li_28 >= 12 && li_28 < 16) ObjectSetText("Current Session Label", "EUROPEAN && NORTH AMERICAN SESSIONS OVERLAPPED", 8, gs_tacoma_392, SkyBlue); + else { + if (li_28 >= 16 && li_28 < 20) ObjectSetText("Current Session Label", "NORTH AMERICAN SESSION", 8, gs_tacoma_392, SkyBlue); + else + if (li_28 >= 20 && li_28 < 23) ObjectSetText("Current Session Label", "PRE ASIAN SESSION", 8, gs_tacoma_392, SkyBlue); + } + } + } + } + for (int l_index_0 = 0; l_index_0 < ArraySize(lsa_16); l_index_0++) { + ObjectCreate(lsa_16[l_index_0] + " Market", OBJ_LABEL, 0, 0, 0, 0, 0); + ObjectSet(lsa_16[l_index_0] + " Market", OBJPROP_XDISTANCE, 50 * l_index_0 + 20); + ObjectSet(lsa_16[l_index_0] + " Market", OBJPROP_YDISTANCE, 260); + ObjectSetText(lsa_16[l_index_0] + " Market", lsa_16[l_index_0], g_fontsize_388, gs_tacoma_392, g_color_400); + ObjectCreate(lsa_16[l_index_0] + " Market Status", OBJ_LABEL, l_window_12, 0, 0, 0, 0); + ObjectSet(lsa_16[l_index_0] + " Market Status", OBJPROP_XDISTANCE, 50 * l_index_0 + 20); + ObjectSet(lsa_16[l_index_0] + " Market Status", OBJPROP_YDISTANCE, 280); + if (lia_20[l_index_0] < lia_24[l_index_0] && (li_28 >= lia_20[l_index_0] && li_28 < lia_24[l_index_0])) ObjectSetText(lsa_16[l_index_0] + " Market Status", "OPEN", g_fontsize_388, gs_tacoma_392, Yellow); + else { + if (lia_20[l_index_0] > lia_24[l_index_0] && li_28 >= lia_20[l_index_0] || li_28 < lia_24[l_index_0]) ObjectSetText(lsa_16[l_index_0] + " Market Status", "OPEN", g_fontsize_388, gs_tacoma_392, Yellow); + else ObjectSetText(lsa_16[l_index_0] + " Market Status", "CLOSED", g_fontsize_388, gs_tacoma_392, Violet); + } + } +} + +void ujdfa78dk() { + int l_icustom_0 = iCustom(NULL, 0, "Five EMA CrossOver", 2, 0); + ObjectDelete("UpArrow"); + ObjectDelete("DownArrow"); + ObjectDelete("StopSignal"); + if (l_icustom_0 == 1) { + ObjectCreate("UpArrow", OBJ_ARROW, 0, TimeCurrent() + 60 * Period(), Bid); + ObjectSet("UpArrow", OBJPROP_ARROWCODE, SYMBOL_ARROWUP); + ObjectSet("UpArrow", OBJPROP_COLOR, White); + return; + } + if (l_icustom_0 == -1) { + ObjectCreate("DownArrow", OBJ_ARROW, 0, TimeCurrent() + 60 * Period(), Ask); + ObjectSet("DownArrow", OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN); + ObjectSet("DownArrow", OBJPROP_COLOR, White); + return; + } + if (l_icustom_0 == 0) { + ObjectCreate("StopSignal", OBJ_ARROW, 0, TimeCurrent() + 60 * Period(), Ask - MarketInfo(Symbol(), MODE_SPREAD) / 8.0 * Point); + ObjectSet("StopSignal", OBJPROP_ARROWCODE, SYMBOL_STOPSIGN); + ObjectSet("StopSignal", OBJPROP_COLOR, White); + } +} + +int init() { + double lda_0[1]; + double lda_4[1]; + double lda_8[1]; + double lda_12[1]; + double lda_16[1]; + double lda_20[1]; + int lia_28[1]; + int lia_32[1]; + int lia_36[1]; + int lia_40[1]; + int lia_44[1]; + int lia_48[1]; + int lia_52[1]; + int lia_56[1]; + int lia_60[1]; + double lda_64[1]; + double lda_68[1]; + int lia_72[1]; + int lia_76[1]; + int lia_80[1]; + int lia_84[1]; + int lia_88[1]; + int lia_92[1]; + int lia_96[1]; + double lda_100[1]; + int lia_104[1]; + int lia_108[1]; + int lia_112[1]; + int lia_116[1]; + int lia_120[1]; + int lia_124[1]; + int lia_128[1]; + int lia_132[1]; + int lia_136[1]; + int lia_140[1]; + int lia_144[1]; + double lda_148[1]; + if (!IsDllsAllowed()) { + Comment("Error: Set Parameter \"Allow DLL Imports\" ON in menu Tools -> Options -> Expert Advisors."); + return (-1); + } + g_acc_number_464 = AccountNumber(); + gsa_468[0] = AccountName(); + gsa_468[1] = AccountCompany(); + gsa_468[2] = AccountCurrency(); + g_bool_472 = IsDemo(); + if (!fun000(KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + Comment("Not Authenticated"); + gi_476 = FALSE; + Alert("Your license key is invalid. Please activate your copy in the member\'s area." + + "\n" + + "Account Number = " + g_acc_number_464 + + "\n" + + "Account Name = " + gsa_468[0] + + "\n" + + "Account Company = " + gsa_468[1] + + "\n" + + "Account Currency = " + gsa_468[2]); + return (-1); + } + gi_476 = TRUE; + Comment("Authenticated"); + gs_316 = StringSubstr(Symbol(), 0, 6); + if (Digits == 5 || Digits == 3) { + gi_508 = TRUE; + MaxSpread = 10.0 * MaxSpread; + } + if (TradeMicroLots) gi_772 = 2; + else gi_772 = 1; + g_symbol_624 = Symbol(); + gd_432 = MarketInfo(g_symbol_624, MODE_MAXLOT); + if (MaxLots < gd_432) gd_432 = MaxLots; + gd_440 = MarketInfo(g_symbol_624, MODE_MINLOT); + if (MinLots > gd_440) gd_440 = MinLots; + g_lotstep_448 = MarketInfo(g_symbol_624, MODE_LOTSTEP); + gd_456 = MarketInfo(g_symbol_624, MODE_MARGINREQUIRED) * g_lotstep_448; + fun022(gs_316, lda_0, lda_4, lda_8, lda_12, lda_16, lda_20, EURCHF_Grid_Strategy); + gd_1628 = lda_0[0]; + gd_1636 = lda_4[0]; + gd_1644 = lda_8[0]; + gd_1652 = lda_12[0]; + gd_1660 = lda_16[0]; + gd_1668 = lda_20[0]; + gi_356 = 0; + for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) { + OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_512 && OrderCloseTime() == 0) { + g_ticket_332 = OrderTicket(); + break; + } + } + fun026(gs_316, lia_28, lia_32, lia_36, lia_40, lia_44, lia_48, lia_52, lia_56, lia_60, lda_64, lda_68, lia_72, lia_76, lia_80); + gi_488 = lia_28[0]; + gi_492 = lia_32[0]; + gi_584 = lia_36[0]; + gi_348 = lia_40[0]; + gi_340 = lia_44[0]; + gi_344 = lia_48[0]; + gi_588 = lia_52[0]; + gi_592 = lia_56[0]; + gi_596 = lia_60[0]; + gd_548 = lda_64[0]; + gd_556 = lda_68[0]; + gi_600 = lia_72[0]; + gi_604 = lia_76[0]; + gi_504 = lia_80[0]; + if (gi_508) { + gi_496 = 10 * gi_496; + gi_500 = 10 * gi_500; + gi_488 = 10 * gi_488; + gi_492 = 10 * gi_492; + TrailingStopStart = 10 * TrailingStopStart; + TrailingStopPriceSteps = 10 * TrailingStopPriceSteps; + TrailingStopPosSteps = 10 * TrailingStopPosSteps; + } + if (Digits < 4) { + gd_616 = 0.01; + gi_612 = 2; + } else { + gd_616 = 0.0001; + gi_612 = 4; + } + fun019(gs_316, lia_84, lia_88, lia_92, lia_96, lda_100, lia_104, lia_108, lia_112, lia_116, lia_120, lia_124, lia_128, lia_132, lia_136, lia_140); + g_magic_608 = lia_84[0]; + gi_632 = lia_88[0]; + gi_636 = lia_92[0]; + gi_unused_640 = lia_96[0]; + gi_unused_644 = lia_104[0]; + gi_652 = lia_108[0]; + gi_660 = lia_112[0]; + gi_668 = lia_116[0]; + gi_676 = lia_120[0]; + gi_648 = lia_124[0]; + gi_656 = lia_128[0]; + gi_664 = lia_132[0]; + gi_672 = lia_136[0]; + gi_680 = lia_140[0]; + gd_716 = (-1 * gi_636) * gd_616; + gd_708 = gi_632 * gd_616; + gi_684 = 60 * gi_652; + gi_688 = 60 * gi_660; + gi_692 = 60 * gi_668; + gi_696 = 60 * gi_676; + gd_724 = gi_648 * gd_616; + gd_732 = gi_656 * gd_616; + gd_740 = gi_664 * gd_616; + gd_748 = gi_672 * gd_616; + gd_756 = gi_680 * gd_616; + gd_764 = (MarketInfo(g_symbol_624, MODE_SPREAD) + 0.1) * Point; + if (!EURCHF_Grid_Strategy) gi_1032 = 12345678; + else gi_1032 = 340843; + fun029(gi_508, Point, Digits, lia_144, lda_148, gda_1152, gda_1156, gia_1160); + gi_1140 = lia_144[0]; + gd_1172 = lda_148[0]; + if (IsTesting()) GlobalVariablesDeleteAll(); + HideTestIndicators(TRUE); + gi_1448 = GlobalVariableGet(g_var_name_1324); + if (GetLastError() != 0/* NO_ERROR */) { + gi_1448 = 0; + GlobalVariableSet(g_var_name_1324, 0); + } + gi_1452 = GlobalVariableGet(g_var_name_1364); + if (GetLastError() != 0/* NO_ERROR */) { + gi_1452 = 0; + GlobalVariableSet(g_var_name_1364, 0); + } + gi_1444 = GlobalVariableGet(g_var_name_1252); + if (GetLastError() != 0/* NO_ERROR */) { + gi_1444 = 0; + GlobalVariableSet(g_var_name_1252, 0); + } + g_lots_1388 = LotSize; + g_lots_1396 = LotSize; + g_global_var_1372 = GlobalVariableGet(g_var_name_1316); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1372 = 0; + GlobalVariableSet(g_var_name_1316, 0); + } + g_global_var_1380 = GlobalVariableGet(g_var_name_1356); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1380 = 0; + GlobalVariableSet(g_var_name_1356, 0); + } + g_global_var_1404 = GlobalVariableGet(g_var_name_1292); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1404 = 0; + GlobalVariableSet(g_var_name_1292, g_global_var_1404); + } + g_global_var_1408 = GlobalVariableGet(g_var_name_1332); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1408 = 0; + GlobalVariableSet(g_var_name_1332, g_global_var_1408); + } + g_global_var_1420 = GlobalVariableGet(g_var_name_1212); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1420 = AccountEquity(); + GlobalVariableSet(g_var_name_1212, g_global_var_1420); + } + g_global_var_1432 = GlobalVariableGet(g_var_name_1220); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1432 = 0; + GlobalVariableSet(g_var_name_1220, g_global_var_1432); + } + g_global_var_1428 = GlobalVariableGet(g_var_name_1228); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1428 = 0; + GlobalVariableSet(g_var_name_1228, g_global_var_1428); + } + g_global_var_1440 = GlobalVariableGet(g_var_name_1236); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1440 = 0; + GlobalVariableSet(g_var_name_1236, g_global_var_1440); + } + g_global_var_1436 = GlobalVariableGet(g_var_name_1244); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1436 = 0; + GlobalVariableSet(g_var_name_1244, g_global_var_1436); + } + g_global_var_1560 = GlobalVariableGet(g_var_name_1260); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1560 = 0; + GlobalVariableSet(g_var_name_1260, g_global_var_1560); + } + g_global_var_1564 = GlobalVariableGet(g_var_name_1268); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1564 = 0; + GlobalVariableSet(g_var_name_1268, g_global_var_1564); + } + g_global_var_1568 = GlobalVariableGet(g_var_name_1276); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1568 = 0; + GlobalVariableSet(g_var_name_1276, g_global_var_1568); + } + g_global_var_1572 = GlobalVariableGet(g_var_name_1284); + if (GetLastError() != 0/* NO_ERROR */) { + g_global_var_1572 = 0; + GlobalVariableSet(g_var_name_1284, g_global_var_1572); + } + return (0); +} + +int deinit() { + ObjectsDeleteAll(); + Comment(""); + return (0); +} + +int lsdjhja(int a_timeframe_0) { + int li_ret_72 = 0; + int li_76 = 1; + double ld_56 = 0; + double ld_64 = 0; + for (int l_index_4 = 0; l_index_4 <= li_76 + 9; l_index_4++) ld_64 += MathAbs(High[l_index_4] - Low[l_index_4]); + ld_56 = ld_64 / 10.0; + double l_ima_8 = iMA(NULL, a_timeframe_0, g_period_1684, 0, MODE_EMA, PRICE_CLOSE, li_76 + 0); + double l_ima_24 = iMA(NULL, a_timeframe_0, g_period_1684, 0, MODE_EMA, PRICE_CLOSE, li_76 + 1); + double l_ima_40 = iMA(NULL, a_timeframe_0, g_period_1684, 0, MODE_EMA, PRICE_CLOSE, li_76 - 1); + double l_ima_16 = iMA(NULL, a_timeframe_0, g_period_1688, 0, MODE_EMA, PRICE_CLOSE, li_76 + 0); + double l_ima_32 = iMA(NULL, a_timeframe_0, g_period_1688, 0, MODE_EMA, PRICE_CLOSE, li_76 + 1); + double l_ima_48 = iMA(NULL, a_timeframe_0, g_period_1688, 0, MODE_EMA, PRICE_CLOSE, li_76 - 1); + if (l_ima_8 > l_ima_16 && l_ima_24 < l_ima_32 && l_ima_40 > l_ima_48) { + li_ret_72 = 1; + gd_unused_1676 = Time[0]; + } else { + if (l_ima_8 < l_ima_16 && l_ima_24 > l_ima_32 && l_ima_40 < l_ima_48) { + li_ret_72 = -1; + gd_unused_1676 = Time[0]; + } + } + return (li_ret_72); +} + +void owjksahsayhd() { + int li_0; + int li_4; + int li_12; + for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { + OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderCloseTime() == 0 && OrderComment() == "scf" || OrderComment() == "" || OrderTicket() == g_ticket_332) { + if (EnableTrailingStops) { + li_0 = zzxvy_s454(OrderTicket()); + if (gi_508) li_0 = 10 * li_0; + if (OrderType() == OP_BUY) { + if (li_0 >= TrailingStopStart) { + if (OrderStopLoss() == 0.0 || OrderStopLoss() < OrderOpenPrice()) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + TrailingStopPosSteps * Point, OrderTakeProfit()); + else li_4 = (OrderClosePrice() - OrderStopLoss()) / Point - TrailingStopStart; + if (li_4 >= TrailingStopPriceSteps) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderStopLoss() + MathCeil(li_4 / TrailingStopPriceSteps) * TrailingStopPosSteps * Point, OrderTakeProfit()); + } + } else { + if (OrderType() == OP_SELL) { + if (li_0 >= TrailingStopStart) { + if (OrderStopLoss() == 0.0 || OrderStopLoss() > OrderOpenPrice()) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - TrailingStopPosSteps * Point, OrderTakeProfit()); + else li_4 = (OrderStopLoss() - OrderClosePrice()) / Point - TrailingStopStart; + if (li_4 >= TrailingStopPriceSteps) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderStopLoss() - MathCeil(li_4 / TrailingStopPriceSteps) * TrailingStopPosSteps * Point, OrderTakeProfit()); + } + } + } + } + if (EnableClosingManualTrades && owuejha(OrderTicket())) { + li_12 = 10; + if (gi_508) li_12 = 10 * li_12; + if (li_0 > 0) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } else { + if (OrderType() == OP_BUY && OrderTakeProfit() != OrderOpenPrice() + li_12 * Point) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() + li_12 * Point); + else + if (OrderType() == OP_SELL && OrderTakeProfit() != OrderOpenPrice() - li_12 * Point) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() - li_12 * Point); + } + } + } + } + } +} + +int owuejha(int a_ticket_0) { + int li_8; + int li_12; + bool li_ret_4 = FALSE; + OrderSelect(a_ticket_0, SELECT_BY_TICKET); + if (TimeCurrent() - OrderOpenTime() >= 300) { + li_8 = zzxvy_s454(a_ticket_0); + if (li_8 <= 10) li_12 = lsdjhja(PERIOD_M5); + else li_12 = lsdjhja(PERIOD_M15); + if (OrderType() == OP_BUY && li_12 == -1) li_ret_4 = TRUE; + else + if (OrderType() == OP_SELL && li_12 == 1) li_ret_4 = TRUE; + } + return (li_ret_4); +} + +bool as5da987asd() { + bool li_4; + int l_bool_0 = OrderSelect(g_ticket_332, SELECT_BY_TICKET); + if (l_bool_0 && OrderCloseTime() == 0) return (TRUE); + if (g_ticket_332 != -1) { + li_4 = FALSE; + if ((OrderType() == OP_BUY && OrderClosePrice() >= OrderTakeProfit()) || (OrderType() == OP_SELL && OrderClosePrice() <= OrderTakeProfit())) Print("Order with Ticket Number " + g_ticket_332 + " reached Take Profit Price"); + else { + if ((OrderType() == OP_BUY && OrderClosePrice() <= OrderStopLoss()) || (OrderType() == OP_SELL && OrderClosePrice() >= OrderStopLoss())) Print("Order with Ticket Number " + g_ticket_332 + " reached Stop Loss Price"); + else { + if (OrderExpiration() == 0) Alert("Order with Ticket Number " + g_ticket_332 + " closed manually"); + else { + if (TimeCurrent() >= OrderExpiration()) { + Print("Order with Ticket Number " + g_ticket_332 + " has expired"); + li_4 = TRUE; + } else Alert("Order with Ticket Number " + g_ticket_332 + " deleted manually"); + } + } + } + if (SoundAlert) PlaySound(SoundFileAtClose); + if (SendEmail) { + if (!li_4) Send_Email(g_ticket_332, "CLOSE"); + else Send_Email(g_ticket_332, "EXPIRE"); + } + g_ticket_332 = -1; + } + return (FALSE); +} + +int start() { + int lia_0[1]; + int lia_4[1]; + int lia_8[1]; + int lia_12[1]; + double lda_16[1]; + double lda_20[1]; + double lda_24[1]; + double lda_28[1]; + double lda_32[1]; + int lia_36[1]; + int lia_40[4]; + if (Year() > 2010 || (Year() == 2010 && Month() >= 6)) Alert("Your copy has expired! Please download a new one in the member\'s area."); + if (!gi_476) return (-1); + if (gi_108 == -100) { + if (UseAutoGMTOffset) { + if (!IsTesting()) { + gi_108 = AutoGMTCalculation(); + Print("Retrieved GMT Offset: " + gi_108); + } else { + Alert("Warning", + "\n", "Automatic GMT offset calculation works only on live/demo trading", + "\n", "Manual GMT Offset will be used for backtesting"); + gi_108 = ManualGMTOffset; + } + } else gi_108 = ManualGMTOffset; + gi_700 = gi_108 + 20; + gi_704 = gi_108; + gi_700 %= 24; + fun006(gs_316, gi_108, lia_0, lia_4, lia_8, lia_12, lda_16, lda_20, lda_24, lda_28, lda_32, lia_36, Digits); + gi_784 = lia_0[0]; + gi_788 = lia_4[0]; + gi_776 = lia_8[0]; + gi_780 = lia_12[0]; + gd_792 = lda_16[0]; + gd_800 = lda_20[0]; + gd_808 = lda_24[0]; + gd_816 = lda_28[0]; + gd_824 = lda_32[0]; + gi_864 = lia_36[0]; + gi_1036 = fun027(gs_316, gi_108); + } + if (!IsTesting()) jsahdjas(); + owjksahsayhd(); + if (EnableTrading != TRUE) return (0); + if (SendTradingStatistics) SendTradingStatistics(); + g_spread_324 = MarketInfo(Symbol(), MODE_SPREAD); + if (EURCHF_Grid_Strategy && GBPUSD_Hedging_Strategy) { + Alert("Error: Cannot use both GBPUSD_Hedging_Strategy and EURCHF_Grid_Strategy strategies together."); + return (0); + } + if (EURCHF_Grid_Strategy) { + if (gs_316 == "EURCHF") { + if (!NFA_Compliant) { + KJSDHF_4S865A_AS85(); + QUYT_A9IA_545A(); + } else Alert("This Strategy cannot be used because of the NFA FIFO rule!"); + } else { + Alert("Error: Wrong Currency Pair."); + Alert("Swing Strategy can be used on EURCHF pair only."); + } + } else { + if (GBPUSD_Hedging_Strategy) { + if (gs_316 == "GBPUSD") { + if (!NFA_Compliant) jr654ej(); + else Alert("Hedging is prohibited by NFA Regulated Brokers!"); + } else { + Alert("Error: Wrong Currency Pair."); + Alert("Hedging & Pyramiding Strategy can be used on GBPUSD pair only."); + } + } else { + if (Period() != PERIOD_M15) { + Alert("Please attach the EA to the M15 Timeframe for the scalping strategy"); + return (0); + } + fun046(gs_316, lia_40); + if (lia_40[0] == 1) SCF_EA_STS(); + if (lia_40[1] == 1) KASD_PEWOSL_18AW(); + if (lia_40[2] == 1) LNMSBHJ_SD54878_58787(); + if (lia_40[3] == 1) QUYT_A9IA_545A(); + } + } + return (0); +} + +int AutoGMTCalculation() { + return (StrToInteger(getGMTOffset(gs_1692 + Hour()))); +} + +string getGMTOffset(string as_0) { + string ls_ret_8 = "XX"; + gi_1708 = InternetOpenA(gs_1700, 0, "0", "0", 0); + if (!GetData(as_0, ls_ret_8)) { + Alert("Error getting GMT offset from server. Using manual GMT offset = " + ManualGMTOffset); + ls_ret_8 = ManualGMTOffset; + } + InternetCloseHandle(gi_1708); + return (ls_ret_8); +} + +bool GetData(string as_0, string &as_8) { + int li_16 = InternetOpenUrlA(gi_1708, as_0, "0", 0, 0, 0); + if (li_16 == 0) return (FALSE); + int lia_20[] = {1}; + string ls_24 = "xx"; + InternetReadFile(li_16, ls_24, 10, lia_20); + if (li_16 != 0) InternetCloseHandle(li_16); + as_8 = ls_24; + return (TRUE); +} + +int egudss2a5a5d11(string a_symbol_0) { + bool li_ret_8 = FALSE; + for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) { + OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == a_symbol_0) { + li_ret_8 = TRUE; + break; + } + } + return (li_ret_8); +} + +double uiasgy_sdf(int a_timeframe_0, int ai_4, int ai_8) { + double ld_ret_12 = 0; + double ld_20 = 0; + for (int l_count_28 = 0; l_count_28 < ai_4; l_count_28++) ld_20 += iClose(Symbol(), a_timeframe_0, l_count_28 + ai_8); + ld_ret_12 = ld_20 / ai_4; + return (ld_ret_12); +} + +void ppsfjia485() { + int li_0 = zzxvy_s454(g_ticket_332); + int li_4 = 3; + if (gi_508) li_4 = 10 * li_4; + if (li_0 >= gi_348) { + if (OrderType() == OP_BUY && OrderStopLoss() < OrderOpenPrice()) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + li_4 * Point, OrderTakeProfit()); + else + if (OrderType() == OP_SELL && OrderStopLoss() > OrderOpenPrice()) nyusgfj(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - li_4 * Point, OrderTakeProfit()); + } + if (li_0 >= gi_340) gi_352 = TRUE; +} + +void ltp_j4857(double ad_0) { + if (zzxvy_s454(g_ticket_332) <= ad_0) { + OrderSelect(g_ticket_332, SELECT_BY_TICKET); + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } +} + +void KASD_PEWOSL_18AW() { + double l_irsi_0; + double l_irsi_8; + double l_ima_16; + int li_40; + if (gi_632 <= 0 && gi_636 <= 0) return; + for (int l_pos_32 = OrdersTotal() - 1; l_pos_32 >= 0; l_pos_32--) { + if (OrderSelect(l_pos_32, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == g_magic_608 && OrderType() == OP_BUY || OrderType() == OP_SELL && OrderSymbol() == g_symbol_624) + if (fun004(OrderClosePrice(), gi_612, OrderOpenPrice(), OrderType(), gd_708, gd_716)) piwejansmj(OrderTicket()); + } + for (int l_pos_36 = OrdersTotal() - 1; l_pos_36 >= 0; l_pos_36--) { + if (OrderSelect(l_pos_36, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == g_magic_608 && OrderType() == OP_BUY || OrderType() == OP_SELL && OrderSymbol() == g_symbol_624) + if (fun002(TimeCurrent(), OrderOpenTime(), OrderClosePrice(), gi_612, OrderOpenPrice(), OrderType(), gi_684, gd_724, gi_688, gd_732, gi_692, gd_740, gi_696, gd_748, gd_756) != 0) piwejansmj(OrderTicket()); + } + if (Ask - Bid <= gd_764) { + if (DayOfWeek() != 0) { + if (DayOfWeek() != 5) { + if (DayOfWeek() == 1 && Hour() < gi_700) return; + if (fun003(TimeHour(TimeCurrent()), gi_700, gi_704, Hour(), Minute()) && ujasgd()) { + HideTestIndicators(TRUE); + l_irsi_0 = iRSI(NULL, 0, 6, PRICE_CLOSE, 0); + l_irsi_8 = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0); + l_ima_16 = iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_MEDIAN, 1); + HideTestIndicators(FALSE); + li_40 = x58a8s(); + if (li_40 == -1 && NFA_Compliant && egudss2a5a5d11(Symbol())) li_40 = 1; + if (li_40 == -1) { + if (fun020(Ask, l_irsi_0, l_irsi_8, l_ima_16, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + if (g_spread_324 <= MaxSpread) ueyr_jdshr54(OP_BUY); + } else { + if (fun021(Bid, l_irsi_0, l_irsi_8, l_ima_16, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) + if (g_spread_324 <= MaxSpread) ueyr_jdshr54(OP_SELL); + } + } + } + } + } + } +} + +int ujasgd() { + bool li_ret_0 = FALSE; + double ld_4 = g_spread_324; + if (gi_508) ld_4 /= 10.0; + if (gs_316 == "EURCHF" && ld_4 <= 5.0) li_ret_0 = TRUE; + else { + if (gs_316 == "EURGBP" && ld_4 <= 3.5) li_ret_0 = TRUE; + else { + if (gs_316 == "USDCAD" && ld_4 <= 3.5) li_ret_0 = TRUE; + else { + if (gs_316 == "GBPCHF" && ld_4 <= 6.6) li_ret_0 = TRUE; + else { + if (gs_316 == "EURUSD" && ld_4 <= 3.0) li_ret_0 = TRUE; + else { + if (gs_316 == "GBPUSD" && ld_4 <= 4.0) li_ret_0 = TRUE; + else { + if (gs_316 == "USDCHF" && ld_4 <= 4.0) li_ret_0 = TRUE; + else + if (gs_316 == "USDJPY" && ld_4 <= 4.0) li_ret_0 = TRUE; + } + } + } + } + } + } + return (li_ret_0); +} + +int x58a8s() { + for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) { + if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { + if (OrderMagicNumber() == g_magic_608 && OrderSymbol() == g_symbol_624) + if (OrderType() == OP_BUY || OrderType() == OP_SELL) return (OrderTicket()); + } + } + return (-1); +} + +int ueyr_jdshr54(int a_cmd_0) { + double ld_4; + double ld_12; + double l_price_20; + color l_color_28; + string ls_unused_32; + g_lots_564 = fun001(gd_1636, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + if (g_spread_324 > MaxSpread) return (-1); + if (AccountFreeMargin() < AccountBalance() * MarginCutOffPercent / 100.0) return (-1); + RefreshRates(); + if (a_cmd_0 == OP_BUY) { + l_price_20 = Ask; + l_color_28 = g_color_288; + } else { + l_price_20 = Bid; + l_color_28 = g_color_292; + } + int li_40 = 1; + if (gi_508) li_40 = 10; + if (a_cmd_0 == OP_BUY) { + ld_4 = Ask + li_40 * (gi_632 + 10) * Point; + ld_12 = Ask - li_40 * (gi_636 + 10) * Point; + } else { + ld_4 = Bid - li_40 * (gi_632 + 10) * Point; + ld_12 = Bid + li_40 * (gi_636 + 10) * Point; + } + int l_ticket_44 = OrderSend(g_symbol_624, a_cmd_0, g_lots_564, l_price_20, Slippage, 0, 0, ExpertComment, g_magic_608, 0, l_color_28); + if (l_ticket_44 > 0 && OrderSelect(l_ticket_44, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_12, ld_4); + if (SoundAlert) { + if (a_cmd_0 == OP_BUY) PlaySound(SoundFileAtBuy); + else PlaySound(SoundFileAtSell); + } + if (SendEmail) Send_Email(l_ticket_44, "OPEN"); + } else Print("OrderSend Error > " + fun045(GetLastError())); + return (l_ticket_44); +} + +void asdf_isaudh() { + HideTestIndicators(TRUE); + gd_unused_936 = 6; + gd_944 = 0; + for (int li_0 = 1; li_0 < Bars; li_0++) { + if (iFractals(NULL, PERIOD_M15, MODE_LOWER, li_0) != 0.0) { + g_ifractals_1008 = iFractals(NULL, PERIOD_M15, MODE_LOWER, li_0); + break; + } + } + for (int li_4 = 1; li_4 < Bars; li_4++) { + if (iFractals(NULL, PERIOD_M15, MODE_UPPER, li_4) != 0.0) { + g_ifractals_1000 = iFractals(NULL, PERIOD_M15, MODE_UPPER, li_4); + break; + } + } + for (int li_8 = 1; li_8 < Bars; li_8++) { + if (iFractals(NULL, PERIOD_H1, MODE_LOWER, li_8) != 0.0) { + g_ifractals_1024 = iFractals(NULL, PERIOD_H1, MODE_LOWER, li_8); + break; + } + } + for (int li_12 = 1; li_12 < Bars; li_12++) { + if (iFractals(NULL, PERIOD_H1, MODE_UPPER, li_12) != 0.0) { + g_ifractals_1016 = iFractals(NULL, PERIOD_H1, MODE_UPPER, li_12); + return; + } + } +} + +int h5sa4dhjsag_n(int a_magic_0) { + bool li_ret_4 = FALSE; + for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) { + if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0) { + if (OrderType() == OP_BUY || OrderType() == OP_SELL) { + li_ret_4 = TRUE; + break; + } + } + } + } + return (li_ret_4); +} + +int ystqlahf(int a_cmd_0, double a_lots_4, double a_price_12, double ad_20, double ad_28, int a_magic_36, color a_color_40) { + if (g_spread_324 > MaxSpread) return (-1); + if (AccountFreeMargin() < AccountBalance() * MarginCutOffPercent / 100.0) return (-1); + int l_ticket_44 = OrderSend(Symbol(), a_cmd_0, a_lots_4, a_price_12, Slippage, 0, 0, ExpertComment, a_magic_36, 0, a_color_40); + if (l_ticket_44 > 0 && OrderSelect(l_ticket_44, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ad_28, ad_20); + if (SoundAlert) { + if (a_cmd_0 == OP_BUY) PlaySound(SoundFileAtBuy); + else PlaySound(SoundFileAtSell); + } + if (SendEmail) Send_Email(l_ticket_44, "OPEN"); + } else Print("OrderSend Error: " + fun045(GetLastError())); + return (l_ticket_44); +} + +int sjdhfjdhfjdhf(int a_magic_0, int a_cmd_4) { + for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { + if (OrderSelect(l_pos_8, SELECT_BY_POS)) { + if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == Symbol()) + if (OrderType() == a_cmd_4) return (OrderTicket()); + } + } + return (-1); +} + +int x45sd_jsakh(int &aia_0[]) { + int l_index_4 = 0; + for (int l_pos_8 = OrdersTotal() - 1; l_pos_8 >= 0; l_pos_8--) { + if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) { + if (l_index_4 >= 499) break; + if (OrderCloseTime() == 0) { + l_index_4++; + aia_0[l_index_4] = OrderMagicNumber(); + } + } + } + return (l_index_4); +} + +int s5sa4d8s(int ai_0) { + if (ai_0 != 0 && ai_0 != 1) return (-1); + if (g_spread_324 > MaxSpread) return (-1); + if (AccountFreeMargin() < AccountBalance() * MarginCutOffPercent / 100.0) return (-1); + int l_ticket_4 = -1; + if (MoneyManagement) g_lots_564 = fun001(gd_1660, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + else g_lots_564 = LotSize; + if (ai_0 == 0) l_ticket_4 = OrderSend(Symbol(), OP_BUY, g_lots_564, Ask, Slippage, 0, 0, ExpertComment, gia_1160[gi_1168], 0, g_color_288); + else l_ticket_4 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, gia_1160[gi_1168], 0, g_color_292); + if (l_ticket_4 > 0 && OrderSelect(l_ticket_4, SELECT_BY_TICKET)) { + if (ai_0 == 0) { + nyusgfj(OrderTicket(), OrderOpenPrice(), 0, Ask + gi_1140 * Point); + if (SoundAlert) PlaySound(SoundFileAtBuy); + } else { + nyusgfj(OrderTicket(), OrderOpenPrice(), 0, Bid - gi_1140 * Point); + if (SoundAlert) PlaySound(SoundFileAtSell); + } + if (SendEmail) Send_Email(l_ticket_4, "OPEN"); + } else Print("Error Opening Order: ", fun045(GetLastError())); + return (0); +} + +double asf47sws(int a_magic_0) { + int l_cmd_4; + double ld_ret_8 = 0; + int l_ord_total_16 = OrdersTotal(); + if (l_ord_total_16 > 0) { + for (int l_pos_20 = l_ord_total_16 - 1; l_pos_20 >= 0; l_pos_20--) { + OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES); + l_cmd_4 = OrderType(); + if (OrderMagicNumber() == a_magic_0) + if (l_cmd_4 == OP_BUY || l_cmd_4 == OP_SELL) ld_ret_8 += OrderProfit() + OrderSwap() + OrderCommission(); + } + return (ld_ret_8); + } + return (0); +} + +double fsd897(int a_magic_0, int ai_4) { + double ld_ret_8 = 0; + int l_hist_total_16 = OrdersHistoryTotal(); + if (l_hist_total_16 > 0 && ai_4 > 0) { + for (int l_pos_20 = l_hist_total_16 - 1; l_pos_20 >= 0; l_pos_20--) { + OrderSelect(l_pos_20, SELECT_BY_POS, MODE_HISTORY); + if (OrderMagicNumber() == a_magic_0) + if (OrderOpenTime() >= ai_4) ld_ret_8 += OrderProfit() + OrderSwap() + OrderCommission(); + } + return (ld_ret_8); + } + return (0); +} + +double pasodajy(int a_magic_0) { + int l_cmd_4; + bool l_ord_close_8; + int l_ord_total_12 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (int l_pos_16 = l_ord_total_12 - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + l_cmd_4 = OrderType(); + l_ord_close_8 = FALSE; + switch (l_cmd_4) { + case OP_BUY: + if (OrderMagicNumber() == a_magic_0) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage, g_color_296); + break; + case OP_SELL: + if (OrderMagicNumber() == a_magic_0) l_ord_close_8 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, g_color_296); + } + if (l_ord_close_8) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + return (0.0); +} + +int aiyui6(int a_magic_0) { + int l_cmd_4; + int l_ord_total_8 = OrdersTotal(); + int l_count_12 = 0; + l_ord_total_8 = OrdersTotal(); + if (l_ord_total_8 > 0) { + for (int l_pos_16 = l_ord_total_8 - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + l_cmd_4 = OrderType(); + if (l_cmd_4 == OP_BUY || l_cmd_4 == OP_SELL && OrderMagicNumber() == a_magic_0) l_count_12++; + } + } + return (l_count_12); +} + +int utg874gbd5(int a_magic_0, int ai_4) { + int l_cmd_8; + double ld_24; + int l_ord_total_12 = OrdersTotal(); + bool li_ret_16 = TRUE; + l_ord_total_12 = OrdersTotal(); + g_ord_open_price_1712 = 0; + g_ord_open_price_1728 = 0; + g_ord_open_price_1720 = 0; + g_ord_open_price_1736 = 0; + g_count_1744 = 0; + g_count_1748 = 0; + if (l_ord_total_12 > 0) { + for (int l_pos_20 = l_ord_total_12 - 1; l_pos_20 >= 0; l_pos_20--) { + if (OrderMagicNumber() == a_magic_0) { + if (OrderType() == OP_SELL) { + g_count_1744++; + if (g_ord_open_price_1712 == 0.0) g_ord_open_price_1712 = OrderOpenPrice(); + else + if (OrderOpenPrice() < g_ord_open_price_1712) g_ord_open_price_1712 = OrderOpenPrice(); + if (g_ord_open_price_1728 == 0.0) g_ord_open_price_1728 = OrderOpenPrice(); + else + if (OrderOpenPrice() > g_ord_open_price_1728) g_ord_open_price_1728 = OrderOpenPrice(); + } else { + if (OrderType() == OP_BUY) { + g_count_1748++; + if (g_ord_open_price_1720 == 0.0) g_ord_open_price_1720 = OrderOpenPrice(); + else + if (OrderOpenPrice() < g_ord_open_price_1720) g_ord_open_price_1720 = OrderOpenPrice(); + if (g_ord_open_price_1736 == 0.0) g_ord_open_price_1736 = OrderOpenPrice(); + else + if (OrderOpenPrice() > g_ord_open_price_1736) g_ord_open_price_1736 = OrderOpenPrice(); + } + } + } + OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES); + l_cmd_8 = OrderType(); + switch (l_cmd_8) { + case OP_BUY: + ld_24 = MathAbs(OrderOpenPrice() - Ask) / Point; + if (gi_508) ld_24 /= 10.0; + if (ai_4 == 0 && OrderMagicNumber() == a_magic_0 && ld_24 < 3.0) li_ret_16 = FALSE; + case OP_SELL: + ld_24 = MathAbs(OrderOpenPrice() - Bid) / Point; + if (gi_508) ld_24 /= 10.0; + if (ai_4 == 1 && OrderMagicNumber() == a_magic_0 && ld_24 < 3.0) li_ret_16 = FALSE; + } + if (!(li_ret_16)) break; + } + } + return (li_ret_16); +} + +int kdsjoa8547(int a_magic_0) { + double ld_4; + string l_comment_12; + string l_comment_20; + int l_ticket_28; + int li_ret_32; + double l_lots_36; + g_global_var_1420 = GlobalVariableGet(g_var_name_1212); + if (a_magic_0 == g_magic_1204) { + ld_4 = g_global_var_1372; + l_comment_12 = gs_1300 + " (" + DoubleToStr(GlobalVariableGet(g_var_name_1324) + 1.0, 0) + "/" + DoubleToStr(g_global_var_1420, 2) + "/" + AccountNumber() + ")"; + l_comment_20 = gs_1308 + " (" + DoubleToStr(GlobalVariableGet(g_var_name_1324) + 1.0, 0) + "/" + DoubleToStr(g_global_var_1420, 2) + "/" + AccountNumber() + ")"; + } else { + if (a_magic_0 == g_magic_1208) { + ld_4 = g_global_var_1380; + l_comment_12 = gs_1340 + " (" + DoubleToStr(GlobalVariableGet(g_var_name_1364) + 1.0, 0) + "/" + DoubleToStr(g_global_var_1420, 2) + "/" + AccountNumber() + ")"; + l_comment_20 = gs_1348 + " (" + DoubleToStr(GlobalVariableGet(g_var_name_1364) + 1.0, 0) + "/" + DoubleToStr(g_global_var_1420, 2) + "/" + AccountNumber() + ")"; + } + } + if (a_magic_0 == g_magic_1204) { + if (gi_1608) { + if (g_count_1748 > g_count_1744) g_ord_open_price_1736 = 0; + else + if (g_count_1744 > g_count_1748) g_ord_open_price_1712 = 0; + } else { + g_ord_open_price_1712 = 0; + g_ord_open_price_1736 = 0; + } + } else { + if (a_magic_0 == g_magic_1208) { + if (gi_1612) { + if (g_count_1748 > g_count_1744) g_ord_open_price_1736 = 0; + else + if (g_count_1744 > g_count_1748) g_ord_open_price_1712 = 0; + } else { + g_ord_open_price_1712 = 0; + g_ord_open_price_1736 = 0; + } + } + } + if (g_spread_324 <= MaxSpread && utg874gbd5(a_magic_0, 1) && Bid < ld_4 && MathMod(Bid / gd_1576, 3) == 0.0 && g_ord_open_price_1712 == 0.0 || Bid < g_ord_open_price_1712) { + l_lots_36 = LotSize; + if (MoneyManagement) l_lots_36 = fun001(gd_1668, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + l_ticket_28 = OrderSend(Symbol(), OP_SELL, l_lots_36, Bid, Slippage, 0, 0, l_comment_20, a_magic_0, 0, g_color_292); + if (l_ticket_28 <= 0) Print("OrderSend Error: " + fun045(GetLastError())); + else + if (SoundAlert) PlaySound(SoundFileAtSell); + return (li_ret_32); + } + if (g_spread_324 <= MaxSpread && utg874gbd5(a_magic_0, 0) && Ask > ld_4 && MathMod(Ask / gd_1576, 3) == 0.0 && g_ord_open_price_1736 == 0.0 || Ask > g_ord_open_price_1736) { + l_lots_36 = LotSize; + if (MoneyManagement) l_lots_36 = fun001(gd_1668, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + l_ticket_28 = OrderSend(Symbol(), OP_BUY, l_lots_36, Ask, Slippage, 0, 0, l_comment_12, a_magic_0, 0, g_color_288); + if (l_ticket_28 <= 0) Print("OrderSend Error: " + fun045(GetLastError())); + else + if (SoundAlert) PlaySound(SoundFileAtBuy); + return (li_ret_32); + } + return (0); +} + +void u58dsax_djsah(int a_magic_0) { + string ls_4; + string ls_12; + double ld_20; + int l_ord_total_28; + int l_cmd_32; + int l_ord_close_36; + int lia_44[4]; + int lia_48[2]; + double l_iclose_56; + if (a_magic_0 == g_magic_1204) { + ld_20 = g_global_var_1372; + ls_4 = gs_1300 + "BRT"; + ls_12 = gs_1308 + "BRT"; + } else { + if (a_magic_0 == g_magic_1208) { + ld_20 = g_global_var_1380; + ls_4 = gs_1340 + "BRT"; + ls_12 = gs_1348 + "BRT"; + } + } + lia_44[0] = g_global_var_1560; + lia_44[1] = g_global_var_1564; + lia_44[2] = g_global_var_1568; + lia_44[3] = g_global_var_1572; + fun039(g_ima_1544, g_ima_1552, iHigh(NULL, PERIOD_D1, 1), gd_1536, gd_1528, iLow(NULL, PERIOD_D1, 1), lia_44, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472); + g_global_var_1560 = lia_44[0]; + g_global_var_1564 = lia_44[1]; + g_global_var_1568 = lia_44[2]; + g_global_var_1572 = lia_44[3]; + GlobalVariableSet(g_var_name_1260, g_global_var_1560); + GlobalVariableSet(g_var_name_1268, g_global_var_1564); + GlobalVariableSet(g_var_name_1276, g_global_var_1568); + GlobalVariableSet(g_var_name_1284, g_global_var_1572); + lia_48[0] = g_global_var_1568; + lia_48[1] = g_global_var_1572; + fun040(g_global_var_1560, g_global_var_1564, iClose(NULL, PERIOD_D1, 1), g_ima_1520, iRSI(NULL, PERIOD_D1, 12, PRICE_CLOSE, 0), lia_48, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472); + g_global_var_1568 = lia_48[0]; + g_global_var_1572 = lia_48[1]; + GlobalVariableSet(g_var_name_1276, g_global_var_1568); + GlobalVariableSet(g_var_name_1284, g_global_var_1572); + if (g_global_var_1568 && iClose(NULL, 0, 0) > gd_1536) { + l_ord_total_28 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (int l_pos_52 = l_ord_total_28 - 1; l_pos_52 >= 0; l_pos_52--) { + OrderSelect(l_pos_52, SELECT_BY_POS); + l_cmd_32 = OrderType(); + if (l_cmd_32 == OP_BUY && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > 0.0 && OrderComment() == ls_4) l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage, g_color_296); + if (l_ord_close_36 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } else { + if (g_global_var_1572 && iClose(NULL, 0, 0) < gd_1528) { + l_ord_total_28 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (l_pos_52 = l_ord_total_28 - 1; l_pos_52 >= 0; l_pos_52--) { + OrderSelect(l_pos_52, SELECT_BY_POS); + l_cmd_32 = OrderType(); + if (l_cmd_32 == OP_SELL && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > 0.0 && OrderComment() == ls_12) l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, g_color_296); + if (l_ord_close_36 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } + } + if (aiyui6(a_magic_0) > 40) { + l_iclose_56 = iClose(NULL, 0, 0); + if (fun041(g_global_var_1572, l_iclose_56, g_ima_1520, g_ima_1544, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + if (l_iclose_56 > ld_20) ld_20 = l_iclose_56; + l_ord_total_28 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (l_pos_52 = l_ord_total_28 - 1; l_pos_52 >= 0; l_pos_52--) { + OrderSelect(l_pos_52, SELECT_BY_POS); + l_cmd_32 = OrderType(); + if (l_cmd_32 == OP_BUY && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > gd_1196) l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage, g_color_296); + if (l_ord_close_36 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } else { + if (fun042(g_global_var_1568, l_iclose_56, g_ima_1520, g_ima_1544, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + if (l_iclose_56 < ld_20) ld_20 = l_iclose_56; + l_ord_total_28 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (l_pos_52 = l_ord_total_28 - 1; l_pos_52 >= 0; l_pos_52--) { + OrderSelect(l_pos_52, SELECT_BY_POS); + l_cmd_32 = OrderType(); + if (l_cmd_32 == OP_SELL && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > gd_1196) l_ord_close_36 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, g_color_296); + if (l_ord_close_36 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } + } + } +} + +int d8s2fpsj5(int a_magic_0) { + string ls_4; + string ls_12; + int l_ord_total_20; + int l_cmd_24; + int l_ord_close_28; + if (a_magic_0 == g_magic_1204) { + ls_4 = gs_1300 + "REAR"; + ls_12 = gs_1308 + "REAR"; + } else { + if (a_magic_0 == g_magic_1208) { + ls_4 = gs_1340 + "REAR"; + ls_12 = gs_1348 + "REAR"; + } + } + double l_iclose_36 = iClose(NULL, 0, 0); + if (fun043(l_iclose_36, gd_1536, g_ima_1520, gd_1576, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + l_ord_total_20 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (int l_pos_44 = l_ord_total_20 - 1; l_pos_44 >= 0; l_pos_44--) { + OrderSelect(l_pos_44, SELECT_BY_POS); + l_cmd_24 = OrderType(); + if (l_cmd_24 == OP_BUY && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > 0.0 && OrderComment() == ls_4) l_ord_close_28 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), Slippage, g_color_296); + if (l_ord_close_28 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } else { + if (l_iclose_36 <= gd_1528 || (g_ima_1520 - l_iclose_36) / gd_1576 >= 0.0) { + l_ord_total_20 = OrdersTotal(); + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + for (l_pos_44 = l_ord_total_20 - 1; l_pos_44 >= 0; l_pos_44--) { + OrderSelect(l_pos_44, SELECT_BY_POS); + l_cmd_24 = OrderType(); + if (l_cmd_24 == OP_SELL && OrderMagicNumber() == a_magic_0 && OrderProfit() + OrderSwap() + OrderCommission() > 0.0 && OrderComment() == ls_12) l_ord_close_28 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, g_color_296); + if (l_ord_close_28 == 1) { + g_count_1604++; + if (OrderProfit() > 0.0) gd_1588 += OrderProfit(); + else gd_1596 += OrderProfit(); + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1588 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); + } + } + return (0); +} + +void s9f7a92(int a_magic_0) { + double ld_8; + int l_ord_total_4 = OrdersTotal(); + gi_1584 = 0; + gd_1588 = 0; + gd_1596 = 0; + g_count_1604 = 0; + bool li_16 = FALSE; + int li_20 = 100; + if (a_magic_0 == g_magic_1204) li_20 = gi_1620; + else + if (a_magic_0 == g_magic_1208) li_20 = gi_1624; + for (int l_pos_24 = l_ord_total_4 - 1; l_pos_24 >= 0; l_pos_24--) { + if (OrderSelect(l_pos_24, SELECT_BY_POS) && OrderMagicNumber() == a_magic_0) { + if (gi_1616 && zzxvy_s454(OrderTicket()) >= li_20) { + li_16 = TRUE; + OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, g_color_296); + if (a_magic_0 == g_magic_1204) gi_1608 = TRUE; + else + if (a_magic_0 == g_magic_1208) gi_1612 = TRUE; + } else { + gi_1584 += zzxvy_s454(OrderTicket()); + g_count_1604++; + ld_8 = OrderProfit() + OrderSwap() + OrderCommission(); + if (ld_8 > 0.0) gd_1588 += ld_8; + else gd_1596 += ld_8; + } + } + } + if (li_16) { + if (a_magic_0 == g_magic_1204) gi_1620 += 10; + else + if (a_magic_0 == g_magic_1208) gi_1624 += 10; + } + if (gi_1584 >= 100 && gd_1588 - gd_1596 >= 10.0) osdufoidsu(a_magic_0, -1); +} + +void osdufoidsu(int a_magic_0, int a_magic_4) { + int l_error_20; + int l_count_8 = 0; + bool l_ord_close_12 = FALSE; + for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { + OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); + if (OrderMagicNumber() != a_magic_0 && OrderMagicNumber() != a_magic_4) continue; + l_count_8 = 0; + while (l_count_8 < 10) { + RefreshRates(); + l_ord_close_12 = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), Slippage, g_color_296); + if (l_ord_close_12) l_count_8 = 10; + else { + l_error_20 = GetLastError(); + Print("Order Ticket: " + OrderTicket()); + Print(l_count_8, " Error closing order : (", fun045(l_error_20), ") "); + if (l_error_20 > 0/* NO_ERROR */) l_count_8++; + } + } + } + if (a_magic_0 == g_magic_1204) { + gi_1620 = 200; + gi_1608 = FALSE; + } else { + if (a_magic_0 == g_magic_1208) { + gi_1624 = 160; + gi_1612 = FALSE; + } + } + if (SendEmail && gd_1588 != 0.0 || gd_1596 != 0.0) jr654ej_Send_Email(g_count_1604, gd_1588, gd_1596); +} + +void SCF_EA_STS() { + int l_datetime_20; + int li_28; + int li_32; + int li_0 = 0.0; + double ld_4 = 0.0; + double ld_12 = 0.0; + int li_unused_24 = 0; + if (as5da987asd()) { + OrderSelect(g_ticket_332, SELECT_BY_TICKET); + li_0 = zzxvy_s454(OrderTicket()); + if (OrderType() == OP_BUY || OrderType() == OP_SELL) { + if (li_0 < gi_580) gi_580 = li_0; + li_28 = TimeCurrent() - OrderOpenTime(); + if (li_28 >= gi_596 && li_0 >= 2) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } else { + if (li_28 >= gi_592 && li_0 >= 4 && li_28 < gi_596) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } else { + if (li_28 >= gi_588 && li_0 >= 6 && li_28 < gi_592) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } else { + if (gi_580 <= gi_584 && li_0 >= 3) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } + } + } + } + if (gi_336) ppsfjia485(); + if (gi_352) ltp_j4857(gi_344); + } else { + if (TimeCurrent() > OrderOpenTime() + 60 * gi_576 + 60) + if (OrderDelete(g_ticket_332)) g_ticket_332 = -1; + } + } else { + gi_352 = FALSE; + gi_580 = 0; + g_ticket_332 = -1; + } + if (AccountFreeMargin() < AccountBalance() * MarginCutOffPercent / 100.0) { + if (g_ticket_332 != -1) { + OrderSelect(g_ticket_332, SELECT_BY_TICKET); + if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT) { + if (piwejansmj(g_ticket_332)) { + g_ticket_332 = -1; + gi_352 = FALSE; + } + } + } + } else { + if (Hour() - gi_108 < gi_600 && Hour() - gi_108 > gi_604) return; + if (!gi_480) + if (DayOfWeek() == 5 && Hour() - gi_108 > 0) return; + if (DayOfWeek() == 1 && Hour() - gi_108 < 1) return; + if (!ujasgd() || g_spread_324 > MaxSpread) return; + if (NFA_Compliant && egudss2a5a5d11(Symbol())) return; + if (gi_504) li_32 = 30; + else li_32 = 60; + for (int l_count_36 = 0; l_count_36 < 4; l_count_36++) { + gda_516[0][l_count_36] = uiasgy_sdf(li_32, gi_520, l_count_36); + gda_516[1][l_count_36] = uiasgy_sdf(li_32, gi_524, l_count_36); + gda_516[2][l_count_36] = uiasgy_sdf(li_32, gi_528, l_count_36); + gda_516[3][l_count_36] = uiasgy_sdf(li_32, gi_532, l_count_36); + gda_516[4][l_count_36] = uiasgy_sdf(li_32, gi_536, l_count_36); + } + if (fun031(gda_516, iRSI(Symbol(), PERIOD_M15, g_period_540, PRICE_CLOSE, 0), iRSI(Symbol(), PERIOD_M5, g_period_544, PRICE_CLOSE, 0), gd_556, gd_548, gba_572)) { + g_lots_564 = fun001(gd_1628, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + if (!as5da987asd()) { + if (gba_572[0] == 1) { + ld_4 = Ask + gi_488 * Point; + ld_12 = Ask - gi_492 * Point; + l_datetime_20 = TimeCurrent() + 60 * gi_576; + if (!gi_484) g_ticket_332 = OrderSend(Symbol(), OP_BUYLIMIT, g_lots_564, Ask - gi_496 * Point, Slippage, 0, 0, ExpertComment, g_magic_512, l_datetime_20, g_color_288); + else g_ticket_332 = OrderSend(Symbol(), OP_BUY, g_lots_564, Ask, Slippage, 0, 0, ExpertComment, g_magic_512, 0, g_color_288); + if (g_ticket_332 <= 0) { + Print("Error opening BUY order (" + fun045(GetLastError()) + ") "); + Sleep(3000); + } else { + OrderSelect(g_ticket_332, SELECT_BY_TICKET); + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_12, ld_4); + if (SoundAlert) PlaySound(SoundFileAtBuy); + if (SendEmail) Send_Email(g_ticket_332, "OPEN"); + } + } else { + if (gba_572[1] == 1) { + ld_4 = Bid - gi_488 * Point; + ld_12 = Bid + gi_492 * Point; + l_datetime_20 = TimeCurrent() + 60 * gi_576; + if (!gi_484) g_ticket_332 = OrderSend(Symbol(), OP_SELLLIMIT, g_lots_564, Bid + gi_500 * Point, Slippage, 0, 0, ExpertComment, g_magic_512, l_datetime_20, g_color_292); + else g_ticket_332 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, g_magic_512, 0, g_color_292); + if (g_ticket_332 <= 0) { + Print("Error opening SELL order (" + fun045(GetLastError()) + ") "); + Sleep(3000); + } else { + OrderSelect(g_ticket_332, SELECT_BY_TICKET); + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_12, ld_4); + if (SoundAlert) PlaySound(SoundFileAtSell); + if (SendEmail) Send_Email(g_ticket_332, "OPEN"); + } + } + } + } + } + } +} + +void LNMSBHJ_SD54878_58787() { + double l_iwpr_16; + double ld_24; + double ld_32; + double ld_64; + double ld_80; + int li_116; + double l_irsi_120; + double l_irsi_128; + double l_ibands_136; + double l_ibands_144; + bool li_152; + double l_icci_156; + double l_icci_164; + double l_icci_172; + double l_icci_180; + double l_imomentum_192; + double ld_0 = 0.0; + double ld_8 = 0.0; + if (gi_864 == TRUE) { + for (int l_pos_104 = 0; l_pos_104 < OrdersTotal(); l_pos_104++) { + OrderSelect(l_pos_104, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && fun032(OrderType(), OrderOpenPrice(), Bid, Ask, OrderMagicNumber(), g_magic_832, g_magic_836, gd_848)) piwejansmj(OrderTicket()); + } + } + for (int l_pos_108 = 0; l_pos_108 < OrdersTotal(); l_pos_108++) { + OrderSelect(l_pos_108, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && fun011(OrderType(), TimeCurrent(), OrderOpenTime(), Bid, Ask, OrderOpenPrice(), gd_848, OrderMagicNumber(), g_magic_832, g_magic_836, DayOfWeek(), Hour())) piwejansmj(OrderTicket()); + } + bool li_112 = fun005(TimeHour(TimeCurrent()), gi_784, gi_788, Hour(), Minute()); + if (li_112) { + li_116 = fun012(iOpen(Symbol(), PERIOD_M5, 0), iOpen(Symbol(), PERIOD_M5, 1), iOpen(Symbol(), PERIOD_M5, 2), Bid, Ask); + l_irsi_120 = iRSI(NULL, PERIOD_M15, 6, PRICE_CLOSE, 0); + l_irsi_128 = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0); + asdf_isaudh(); + gi_952 = MathRound((g_ifractals_1000 - g_ifractals_1008) / gd_848); + gd_956 = 0; + gd_956 = fun023(1221, 0, g_ifractals_1000, g_ifractals_1000, g_ifractals_1008); + gi_964 = MathRound(iATR(Symbol(), PERIOD_M15, 4, 0) / gd_848); + l_ibands_136 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_UPPER, 1); + l_ibands_144 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_LOWER, 1); + li_152 = FALSE; + if (Close[0] <= g_ifractals_1016 && Close[0] >= g_ifractals_1024) li_152 = TRUE; + l_icci_156 = iCCI(Symbol(), PERIOD_M15, 14, PRICE_CLOSE, 0); + l_icci_164 = iCCI(Symbol(), PERIOD_M5, 42, PRICE_CLOSE, 0); + l_icci_172 = iCCI(Symbol(), PERIOD_M1, 210, PRICE_CLOSE, 0); + l_icci_180 = iCCI(Symbol(), PERIOD_M1, 80, PRICE_CLOSE, 0); + g_count_916 = 0; + g_count_920 = 0; + g_count_924 = 0; + g_count_928 = 0; + g_count_932 = 0; + for (int l_pos_188 = 0; l_pos_188 < OrdersTotal(); l_pos_188++) { + OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES); + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_832 || OrderMagicNumber() == g_magic_836) g_count_916++; + else { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_832) { + if (OrderType() == OP_BUY) g_count_928++; + if (OrderType() == OP_SELL) g_count_920++; + } else { + if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_836) { + if (OrderType() == OP_BUY) g_count_932++; + if (OrderType() == OP_SELL) g_count_924++; + } + } + } + } + l_imomentum_192 = iMomentum(Symbol(), PERIOD_M5, 4, PRICE_CLOSE, 0); + if (NFA_Compliant && egudss2a5a5d11(Symbol())) { + li_116 = 0; + li_112 = FALSE; + } + if (li_116 && gi_952 < gi_880 && gi_964 < gi_884 && g_count_916 < gi_844 && li_152) { + l_iwpr_16 = iWPR(Symbol(), PERIOD_M5, 14, 0); + gi_912 = NormalizeDouble(gi_844 / 2, 0); + ld_24 = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4); + ld_32 = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4); + if (li_116 && g_count_916 < gi_844 && li_152) { + if (!h5sa4dhjsag_n(g_magic_832)) { + if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour() >= 14) return; + if (fun013(l_irsi_120, gd_808, l_irsi_128, gd_816, ld_24, Ask, gd_848, g_count_928, gi_888, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + gd_944 = Ask - ld_64; + ld_8 = Ask + gi_780 * Point; + ld_0 = Ask - gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_976 = OrderSend(Symbol(), OP_BUY, g_lots_564, Ask, Slippage, 0, 0, ExpertComment, g_magic_832, 0, g_color_288); + if (g_ticket_976 > 0 && OrderSelect(g_ticket_976, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtBuy); + if (SendEmail) Send_Email(g_ticket_976, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_888 = FALSE; + gi_892 = TRUE; + } + if (fun014(l_irsi_120, gd_792, l_irsi_128, gd_800, ld_32, Bid, gd_848, g_count_920, gi_892, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + gd_944 = Bid + ld_80; + ld_8 = Bid - gi_780 * Point; + ld_0 = Bid + gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_980 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, g_magic_832, 0, g_color_292); + if (g_ticket_980 > 0 && OrderSelect(g_ticket_980, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtSell); + if (SendEmail) Send_Email(g_ticket_980, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_892 = FALSE; + gi_888 = TRUE; + } + } + if (l_irsi_120 < 60.0 && l_irsi_120 > 40.0) { + gi_892 = TRUE; + gi_888 = TRUE; + } + } + if (li_112) { + if (!h5sa4dhjsag_n(g_magic_836)) { + if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour() >= 14) return; + if (fun015(l_icci_164, l_icci_172, l_icci_156, Bid, gd_956, gd_848, g_count_932, gi_912, gi_896, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + if (gi_864) gd_unused_936 = g_ifractals_1000; + ld_8 = Ask + gi_780 * Point; + ld_0 = Ask - gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_984 = OrderSend(Symbol(), OP_BUY, g_lots_564, Ask, Slippage, 0, 0, ExpertComment, g_magic_836, 0, g_color_288); + if (g_ticket_984 > 0 && OrderSelect(g_ticket_984, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtBuy); + if (SendEmail) Send_Email(g_ticket_984, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_896 = FALSE; + gi_900 = TRUE; + } + if (fun016(l_icci_164, l_icci_172, l_icci_156, Ask, gd_956, gd_848, g_count_924, gi_912, gi_900, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + if (gi_864) gd_unused_936 = g_ifractals_1008; + ld_8 = Bid - gi_780 * Point; + ld_0 = Bid + gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_988 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, g_magic_836, 0, g_color_292); + if (g_ticket_988 > 0 && OrderSelect(g_ticket_988, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtSell); + if (SendEmail) Send_Email(g_ticket_988, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_900 = FALSE; + gi_896 = TRUE; + } + } + if (l_icci_156 < 50.0 && l_icci_156 > -50.0) { + gi_900 = TRUE; + gi_896 = TRUE; + } + if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour() >= 14) return; + if (fun017(l_imomentum_192, gd_824, l_icci_180, Ask, gd_956, gd_848, gi_912, gi_904, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + if (gi_864) gd_unused_936 = g_ifractals_1008; + if (gi_868) gd_944 = g_ifractals_1000 + gd_872 * gd_848; + else gd_944 = Bid + gd_872 * gd_848; + ld_8 = Bid - gi_780 * Point; + ld_0 = Bid + gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_992 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, g_magic_836, 0, g_color_292); + if (g_ticket_992 > 0 && OrderSelect(g_ticket_992, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtSell); + if (SendEmail) Send_Email(g_ticket_992, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_904 = FALSE; + } + if (l_icci_180 >= -50.0 && l_icci_180 <= 50.0) gi_904 = TRUE; + if (DayOfWeek() == 0 || DayOfWeek() == 5 && Hour() >= 14) return; + if (fun018(l_iwpr_16, iMA(Symbol(), PERIOD_M5, 1, 0, MODE_EMA, PRICE_HIGH, 0), l_ibands_136, Bid, gd_956, gd_848, gi_912, gi_908, g_spread_324, MaxSpread, AccountFreeMargin(), AccountBalance(), MarginCutOffPercent, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + gd_unused_936 = 0; + gd_944 = 0; + if (gi_864) gd_unused_936 = g_ifractals_1008; + if (gi_868) gd_944 = Bid + gi_880 * gd_848; + else gd_944 = Bid + gd_872 * gd_848; + ld_8 = Bid - gi_780 * Point; + ld_0 = Bid + gi_776 * Point; + g_lots_564 = fun001(gd_1644, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + g_ticket_996 = OrderSend(Symbol(), OP_SELL, g_lots_564, Bid, Slippage, 0, 0, ExpertComment, g_magic_836, 0, g_color_292); + if (g_ticket_996 > 0 && OrderSelect(g_ticket_996, SELECT_BY_TICKET)) { + nyusgfj(OrderTicket(), OrderOpenPrice(), ld_0, ld_8); + if (SoundAlert) PlaySound(SoundFileAtSell); + if (SendEmail) Send_Email(g_ticket_996, "OPEN"); + } else Print("OrderSend Error ", fun045(GetLastError())); + gi_908 = FALSE; + } + } + if (l_irsi_120 < 60.0 && l_irsi_120 > 40.0) gi_908 = TRUE; + } + } +} + +void QUYT_A9IA_545A() { + double l_iclose_0; + double l_iclose_8; + int l_shift_16; + int l_shift_20; + bool li_32; + int lia_36[500]; + int lia_40[1]; + double lda_44[1]; + double lda_48[1]; + double lda_52[1]; + double lda_56[1]; + gi_1044 = TimeCurrent() - 3600.0 * gi_1036; + g_hour_1048 = TimeHour(gi_1044); + gi_1052 = (-3600.0 * g_hour_1048) - 60 * TimeMinute(gi_1052) - TimeSeconds(gi_1044); + g_stoplevel_1056 = MarketInfo(Symbol(), MODE_STOPLEVEL); + gd_1060 = 0.0001 / Point; + if (Digits < 4) gd_1060 = 100.0 * gd_1060; + if (g_ticket_1124 < 0) { + g_ticket_1124 = sjdhfjdhfjdhf(gi_1032, OP_BUY); + if (g_ticket_1124 >= 0) OrderSelect(g_ticket_1124, SELECT_BY_TICKET); + } + if (g_ticket_1128 < 0) { + g_ticket_1128 = sjdhfjdhfjdhf(gi_1032, OP_SELL); + if (g_ticket_1128 >= 0) OrderSelect(g_ticket_1128, SELECT_BY_TICKET); + } + HideTestIndicators(TRUE); + g_irsi_1068 = iRSI(NULL, PERIOD_M15, 6, PRICE_CLOSE, 0); + g_irsi_1076 = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0); + g_icci_1084 = iCCI(NULL, PERIOD_M15, 8, PRICE_TYPICAL, 0); + g_ima_1092 = iMA(NULL, PERIOD_M15, 8, 0, MODE_SMA, PRICE_MEDIAN, 0); + HideTestIndicators(FALSE); + if (g_ticket_1124 >= 0) { + if (OrderSelect(g_ticket_1124, SELECT_BY_TICKET) && OrderCloseTime() == 0) { + if (fun009(Bid, OrderOpenPrice(), Digits, gd_1060, OrderOpenTime(), g_icci_1084, g_irsi_1068, OrderProfit(), Point, zzxvy_s454(OrderTicket())) || fun044(gs_316, zzxvy_s454(OrderTicket()), TimeCurrent() - OrderOpenTime(), gi_588, gi_592, gi_596, EURCHF_Grid_Strategy)) + if (piwejansmj(g_ticket_1124)) g_ticket_1124 = -1; + } else g_ticket_1124 = -1; + } + if (g_ticket_1128 >= 0) { + if (OrderSelect(g_ticket_1128, SELECT_BY_TICKET) && OrderCloseTime() == 0) { + if (fun010(Ask, OrderOpenPrice(), Digits, gd_1060, OrderOpenTime(), g_icci_1084, g_irsi_1068, OrderProfit(), Point, zzxvy_s454(OrderTicket())) || fun044(gs_316, zzxvy_s454(OrderTicket()), TimeCurrent() - OrderOpenTime(), gi_588, gi_592, gi_596, EURCHF_Grid_Strategy)) + if (piwejansmj(g_ticket_1128)) g_ticket_1128 = -1; + } else g_ticket_1128 = -1; + } + if (EURCHF_Grid_Strategy == FALSE && !fun005(TimeHour(TimeCurrent()), gi_784, gi_788, Hour(), Minute())) return; + int li_24 = -1; + int li_28 = -1; + if (-gi_1052 < 43200) g_shift_1100 = iBarShift(NULL, PERIOD_M15, gi_1052 - 86400); + else g_shift_1100 = iBarShift(NULL, PERIOD_M15, gi_1052); + g_ihigh_1104 = iHigh(NULL, PERIOD_M15, iHighest(NULL, PERIOD_M15, MODE_HIGH, g_shift_1100, 0)); + g_ilow_1112 = iLow(NULL, PERIOD_M15, iLowest(NULL, PERIOD_M15, MODE_LOW, g_shift_1100, 0)); + if (NFA_Compliant && g_ticket_1124 < 0 && egudss2a5a5d11(Symbol())) g_ticket_1124 = 1; + if (g_ticket_1124 < 0) { + if (-gi_1052 < 43200) { + l_shift_16 = iBarShift(NULL, PERIOD_M15, gi_1052 - 86400); + l_shift_20 = iBarShift(NULL, PERIOD_M15, gi_1052); + } else { + l_shift_16 = iBarShift(NULL, PERIOD_M15, gi_1052); + l_shift_20 = 0; + } + l_iclose_8 = iClose(NULL, PERIOD_M15, l_shift_16); + l_iclose_0 = iClose(NULL, PERIOD_M15, l_shift_20); + if (l_iclose_0 < l_iclose_8) li_24 = 0; + else li_24 = fun024(Ask, g_icci_1084, g_irsi_1068, g_irsi_1076, g_ima_1092, gd_1060 * Point, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472); + } + if (NFA_Compliant && g_ticket_1128 < 0 && egudss2a5a5d11(Symbol())) g_ticket_1128 = 1; + if (g_ticket_1128 < 0) { + if (-gi_1052 < 43200) { + l_shift_16 = iBarShift(NULL, PERIOD_M15, gi_1052 - 86400); + l_shift_20 = iBarShift(NULL, PERIOD_M15, gi_1052); + } else { + l_shift_16 = iBarShift(NULL, PERIOD_M15, gi_1052); + l_shift_20 = 0; + } + l_iclose_8 = iClose(NULL, PERIOD_M15, l_shift_16); + l_iclose_0 = iClose(NULL, PERIOD_M15, l_shift_20); + if (l_iclose_0 > l_iclose_8) li_28 = 0; + else li_28 = fun025(Bid, g_icci_1084, g_irsi_1068, g_irsi_1076, g_ima_1092, gd_1060 * Point, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472); + } + if (li_24 == 1 && g_datetime_1132 != iTime(NULL, PERIOD_M15, 0)) { + li_32 = FALSE; + if (!EURCHF_Grid_Strategy) li_32 = TRUE; + else { + ArrayInitialize(lia_36, 0); + ArrayInitialize(lia_40, 0); + if (fun030(Ask, Bid, gda_1152, gda_1156, gia_1160, gd_1172, lia_36, 1, lia_40, 0, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472) == 0) li_32 = TRUE; + } + if (li_32) { + lda_44[0] = 0; + lda_48[0] = 0; + fun007(g_ilow_1112, Bid, Ask, Point, gd_1060, g_stoplevel_1056, gi_772, lda_44, lda_48, lda_52, lda_56, Digits, gs_316); + g_lots_564 = fun001(gd_1652, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + if (EURCHF_Grid_Strategy) lda_52[0] = 0; + g_ticket_1124 = ystqlahf(OP_BUY, g_lots_564, Ask, lda_56[0], lda_52[0], gi_1032, g_color_288); + if (g_ticket_1124 >= 0) g_datetime_1132 = iTime(NULL, PERIOD_M15, 0); + } + } + if (li_28 == 1 && g_datetime_1136 != iTime(NULL, PERIOD_M15, 0)) { + li_32 = FALSE; + if (!EURCHF_Grid_Strategy) li_32 = TRUE; + else { + ArrayInitialize(lia_36, 0); + ArrayInitialize(lia_40, 0); + if (fun030(Ask, Bid, gda_1152, gda_1156, gia_1160, gd_1172, lia_36, 1, lia_40, 0, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472) == 1) li_32 = TRUE; + } + if (li_32) { + lda_44[0] = 0; + lda_48[0] = 0; + fun008(g_ihigh_1104, Ask, Bid, Point, gd_1060, g_stoplevel_1056, gi_772, lda_44, lda_48, lda_52, lda_56, Digits, gs_316); + g_lots_564 = fun001(gd_1652, MoneyManagement, LotSize, RiskLevel, AccountLeverage(), AccountFreeMargin(), gd_456, g_lotstep_448, gi_772, gd_440, gd_432, MaxLots); + if (EURCHF_Grid_Strategy) lda_52[0] = 0; + g_ticket_1128 = ystqlahf(OP_SELL, g_lots_564, Bid, lda_56[0], lda_52[0], gi_1032, g_color_292); + if (g_ticket_1128 >= 0) g_datetime_1136 = iTime(NULL, PERIOD_M15, 0); + } + } +} + +void KJSDHF_4S865A_AS85() { + int lia_0[1]; + ArrayInitialize(gia_1144, 0); + gi_1148 = x45sd_jsakh(gia_1144); + gi_1164 = fun030(Ask, Bid, gda_1152, gda_1156, gia_1160, gd_1172, gia_1144, gi_1148, lia_0, 1, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472); + gi_1168 = lia_0[0]; + s5sa4d8s(gi_1164); +} + +void jr654ej() { + double ld_0; + double ld_8; + double ld_16; + double lda_24[1]; + int lia_28[1]; + int lia_32[1]; + int lia_40[1]; + int lia_44[1]; + double lda_48[1]; + double lda_52[1]; + double lda_56[1]; + double ld_60; + if (GBPUSD_Hedging_CloseAll) { + osdufoidsu(g_magic_1204, g_magic_1208); + return; + } + if (IsTesting()) { + if (TimeCurrent() - g_datetime_1752 >= 1800) { + Print("Bid/Ask = ", DoubleToStr(Bid, Digits) + "/" + DoubleToStr(Ask, Digits)); + Print("Account equity = ", AccountEquity()); + Print("Account balance = ", AccountBalance()); + g_datetime_1752 = TimeCurrent(); + } + } + int li_36 = fun035(Digits, Point, MarketInfo(Symbol(), MODE_LOTSIZE), Symbol(), iBars(Symbol(), PERIOD_H4), iBars(Symbol(), PERIOD_D1), lda_24, lia_28, lia_32); + gd_1576 = lda_24[0]; + gi_1184 = lia_32[0]; + if (li_36) { + g_iadx_1464 = iADX(NULL, PERIOD_M30, 19, PRICE_CLOSE, MODE_MAIN, 0); + g_iadx_1472 = iADX(NULL, PERIOD_M30, 19, PRICE_CLOSE, MODE_MAIN, 1); + g_ima_1488 = iMA(NULL, PERIOD_M30, 12, 0, MODE_SMA, PRICE_CLOSE, 0); + gd_1480 = 2.0 * iATR(NULL, PERIOD_M30, 12, 0); + gd_1504 = g_ima_1488 + gd_1480; + gd_1496 = g_ima_1488 - gd_1480; + g_ima_1520 = iMA(NULL, PERIOD_D1, 50, 0, MODE_SMA, PRICE_CLOSE, 0); + gd_1512 = 2.0 * iATR(NULL, PERIOD_D1, 50, 0); + gd_1536 = g_ima_1520 + gd_1512; + gd_1528 = g_ima_1520 - gd_1512; + g_ima_1552 = iMA(NULL, PERIOD_D1, 9, 0, MODE_SMA, PRICE_CLOSE, 0); + g_ima_1544 = iMA(NULL, PERIOD_D1, 9, 0, MODE_SMA, PRICE_CLOSE, 0); + lia_40[0] = g_global_var_1428; + lia_44[0] = g_global_var_1432; + fun037(lia_40, iRSI(NULL, PERIOD_D1, 12, PRICE_CLOSE, 0), lia_44); + g_global_var_1428 = lia_40[0]; + g_global_var_1432 = lia_44[0]; + GlobalVariableSet(g_var_name_1228, g_global_var_1428); + GlobalVariableSet(g_var_name_1220, g_global_var_1432); + lia_40[0] = g_global_var_1436; + lia_44[0] = g_global_var_1440; + fun038(lia_40, iRSI(NULL, PERIOD_H4, 12, PRICE_CLOSE, 0), iRSI(NULL, PERIOD_D1, 12, PRICE_CLOSE, 0), lia_44); + g_global_var_1436 = lia_40[0]; + g_global_var_1440 = lia_44[0]; + GlobalVariableSet(g_var_name_1244, g_global_var_1436); + GlobalVariableSet(g_var_name_1236, g_global_var_1440); + g_global_var_1420 = GlobalVariableGet(g_var_name_1212); + if (asf47sws(g_magic_1204) < (-0.2 * g_global_var_1420) || asf47sws(g_magic_1208) < (-0.2 * g_global_var_1420) || asf47sws(g_magic_1204) + asf47sws(g_magic_1208) < (-0.2 * g_global_var_1420) || + AccountProfit() < (-0.2 * g_global_var_1420) || OrdersTotal() > 90) { + gi_1456 = FALSE; + gi_1460 = FALSE; + } else { + gi_1456 = TRUE; + gi_1460 = TRUE; + } + if (OrdersTotal() > 0) { + fun033(g_lots_1388, g_lots_1396, gi_1184, lda_48, lda_52, lda_56); + ld_0 = lda_48[0]; + gd_1188 = lda_52[0]; + } + if (!gi_1184) ld_8 = 1000.0 * ld_0; + else ld_8 = 1000.0 * (ld_0 / 10.0); + gi_1616 = TRUE; + if (g_count_1748 + g_count_1744 > 59 || AccountEquity() > g_global_var_1420 + gd_1188 || (g_global_var_1372 != 0.0 && MathAbs(TimeDayOfYear(TimeCurrent()) - TimeDayOfYear(g_global_var_1404)) > 20.0) || + (g_global_var_1380 != 0.0 && MathAbs(TimeDayOfYear(TimeCurrent()) - TimeDayOfYear(g_global_var_1408)) > 20.0)) gi_1616 = TRUE; + else gi_1616 = FALSE; + if (gi_1616) { + if (AccountEquity() > g_global_var_1420 + ld_8) { + if (g_global_var_1372 != 0.0) { + while (aiyui6(g_magic_1204) > 0) pasodajy(g_magic_1204); + g_global_var_1372 = 0; + GlobalVariableSet(g_var_name_1316, g_global_var_1372); + g_global_var_1404 = 0; + GlobalVariableSet(g_var_name_1292, g_global_var_1404); + } + if (g_global_var_1380 != 0.0) { + while (aiyui6(g_magic_1208) > 0) pasodajy(g_magic_1208); + g_global_var_1380 = 0; + GlobalVariableSet(g_var_name_1356, g_global_var_1380); + g_global_var_1408 = 0; + GlobalVariableSet(g_var_name_1332, g_global_var_1408); + } + gi_1444++; + GlobalVariableSet(g_var_name_1252, gi_1444); + } + } + if (OrdersTotal() == 0 && AccountEquity() > g_global_var_1420) { + g_global_var_1420 = AccountEquity(); + GlobalVariableSet(g_var_name_1212, g_global_var_1420); + } + ld_60 = 0; + if (g_global_var_1372 != 0.0) { + if (!gi_1184) ld_60 = 1000.0 * g_lots_1388; + else ld_60 = 1000.0 * (g_lots_1388 / 10.0); + g_global_var_1404 = GlobalVariableGet(g_var_name_1292); + if (asf47sws(g_magic_1204) + fsd897(g_magic_1204, g_global_var_1404) >= ld_60) { + while (aiyui6(g_magic_1204) > 0) pasodajy(g_magic_1204); + gi_1448++; + GlobalVariableSet(g_var_name_1324, gi_1448); + g_global_var_1372 = 0; + GlobalVariableSet(g_var_name_1316, g_global_var_1372); + g_global_var_1404 = 0; + GlobalVariableSet(g_var_name_1292, g_global_var_1404); + } + } + if (g_global_var_1372 == 0.0 && gi_1456) { + if (fun034(g_iadx_1464, g_iadx_1472, iClose(NULL, 0, 0), gd_1504, gd_1496, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + if (fun036(0, g_magic_1204, iClose(NULL, 0, 0), g_global_var_1380, gi_1180, gd_1576, TimeDayOfYear(TimeCurrent()), TimeDayOfYear(g_global_var_1408), TimeDayOfYear(gi_1412), TimeDayOfYear(gi_1416), g_global_var_1372, TimeDayOfYear(g_global_var_1404), KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + g_global_var_1372 = iClose(NULL, 0, 0); + GlobalVariableSet(g_var_name_1316, g_global_var_1372); + g_global_var_1404 = TimeCurrent(); + GlobalVariableSet(g_var_name_1292, g_global_var_1404); + } + } + } + if (g_global_var_1372 != 0.0) { + kdsjoa8547(g_magic_1204); + u58dsax_djsah(g_magic_1204); + d8s2fpsj5(g_magic_1204); + s9f7a92(g_magic_1204); + } + if (g_global_var_1380 != 0.0) { + if (!gi_1184) ld_16 = 1000.0 * g_lots_1396; + else ld_16 = 1000.0 * (g_lots_1396 / 10.0); + if (asf47sws(g_magic_1208) + fsd897(g_magic_1208, g_global_var_1408) >= ld_16) { + pasodajy(g_magic_1208); + gi_1452++; + GlobalVariableSet(g_var_name_1364, gi_1452); + g_global_var_1380 = 0; + GlobalVariableSet(g_var_name_1356, g_global_var_1380); + g_global_var_1408 = 0; + GlobalVariableSet(g_var_name_1332, g_global_var_1408); + } + } + if (g_global_var_1380 == 0.0 && gi_1460) { + if (fun034(g_iadx_1464, g_iadx_1472, iClose(NULL, 0, 0), gd_1504, gd_1496, KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + if (fun036(1, g_magic_1204, iClose(NULL, 0, 0), g_global_var_1380, gi_1180, gd_1576, TimeDayOfYear(TimeCurrent()), TimeDayOfYear(g_global_var_1408), TimeDayOfYear(gi_1412), TimeDayOfYear(gi_1416), g_global_var_1372, TimeDayOfYear(g_global_var_1404), KEY, g_acc_number_464, gsa_468[0], gsa_468[1], gsa_468[2], g_bool_472)) { + g_global_var_1380 = iClose(NULL, 0, 0); + GlobalVariableSet(g_var_name_1356, g_global_var_1380); + g_global_var_1408 = TimeCurrent(); + GlobalVariableSet(g_var_name_1332, g_global_var_1408); + } + } + } + if (g_global_var_1380 != 0.0) { + kdsjoa8547(g_magic_1208); + u58dsax_djsah(g_magic_1208); + d8s2fpsj5(g_magic_1208); + s9f7a92(g_magic_1208); + } + } +} diff --git a/RD-PivotLines.mq4 b/RD-PivotLines.mq4 new file mode 100644 index 0000000..290b528 --- /dev/null +++ b/RD-PivotLines.mq4 @@ -0,0 +1,445 @@ +//+------------------------------------------------------------------+ +//| Pivot.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" + +#property indicator_chart_window + +// ---- user input --------------- +/* + LocalTimeZone: TimeZone for which MT4 shows your local time, + e.g. 1 or 2 for Europe (GMT+1 or GMT+2 (daylight + savings time). Use zero for no adjustment. + + DestTimeZone: TimeZone for the session from which to calculate + the levels (e.g. 1 or 2 for the European session + (without or with daylight savings time). + Use zero for GMT + + Example: If your MT server is living in the EST (Eastern Standard Time, + GMT-5) zone and want to calculate the levels for the London trading + session (European time in summer GMT+1), then enter -5 for + LocalTimeZone, 1 for Dest TimeZone. + + Please understand that the LocalTimeZone setting depends on the + time on your MetaTrader charts (for example the demo server + from MetaQuotes always lives in CDT (+2) or CET (+1), no matter + what the clock on your wall says. + + If in doubt, leave everything to zero. +*/ + + +extern int LocalTimeZone= 0; +extern int DestTimeZone= 0; + + +extern bool ShowPivots = false; +extern bool ShowFibos= true; +extern bool ShowYesterdayHighLow = false; +extern bool ShowMidPitvot = false; +extern bool ShowCamarilla = false; + +extern int BarForLabels= 10; // number of bars from right, where lines labels will be shown + +extern bool DebugLogger = false; + + + +/* + The following doesn't work yet, please leave it to 0/24: + + TradingHoursFrom: First hour of the trading session in the destination + time zone. + + TradingHoursTo: Last hour of the trading session in the destination + time zone (the hour starting with this value is excluded, + i.e. 18 means up to 17:59 o'clock) + + Example: If you are lving in the EST (Eastern Standard Time, GMT-5) + zone and want to calculate the levels for the London trading + session (European time GMT+1, 08:00 - 17:00), then enter + -5 for LocalTimeZone, 1 for Dest TimeZone, 8 for HourFrom + and 17 for hour to. +*/ + +int TradingHoursFrom= 0; +int TradingHoursTo= 24; + + + + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ + return(0); +} + +int deinit() +{ + int obj_total= ObjectsTotal(); + + for (int i= obj_total; i>=0; i--) { + string name= ObjectName(i); + + if (StringSubstr(name,0,7)=="[PIVOT]") + ObjectDelete(name); + } + + + // delete objects from older version + ObjectDelete("YesterdayStart"); + ObjectDelete("YesterdayEnd"); + + ObjectDelete("YesterdayStart Label"); + ObjectDelete("YesterdayEnd Label"); + + ObjectDelete("Pivot Label"); + ObjectDelete("Pivot Line"); + + string types= "RSHLM"; // beginning letters of objects + + for ( i= 0; i 1440) + { + Print("Error - Chart period is greater than 1 day."); + return(-1); // then exit + } + + datetime startofday= 0; + + double day_high= 0; + double day_low= 0; + double yesterday_high= 0; + double yesterday_open= 0; + double yesterday_low= 0; + double yesterday_close= 0; + double today_open= 0; + double today_high= 0; + double today_low= 0; + + double rates_d1[2][6]; + double rates_h1[2][6]; + + + //---- Get new daily prices + /* flat time + ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1); + yesterday_close= rates_d1[1][4]; + yesterday_open= rates_d1[1][1]; + today_open= rates_d1[0][1]; + yesterday_high= rates_d1[1][3]; + yesterday_low= rates_d1[1][2]; + day_high= rates_d1[0][3]; + day_low= rates_d1[0][2]; + + Print("unzoned1: yc =", yesterday_close, ", yo= ", yesterday_open, ", to= ", today_open, ", yhigh= ", yesterday_high, ", ylow= ", yesterday_low); + */ + + + if (DebugLogger) { + Print("Local time current bar:", TimeToStr(iTime(NULL, PERIOD_H1, 0))); + Print("Dest time current bar: ", TimeToStr(iTime(NULL, PERIOD_H1, 0)- (LocalTimeZone - DestTimeZone)*3600), ", tzdiff= ", LocalTimeZone - DestTimeZone); + } + + int tzdiff= LocalTimeZone - DestTimeZone, + tzdiffsec= tzdiff*3600; + + int dayofweektoday= TimeDayOfWeek(iTime(NULL, PERIOD_H1, 0) - tzdiffsec), // what day is today in the dest timezone? + dayofweektofind= -1; + + int idxfirstbaroftoday= 0, + idxfirstbarofyesterday= 0, + idxlastbarofyesterday= 0; + + switch (dayofweektoday) { + case 6: // sat + case 0: // sun + case 1: // mon + dayofweektofind= 5; // prev friday + break; + + default: + dayofweektofind= dayofweektoday -1; + break; + } + + if (DebugLogger) { + Print("Dayofweektoday= ", dayofweektoday); + Print("Dayofweekyesterday= ", dayofweektofind); + } + + for (int i=1; i<=25; i++) { + datetime timet= iTime(NULL, PERIOD_H1, i) - tzdiffsec; + if (TimeDayOfWeek(timet)!=dayofweektoday) { + idxfirstbaroftoday= i-1; + break; + } + } + + + if (DebugLogger) + Print("Dest time zone\'s current day starts:", TimeToStr(iTime(NULL, PERIOD_H1, idxfirstbaroftoday)), " (local time), idxbar= ", idxfirstbaroftoday); + + // search backwards for the first day of the weekday we are looking for (yesterday's last bar) + for (int j= 0; j<=48; j++) { + datetime timey= iTime(NULL, PERIOD_H1, i+j) - tzdiffsec; + if (TimeDayOfWeek(timey)==dayofweektofind) { // ignore saturdays (a Sa may happen due to TZ conversion) + idxlastbarofyesterday= i+j; + break; + } + } + + if (DebugLogger) + Print("Dest time zone\'s previous day ends:", TimeToStr(iTime(NULL, PERIOD_H1, idxlastbarofyesterday)), " (local time), idxbar= ", idxlastbarofyesterday); + + + for (j= 1; j<=24; j++) { + datetime timey2= iTime(NULL, PERIOD_H1, idxlastbarofyesterday+j) - tzdiffsec; + if (TimeDayOfWeek(timey2)!=dayofweektofind) { // ignore saturdays (a Sa may happen due to TZ conversion) + idxfirstbarofyesterday= idxlastbarofyesterday+j-1; + break; + } + } + + datetime timeyesterdayopen= iTime(NULL, PERIOD_H1, idxfirstbarofyesterday); + + if (DebugLogger) + Print("Dest time zone\'s previous day starts:", TimeToStr(timeyesterdayopen), " (local time), idxbar= ", idxfirstbarofyesterday); + + + // + // walk forward from yestday's start and collect hours within the same day and within trading hours + // + yesterday_high= -99999; // not high enough to remain alltime high + yesterday_low= +99999; // not low enough to remain alltime low + + for (j= idxfirstbarofyesterday; j>=idxlastbarofyesterday; j--) { + int idxbar= j; + datetime bartime= iTime(NULL, PERIOD_H1, idxbar) - tzdiffsec; + + if (yesterday_open==0) // grab first value for open + yesterday_open= iOpen(NULL, PERIOD_H1, idxbar); + + yesterday_high= MathMax(iHigh(NULL, PERIOD_H1, idxbar), yesterday_high); + yesterday_low= MathMin(iLow(NULL, PERIOD_H1, idxbar), yesterday_low); + + // overwrite close in loop until we leave with the last bar's value + yesterday_close= iClose(NULL, PERIOD_H1, idxbar); + } + + + if (tzdiff!=0 || TradingHoursFrom!=0 || TradingHoursTo!=24|| true) { + double level= (yesterday_high + yesterday_low + yesterday_close) / 3; + SetTimeLine("YesterdayStart", "start", idxfirstbarofyesterday, CadetBlue, level - 4*Point); + SetTimeLine("YesterdayEnd", "end", idxlastbarofyesterday-1, CadetBlue, level - 4*Point); + } + + today_open= iOpen(NULL, PERIOD_H1, idxfirstbaroftoday); // should be open of today start trading hour + startofday= iTime(NULL, PERIOD_H1, idxfirstbaroftoday); + + // Print("Ybar= ", idxlastbarofyesterday, " tbar= ", idxfirstbaroftoday, "/", TimeToStr(startofday)); + + day_high= -99999; // not high enough to remain alltime high + day_low= +99999; // not low enough to remain alltime low + for (j= idxfirstbaroftoday; j>=0; j--) { + day_high= MathMax(day_high, iHigh(NULL, PERIOD_H1, j)); + day_low= MathMin(day_low, iLow(NULL, PERIOD_H1, j)); + } + + if (DebugLogger) + Print("Timezoned values: yo= ", yesterday_open, ", yc =", yesterday_close, ", yhigh= ", yesterday_high, ", ylow= ", yesterday_low, ", to= ", today_open); + + + //---- Calculate Levels + + double P, Q, D, R1,R2,R3, S1,S2,S3; + + D = (day_high - day_low); + Q = (yesterday_high - yesterday_low); + P = (yesterday_high + yesterday_low + yesterday_close) / 3; + + R1 = (2*P)-yesterday_low; + R2 = P+(yesterday_high - yesterday_low); + R3 = (2*P)+(yesterday_high-(2*yesterday_low)); + S1 = (2*P)-yesterday_high; + S2 = P-(yesterday_high - yesterday_low); + S3 = (2*P)-((2* yesterday_high)-yesterday_low); + + // R2 = P-S1+R1; + // R1 = (2*P)-yesterday_low; + // P = (yesterday_high + yesterday_low + yesterday_close)/3; + // S1 = (2*P)-yesterday_high; + // S2 = P-R1+S1; + + + string comment= + "-- Good Luck Trading FX-50 System! ---\n" + + "Range: Yesterday "+DoubleToStr(MathRound(Q/Point),0)+" pips, Today "+DoubleToStr(MathRound(D/Point),0)+" pips" + "\n"+ + "Highs: Yesterday "+DoubleToStr(yesterday_high,Digits) +", Today "+DoubleToStr(day_high,Digits) +"\n" + + "Lows: Yesterday "+DoubleToStr(yesterday_low,Digits) +", Today "+DoubleToStr(day_low,Digits) +"\n" + + "Close: Yesterday "+DoubleToStr(yesterday_close,Digits); + + //---- Set line labels on chart window + + if (ShowYesterdayHighLow) { + SetLevel("Y\'s High", yesterday_high, Orange, startofday); + SetLevel("Y\'s Low", yesterday_low, Orange, startofday); + } + + //---- Pivot Lines + if (ShowPivots==true) { + SetLevel("R1", R1, Blue, startofday); + SetLevel("R2", R2, Blue, startofday); + SetLevel("R3", R3, Blue, startofday); + + SetLevel("Pivot", P, Magenta, startofday); + + SetLevel("S1", S1, Red, startofday); + SetLevel("S2", S2, Red, startofday); + SetLevel("S3", S3, Red, startofday); + } + + if (ShowFibos) { + // .618, .5 and .382 + SetLevel("Low - 61.8%", yesterday_low - Q*0.618, Yellow, startofday); + SetLevel("Low - 38.2%", yesterday_low - Q*0.382, Yellow, startofday); + SetLevel("Low + 38.2%", yesterday_low + Q*0.382, Yellow, startofday); + SetLevel("LowHigh 50%", yesterday_low + Q*0.5, Yellow, startofday); + SetLevel("High - 38.2%", yesterday_high - Q*0.382, Yellow, startofday); + SetLevel("High + 38.2%", yesterday_high + Q*0.382, Yellow, startofday); + SetLevel("High + 61.8%", yesterday_high + Q*0.618, Yellow, startofday); + + + + } + + + //----- Camarilla Lines + if (ShowCamarilla==true) { + + // Camarilla (http://www.moneytec.com/forums/showthread.php?t=14179&page=5) + // H4= (high-low)*1.1/2+close; H3= (high-low)*1.1/4+close; + // H2= (high-low)*1.1/6+close; H1= (high-low)*1.1/12+close + // L1= close-(high-low)*1.1/12; L2= close-(high-low)*1.1/6; + // L3= close-(high-low)*1.1/4; L4= close-(high-low)*1.1/2; + + double H4,H3,L4,L3; + H4 = (Q*0.55)+yesterday_close; + H3 = (Q*0.27)+yesterday_close; + L3 = yesterday_close-(Q*0.27); + L4 = yesterday_close-(Q*0.55); + + SetLevel("H3", H3, Yellow, startofday); + SetLevel("H4", H4, Yellow, startofday); + SetLevel("L3", L3, Yellow, startofday); + SetLevel("L4", L4, Yellow, startofday); + } + + + //------ Midpoints Pivots + if (ShowMidPitvot==true) { + // mid levels between pivots + double M0,M1,M2,M3,M4,M5; + M5 = (R2+R3)/2; + M4 = (R1+R2)/2; + M3 = (P+R1)/2; + M2 = (P+S1)/2; + M1 = (S1+S2)/2; + M0 = (S2+S3)/2; + SetLevel("MR3", M5, Green, startofday); + SetLevel("MR2", M4, Green, startofday); + SetLevel("MR1", M3, Green, startofday); + SetLevel("MS1", M2, Green, startofday); + SetLevel("MS2", M1, Green, startofday); + SetLevel("MS3", M0, Green, startofday); + } + + Comment(comment); + + return(0); +} + + +//+------------------------------------------------------------------+ +//| Helper | +//+------------------------------------------------------------------+ +void SetLevel(string text, double level, color col1, datetime startofday) +{ + string labelname= "[PIVOT] " + text + " Label"; + string linename= "[PIVOT] " + text + " Line"; + int digits= MarketInfo(Symbol(), MODE_DIGITS); + + if (ObjectFind(labelname) != 0) { + ObjectCreate(labelname, OBJ_TEXT, 0, MathMin(Time[BarForLabels], startofday), level); + } + else { + ObjectMove(labelname, 0, MathMin(Time[BarForLabels], startofday), level); + } + ObjectSetText(labelname, " " + text + ": "+DoubleToStr(level, Digits), 8, "Arial", White); + + if (ObjectFind(linename) != 0) { + ObjectCreate(linename, OBJ_TREND, 0, startofday, level, Time[0],level); + ObjectSet(linename, OBJPROP_STYLE, STYLE_DASHDOTDOT); + ObjectSet(linename, OBJPROP_COLOR, col1); + } + else { + ObjectMove(linename, 1, Time[0],level); + ObjectMove(linename, 0, startofday, level); + } +} + + +//+------------------------------------------------------------------+ +//| Helper | +//+------------------------------------------------------------------+ +void SetTimeLine(string objname, string text, int idx, color col1, double vleveltext) +{ + string name= "[PIVOT] " + objname; + int x= iTime(NULL, PERIOD_H1, idx); + + if (ObjectFind(name) != 0) + ObjectCreate(name, OBJ_TREND, 0, x, 0, x, 100); + else { + ObjectMove(name, 0, x, 0); + ObjectMove(name, 1, x, 100); + } + + ObjectSet(name, OBJPROP_STYLE, STYLE_DOT); + ObjectSet(name, OBJPROP_COLOR, DarkGray); + + if (ObjectFind(name + " Label") != 0) + ObjectCreate(name + " Label", OBJ_TEXT, 0, x, vleveltext); + else + ObjectMove(name + " Label", 0, x, vleveltext); + + ObjectSetText(name + " Label", text, 8, "Arial", col1); +} \ No newline at end of file diff --git a/RainbowMMA_01.mq4 b/RainbowMMA_01.mq4 new file mode 100644 index 0000000..ef669e5 --- /dev/null +++ b/RainbowMMA_01.mq4 @@ -0,0 +1,89 @@ +/* + +********************************************************************* + + Rainbow MMA 1 + Copyright © 2006 Akuma99 + http://www.beginnertrader.com + +********************************************************************* + +*/ + + +#property copyright "Code written by - Akuma99" + +#property indicator_chart_window +#property indicator_buffers 8 +#property indicator_color1 MediumOrchid +#property indicator_color2 MediumOrchid +#property indicator_color3 MediumOrchid +#property indicator_color4 MediumOrchid +#property indicator_color5 MediumOrchid +#property indicator_color6 MediumOrchid +#property indicator_color7 MediumOrchid +#property indicator_color8 MediumOrchid + +//---- buffers +double ExtMapBuffer1[]; +double ExtMapBuffer2[]; +double ExtMapBuffer3[]; +double ExtMapBuffer4[]; +double ExtMapBuffer5[]; +double ExtMapBuffer6[]; +double ExtMapBuffer7[]; +double ExtMapBuffer8[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators + SetIndexStyle(0,DRAW_LINE,EMPTY,1); + SetIndexBuffer(0,ExtMapBuffer1); + SetIndexStyle(1,DRAW_LINE,EMPTY,1); + SetIndexBuffer(1,ExtMapBuffer2); + SetIndexStyle(2,DRAW_LINE,EMPTY,1); + SetIndexBuffer(2,ExtMapBuffer3); + SetIndexStyle(3,DRAW_LINE,EMPTY,1); + SetIndexBuffer(3,ExtMapBuffer4); + SetIndexStyle(4,DRAW_LINE,EMPTY,1); + SetIndexBuffer(4,ExtMapBuffer5); + SetIndexStyle(5,DRAW_LINE,EMPTY,1); + SetIndexBuffer(5,ExtMapBuffer6); + SetIndexStyle(6,DRAW_LINE,EMPTY,1); + SetIndexBuffer(6,ExtMapBuffer7); + SetIndexStyle(7,DRAW_LINE,EMPTY,1); + SetIndexBuffer(7,ExtMapBuffer8); +//---- + return(0); + } + +int deinit() + { + return(0); + } + +int start() + { + int i,j,limit,counted_bars=IndicatorCounted(); + + + if(counted_bars<0) return(-1); + if(counted_bars>0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i0) counted_bars--; + limit=Bars-counted_bars; + + for(i=0; i 0.0 && EquityPercentTakeProfit < 100.05) { + Comment("EquitPercentProfit must either be 0 or greater than 100 "); + return (0); + } + if (Symbol() != "AUDNZD" && Symbol() != "AUDNZDm" && StringSubstr(Symbol(), 0, 6) != "AUDNZD") { + if (Symbol() != "EURCHF" && Symbol() != "EURCHFm" && StringSubstr(Symbol(), 0, 6) != "EURCHF") { + Comment("Expert Only Trades on the AUD/NZD or EUR/CHF"); + return (0); + } + } + if (gi_176 == TRUE) gi_1304 = FALSE; + if (gi_176 == FALSE) gi_1304 = TRUE; + if (AllowInternalClose == FALSE) StealthMode = FALSE; + if (StealthMode == TRUE) AllowInternalClose = TRUE; + gi_1380 = FALSE; + if (gi_264 != 1 && gi_264 != 2 && gi_264 != 3 && gi_264 != 9 && gi_264 < 10) gi_264 = 2; + if (gi_188 == TRUE) { + if (Symbol() == "AUDNZD" || Symbol() == "AUDNZDm" || StringSubstr(Symbol(), 0, 6) == "AUDNZD") { + if (gi_264 == 2) { + gd_308 = 1.07; + gd_308 = StartPoint() * Point + 1.065; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.065; + gi_300 = 50; + gi_1364 = 7; + gi_296 = 40; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 27; + gi_288 = 27; + } + if (gi_264 == 1) { + gd_308 = 1.045; + gd_308 = StartPoint() * Point + 1.04; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.04; + gi_300 = 50; + gi_1364 = 2; + gi_296 = 54; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 27; + gi_288 = 27; + } + if (gi_264 == 3) { + gd_308 = 1.085; + gd_308 = StartPoint() * Point + 1.08; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.08; + gi_300 = 50; + gi_1364 = 10; + gi_296 = 30; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 27; + gi_288 = 27; + } + if (gi_264 == 9) { + gd_308 = 1.04; + gd_308 = StartPoint() * Point + 1.035; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.035; + gi_300 = 50; + gi_1364 = 1; + gi_296 = 54; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 27; + gi_288 = 27; + } + if (gi_264 > 9) { + gd_308 = 1.04; + gd_308 = StartPoint() * Point + 1.035; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.035; + gi_300 = 50; + gi_1364 = 1; + gi_296 = gi_264; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = gi_296 / 2; + gi_288 = gi_296 / 2; + } + } + if (Symbol() == "EURCHF" || Symbol() == "EURCHFm" || StringSubstr(Symbol(), 0, 6) == "EURCHF") { + if (gi_264 == 2) { + gd_308 = 1.459; + gd_308 = StartPoint() * Point + 1.454; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 50; + gi_1364 = 5; + gi_296 = 42; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 26; + gi_288 = 26; + } + if (gi_264 == 1) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 50; + gi_1364 = 1; + gi_296 = 52; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 26; + gi_288 = 26; + } + if (gi_264 == 3) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 50; + gi_1364 = 1; + gi_296 = 52; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 26; + gi_288 = 26; + } + if (gi_264 == 9) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 50; + gi_1364 = 1; + gi_296 = 52; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 26; + gi_288 = 26; + } + if (gi_264 > 9) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 50; + gi_1364 = 1; + gi_296 = gi_264; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = gi_296 / 2; + gi_288 = gi_296 / 2; + } + } + } + if (gi_188 == FALSE) { + if (Symbol() == "AUDNZD" || Symbol() == "AUDNZDm" || StringSubstr(Symbol(), 0, 6) == "AUDNZD") { + if (gi_264 == 2) { + gd_308 = 1.07; + gd_308 = StartPoint() * Point + 1.065; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.065; + gi_300 = 40; + gi_1364 = 8; + gi_296 = 50; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 33; + gi_288 = 33; + } + if (gi_264 == 1) { + gd_308 = 1.042; + gd_308 = StartPoint() * Point + 1.037; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.037; + gi_300 = 40; + gi_1364 = 1; + gi_296 = 66; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 33; + gi_288 = 33; + } + if (gi_264 == 3) { + gd_308 = 1.07; + gd_308 = StartPoint() * Point + 1.065; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.065; + gi_300 = 40; + gi_1364 = 8; + gi_296 = 50; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 33; + gi_288 = 33; + } + if (gi_264 == 9) { + gd_308 = 1.042; + gd_308 = StartPoint() * Point + 1.037; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.037; + gi_300 = 40; + gi_1364 = 1; + gi_296 = 66; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 33; + gi_288 = 33; + } + if (gi_264 > 9) { + gd_308 = 1.042; + gd_308 = StartPoint() * Point + 1.037; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.037; + gi_300 = 40; + gi_1364 = 1; + gi_296 = gi_264; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = gi_296 / 2; + gi_288 = gi_296 / 2; + } + } + if (Symbol() == "EURCHF" || Symbol() == "EURCHFm" || StringSubstr(Symbol(), 0, 6) == "EURCHF") { + if (gi_264 == 2) { + gd_308 = 1.463; + gd_308 = StartPoint() * Point + 1.458; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.458; + gi_300 = 40; + gi_1364 = 7; + gi_296 = 50; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 31; + gi_288 = 31; + } + if (gi_264 == 1) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 40; + gi_1364 = 1; + gi_296 = 64; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 31; + gi_288 = 31; + } + if (gi_264 == 3) { + gd_308 = 1.463; + gd_308 = StartPoint() * Point + 1.458; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.458; + gi_300 = 40; + gi_1364 = 7; + gi_296 = 50; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 31; + gi_288 = 31; + } + if (gi_264 == 9) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 40; + gi_1364 = 1; + gi_296 = 64; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = 31; + gi_288 = 31; + } + if (gi_264 > 9) { + gd_308 = 1.439; + gd_308 = StartPoint() * Point + 1.434; + if (Digits == 5) gd_308 = 10.0 * StartPoint() * Point + 1.434; + gi_300 = 40; + gi_1364 = 1; + gi_296 = gi_264; + gi_1368 = gi_1364 + gi_296 - 1; + gi_284 = gi_296 / 2; + gi_288 = gi_296 / 2; + } + } + } + if (Digits == 5) { + gi_300 = 10 * gi_300; + gi_320 = 50; + gi_368 = 160; + } + CalculateHighsAndLows(); + gi_1228 = TRUE; + gs_584 = Symbol(); + if (gi_1228 == TRUE) g_comment_1260 = "RoboMiner II "; + if (gi_1228 == FALSE) g_comment_1260 = "RoboMiner II "; + if (gi_1228 == TRUE) g_digits_1300 = Digits; + if (gi_1228 == FALSE) g_digits_1300 = 2; + gi_unused_1220 = 0; + ArrayInitialize(gda_548, 0.0); + ArrayInitialize(gda_552, 0.0); + ArrayInitialize(gda_556, 0.0); + ArrayInitialize(gda_560, 0.0); + ArrayInitialize(gia_564, 0); + ArrayInitialize(gda_1248, 0.0); + g_count_1372 = 0; + gi_1232 = gi_1364 - 1; + while (gi_1232 < gi_1368) { + gi_1232++; + g_count_1372++; + gda_548[gi_1232] = gd_308 + (gi_300 * Point + gi_304 * Point) * (g_count_1372 - 1); + gda_552[gi_1232] = gda_548[gi_1232] + gi_300 * Point; + gda_556[gi_1232] = gda_552[gi_1232]; + gda_560[gi_1232] = gda_548[gi_1232]; + gda_548[gi_1232] += gi_316 * Point; + gda_552[gi_1232] += gi_316 * Point; + gda_556[gi_1232] += gi_316 * Point; + gda_560[gi_1232] += gi_316 * Point; + gd_1252 = gi_320 * (1.0 * Point); + gda_1248[gi_1232] = EAProfit(); + gia_564[gi_1232] = MagicNumber1 + (gi_1232 - 1); + gda_1248[gi_1232] = EAProfit(); + } + gd_920 = CalculateLots(); + SetCurrenciesAndLotSize(); + SetForwardActions(); + gi_1232 = gi_1364; + gd_872 = CalculateShadowProfit("current"); + CalculateHighAndLow(); + g_ihigh_1316 = g_ihigh_476; + g_ilow_1324 = g_ilow_468; + g_ihigh_1316 = NormalizeDouble(g_ihigh_1316, Digits); + g_ilow_1324 = NormalizeDouble(g_ilow_1324, Digits); + gd_1308 = (g_ihigh_1316 + g_ilow_1324) / 2.0; + gd_1308 = NormalizeDouble(gd_1308, Digits); + gi_1232 = gi_1364 - 1; + while (gi_1232 < gi_1368) { + gi_1232++; + if (gi_1332 >= gi_1232) gi_460 = TRUE; + if (gi_1332 < gi_1232) gi_460 = FALSE; + if (gi_1336 > gi_1232) gi_464 = FALSE; + if (gi_1336 <= gi_1232) gi_464 = TRUE; + if (gd_872 >= gda_548[gi_1232] && gd_872 <= gda_552[gi_1232]) { + gi_1236 = gi_1232; + gi_1240 = gi_460; + gi_1244 = gi_464; + } + if (gd_1308 >= gda_548[gi_1232] && gd_1308 <= gda_552[gi_1232]) gi_1340 = gi_1232; + if (g_ihigh_1316 >= gda_548[gi_1232] && g_ihigh_1316 <= gda_552[gi_1232]) gi_1344 = gi_1232; + if (g_ilow_1324 >= gda_548[gi_1232] && g_ilow_1324 <= gda_552[gi_1232]) gi_1348 = gi_1232; + gda_1248[gi_1232] = EAProfit(); + } + gi_1332 = gi_284; + gi_1336 = gi_288; + if (gi_292 == 1 && gd_872 > gd_1308) { + if (gi_284 == 0 && gi_1344 != 0) gi_1332 = gi_1344 - 1; + if (gi_288 == 0 && gi_1340 != 0) gi_1336 = gi_1340; + } + if (gi_292 == 1 && gd_872 < gd_1308) { + if (gi_288 == 0 && gi_1348 != 0) gi_1336 = gi_1348 + 1; + if (gi_284 == 0 && gi_1340 != 0) gi_1332 = gi_1340; + } + if (gi_292 == 0) { + if (gi_1332 == 0) gi_1332 = gi_1340; + if (gi_1336 == 0) gi_1336 = gi_1340; + } + if (gi_1332 == 0) gi_1332 = gi_296; + if (gi_1336 == 0) gi_1336 = 1; + gi_1232 = gi_1364 - 1; + while (gi_1232 < gi_1368) { + gi_1232++; + li_0 = search_for_conflict(gia_564[gi_1232]); + if (li_0 == 1) break; + } + if (li_0 == 1) { + Comment("\nMagic Number Conflict With Another Pair..."); + return (-1); + } + ShowComments(); + return (0); +} + +int deinit() { + return (0); +} + +int start() { + int li_0; + double ld_12; + double ld_20; + double ld_28; + if (EquityPercentTakeProfit > 0.0 && EquityPercentTakeProfit < 100.05) { + Comment("EquitPercentProfit must either be 0 or greater than 100 "); + return (0); + } + if (Symbol() != "AUDNZD" && Symbol() == "AUDNZDm" && StringSubstr(Symbol(), 0, 6) != "AUDNZD") { + if (Symbol() != "EURCHF" && Symbol() != "EURCHFm" && StringSubstr(Symbol(), 0, 6) != "EURCHF") { + Comment("Expert Only Trades on the AUD/NZD or EUR/CHF"); + return (0); + } + } + gi_1232 = gi_1364 - 1; + while (gi_1232 < gi_1368) { + gi_1232++; + li_0 = search_for_conflict(gia_564[gi_1232]); + if (li_0 == 1) break; + } + if (li_0 == 1) { + Comment("\nMagic Number Conflict With Another Pair..."); + return (-1); + } + if (EmergencyCloseAllTrades == TRUE) { + while (EAProfitAll() != 0.0) { + FindAndCloseAll(); + Sleep(5000); + } + return (0); + } + if (gi_176 == TRUE) gi_1304 = FALSE; + if (gi_176 == FALSE) gi_1304 = TRUE; + double ld_4 = MathAbs(AddLots(gs_584)); + if (gd_1396 == 0.0) gd_1396 = ld_4; + if (Send_EMail == TRUE) { + if (ld_4 > gd_1396) { + SendMail("RoboMiner II Trade Opened", "The RoboMiner II just opened a trade on the " + Symbol() + " currency pair on account " + DoubleToStr(AccountNumber(), 0) + + " at " + DoubleToStr(search_for_latest_open(), Digits) + "."); + gd_1396 = ld_4; + } + if (ld_4 < gd_1396) { + SendMail("RoboMiner II Trade Closed", "The RoboMiner II just closed a trade on the " + Symbol() + " currency pair on account " + DoubleToStr(AccountNumber(), 0) + + " at " + DoubleToStr(search_for_latest_closed(), Digits) + "."); + gd_1396 = ld_4; + } + } + CalculateHighAndLow(); + g_ihigh_1316 = g_ihigh_476; + g_ilow_1324 = g_ilow_468; + g_ihigh_1316 = NormalizeDouble(g_ihigh_1316, Digits); + g_ilow_1324 = NormalizeDouble(g_ilow_1324, Digits); + gd_1308 = (g_ihigh_1316 + g_ilow_1324) / 2.0; + gd_1308 = NormalizeDouble(gd_1308, Digits); + gi_1332 = gi_284; + gi_1336 = gi_288; + if (gi_292 == 1 && gd_872 > gd_1308) { + if (gi_284 == 0 && gi_1344 != 0) gi_1332 = gi_1344 - 1; + if (gi_288 == 0 && gi_1340 != 0) gi_1336 = gi_1340; + } + if (gi_292 == 1 && gd_872 < gd_1308) { + if (gi_288 == 0 && gi_1348 != 0) gi_1336 = gi_1348 + 1; + if (gi_284 == 0 && gi_1340 != 0) gi_1332 = gi_1340; + } + if (gi_292 == 0) { + if (gi_1332 == 0) gi_1332 = gi_1340; + if (gi_1336 == 0) gi_1336 = gi_1340; + } + if (gi_1332 == 0) gi_1332 = gi_296; + if (gi_1336 == 0) gi_1336 = 1; + SetCurrenciesAndLotSize(); + SetForwardActions(); + gi_1232 = gi_1364; + gd_920 = CalculateLots(); + gd_872 = CalculateShadowProfit("current"); + gd_880 = CalculateShadowProfit("average"); + if (gd_872 != 0.0) { + gi_1232 = gi_1364 - 1; + while (gi_1232 < gi_1368) { + gi_1232++; + if (gi_1332 >= gi_1232) gi_460 = TRUE; + if (gi_1332 < gi_1232) gi_460 = FALSE; + if (gi_1336 > gi_1232) gi_464 = FALSE; + if (gi_1336 <= gi_1232) gi_464 = TRUE; + if (gd_872 >= gda_548[gi_1232] && gd_872 <= gda_552[gi_1232]) { + gi_1236 = gi_1232; + gi_1240 = gi_460; + gi_1244 = gi_464; + } + if (gd_1308 >= gda_548[gi_1232] && gd_1308 <= gda_552[gi_1232]) gi_1340 = gi_1232; + if (g_ihigh_1316 >= gda_548[gi_1232] && g_ihigh_1316 <= gda_552[gi_1232]) gi_1344 = gi_1232; + if (g_ilow_1324 >= gda_548[gi_1232] && g_ilow_1324 <= gda_552[gi_1232]) gi_1348 = gi_1232; + gda_1248[gi_1232] = EAProfit(); + if (DoTrades == TRUE) { + scanfororders2(); + if (gi_1304 == FALSE) CloseAll(); + if (AllowForSpread == TRUE) gd_872 = CalculateShadowProfit("ask"); + if (AllowForSpread == FALSE) gd_872 = CalculateShadowProfit("current"); + if (FIFO == TRUE && EquityPercentTakeProfit > 100.0) { + ld_12 = EAProfitAll() + AccountBalance(); + if (ld_12 / AccountBalance() >= EquityPercentTakeProfit / 100.0) { + while (EAProfitAll() != 0.0) { + FindAndCloseAll(); + Sleep(5000); + } + } + } + if (FIFO == TRUE && EquityPercentTakeProfit == 0.0) { + gd_1384 = search_for_inside_price(); + ld_20 = gd_1384 + gi_300 * Point; + ld_28 = gd_1384 - gi_300 * Point; + if (search_for(gia_564[gi_1232]) == gia_564[gi_1232]) { + if (OrderType() == OP_BUY && OrderTakeProfit() != ld_20 && gi_1376 && OrderMagicNumber() != 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(ld_20, Digits), 0, CLR_NONE); + if (OrderType() == OP_SELL && OrderTakeProfit() != ld_28 && gi_1376 && OrderMagicNumber() != 0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(ld_28, Digits), 0, CLR_NONE); + } + } + if (FIFO == FALSE && StealthMode == FALSE) { + if (search_for(gia_564[gi_1232]) == gia_564[gi_1232]) { + if (OrderTakeProfit() == 0.0 && gi_1376 && OrderMagicNumber() != 0) { + if (OrderType() == OP_BUY) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(OrderOpenPrice() + gi_300 * Point, Digits), 0, CLR_NONE); + if (OrderType() == OP_SELL) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(OrderOpenPrice() - gi_300 * Point, Digits), 0, CLR_NONE); + } + } + } + if (search_for_hedge(2) == 0.0 && gi_1224 == FALSE && scanfororders() == 0 && (gi_396 == FALSE && gd_872 <= gda_548[gi_1232]) || (gi_396 == TRUE && (gi_324 != 0 && + gd_872 > gd_880) || gi_324 == 0 && gd_872 <= gda_548[gi_1232] && gd_872 >= gda_548[gi_1232] - gd_1252) && gi_1304 == TRUE && gi_460 == TRUE) { + gd_372 = gd_872; + SetForwardActions(); + OpenAll(); + gi_unused_1032 = 1; + gd_872 = CalculateShadowProfit("current"); + gi_1180 = FALSE; + } + gd_872 = CalculateShadowProfit("current"); + if (FIFO == FALSE && AllowInternalClose == TRUE && gi_1180 == FALSE && gd_872 >= gda_552[gi_1232] && scanfororders() > 0) { + gd_372 = gd_872; + CloseAll(); + gi_1224 = FALSE; + } + gd_872 = CalculateShadowProfit("current"); + if (search_for_hedge(1) == 0.0 && gi_1224 == FALSE && gi_464 == TRUE && scanfororders() == 0 && (gi_396 == FALSE && gd_872 >= gda_556[gi_1232]) || (gi_396 == TRUE && + (gi_324 != 0 && gd_872 < gd_880) || gi_324 == 0 && gd_872 <= gda_556[gi_1232] + gd_1252 && gd_872 >= gda_556[gi_1232]) && gi_1304 == TRUE) { + gd_372 = gd_872; + SetReverseActions(); + gi_1180 = TRUE; + OpenAll(); + gi_unused_1032 = 1; + SetForwardActions(); + gd_872 = CalculateShadowProfit("current"); + } + if (AllowForSpread == TRUE) gd_872 = CalculateShadowProfit("ask"); + if (AllowForSpread == FALSE) gd_872 = CalculateShadowProfit("current"); + if (FIFO == FALSE && AllowInternalClose == TRUE && gi_1180 == TRUE && gd_872 <= gda_560[gi_1232] && scanfororders() > 0) { + gd_372 = gd_872; + CloseAll(); + gi_1224 = FALSE; + } + gd_872 = CalculateShadowProfit("current"); + } + } + } + scanfororders2(); + CalculateHighsAndLows(); + ShowComments(); + return (0); +} + +int ShowComments() { + SetCurrenciesAndLotSize(); + SetForwardActions(); + string ls_unused_0 = ""; + if (gi_580 == 60) ls_unused_0 = "Hourly"; + if (gi_580 == 240) ls_unused_0 = "4 Hour"; + if (gi_580 == 1440) ls_unused_0 = "Daily"; + if (gi_580 == 30) ls_unused_0 = "30 Minute"; + if (gi_580 == 15) ls_unused_0 = "15 Minute"; + if (gi_580 == 1) ls_unused_0 = "1 Minute"; + if (gi_580 == 5) ls_unused_0 = "5 Minute"; + double ld_8 = gd_532 / 100.0; + double ld_16 = gd_616 - gd_624; + double ld_24 = ld_16 * ld_8; + double ld_32 = gd_632 - gd_640; + double ld_40 = ld_32 * ld_8; + int li_48 = gi_1236; + if (DisplayLevel != 0) gi_1236 = DisplayLevel; + if (gi_1332 >= gi_1236) gi_460 = TRUE; + if (gi_1332 < gi_1236) gi_460 = FALSE; + if (gi_1336 > gi_1236) gi_464 = FALSE; + if (gi_1336 <= gi_1236) gi_464 = TRUE; + gi_1240 = gi_460; + gi_1244 = gi_464; + string ls_52 = "True"; + if (DoTrades == FALSE) ls_52 = "False"; + string ls_60 = "True"; + if (gi_1240 == FALSE) ls_60 = "False"; + string ls_68 = "True"; + if (gi_1244 == FALSE) ls_68 = "False"; + string ls_unused_76 = "False"; + if (gi_176 == TRUE) ls_unused_76 = "True"; + double ld_84 = gd_308 + gi_296 * gi_300 * Point; + if (gi_1236 > gi_1332) { + if (gi_1360 == FALSE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nShort Open for Range " + gi_1236 + " = " + DoubleToStr(gda_556[gi_1236], Digits) + + "\nShort Close for Range " + gi_1236 + " = " + DoubleToStr(gda_560[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\n\nDoTrades = " + ls_52 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ") "); + } + if (gi_1360 == TRUE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nShort Open for Range " + gi_1236 + " = " + DoubleToStr(gda_556[gi_1236], Digits) + + "\nShort Close for Range " + gi_1236 + " = " + DoubleToStr(gda_560[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\n\nDoTrades = " + ls_52 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ")" + + "\n\n**WARNING -- Account Balance may be too low to safely trade at this setting level ***"); + } + } + if (gi_1236 < gi_1332) { + if (gi_1360 == FALSE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nLong Open for Range " + gi_1236 + " = " + DoubleToStr(gda_548[gi_1236], Digits) + + "\nLong Close for Range " + gi_1236 + " = " + DoubleToStr(gda_552[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\n\nDoTrades = " + ls_52 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ") "); + } + if (gi_1360 == TRUE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nLong Open for Range " + gi_1236 + " = " + DoubleToStr(gda_548[gi_1236], Digits) + + "\nLong Close for Range " + gi_1236 + " = " + DoubleToStr(gda_552[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\n\nDoTrades = " + ls_52 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ")" + + "\n\n**WARNING -- Account Balance may be too low to safely trade at this setting level ***"); + } + } + if (gi_1236 == gi_1332) { + if (gi_1360 == FALSE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nLong Open for Range " + gi_1236 + " = " + DoubleToStr(gda_548[gi_1236], Digits) + + "\nLong Close for Range " + gi_1236 + " = " + DoubleToStr(gda_552[gi_1236], Digits) + + "\nShort Open for Range " + gi_1236 + " = " + DoubleToStr(gda_556[gi_1236], Digits) + + "\nShort Close for Range " + gi_1236 + " = " + DoubleToStr(gda_560[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ") "); + } + if (gi_1360 == TRUE && gi_1228 == TRUE) { + Comment("\n" + + gs_76 + + "\n" + + gs_100 + + "\n\nCurrent Bid Price= " + DoubleToStr(gd_872, Digits) + + "\nCurrent Range = " + gi_1236 + + "\n\nLong Open for Range " + gi_1236 + " = " + DoubleToStr(gda_548[gi_1236], Digits) + + "\nLong Close for Range " + gi_1236 + " = " + DoubleToStr(gda_552[gi_1236], Digits) + + "\nShort Open for Range " + gi_1236 + " = " + DoubleToStr(gda_556[gi_1236], Digits) + + "\nShort Close for Range " + gi_1236 + " = " + DoubleToStr(gda_560[gi_1236], Digits) + + "\n\nRangeStart = " + DoubleToStr(gd_308, Digits) + + "\nRangeEnd = " + DoubleToStr(ld_84, Digits) + + "\nFirst Range = " + gi_1364 + + "\nLast Range = " + gi_1368 + + "\nBalanceFactor = " + DoubleToStr(BalanceFactor, 2) + + "\nRanges Setting = " + gi_264 + + "\nTradeRange = " + gi_300 + + "\nTradeWindow = " + DoubleToStr(gd_1252, Digits) + + "\n\nPrice " + gi_272 + " Month High = " + DoubleToStr(g_ihigh_1316, Digits) + " (" + gi_1344 + ") " + + "\nPrice " + gi_272 + " Month Low = " + DoubleToStr(g_ilow_1324, Digits) + " (" + gi_1348 + ") " + + "\nPrice " + gi_272 + " Month Mid-Range = " + DoubleToStr(gd_1308, Digits) + " (" + gi_1340 + ") " + + "\n\nProfit for this Instance of EA = " + DoubleToStr(gda_1248[gi_1236], 2) + + "\nProfit for this Currency Pair = " + DoubleToStr(EAProfitAll(), 2) + " (" + DoubleToStr(100.0 * ((AccountBalance() + EAProfitAll()) / AccountBalance()), 2) + " % )" + + "\n\nLots1 = " + DoubleToStr(gd_920, gi_364) + " " + gs_584 + " " + gia_564[gi_1236] + " Net Total Lots = " + DoubleToStr(AddLots(gs_584), 2) + + "\nLotSize = " + DoubleToStr(MarketInfo(Symbol(), MODE_LOTSIZE), 0) + + "\nAccount Leverage = " + AccountLeverage() + " : 1" + + "\nDecimals = " + gi_364 + + "\nOpen Long Trades = " + ls_60 + " (" + gi_1332 + ") " + + "\nOpen Short Trades = " + ls_68 + " (" + gi_1336 + ")" + + "\n\n**WARNING -- Account Balance may be too low to safely trade at this setting level ***"); + } + } + gi_1236 = li_48; + return (0); +} + +double EAProfit() { + double ld_ret_0 = 0.0; + if (search_for(gia_564[gi_1232]) != 0) ld_ret_0 += OrderProfit(); + return (ld_ret_0); +} + +double EAProfitAll() { + double ld_ret_0 = 0.0; + gi_1016 = OrdersTotal(); + for (int l_pos_8 = 0; l_pos_8 <= gi_1016 - 1; l_pos_8++) { + if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_8, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderMagicNumber() < MagicNumber1 || OrderMagicNumber() > MagicNumber1 + 100) continue; + if (OrderCloseTime() == 0) { + if (OrderTakeProfit() != 0.0 && (FIFO == TRUE && EquityPercentTakeProfit > 100.0) || (StealthMode == TRUE && FIFO == FALSE)) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0.0, 0, CLR_NONE); + ld_ret_0 += OrderProfit(); + } + } + } + } + return (ld_ret_0); +} + +int search_for(int a_magic_0) { + gi_1016 = OrdersTotal(); + for (int l_pos_4 = gi_1016 - 1; l_pos_4 >= 0; l_pos_4--) { + if (!OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_4, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderMagicNumber() == a_magic_0) + if (OrderCloseTime() == 0) return (a_magic_0); + } + } + return (0); +} + +int search_for_conflict(int a_magic_0) { + bool li_4 = FALSE; + gi_1016 = OrdersTotal(); + for (int l_pos_8 = gi_1016 - 1; l_pos_8 >= 0; l_pos_8--) { + if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_8, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderMagicNumber() == a_magic_0) { + if (OrderCloseTime() == 0) { + if (OrderSymbol() != Symbol()) { + if (OrderSymbol() != Symbol()) li_4 = TRUE; + if (li_4 == TRUE) return (1); + } + } + } + } + } + return (0); +} + +int FindAndCloseAll() { + gi_1016 = OrdersTotal(); + for (int l_pos_0 = gi_1016 - 1; l_pos_0 >= 0; l_pos_0--) { + if (!OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_0, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderMagicNumber() < MagicNumber1 || OrderMagicNumber() > MagicNumber1 + 100) continue; + if (OrderCloseTime() == 0) { + Close_it(); + Sleep(1000); + } + } + } + } + return (0); +} + +double AddLots(string a_symbol_0) { + double ld_ret_8 = 0.0; + gi_1016 = OrdersTotal(); + for (int l_pos_16 = gi_1016 - 1; l_pos_16 >= 0; l_pos_16--) { + if (!OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_16, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == a_symbol_0) { + if (OrderCloseTime() == 0) { + if (OrderType() == OP_BUY) ld_ret_8 += OrderLots(); + if (OrderType() == OP_SELL) ld_ret_8 -= OrderLots(); + } + } + } + } + return (ld_ret_8); +} + +int open_buy_market(int a_magic_0, double a_lots_4, string a_symbol_12) { + int l_slippage_20 = gi_368; + int l_count_24 = 0; + int l_ticket_28 = -1; + double l_price_32 = 0.0; + if (gi_1376 == TRUE && gi_1228 == TRUE) { + l_price_32 = gda_548[gi_1232] + gi_300 * MarketInfo(a_symbol_12, MODE_POINT); + l_price_32 = NormalizeDouble(l_price_32, MarketInfo(a_symbol_12, MODE_DIGITS)); + } + l_price_32 = 0.0; + string l_comment_40 = g_comment_1260; + g_comment_1260 = g_comment_1260 + DoubleToStr(gd_872, g_digits_1300) + " " + DoubleToStr(a_magic_0, 0); + while (l_ticket_28 == -1 && l_count_24 <= gi_1024) { + if (gi_368 != 0 && gi_1228 == TRUE && Ask - gd_372 < gi_368 * Point) l_ticket_28 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, l_slippage_20, 0.0, l_price_32, g_comment_1260, a_magic_0, 0, CLR_NONE); + if (gi_368 == 0 || gi_1228 == FALSE) l_ticket_28 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, l_slippage_20, 0.0, 0.0, g_comment_1260, a_magic_0, 0, CLR_NONE); + l_count_24++; + if (l_ticket_28 >= 0) break; + if (l_count_24 > gi_1024) break; + Sleep(10000); + } + if (l_ticket_28 != 0) { + g_error_1020 = GetLastError(); + if (gi_276 == TRUE) Alert("Error OrderSend # ", g_error_1020); + } + g_comment_1260 = l_comment_40; + return (0); +} + +int open_sell_market(int a_magic_0, double a_lots_4, string a_symbol_12) { + int l_slippage_20 = gi_368; + int l_count_24 = 0; + int l_ticket_28 = -1; + double l_price_32 = 0.0; + if (gi_1376 == TRUE && gi_1228 == TRUE) { + l_price_32 = gda_556[gi_1232] - gi_300 * MarketInfo(a_symbol_12, MODE_POINT); + l_price_32 = NormalizeDouble(l_price_32, MarketInfo(a_symbol_12, MODE_DIGITS)); + } + l_price_32 = 0.0; + string l_comment_40 = g_comment_1260; + g_comment_1260 = g_comment_1260 + DoubleToStr(gd_872, g_digits_1300) + " " + DoubleToStr(a_magic_0, 0); + while (l_ticket_28 == -1 && l_count_24 <= gi_1024) { + if (gi_368 != 0 && gi_1228 == TRUE && gd_372 - Bid < gi_368 * Point) l_ticket_28 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, l_slippage_20, 0.0, l_price_32, g_comment_1260, a_magic_0, 0, CLR_NONE); + if (gi_368 == 0 || gi_1228 == FALSE) l_ticket_28 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, l_slippage_20, 0.0, 0.0, g_comment_1260, a_magic_0, 0, CLR_NONE); + l_count_24++; + if (l_ticket_28 >= 0) break; + if (l_count_24 > gi_1024) break; + Sleep(10000); + } + if (l_ticket_28 != 0) { + g_error_1020 = GetLastError(); + if (gi_276 == TRUE) Alert("Error OrderSend # ", g_error_1020); + } + g_comment_1260 = l_comment_40; + return (0); +} + +int Close_it() { + if (FIFO == FALSE && gi_280 == TRUE && OrderTakeProfit() != 0.0 && OrderProfit() + OrderSwap() < 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), 0.0, OrderExpiration(), CLR_NONE); + if ((FIFO == FALSE && gi_280 == TRUE && OrderProfit() + OrderSwap() > 0.0) || gi_280 == FALSE || FIFO == TRUE) { + if (OrderType() == OP_BUY) { + if (FIFO == FALSE && gi_368 != 0 && gi_1228 == TRUE && gd_372 - Bid < gi_368 * Point) close_buy(); + if (FIFO == TRUE || gi_368 == 0 || gi_1228 == FALSE) close_buy(); + } + if (OrderType() == OP_SELL) { + if (FIFO == FALSE && gi_368 != 0 && gi_1228 == TRUE && Ask - gd_372 < gi_368 * Point) close_sell(); + if (FIFO == TRUE || gi_368 == 0 || gi_1228 == FALSE) close_sell(); + } + } + return (0); +} + +int OpenAll() { + if (gs_1140 == "Sell") open_sell_market(gia_564[gi_1232], gd_920, gs_584); + if (gs_1140 == "Buy") open_buy_market(gia_564[gi_1232], gd_920, gs_584); + return (0); +} + +int CloseAll() { + int l_count_0 = 0; + while (l_count_0 < 4) { + l_count_0++; + if (search_for(gia_564[gi_1232]) != 0) Close_it(); + } + return (0); +} + +int scanfororders() { + int l_count_0 = 0; + int li_4 = search_for(gia_564[gi_1232]); + if (li_4 == gia_564[gi_1232]) l_count_0++; + return (l_count_0); +} + +int scanfororders2() { + bool li_ret_0 = FALSE; + int li_4 = search_for(gia_564[gi_1232]); + if (li_4 == gia_564[gi_1232]) { + if (gs_1140 == "Sell" && OrderType() == OP_SELL) gi_1180 = FALSE; + if (gs_1140 == "Buy" && OrderType() == OP_BUY) gi_1180 = FALSE; + if (gs_1140 == "Buy" && OrderType() == OP_SELL) gi_1180 = TRUE; + if (gs_1140 == "Sell" && OrderType() == OP_BUY) gi_1180 = TRUE; + } + return (li_ret_0); +} + +int close_buy() { + int l_slippage_0 = gi_368; + g_count_1028 = 0; + bool l_ord_close_4 = FALSE; + while (!l_ord_close_4 && g_count_1028 <= 0) { + if (FIFO == FALSE && gi_368 != 0 && gi_1228 == TRUE && gd_372 - Bid < gi_368 * Point) l_ord_close_4 = OrderClose(OrderTicket(), OrderLots(), Bid, l_slippage_0, CLR_NONE); + if (FIFO == TRUE || gi_368 == 0 || gi_1228 == FALSE) l_ord_close_4 = OrderClose(OrderTicket(), OrderLots(), Bid, l_slippage_0, CLR_NONE); + g_count_1028++; + if (l_ord_close_4) break; + if (g_count_1028 > 0) break; + Sleep(10000); + } + if (l_ord_close_4 == 0) { + g_error_1020 = GetLastError(); + if (gi_276 == TRUE) Alert("Error OrderClose # ", g_error_1020); + return (-1); + } + return (0); +} + +int close_sell() { + int l_slippage_0 = gi_368; + g_count_1028 = 0; + bool l_ord_close_4 = FALSE; + while (!l_ord_close_4 && g_count_1028 <= 0) { + if (FIFO == FALSE && gi_368 != 0 && gi_1228 == TRUE && Ask - gd_372 < gi_368 * Point) l_ord_close_4 = OrderClose(OrderTicket(), OrderLots(), Ask, l_slippage_0, CLR_NONE); + if (FIFO == TRUE || gi_368 == 0 || gi_1228 == FALSE) l_ord_close_4 = OrderClose(OrderTicket(), OrderLots(), Ask, l_slippage_0, CLR_NONE); + g_count_1028++; + if (l_ord_close_4) break; + if (g_count_1028 > 0) break; + Sleep(10000); + } + if (l_ord_close_4 == 0) { + g_error_1020 = GetLastError(); + if (gi_276 == TRUE) Alert("?????? OrderClose No ", g_error_1020); + return (-1); + } + return (0); +} + +double CalculateLots() { + double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT); + double l_maxlot_8 = MarketInfo(Symbol(), MODE_MAXLOT); + double ld_ret_16 = 0.0; + bool li_24 = FALSE; + double l_lotsize_28 = MarketInfo(Symbol(), MODE_LOTSIZE); + if (MarketInfo(Symbol(), MODE_MINLOT) < 1.0) gi_364 = 1; + if (MarketInfo(Symbol(), MODE_MINLOT) < 0.1) gi_364 = 2; + if (MarketInfo(Symbol(), MODE_MINLOT) < 0.01) gi_364 = 3; + if (MarketInfo(Symbol(), MODE_MINLOT) < 0.001) gi_364 = 4; + if (MarketInfo(Symbol(), MODE_MINLOT) < 0.0001) gi_364 = 5; + if (Lots > 0.0) ld_ret_16 = Lots; + if (ld_ret_16 > 0.0) { + if (ld_ret_16 < l_minlot_0) ld_ret_16 = l_minlot_0; + if (ld_ret_16 > l_maxlot_8) ld_ret_16 = l_maxlot_8; + ld_ret_16 = NormalizeDouble(ld_ret_16, gi_364); + return (ld_ret_16); + } + double ld_36 = AccountBalance(); + double ld_44 = BalanceFactor; + if (ld_44 == 0.0) { + if (AccountBalance() < 12000.0) ld_44 = 4000.0; + if (AccountBalance() >= 12000.0 && AccountBalance() < 22500.0) ld_44 = 5000.0; + if (AccountBalance() >= 22500.0 && AccountBalance() < 35000.0) ld_44 = 5500.0; + if (AccountBalance() >= 35000.0 && AccountBalance() < 60000.0) ld_44 = 6000.0; + if (AccountBalance() >= 60000.0 && AccountBalance() < 100000.0) ld_44 = 7000.0; + if (AccountBalance() >= 100000.0) ld_44 = 8000.0; + } + ld_44 /= 100000 / l_lotsize_28; + gi_1360 = FALSE; + if (ld_36 < ld_44) gi_1360 = TRUE; + li_24 = ld_36 / ld_44; + ld_ret_16 = li_24 / 100.0; + ld_ret_16 = NormalizeDouble(ld_ret_16, gi_364); + if (ld_ret_16 < l_minlot_0) ld_ret_16 = l_minlot_0; + if (ld_ret_16 > l_maxlot_8) ld_ret_16 = l_maxlot_8; + ld_ret_16 = NormalizeDouble(ld_ret_16, gi_364); + if (gi_1380 == FALSE && ld_ret_16 > 0.09 && ld_36 < 10000.0 && l_lotsize_28 == 100000.0) { + Alert("Is your account set to trade only 1 decimal place for lots? Your account balance should be higher for this lot size!"); + gi_1380 = TRUE; + } + if (gi_1380 == FALSE && ld_ret_16 > 0.09 && ld_36 < 1000.0 && l_lotsize_28 == 10000.0) { + Alert("Is your account set to trade only 1 decimal place for lots? Your account balance should be higher for this lot size!"); + gi_1380 = TRUE; + } + if (gi_1380 == FALSE && gi_364 == 1) { + Alert("Is your account set to trade only 1 decimal place for lots? We recommend 2 decimal places for lot sizes if possible!"); + gi_1380 = TRUE; + } + return (ld_ret_16); +} + +void CalculateHighAndLow() { + g_ihigh_476 = iHigh(Symbol(), PERIOD_MN1, iHighest(Symbol(), PERIOD_MN1, MODE_HIGH, gi_272, 0)); + g_ilow_468 = iLow(Symbol(), PERIOD_MN1, iLowest(Symbol(), PERIOD_MN1, MODE_LOW, gi_272, 0)); + gd_1404 = (g_ihigh_476 + g_ilow_468) / 2.0; + gd_1404 = NormalizeDouble(gd_1404, Digits); +} + +int SetForwardActions() { + gs_1140 = "Buy"; + return (0); +} + +int SetReverseActions() { + gs_1140 = "Sell"; + return (0); +} + +int CalculateHighsAndLows() { + gd_872 = CalculateShadowProfit("current"); + if (Minute() > 10) gi_1188 = FALSE; + if (Minute() < 10 && gi_1188 == FALSE) { + gd_632 = -10000000.0; + gd_640 = 10000000.0; + gi_1188 = TRUE; + } + if (gd_616 < gd_872) gd_616 = gd_872; + if (gd_632 < gd_872) gd_632 = gd_872; + if (gd_624 > gd_872) gd_624 = gd_872; + if (gd_640 > gd_872) gd_640 = gd_872; + if (gd_640 == 0.0) gd_640 = gd_872; + if (gd_648 < AccountEquity()) gd_648 = AccountEquity(); + if (gd_656 > AccountEquity()) gd_656 = AccountEquity(); + if (g_free_magrin_672 < AccountFreeMargin()) g_free_magrin_672 = AccountFreeMargin(); + if (g_free_magrin_664 > AccountFreeMargin()) g_free_magrin_664 = AccountFreeMargin(); + if (gd_680 < AccountBalance()) gd_680 = AccountBalance(); + if (gd_688 > AccountBalance()) gd_688 = AccountBalance(); + return (0); +} + +int SetCurrenciesAndLotSize() { + gs_584 = Symbol(); + g_lotsize_1052 = MarketInfo(Symbol(), MODE_LOTSIZE); + if (g_lotsize_1052 == 0.0) g_lotsize_1052 = MarketInfo(Symbol(), MODE_LOTSIZE); + if (g_lotsize_1052 == 100000.0) gd_unused_1060 = 0.1; + if (g_lotsize_1052 == 10000.0) gd_unused_1060 = 0.01; + SetForwardActions(); + if (StringLen(StringTrimLeft(gs_1140)) < 2) gs_584 = " "; + if (StringLen(StringTrimLeft(gs_584)) < 2) gs_1140 = " "; + return (0); +} + +double CalculateShadowProfit(string as_0) { + if ((gi_1228 == TRUE && as_0 == "current") || (gi_1228 == TRUE && as_0 == "ask" && AllowForSpread == FALSE)) g_price_856 = Bid; + if (gi_1228 == TRUE && as_0 == "ask" && AllowForSpread == TRUE) g_price_856 = Ask; + if (gi_1228 == TRUE && as_0 == "average") g_price_856 = gma(gs_584); + return (g_price_856); +} + +double gma(string a_symbol_0) { + double l_ima_8 = 0.0; + int l_period_16 = gi_324; + if (l_period_16 == 0) l_period_16 = 36; + int li_20 = 0; + int l_timeframe_24 = 60; + l_ima_8 = iMA(a_symbol_0, l_timeframe_24, l_period_16, li_20, MODE_SMA, PRICE_TYPICAL, 0); + return (l_ima_8); +} + +double StartPoint() { + double l_acc_number_0 = AccountNumber(); + string l_dbl2str_8 = DoubleToStr(l_acc_number_0, 0); + int l_str2int_16 = StrToInteger(StringSubstr(l_dbl2str_8, StringLen(l_dbl2str_8) - 2, 2)); + return (l_str2int_16); +} + +double search_for_inside_price() { + double l_ord_open_price_0 = 0.0; + gi_1016 = OrdersTotal(); + for (int l_pos_8 = gi_1016 - 1; l_pos_8 >= 0; l_pos_8--) { + if (!OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_8, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderMagicNumber() < MagicNumber1 || OrderMagicNumber() > MagicNumber1 + 100) continue; + if (OrderCloseTime() == 0) { + if (OrderType() == OP_SELL && l_ord_open_price_0 == 0.0) l_ord_open_price_0 = 999999.9999000001; + if (OrderType() == OP_BUY && OrderOpenPrice() <= l_ord_open_price_0) continue; + if (OrderType() == OP_SELL && OrderOpenPrice() >= l_ord_open_price_0) continue; + l_ord_open_price_0 = OrderOpenPrice(); + } + } + } + } + return (l_ord_open_price_0); +} + +double search_for_hedge(int ai_0) { + double l_ord_lots_4 = 0.0; + gi_1016 = OrdersTotal(); + for (int l_pos_12 = gi_1016 - 1; l_pos_12 >= 0; l_pos_12--) { + if (!OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_12, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderCloseTime() == 0) { + if (ai_0 == 1 && OrderType() == OP_SELL) continue; + if (ai_0 == 2 && OrderType() == OP_BUY) continue; + if (OrderLots() > l_ord_lots_4) l_ord_lots_4 = OrderLots(); + } + } + } + } + return (l_ord_lots_4); +} + +double search_for_latest_closed() { + gi_1016 = OrdersHistoryTotal(); + int l_datetime_0 = 0; + bool li_4 = FALSE; + int l_ticket_8 = 0; + int li_unused_12 = 0; + for (int l_pos_16 = gi_1016 - 1; l_pos_16 >= 0; l_pos_16--) { + if (!OrderSelect(l_pos_16, SELECT_BY_POS, MODE_HISTORY)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_16, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderCloseTime() != 0) { + if (OrderCloseTime() > l_datetime_0) { + l_datetime_0 = OrderCloseTime(); + l_ticket_8 = OrderTicket(); + li_4 = TRUE; + } + } + } + } + } + if (li_4 == TRUE) { + for (l_pos_16 = gi_1016 - 1; l_pos_16 >= 0; l_pos_16--) { + if (!OrderSelect(l_pos_16, SELECT_BY_POS, MODE_HISTORY)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_16, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) + if (OrderTicket() == l_ticket_8) return (OrderClosePrice()); + } + } + } + return (0.0); +} + +double search_for_latest_open() { + gi_1016 = OrdersTotal(); + int l_datetime_0 = 0; + bool li_4 = FALSE; + int l_ticket_8 = 0; + int li_unused_12 = 0; + for (int l_pos_16 = gi_1016 - 1; l_pos_16 >= 0; l_pos_16--) { + if (!OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_16, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) { + if (OrderCloseTime() == 0) { + if (OrderOpenTime() > l_datetime_0) { + l_datetime_0 = OrderOpenTime(); + l_ticket_8 = OrderTicket(); + li_4 = TRUE; + } + } + } + } + } + if (li_4 == TRUE) { + for (l_pos_16 = gi_1016 - 1; l_pos_16 >= 0; l_pos_16--) { + if (!OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { + g_error_1020 = GetLastError(); + Print("OrderSelect( ", l_pos_16, ", SELECT_BY_POS ) - Error #", g_error_1020); + } else { + if (OrderSymbol() == Symbol()) + if (OrderTicket() == l_ticket_8) return (OrderOpenPrice()); + } + } + } + return (0.0); +} + diff --git a/SAR ADX Expert Advisor.mq4 b/SAR ADX Expert Advisor.mq4 new file mode 100644 index 0000000..442a876 --- /dev/null +++ b/SAR ADX Expert Advisor.mq4 @@ -0,0 +1,471 @@ +//+------------------------------------------------------------------+ +//| SAR ADX Expert Advisor.mq4 | +//| Copyright © 2009, TradingSytemForex | +//| http://www.tradingsystemforex.com | +//+------------------------------------------------------------------+ + +#property copyright "Copyright © 2009, TradingSytemForex" +#property link "http://www.tradingsystemforex.com" + +//|----------------------------------------------you can modify this expert +//|----------------------------------------------you can change the name +//|----------------------------------------------you can add "modified by you" +//|----------------------------------------------but you are not allowed to erase the copyrights + +#define EAName "SAR ADX Expert Advisor" + +extern string S1="---------------- Entry Settings"; + +extern double Step=0.02; +extern double Maximum=0.2; +extern int ADXPeriod=50; + +extern string S2="---------------- Money Management"; + +extern double Lots=0.1;//|-----------------------lots size +extern bool RiskMM=false;//|---------------------risk management +extern double RiskPercent=1;//|------------------risk percentage + +/* +extern bool Martingale=false;//|-----------------martingale +extern double Multiplier=2.0;//|-----------------multiplier martingale +extern double MinProfit=50;//--------------------minimum profit to apply the martingale +extern bool BasketProfitLoss=false;//|-----------use basket loss/profit +extern int BasketProfit=100000;//|---------------if equity reaches this level, close trades +extern int BasketLoss=9999;//|-------------------if equity reaches this negative level, close trades +*/ + +extern string S3="---------------- Order Management"; + +extern int StopLoss=0;//|------------------------stop loss +extern int TakeProfit=0;//|----------------------take profit +extern bool HideSL=false;//|---------------------hide stop loss +extern bool HideTP=false;//|---------------------hide take profit +extern int TrailingStop=0;//|--------------------trailing stop +extern int TrailingStep=0;//|--------------------trailing step +extern int BreakEven=0;//|-----------------------break even +extern int MaxOrders=100;//|---------------------maximum orders allowed +extern int Slippage=3;//|------------------------slippage +extern int Magic=2009;//|------------------------magic number + +/* +extern string S4="---------------- MA Filter"; + +extern bool MAFilter=false;//|-------------------moving average filter +extern int MAPeriod=20;//|-----------------------ma filter period +extern int MAMethod=0;//|------------------------ma filter method +extern int MAPrice=0;//|-------------------------ma filter price +*/ + +/* +extern string S5="---------------- Time Filter"; + +extern bool TradeOnSunday=true;//|---------------time filter on sunday +extern bool MondayToThursdayTimeFilter=false;//|-time filter the week +extern int MondayToThursdayStartHour=0;//|-------start hour time filter the week +extern int MondayToThursdayEndHour=24;//|--------end hour time filter the week +extern bool FridayTimeFilter=false;//|-----------time filter on friday +extern int FridayStartHour=0;//|-----------------start hour time filter on friday +extern int FridayEndHour=21;//|------------------end hour time filter on friday +*/ + +extern string S6="---------------- Extras"; + +extern bool Hedge=false;//|----------------------enter an opposite trade +extern int HedgeSL=0;//|-------------------------stop loss +extern int HedgeTP=0;//|-------------------------take profit +extern bool ReverseSystem=false;//|--------------buy instead of sell, sell instead of buy + +/* +extern bool ReverseAtStop=false;//|--------------buy instead of sell, sell instead of buy +extern int Expiration=240;//|--------------------expiration in minute for the reverse pending order +extern bool Comments=true;//|--------------------allow comments on chart +*/ + +datetime PreviousBarTime1; +datetime PreviousBarTime2; + +double maxEquity,minEquity,Balance=0.0; + +//|---------initialization + +int init() +{ + /*if(Comments)Comment("\nLoading...");*/ + return(0); +} + +//|---------deinitialization + +/*int deinit() +{ + return(0); +}*/ + +int start() +{ + +//|---------trailing stop + + if(TrailingStop>0)MoveTrailingStop(); + +//|---------break even + + if(BreakEven>0)MoveBreakEven(); + +/* +//|---------basket profit loss + + if(BasketProfitLoss) + { + double CurrentProfit=0,CurrentBasket=0; + CurrentBasket=AccountEquity()-AccountBalance(); + if(CurrentBasket>maxEquity)maxEquity=CurrentBasket; + if(CurrentBasket=BasketProfit||CurrentBasket<=(BasketLoss*(-1))) + { + CloseBuyOrders(Magic); + CloseSellOrders(Magic); + return(0); + } + } +*/ + +/* +//|---------time filter + + if((TradeOnSunday==false&&DayOfWeek()==0)||(MondayToThursdayTimeFilter&&DayOfWeek()>=1&&DayOfWeek()<=4&&!(Hour()>=MondayToThursdayStartHour&&Hour()<=MondayToThursdayEndHour))||(FridayTimeFilter&&DayOfWeek()==5&&!(Hour()>=FridayStartHour&&Hour()<=FridayEndHour))) + { + CloseBuyOrders(Magic); + CloseSellOrders(Magic); + return(0); + } +*/ + +//|---------signal conditions + + int limit=1; + for(int i=1;i<=limit;i++) + { + +/* + //|---------moving average filter + + double MAF=iMA(Symbol(),0,MAPeriod,0,MAMethod,MAPrice,i); + + string MABUY="false";string MASELL="false"; + + if((MAFilter==false)||(MAFilter&&Bid>MAF))MABUY="true"; + if((MAFilter==false)||(MAFilter&&AskSAR2&&ADXP2>ADXM2)|| + (Close[i]>SAR2&&ADXP1ADXM2))BUY="true"; + if( + (Close[i+1]>SAR1&&Close[i]ADXM1&&ADXP20)Expire=TimeCurrent()+(Expiration*60)-5;*/ + + if(OrdersTotal()0){SL=Ask-StopLoss*Point;/*OPP=Bid-StopLoss*Point;SLP=Bid;*/}else {SL=0;} + if(SL>0&&SL>(Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)){SL=Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;} + if(HideTP==false&&TakeProfit>0){TP=Ask+TakeProfit*Point;/*TPP=Bid-(TakeProfit*2)*Point;*/}else {TP=0;/*TPP=0;*/} + + Ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,EAName,Magic,0,Blue); + if(Hedge)TicketH=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,TP,SL,EAName,Magic,0,Red); + /*if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_SELLSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);*/ + } + if (SignalSELL=="true"&&NewBarSell()) + { + if(HideSL==false&&StopLoss>0){SL=Bid+StopLoss*Point;/*OPP=Ask+StopLoss*Point;SLP=Ask;*/}else {SL=0;} + if(SL>0&&SL<(Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)){SL=Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;} + if(HideTP==false&&TakeProfit>0){TP=Bid-TakeProfit*Point;/*TPP=Ask+(TakeProfit*2)*Point;*/}else {TP=0;/*TPP=0;*/} + + Ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,EAName,Magic,0,Red); + if(Hedge)TicketH=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,TP,SL,EAName,Magic,0,Blue); + /*if(ReverseAtStop&&StopLoss>0)TicketP=OrderSend(Symbol(),OP_BUYSTOP,Lots,OPP,Slippage,SLP,TPP,EAName,Magic,Expire,Red);*/ + } + } + +//|---------close orders + + if(Hedge==false) + { + if((SELL=="true")||(ReverseSystem==false&&HideSL&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&(Bid-OrderOpenPrice())/Point>=TakeProfit)||(ReverseSystem&&HideSL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem&&HideTP&&(OrderOpenPrice()-Ask)/Point>=TakeProfit)) + { + if(ReverseSystem)CloseSellOrders(Magic);else CloseBuyOrders(Magic); + } + if((BUY=="true")||(ReverseSystem==false&&HideSL&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(ReverseSystem==false&&HideTP&&(OrderOpenPrice()-Ask)/Point>=TakeProfit)||(ReverseSystem&&HideSL&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(ReverseSystem&&HideTP&&(Bid-OrderOpenPrice())/Point>=TakeProfit)) + { + if(ReverseSystem)CloseBuyOrders(Magic);else CloseSellOrders(Magic); + } + } + else + { + if((HideSL&&StopLoss>0&&(OrderOpenPrice()-Ask)/Point>=StopLoss)||(HideTP&&TakeProfit>0&&(Bid-OrderOpenPrice())/Point>=TakeProfit)) + { + CloseBuyOrders(Magic); + } + if((HideSL&&StopLoss>0&&(Bid-OrderOpenPrice())/Point>=StopLoss)||(HideTP&&TakeProfit>0&&(OrderOpenPrice()-Ask)/Point>=TakeProfit)) + { + CloseSellOrders(Magic); + } + } + + +//|---------not enough money warning + + int err=0; + if(Ticket<0) + { + if(GetLastError()==134) + { + err=1; + Print("Not enough money!"); + } + return (-1); + } + +/* + if(Comments) + { + Comment("\nCopyright © 2009, TradingSytemForex", + "\n\nL o t s = " + DoubleToStr(Lots,2), + "\nB a l a n c e = " + DoubleToStr(AccountBalance(),2), + "\nE q u i t y = " + DoubleToStr(AccountEquity(),2)); + } +*/ + + return(0); +} + +//|---------close buy orders + +int CloseBuyOrders(int Magic) +{ + int result,total=OrdersTotal(); + + for (int cnt=total-1;cnt>=0;cnt--) + { + OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); + if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()) + { + if(OrderType()==OP_BUY) + { + OrderClose(OrderTicket(),OrderLots(),Bid,3); + switch(OrderType()) + { + case OP_BUYLIMIT: + case OP_BUYSTOP: + result=OrderDelete(OrderTicket()); + } + } + } + } + return(0); +} + +//|---------close sell orders + +int CloseSellOrders(int Magic) +{ + int result,total=OrdersTotal(); + + for(int cnt=total-1;cnt>=0;cnt--) + { + OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); + if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol()) + { + if(OrderType()==OP_SELL) + { + OrderClose(OrderTicket(),OrderLots(),Ask,3); + switch(OrderType()) + { + case OP_SELLLIMIT: + case OP_SELLSTOP: + result=OrderDelete(OrderTicket()); + } + } + } + } + return(0); +} + +//|---------trailing stop + +void MoveTrailingStop() +{ + int cnt,total=OrdersTotal(); + for(cnt=0;cnt0) + { + if((NormalizeDouble(OrderStopLoss(),Digits)0) + { + if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+Point*(TrailingStop+TrailingStep),Digits)))||(OrderStopLoss()==0)) + { + OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+Point*TrailingStop,Digits),OrderTakeProfit(),0,Red); + return(0); + } + } + } + } + } +} + +//|---------break even + +void MoveBreakEven() +{ + int cnt,total=OrdersTotal(); + for(cnt=0;cnt0) + { + if(NormalizeDouble((Bid-OrderOpenPrice()),Digits)>BreakEven*Point) + { + if(NormalizeDouble((OrderStopLoss()-OrderOpenPrice()),Digits)<0) + { + OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+0*Point,Digits),OrderTakeProfit(),0,Blue); + return(0); + } + } + } + } + else + { + if(BreakEven>0) + { + if(NormalizeDouble((OrderOpenPrice()-Ask),Digits)>BreakEven*Point) + { + if(NormalizeDouble((OrderOpenPrice()-OrderStopLoss()),Digits)<0) + { + OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-0*Point,Digits),OrderTakeProfit(),0,Red); + return(0); + } + } + } + } + } + } +} + +//|---------allow one action per bar + +bool NewBarBuy() +{ + if(PreviousBarTime1MaxLots)Lots=MaxLots; + return(0); +} + +/* +//|---------calculate martingale + +void CalculateMartingale() +{ + double MinLots=MarketInfo(Symbol(),MODE_MINLOT); + double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT); + if(Balance!=0.0) + { + if(Balance>AccountBalance())Lots=Multiplier*Lots; + else if((Balance+MinProfit)=AccountBalance())Lots=Lots; + if(LotsMaxLots)Lots=MaxLots; + } + return(0); +} +*/ + diff --git a/Signal_Bars_Executive_v1.mq4 b/Signal_Bars_Executive_v1.mq4 new file mode 100644 index 0000000..27dd5f2 --- /dev/null +++ b/Signal_Bars_Executive_v1.mq4 @@ -0,0 +1,2353 @@ +/* + Generated by EX4-TO-MQ4 decompiler V4.0.220.2c [] + Website: http://purebeam.biz + E-mail : purebeam@gmail.com + +*/ +#property copyright "Copyright © 2007, #Signal_Bars_Executive by cja." +#property link "Bars Concept Created by cja ccjjaa@gmail.com" +//EDUCATED by Player +#property indicator_chart_window + +extern string Note1 = "See Indicator Instructions for the"; +extern string Note2 = "Operation of this Indicator"; +extern string ___________________ = "____________________________________________________"; +extern bool Show_Indicator_Instructions = FALSE; +extern bool Show_Indicator_Instructions_2 = FALSE; +extern string __________________ = "____________________________________________________"; +extern int SIGBARS_Multi_No = 1; +extern string IIIIIIIIIIIIIIII_NOTE......Load = "Currency Pairs Below >>>>>>>>>>>>>>>>>>"; +extern string symbol = ""; +extern bool Digit_Switch = FALSE; +extern bool Spread_Digit_Shift = FALSE; +extern string IIIIIIIIIIIIIIIII = "<<<< Chart Position Settings >>>>>"; +extern bool Corner_of_Chart_RIGHT_TOP = TRUE; +extern int Shift_UP_DN = 0; +extern int Adjust_Side_to_side = 20; +extern int Sig_Bars_Window = 0; +extern string IIIIIIIIIIIIIIIIII = "<<<< Adjustable TimeFrames >>>>>>>>>>>>>>>>>>>>>>>>"; +extern int TF1 = 1; +extern int TF2 = 5; +extern int TF3 = 15; +extern int TF4 = 30; +extern int TF5 = 60; +extern int TF6 = 240; +extern string IIIIIIIIIIIIIIIIII. = "<<<< Number of TimeFrames >>>>"; +extern int No_of_TFs = 6; +extern string IIIIIIIIIIIIIIIIIII = "<<<< Alert & Sound Settings >>>>>"; +extern int AlertLevel = 60; +extern bool POPUP_Alert_ON = FALSE; +extern bool Sound_Constant_Alert_ON = FALSE; +extern bool Sound_Limited_Alert_ON = FALSE; +extern bool Show_Visual_Alert = TRUE; +extern color Alert_col_UP = Lime; +extern color Alert_col_DN = Red; +extern color Alert_col_NEUTRAL = Gray; +extern string ____________________NOTE.. = "Minutes = 1/5/15/30 = TFrame mins"; +extern int Alert_Frequency_Minutes = 1; +extern string IIIIIIIIIIIIIIIIIII. = " <<<< Comments Settings >>>>>>>>"; +extern bool Show_Price = TRUE; +extern bool Show_Xtra_Details = TRUE; +extern bool Show_Smaller_Size = TRUE; +extern bool Show_BrokerTime = FALSE; +extern bool Show_Header = TRUE; +extern bool Show_Indicator_Bars = TRUE; +extern string ____________________NOTE = "Average Settings 0 to 10 & 15/20/25 "; +extern string ____________________NOTE. = "30/35/40/45/50/60/70/80/90/100 "; +extern int Select_Average = 0; +extern string _______________________________ = "_______________________________________________"; +extern color Title_Color = Black; +extern color TimeFrame_Label_color = DimGray; +extern color BarLabel_color = DimGray; +extern color CommentLabel_color = Gray; +extern color Spread_color = DarkSlateGray; +extern color HI_LO_color = DarkSlateGray; +extern color Pips_UP = Lime; +extern color Pips_DN = OrangeRed; +extern color Daily_AV_UP = Lime; +extern color Daily_AV_DN = OrangeRed; +extern string IIIIIIIIIIIIIIIIIIII = " <<<< Price Color Settings >>>>>>>>"; +extern color Price_UP = Lime; +extern color Price_DN = Red; +extern color Price_Neutral = Orange; +extern string IIIIIIIIIIIIIIIIIIIII = "<<<< MACD Settings >>>>>>>>>>>"; +extern int MACD_Fast = 8; +extern int MACD_Slow = 17; +extern int MACD_Signal = 9; +extern int MACD_PRICE_TYPE = 0; +extern string IIIIIIIIIIIIIIIIIIIIIII = "<<<< MACD Colors >>>>>>>>>>>>>>>>>>"; +extern color XUP_above_0 = Lime; +extern color XDN_above_0 = Tomato; +extern color XUP_below_0 = Green; +extern color XDN_below_0 = Red; +extern string IIIIIIIIIIIIIIIIIIIIIIII = "<<<< STR or RSI Settings >>>>>>>>>>>>>"; +extern bool Switch_STR_to_RSI = TRUE; +extern int RSI_Period1 = 5; +extern int RSI_Period2 = 9; +extern int RSI_Period3 = 18; +extern int RSI_Price = 0; +extern string IIIIIIIIIIIIIIIIIIIIIIIII = "<<<< STR RSI Settings >>>>>>>>>>>>>"; +extern int RSI_Period = 9; +extern int RSI_PRICE_TYPE = 0; +extern string IIIIIIIIIIIIIIIIIIIIIIIIII = "<<<< STR CCI Settings >>>>>>>>>>>>>>"; +extern int CCI_Period = 13; +extern int CCI_PRICE_TYPE = 0; +extern string IIIIIIIIIIIIIIIIIIIIIIIIIII = "<<<< STR STOCH Settings >>>>>>>>>>>"; +extern int STOCH_K_Period = 5; +extern int STOCH_D_Period = 3; +extern int STOCH_Slowing = 3; +extern int STOCH_MA_MODE = 1; +extern string IIIIIIIIIIIIIIIIIIIIIIIIIIII = "<<<< STR Colors >>>>>>>>>>>>>>>>"; +extern color STR_UP = Lime; +extern color STR_DN = Red; +extern color STR_NO_Signal = Orange; +extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIII = "<<<< MA Settings >>>>>>>>>>>>>>"; +extern int MA_Fast = 5; +extern int MA_Slow = 9; +extern int MA_MODE = 1; +extern int MA_PRICE_TYPE = 0; +extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIIII = "<<<< MA Colors >>>>>>>>>>>>>>"; +extern color MA_UP = Lime; +extern color MA_DN = Red; +int gi_576; +int gi_580; +int gi_584; +int gi_588; +double g_color_592; +int g_datetime_600 = 0; + +int init() { + IndicatorShortName("#Signal Bars Executive"); + return (0); +} + +int deinit() { + ObjectDelete("cja" + SIGBARS_Multi_No + ""); + ObjectDelete("Signalprice" + SIGBARS_Multi_No + ""); + ObjectDelete("tsd_FREE" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF1" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF2" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF3" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF4" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF5" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_BARS_TF6" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACD_TEXT" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDM1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDM5" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDM15" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDM30" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDH1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalMACDH4" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTR_TEXT" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRM1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRM5" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRM15" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRM30" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH4" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMA_TEXT" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAM1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAM5" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAM15" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAM30" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH1" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH4" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_1" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_2" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_3" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_4" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_5" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_6" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_7" + SIGBARS_Multi_No + ""); + ObjectDelete("SIG_DETAIL_8" + SIGBARS_Multi_No + ""); + ObjectDelete("Signalcurr" + SIGBARS_Multi_No + ""); + Comment(""); + ObjectDelete("SSignalMACDM30tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SSignalMACDH1tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SSignalMACDH4tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SSignalMACDH4tfx" + SIGBARS_Multi_No + ""); + ObjectDelete("SSignalMACDH4tfxx" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRM30tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH1tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH4tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH4tfx" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalSTRH4tfxx" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAM30tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH1tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH4tf" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH4tfx" + SIGBARS_Multi_No + ""); + ObjectDelete("SignalEMAH4tfxx" + SIGBARS_Multi_No + ""); + ObjectDelete("BrokerTime" + SIGBARS_Multi_No + ""); + ObjectDelete("Signal_Bars_Trial_Info"); + ObjectDelete("cja Copyright" + SIGBARS_Multi_No + ""); + ObjectDelete("SigAlert" + SIGBARS_Multi_No + ""); + ObjectDelete("SigAlert1" + SIGBARS_Multi_No + ""); + //ObjectDelete("EXPIRED"); + //ObjectDelete("EXPIRED1"); + //ObjectDelete("EXPIRED2"); + //ObjectDelete("EXPIRED3"); + //ObjectDelete("EXPIRED4"); + //ObjectDelete("EXPIRED5"); + //ObjectDelete("AAEXPIRED6"); + return (0); +} + +int start() { + color l_color_32; + int li_96; + int li_100; + int li_104; + int li_108; + int li_112; + int li_116; + int li_124; + int li_128; + int li_132; + int li_136; + int li_140; + int li_144; + int l_fontsize_148; + int li_152; + double ld_156; + double ld_164; + double ld_172; + double ld_180; + double ld_188; + double ld_196; + double ld_204; + double ld_212; + double ld_220; + double ld_228; + double ld_236; + double ld_244; + double ld_252; + double ld_260; + double ld_268; + double ld_276; + double ld_284; + double ld_292; + double ld_300; + double ld_308; + double ld_316; + double ld_324; + double ld_332; + double ld_340; + double ld_348; + double ld_356; + double ld_364; + double ld_372; + double ld_380; + double ld_388; + double ld_396; + double ld_404; + double ld_412; + double ld_420; + double ld_428; + double ld_436; + color l_color_520; + color l_color_524; + color l_color_528; + color l_color_532; + color l_color_536; + color l_color_540; + int li_648; + int li_652; + int li_656; + int li_660; + int li_664; + int li_668; + int li_672; + int li_676; + int li_680; + int li_684; + int li_688; + int li_692; + int l_fontsize_696; + int l_fontsize_700; + int li_704; + int li_708; + int li_712; + int li_716; + int li_720; + int li_724; + int li_728; + double l_irsi_732; + double l_irsi_740; + double l_irsi_748; + double l_irsi_756; + double l_irsi_764; + double l_irsi_772; + int li_1084; + int li_1088; + int li_1092; + int li_1096; + int li_1100; + int li_1104; + int li_1108; + int li_1112; + int li_1116; + int li_1120; + int li_1124; + int li_1128; + int l_fontsize_1132; + int l_fontsize_1136; + int li_1140; + int li_1144; + int li_1148; + int li_1152; + int li_1156; + int li_1160; + int li_1164; + string ls_unused_1336; + color l_color_1344; + color l_color_1348; + color l_color_1352; + color l_color_1356; + color l_color_1360; + color l_color_1364; + int li_1380; + int li_1384; + int li_1388; + int li_1392; + int li_1396; + int li_1400; + int li_1404; + int li_1408; + int li_1412; + int li_1416; + int li_1420; + int li_1424; + int l_fontsize_1428; + int l_fontsize_1432; + int li_1436; + int li_1440; + int li_1444; + int li_1448; + int li_1452; + int li_1456; + int li_1460; + int li_1464; + string l_dbl2str_1484; + string l_dbl2str_1492; + color l_color_1508; + color l_color_1512; + int li_1516; + int li_1520; + int l_fontsize_1524; + int li_1528; + color l_color_1556; + double ld_2360; + double ld_2368; + color l_color_2392; + color l_color_2396; + int l_fontsize_2464; + int l_fontsize_2468; + int l_fontsize_2472; + int li_2476; + int li_2480; + int li_2484; + int li_2488; + int li_2492; + int li_2496; + int li_2500; + int li_2504; + int li_2508; + int li_2512; + int li_2516; + int li_2520; + int li_2524; + int li_2528; + int li_2532; + int li_2536; + int li_2540; + int li_2544; + int li_0 = 000000; + int li_4 = 000000; + //if (AccountNumber() == 0) return (0);xxxxxxxxxxxxxxxxxxx + double ld_8 = NormalizeDouble(MarketInfo(Symbol(), MODE_BID), Digits); + double l_ima_16 = iMA(Symbol(), PERIOD_M1, 1, 0, MODE_EMA, PRICE_CLOSE, 1); + string ls_unused_24 = ""; + if (l_ima_16 > ld_8) { + ls_unused_24 = ""; + l_color_32 = DarkBlue; + g_color_592 = DarkOrange; + } + if (l_ima_16 < ld_8) { + ls_unused_24 = ""; + l_color_32 = Silver; + g_color_592 = Red; + } + if (l_ima_16 == ld_8) { + ls_unused_24 = ""; + l_color_32 = DarkOrange; + g_color_592 = Blue; + //}xxxxxxxxxxxxxxxxxxxxxxxx + //string ls_unused_36 = "";xxxxxxxxxxxxxxxxxx + //if (li_0 != AccountNumber()) {xxxxxxxxxxxxxxxxxxx + //if (li_4 != AccountNumber()) {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + // ObjectCreate("AAEXPIRED6", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("AAEXPIRED6", "g", 410, "Webdings", l_color_32); + // ObjectSet("AAEXPIRED6", OBJPROP_CORNER, 0); + // ObjectSet("AAEXPIRED6", OBJPROP_XDISTANCE, 234); + // ObjectSet("AAEXPIRED6", OBJPROP_YDISTANCE, 15); + // ObjectCreate("EXPIRED", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED", "g", 400, "Webdings", g_color_592); + // ObjectSet("EXPIRED", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED", OBJPROP_XDISTANCE, 240); + // ObjectSet("EXPIRED", OBJPROP_YDISTANCE, 20); + // ObjectSet("EXPIRED", OBJPROP_BACK, FALSE); + // ObjectCreate("EXPIRED1", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED1", "N", 300, "Wingdings", l_color_32); + // ObjectSet("EXPIRED1", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED1", OBJPROP_XDISTANCE, 370); + // ObjectSet("EXPIRED1", OBJPROP_YDISTANCE, 0); + // ObjectSet("EXPIRED1", OBJPROP_BACK, FALSE); + // ObjectCreate("EXPIRED2", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED2", "WARNING ! Incorrect ACCOUNT", 25, "Arial", l_color_32); + // ObjectSet("EXPIRED2", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED2", OBJPROP_XDISTANCE, 260); + // ObjectSet("EXPIRED2", OBJPROP_YDISTANCE, 380); + // ObjectSet("EXPIRED2", OBJPROP_BACK, FALSE); + // ObjectCreate("EXPIRED3", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED3", "Any attempts at file access may cause system corruption", 14, "Arial", l_color_32); + // ObjectSet("EXPIRED3", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED3", OBJPROP_XDISTANCE, 280); + // ObjectSet("EXPIRED3", OBJPROP_YDISTANCE, 430); + // ObjectSet("EXPIRED3", OBJPROP_BACK, FALSE); + /// ObjectCreate("EXPIRED4", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED4", "For a License permitting further use", 11, "Arial", l_color_32); + // ObjectSet("EXPIRED4", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED4", OBJPROP_XDISTANCE, 385); + // ObjectSet("EXPIRED4", OBJPROP_YDISTANCE, 460); + // ObjectSet("EXPIRED4", OBJPROP_BACK, FALSE); + // ObjectCreate("EXPIRED5", OBJ_LABEL, 0, 0, 0); + // ObjectSetText("EXPIRED5", " contact *cja* at ccjjaa@gmail.com ", 18, "Arial", l_color_32); + // ObjectSet("EXPIRED5", OBJPROP_CORNER, 0); + // ObjectSet("EXPIRED5", OBJPROP_XDISTANCE, 315); + // ObjectSet("EXPIRED5", OBJPROP_YDISTANCE, 490); + // ObjectSet("EXPIRED5", OBJPROP_BACK, FALSE); + // PlaySound("timeout"); + //return (0);xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + //}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + } + int l_ind_counted_44 = IndicatorCounted(); + string l_text_48 = ""; + string l_text_56 = ""; + string l_text_64 = ""; + string l_text_72 = ""; + string l_text_80 = ""; + string l_text_88 = ""; + if (TF1 == PERIOD_M1) l_text_48 = "M1"; + if (TF1 == PERIOD_M5) l_text_48 = "M5"; + if (TF1 == PERIOD_M15) l_text_48 = "M15"; + if (TF1 == PERIOD_M30) l_text_48 = "M30"; + if (TF1 == PERIOD_H1) l_text_48 = "H1"; + if (TF1 == PERIOD_H4) l_text_48 = "H4"; + if (TF1 == PERIOD_D1) l_text_48 = "D1"; + if (TF1 == PERIOD_W1) l_text_48 = "W1"; + if (TF1 == PERIOD_MN1) l_text_48 = "MN"; + if (TF2 == PERIOD_M1) l_text_56 = "M1"; + if (TF2 == PERIOD_M5) l_text_56 = "M5"; + if (TF2 == PERIOD_M15) l_text_56 = "M15"; + if (TF2 == PERIOD_M30) l_text_56 = "M30"; + if (TF2 == PERIOD_H1) l_text_56 = "H1"; + if (TF2 == PERIOD_H4) l_text_56 = "H4"; + if (TF2 == PERIOD_D1) l_text_56 = "D1"; + if (TF2 == PERIOD_W1) l_text_56 = "W1"; + if (TF2 == PERIOD_MN1) l_text_56 = "MN"; + if (TF3 == PERIOD_M1) l_text_64 = "M1"; + if (TF3 == PERIOD_M5) l_text_64 = "M5"; + if (TF3 == PERIOD_M15) l_text_64 = "M15"; + if (TF3 == PERIOD_M30) l_text_64 = "M30"; + if (TF3 == PERIOD_H1) l_text_64 = "H1"; + if (TF3 == PERIOD_H4) l_text_64 = "H4"; + if (TF3 == PERIOD_D1) l_text_64 = "D1"; + if (TF3 == PERIOD_W1) l_text_64 = "W1"; + if (TF3 == PERIOD_MN1) l_text_64 = "MN"; + if (TF4 == PERIOD_M1) l_text_72 = "M1"; + if (TF4 == PERIOD_M5) l_text_72 = "M5"; + if (TF4 == PERIOD_M15) l_text_72 = "M15"; + if (TF4 == PERIOD_M30) l_text_72 = "M30"; + if (TF4 == PERIOD_H1) l_text_72 = "H1"; + if (TF4 == PERIOD_H4) l_text_72 = "H4"; + if (TF4 == PERIOD_D1) l_text_72 = "D1"; + if (TF4 == PERIOD_W1) l_text_72 = "W1"; + if (TF4 == PERIOD_MN1) l_text_72 = "MN"; + if (TF5 == PERIOD_M1) l_text_80 = "M1"; + if (TF5 == PERIOD_M5) l_text_80 = "M5"; + if (TF5 == PERIOD_M15) l_text_80 = "M15"; + if (TF5 == PERIOD_M30) l_text_80 = "M30"; + if (TF5 == PERIOD_H1) l_text_80 = "H1"; + if (TF5 == PERIOD_H4) l_text_80 = "H4"; + if (TF5 == PERIOD_D1) l_text_80 = "D1"; + if (TF5 == PERIOD_W1) l_text_80 = "W1"; + if (TF5 == PERIOD_MN1) l_text_80 = "MN"; + if (TF6 == PERIOD_M1) l_text_88 = "M1"; + if (TF6 == PERIOD_M5) l_text_88 = "M5"; + if (TF6 == PERIOD_M15) l_text_88 = "M15"; + if (TF6 == PERIOD_M30) l_text_88 = "M30"; + if (TF6 == PERIOD_H1) l_text_88 = "H1"; + if (TF6 == PERIOD_H4) l_text_88 = "H4"; + if (TF6 == PERIOD_D1) l_text_88 = "D1"; + if (TF6 == PERIOD_W1) l_text_88 = "W1"; + if (TF6 == PERIOD_MN1) l_text_88 = "MN"; + if (TF1 == PERIOD_M15) li_96 = -2; + if (TF1 == PERIOD_M30) li_96 = -2; + if (TF2 == PERIOD_M15) li_100 = -2; + if (TF2 == PERIOD_M30) li_100 = -2; + if (TF3 == PERIOD_M15) li_104 = -2; + if (TF3 == PERIOD_M30) li_104 = -2; + if (TF4 == PERIOD_M15) li_108 = -2; + if (TF4 == PERIOD_M30) li_108 = -2; + if (TF5 == PERIOD_M15) li_112 = -2; + if (TF5 == PERIOD_M30) li_112 = -2; + if (TF6 == PERIOD_M15) li_116 = -2; + if (TF6 == PERIOD_M30) li_116 = -2; + if (Shift_UP_DN < 0) return (0); + if (Show_Smaller_Size == FALSE) { + l_fontsize_148 = 7; + if (No_of_TFs >= 1) li_144 = 24; + if (No_of_TFs >= 2) { + li_140 = 22; + li_144 = 9; + } + if (No_of_TFs >= 3) { + li_136 = 20; + li_140 = 13; + li_144 = 5; + } + if (No_of_TFs >= 4) { + li_132 = 0; + li_136 = 0; + li_140 = 0; + li_144 = 1; + } + if (No_of_TFs >= 5) { + li_128 = 0; + li_132 = 0; + li_136 = 0; + li_140 = 0; + li_144 = 1; + } + if (No_of_TFs >= 6) { + li_124 = 0; + li_128 = 0; + li_132 = 0; + li_136 = 0; + li_140 = 0; + li_144 = 1; + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Smaller_Size == TRUE) li_152 = 3; + l_fontsize_148 = 6; + if (No_of_TFs >= 1) li_144 = 24; + if (No_of_TFs >= 2) { + li_140 = 22; + li_144 = 9; + } + if (No_of_TFs >= 3) { + li_136 = 12; + li_140 = 8; + li_144 = 3; + } + if (No_of_TFs >= 4) { + li_132 = -6; + li_136 = -4; + li_140 = -1; + li_144 = 1; + } + if (No_of_TFs >= 5) { + li_128 = -8; + li_132 = -6; + li_136 = -4; + li_140 = -1; + li_144 = 1; + } + if (No_of_TFs >= 6) { + li_124 = -10; + li_128 = -8; + li_132 = -6; + li_136 = -4; + li_140 = -1; + li_144 = 1; + } + } + if (Show_Indicator_Bars) { + if (No_of_TFs >= 6) { + ObjectDelete("SIG_BARS_TF1" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF1" + SIGBARS_Multi_No + "", l_text_48, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 114 + li_96 + li_124); + ObjectSet("SIG_BARS_TF1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + if (No_of_TFs >= 5) { + ObjectDelete("SIG_BARS_TF2" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF2" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF2" + SIGBARS_Multi_No + "", l_text_56, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF2" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF2" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 94 + li_100 + li_128); + ObjectSet("SIG_BARS_TF2" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + if (No_of_TFs >= 4) { + ObjectDelete("SIG_BARS_TF3" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF3" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF3" + SIGBARS_Multi_No + "", l_text_64, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF3" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF3" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 74 + li_104 + li_132); + ObjectSet("SIG_BARS_TF3" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + if (No_of_TFs >= 3) { + ObjectDelete("SIG_BARS_TF4" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF4" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF4" + SIGBARS_Multi_No + "", l_text_72, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF4" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF4" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 54 + li_108 + li_136); + ObjectSet("SIG_BARS_TF4" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + if (No_of_TFs >= 2) { + ObjectDelete("SIG_BARS_TF5" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF5" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF5" + SIGBARS_Multi_No + "", l_text_80, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF5" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF5" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 34 + li_112 + li_140); + ObjectSet("SIG_BARS_TF5" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + if (No_of_TFs >= 1) { + ObjectDelete("SIG_BARS_TF6" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_BARS_TF6" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_BARS_TF6" + SIGBARS_Multi_No + "", l_text_88, l_fontsize_148, "Arial Bold", TimeFrame_Label_color); + ObjectSet("SIG_BARS_TF6" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_BARS_TF6" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 14 + li_116 + li_144); + ObjectSet("SIG_BARS_TF6" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 25 + li_152); + } + } + if (symbol == "") symbol = Symbol(); + string ls_unused_444 = ""; + string l_text_452 = ""; + string l_text_460 = ""; + string l_text_468 = ""; + string l_text_476 = ""; + string l_text_484 = ""; + string l_text_492 = ""; + string ls_unused_500 = ""; + string ls_unused_508 = ""; + double l_imacd_552 = iMACD(symbol, TF1, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_560 = iMACD(symbol, TF1, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + double l_imacd_568 = iMACD(symbol, TF2, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_576 = iMACD(symbol, TF2, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + double l_imacd_584 = iMACD(symbol, TF3, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_592 = iMACD(symbol, TF3, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + double l_imacd_600 = iMACD(symbol, TF4, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_608 = iMACD(symbol, TF4, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + double l_imacd_616 = iMACD(symbol, TF5, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_624 = iMACD(symbol, TF5, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + double l_imacd_632 = iMACD(symbol, TF6, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_MAIN, 0); + double l_imacd_640 = iMACD(symbol, TF6, MACD_Fast, MACD_Slow, MACD_Signal, MACD_PRICE_TYPE, MODE_SIGNAL, 0); + if (l_imacd_552 > l_imacd_560) { + l_text_468 = "-"; + l_color_528 = XUP_below_0; + ld_156 = 1; + ld_300 = 0; + } + if (l_imacd_552 <= l_imacd_560) { + l_text_468 = "-"; + l_color_528 = XDN_above_0; + ld_156 = 0; + ld_300 = 1; + } + if (l_imacd_552 > l_imacd_560 && l_imacd_552 > 0.0) { + l_text_468 = "-"; + l_color_528 = XUP_above_0; + } + if (l_imacd_552 <= l_imacd_560 && l_imacd_552 < 0.0) { + l_text_468 = "-"; + l_color_528 = XDN_below_0; + } + if (l_imacd_568 > l_imacd_576) { + l_text_476 = "-"; + l_color_532 = XUP_below_0; + ld_164 = 1; + ld_308 = 0; + } + if (l_imacd_568 <= l_imacd_576) { + l_text_476 = "-"; + l_color_532 = XDN_above_0; + ld_164 = 0; + ld_308 = 1; + } + if (l_imacd_568 > l_imacd_576 && l_imacd_568 > 0.0) { + l_text_476 = "-"; + l_color_532 = XUP_above_0; + } + if (l_imacd_568 <= l_imacd_576 && l_imacd_568 < 0.0) { + l_text_476 = "-"; + l_color_532 = XDN_below_0; + } + if (l_imacd_584 > l_imacd_592) { + l_text_484 = "-"; + l_color_536 = XUP_below_0; + ld_172 = 1; + ld_316 = 0; + } + if (l_imacd_584 <= l_imacd_592) { + l_text_484 = "-"; + l_color_536 = XDN_above_0; + ld_172 = 0; + ld_316 = 1; + } + if (l_imacd_584 > l_imacd_592 && l_imacd_584 > 0.0) { + l_text_484 = "-"; + l_color_536 = XUP_above_0; + } + if (l_imacd_584 <= l_imacd_592 && l_imacd_584 < 0.0) { + l_text_484 = "-"; + l_color_536 = XDN_below_0; + } + if (l_imacd_600 > l_imacd_608) { + l_text_492 = "-"; + l_color_540 = XUP_below_0; + ld_180 = 1; + ld_324 = 0; + } + if (l_imacd_600 <= l_imacd_608) { + l_text_492 = "-"; + l_color_540 = XDN_above_0; + ld_180 = 0; + ld_324 = 1; + } + if (l_imacd_600 > l_imacd_608 && l_imacd_600 > 0.0) { + l_text_492 = "-"; + l_color_540 = XUP_above_0; + } + if (l_imacd_600 <= l_imacd_608 && l_imacd_600 < 0.0) { + l_text_492 = "-"; + l_color_540 = XDN_below_0; + } + if (l_imacd_616 > l_imacd_624) { + l_text_452 = "-"; + l_color_520 = XUP_below_0; + ld_188 = 1; + ld_332 = 0; + } + if (l_imacd_616 <= l_imacd_624) { + l_text_452 = "-"; + l_color_520 = XDN_above_0; + ld_188 = 0; + ld_332 = 1; + } + if (l_imacd_616 > l_imacd_624 && l_imacd_616 > 0.0) { + l_text_452 = "-"; + l_color_520 = XUP_above_0; + } + if (l_imacd_616 <= l_imacd_624 && l_imacd_616 < 0.0) { + l_text_452 = "-"; + l_color_520 = XDN_below_0; + } + if (l_imacd_632 > l_imacd_640) { + l_text_460 = "-"; + l_color_524 = XUP_below_0; + ld_196 = 1; + ld_340 = 0; + } + if (l_imacd_632 <= l_imacd_640) { + l_text_460 = "-"; + l_color_524 = XDN_above_0; + ld_196 = 0; + ld_340 = 1; + } + if (l_imacd_632 > l_imacd_640 && l_imacd_632 > 0.0) { + l_text_460 = "-"; + l_color_524 = XUP_above_0; + } + if (l_imacd_632 <= l_imacd_640 && l_imacd_632 < 0.0) { + l_text_460 = "-"; + l_color_524 = XDN_below_0; + } + if (Show_Smaller_Size == FALSE) { + li_648 = 135; + li_704 = 35; + l_fontsize_700 = 6; + li_652 = 110; + li_708 = 2; + l_fontsize_696 = 45; + li_656 = 90; + li_712 = 2; + l_fontsize_696 = 45; + li_660 = 70; + li_716 = 2; + l_fontsize_696 = 45; + li_664 = 50; + li_720 = 2; + l_fontsize_696 = 45; + li_668 = 30; + li_724 = 2; + l_fontsize_696 = 45; + li_672 = 10; + li_728 = 2; + l_fontsize_696 = 45; + if (No_of_TFs >= 1) { + li_672 = 10; + li_648 = 82; + li_684 = 26; + li_688 = 42; + li_692 = 58; + } + if (No_of_TFs >= 2) { + li_668 = 60; + li_672 = 10; + li_648 = 85; + li_680 = 45; + li_684 = 25; + } + if (No_of_TFs >= 3) { + li_664 = 66; + li_668 = 38; + li_672 = 10; + li_648 = 97; + li_676 = 74; + li_680 = 46; + li_684 = 18; + } + if (No_of_TFs >= 4) { + li_664 = 50; + li_668 = 30; + li_672 = 10; + li_648 = 95; + li_676 = 50; + li_680 = 30; + li_684 = 10; + } + if (No_of_TFs >= 5) li_648 = 115; + if (No_of_TFs >= 6) li_648 = 135; + } + if (Show_Smaller_Size == TRUE) { + li_648 = 120; + li_704 = 35; + l_fontsize_700 = 6; + li_652 = 100; + li_708 = 6; + l_fontsize_696 = 40; + li_656 = 82; + li_712 = 6; + l_fontsize_696 = 40; + li_660 = 64; + li_716 = 6; + l_fontsize_696 = 40; + li_664 = 46; + li_720 = 6; + l_fontsize_696 = 40; + li_668 = 28; + li_724 = 6; + l_fontsize_696 = 40; + li_672 = 10; + li_728 = 6; + l_fontsize_696 = 40; + if (No_of_TFs >= 1) { + li_672 = 10; + li_648 = 82; + li_684 = 25; + li_688 = 40; + li_692 = 55; + } + if (No_of_TFs >= 2) { + li_668 = 58; + li_672 = 10; + li_648 = 85; + li_680 = 43; + li_684 = 25; + } + if (No_of_TFs >= 3) { + li_664 = 58; + li_668 = 33; + li_672 = 10; + li_648 = 85; + li_676 = 63; + li_680 = 40; + li_684 = 15; + } + if (No_of_TFs >= 4) { + li_664 = 46; + li_668 = 28; + li_672 = 10; + li_648 = 85; + li_676 = 46; + li_680 = 28; + li_684 = 10; + } + if (No_of_TFs >= 5) li_648 = 103; + if (No_of_TFs >= 6) li_648 = 120; + } + if (Show_Indicator_Bars) { + if (No_of_TFs >= 3) { + ObjectDelete("SSignalMACDM30tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SSignalMACDM30tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SSignalMACDM30tf" + SIGBARS_Multi_No + "", l_text_492, l_fontsize_696, "Tahoma Narrow", l_color_540); + ObjectSet("SSignalMACDM30tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM30tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_676 + Adjust_Side_to_side); + ObjectSet("SSignalMACDM30tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_720 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SSignalMACDH1tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SSignalMACDH1tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SSignalMACDH1tf" + SIGBARS_Multi_No + "", l_text_452, l_fontsize_696, "Tahoma Narrow", l_color_520); + ObjectSet("SSignalMACDH1tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH1tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_680 + Adjust_Side_to_side); + ObjectSet("SSignalMACDH1tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_724 + Shift_UP_DN); + } + ObjectDelete("SSignalMACDH4tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SSignalMACDH4tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SSignalMACDH4tf" + SIGBARS_Multi_No + "", l_text_460, l_fontsize_696, "Tahoma Narrow", l_color_524); + ObjectSet("SSignalMACDH4tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH4tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_684 + Adjust_Side_to_side); + ObjectSet("SSignalMACDH4tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_728 + Shift_UP_DN); + if (No_of_TFs < 2) { + ObjectDelete("SSignalMACDH4tfx" + SIGBARS_Multi_No + ""); + ObjectCreate("SSignalMACDH4tfx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SSignalMACDH4tfx" + SIGBARS_Multi_No + "", l_text_460, l_fontsize_696, "Tahoma Narrow", l_color_524); + ObjectSet("SSignalMACDH4tfx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH4tfx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_688 + Adjust_Side_to_side); + ObjectSet("SSignalMACDH4tfx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_728 + Shift_UP_DN); + ObjectDelete("SSignalMACDH4tfxx" + SIGBARS_Multi_No + ""); + ObjectCreate("SSignalMACDH4tfxx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SSignalMACDH4tfxx" + SIGBARS_Multi_No + "", l_text_460, l_fontsize_696, "Tahoma Narrow", l_color_524); + ObjectSet("SSignalMACDH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_692 + Adjust_Side_to_side); + ObjectSet("SSignalMACDH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_728 + Shift_UP_DN); + } + ObjectDelete("SignalMACD_TEXT" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACD_TEXT" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACD_TEXT" + SIGBARS_Multi_No + "", "MACD", l_fontsize_700, "Tahoma Narrow", BarLabel_color); + ObjectSet("SignalMACD_TEXT" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACD_TEXT" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_648 + Adjust_Side_to_side); + ObjectSet("SignalMACD_TEXT" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_704 + Shift_UP_DN); + if (No_of_TFs >= 6) { + ObjectDelete("SignalMACDM1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDM1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDM1" + SIGBARS_Multi_No + "", l_text_468, l_fontsize_696, "Tahoma Narrow", l_color_528); + ObjectSet("SignalMACDM1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDM1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_652 + Adjust_Side_to_side); + ObjectSet("SignalMACDM1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_708 + Shift_UP_DN); + } + if (No_of_TFs >= 5) { + ObjectDelete("SignalMACDM5" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDM5" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDM5" + SIGBARS_Multi_No + "", l_text_476, l_fontsize_696, "Tahoma Narrow", l_color_532); + ObjectSet("SignalMACDM5" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDM5" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_656 + Adjust_Side_to_side); + ObjectSet("SignalMACDM5" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_712 + Shift_UP_DN); + } + if (No_of_TFs >= 4) { + ObjectDelete("SignalMACDM15" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDM15" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDM15" + SIGBARS_Multi_No + "", l_text_484, l_fontsize_696, "Tahoma Narrow", l_color_536); + ObjectSet("SignalMACDM15" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDM15" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_660 + Adjust_Side_to_side); + ObjectSet("SignalMACDM15" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_716 + Shift_UP_DN); + } + if (No_of_TFs >= 3) { + ObjectDelete("SignalMACDM30" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDM30" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDM30" + SIGBARS_Multi_No + "", l_text_492, l_fontsize_696, "Tahoma Narrow", l_color_540); + ObjectSet("SignalMACDM30" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDM30" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_664 + Adjust_Side_to_side); + ObjectSet("SignalMACDM30" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_720 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SignalMACDH1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDH1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDH1" + SIGBARS_Multi_No + "", l_text_452, l_fontsize_696, "Tahoma Narrow", l_color_520); + ObjectSet("SignalMACDH1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDH1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_668 + Adjust_Side_to_side); + ObjectSet("SignalMACDH1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_724 + Shift_UP_DN); + } + if (No_of_TFs >= 1) { + ObjectDelete("SignalMACDH4" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalMACDH4" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalMACDH4" + SIGBARS_Multi_No + "", l_text_460, l_fontsize_696, "Tahoma Narrow", l_color_524); + ObjectSet("SignalMACDH4" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalMACDH4" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_672 + Adjust_Side_to_side); + ObjectSet("SignalMACDH4" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_728 + Shift_UP_DN); + } + } + if (Switch_STR_to_RSI == FALSE) { + l_irsi_732 = iRSI(symbol, TF6, RSI_Period, RSI_PRICE_TYPE, 0); + l_irsi_740 = iRSI(symbol, TF5, RSI_Period, RSI_PRICE_TYPE, 0); + l_irsi_748 = iRSI(symbol, TF4, RSI_Period, RSI_PRICE_TYPE, 0); + l_irsi_756 = iRSI(symbol, TF3, RSI_Period, RSI_PRICE_TYPE, 0); + l_irsi_764 = iRSI(symbol, TF2, RSI_Period, RSI_PRICE_TYPE, 0); + l_irsi_772 = iRSI(symbol, TF1, RSI_Period, RSI_PRICE_TYPE, 0); + } + double l_istochastic_780 = iStochastic(symbol, TF6, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_istochastic_788 = iStochastic(symbol, TF5, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_istochastic_796 = iStochastic(symbol, TF4, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_istochastic_804 = iStochastic(symbol, TF3, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_istochastic_812 = iStochastic(symbol, TF2, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_istochastic_820 = iStochastic(symbol, TF1, STOCH_K_Period, STOCH_D_Period, STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double l_icci_828 = iCCI(symbol, TF6, CCI_Period, CCI_PRICE_TYPE, 0); + double l_icci_836 = iCCI(symbol, TF5, CCI_Period, CCI_PRICE_TYPE, 0); + double l_icci_844 = iCCI(symbol, TF4, CCI_Period, CCI_PRICE_TYPE, 0); + double l_icci_852 = iCCI(symbol, TF3, CCI_Period, CCI_PRICE_TYPE, 0); + double l_icci_860 = iCCI(symbol, TF2, CCI_Period, CCI_PRICE_TYPE, 0); + double l_icci_868 = iCCI(symbol, TF1, CCI_Period, CCI_PRICE_TYPE, 0); + l_irsi_732 = iRSI(symbol, TF6, RSI_Period1, RSI_Price, 0); + l_irsi_740 = iRSI(symbol, TF5, RSI_Period1, RSI_Price, 0); + l_irsi_748 = iRSI(symbol, TF4, RSI_Period1, RSI_Price, 0); + l_irsi_756 = iRSI(symbol, TF3, RSI_Period1, RSI_Price, 0); + l_irsi_764 = iRSI(symbol, TF2, RSI_Period1, RSI_Price, 0); + l_irsi_772 = iRSI(symbol, TF1, RSI_Period1, RSI_Price, 0); + double l_irsi_876 = iRSI(symbol, TF6, RSI_Period2, RSI_Price, 0); + double l_irsi_884 = iRSI(symbol, TF5, RSI_Period2, RSI_Price, 0); + double l_irsi_892 = iRSI(symbol, TF4, RSI_Period2, RSI_Price, 0); + double l_irsi_900 = iRSI(symbol, TF3, RSI_Period2, RSI_Price, 0); + double l_irsi_908 = iRSI(symbol, TF2, RSI_Period2, RSI_Price, 0); + double l_irsi_916 = iRSI(symbol, TF1, RSI_Period2, RSI_Price, 0); + double l_irsi_924 = iRSI(symbol, TF6, RSI_Period3, RSI_Price, 0); + double l_irsi_932 = iRSI(symbol, TF5, RSI_Period3, RSI_Price, 0); + double l_irsi_940 = iRSI(symbol, TF4, RSI_Period3, RSI_Price, 0); + double l_irsi_948 = iRSI(symbol, TF3, RSI_Period3, RSI_Price, 0); + double l_irsi_956 = iRSI(symbol, TF2, RSI_Period3, RSI_Price, 0); + double l_irsi_964 = iRSI(symbol, TF1, RSI_Period3, RSI_Price, 0); + string l_text_972 = ""; + string l_text_980 = ""; + string l_text_988 = ""; + string l_text_996 = ""; + string l_text_1004 = ""; + string l_text_1012 = ""; + string ls_unused_1020 = ""; + string ls_unused_1028 = ""; + string ls_unused_1036 = ""; + l_text_1004 = "-"; + color l_color_1068 = STR_NO_Signal; + l_text_972 = "-"; + color l_color_1064 = STR_NO_Signal; + l_text_1012 = "-"; + color l_color_1060 = STR_NO_Signal; + l_text_980 = "-"; + color l_color_1056 = STR_NO_Signal; + l_text_988 = "-"; + color l_color_1052 = STR_NO_Signal; + l_text_996 = "-"; + color l_color_1048 = STR_NO_Signal; + if (Switch_STR_to_RSI == FALSE) { + if (l_irsi_732 > 50.0 && l_istochastic_780 > 40.0 && l_icci_828 > 0.0) { + l_text_1004 = "-"; + l_color_1068 = STR_UP; + ld_204 = 1; + ld_348 = 0; + } + if (l_irsi_740 > 50.0 && l_istochastic_788 > 40.0 && l_icci_836 > 0.0) { + l_text_972 = "-"; + l_color_1064 = STR_UP; + ld_212 = 1; + ld_356 = 0; + } + if (l_irsi_748 > 50.0 && l_istochastic_796 > 40.0 && l_icci_844 > 0.0) { + l_text_1012 = "-"; + l_color_1060 = STR_UP; + ld_220 = 1; + ld_364 = 0; + } + if (l_irsi_756 > 50.0 && l_istochastic_804 > 40.0 && l_icci_852 > 0.0) { + l_text_980 = "-"; + l_color_1056 = STR_UP; + ld_228 = 1; + ld_372 = 0; + } + if (l_irsi_764 > 50.0 && l_istochastic_812 > 40.0 && l_icci_860 > 0.0) { + l_text_988 = "-"; + l_color_1052 = STR_UP; + ld_236 = 1; + ld_380 = 0; + } + if (l_irsi_772 > 50.0 && l_istochastic_820 > 40.0 && l_icci_868 > 0.0) { + l_text_996 = "-"; + l_color_1048 = STR_UP; + ld_244 = 1; + ld_388 = 0; + } + if (l_irsi_732 < 50.0 && l_istochastic_780 < 60.0 && l_icci_828 < 0.0) { + l_text_1004 = "-"; + l_color_1068 = STR_DN; + ld_204 = 0; + ld_348 = 1; + } + if (l_irsi_740 < 50.0 && l_istochastic_788 < 60.0 && l_icci_836 < 0.0) { + l_text_972 = "-"; + l_color_1064 = STR_DN; + ld_212 = 0; + ld_356 = 1; + } + if (l_irsi_748 < 50.0 && l_istochastic_796 < 60.0 && l_icci_844 < 0.0) { + l_text_1012 = "-"; + l_color_1060 = STR_DN; + ld_220 = 0; + ld_364 = 1; + } + if (l_irsi_756 < 50.0 && l_istochastic_804 < 60.0 && l_icci_852 < 0.0) { + l_text_980 = "-"; + l_color_1056 = STR_DN; + ld_228 = 0; + ld_372 = 1; + } + if (l_irsi_764 < 50.0 && l_istochastic_812 < 60.0 && l_icci_860 < 0.0) { + l_text_988 = "-"; + l_color_1052 = STR_DN; + ld_236 = 0; + ld_380 = 1; + } + if (l_irsi_772 < 50.0 && l_istochastic_820 < 60.0 && l_icci_868 < 0.0) { + l_text_996 = "-"; + l_color_1048 = STR_DN; + ld_244 = 0; + ld_388 = 1; + } + } + if (Switch_STR_to_RSI == TRUE) { + if (l_irsi_732 > 50.0 && l_irsi_876 > 50.0 && l_irsi_924 > 50.0) { + l_text_1004 = "-"; + l_color_1068 = STR_UP; + ld_204 = 1; + ld_348 = 0; + } + if (l_irsi_740 > 50.0 && l_irsi_884 > 50.0 && l_irsi_932 > 50.0) { + l_text_972 = "-"; + l_color_1064 = STR_UP; + ld_212 = 1; + ld_356 = 0; + } + if (l_irsi_748 > 50.0 && l_irsi_892 > 50.0 && l_irsi_940 > 50.0) { + l_text_1012 = "-"; + l_color_1060 = STR_UP; + ld_220 = 1; + ld_364 = 0; + } + if (l_irsi_756 > 50.0 && l_irsi_900 > 50.0 && l_irsi_948 > 50.0) { + l_text_980 = "-"; + l_color_1056 = STR_UP; + ld_228 = 1; + ld_372 = 0; + } + if (l_irsi_764 > 50.0 && l_irsi_908 > 50.0 && l_irsi_956 > 50.0) { + l_text_988 = "-"; + l_color_1052 = STR_UP; + ld_236 = 1; + ld_380 = 0; + } + if (l_irsi_772 > 50.0 && l_irsi_916 > 50.0 && l_irsi_964 > 50.0) { + l_text_996 = "-"; + l_color_1048 = STR_UP; + ld_244 = 1; + ld_388 = 0; + } + if (l_irsi_732 <= 50.0 && l_irsi_876 < 50.0 && l_irsi_924 < 50.0) { + l_text_1004 = "-"; + l_color_1068 = STR_DN; + ld_204 = 0; + ld_348 = 1; + } + if (l_irsi_740 <= 50.0 && l_irsi_884 < 50.0 && l_irsi_932 < 50.0) { + l_text_972 = "-"; + l_color_1064 = STR_DN; + ld_212 = 0; + ld_356 = 1; + } + if (l_irsi_748 <= 50.0 && l_irsi_892 < 50.0 && l_irsi_940 < 50.0) { + l_text_1012 = "-"; + l_color_1060 = STR_DN; + ld_220 = 0; + ld_364 = 1; + } + if (l_irsi_756 <= 50.0 && l_irsi_900 < 50.0 && l_irsi_948 < 50.0) { + l_text_980 = "-"; + l_color_1056 = STR_DN; + ld_228 = 0; + ld_372 = 1; + } + if (l_irsi_764 <= 50.0 && l_irsi_908 < 50.0 && l_irsi_956 < 50.0) { + l_text_988 = "-"; + l_color_1052 = STR_DN; + ld_236 = 0; + ld_380 = 1; + } + if (l_irsi_772 <= 50.0 && l_irsi_916 < 50.0 && l_irsi_964 < 50.0) { + l_text_996 = "-"; + l_color_1048 = STR_DN; + ld_244 = 0; + ld_388 = 1; + } + } + if (Show_Smaller_Size == FALSE) { + li_1084 = 135; + li_1140 = 43; + l_fontsize_1136 = 6; + li_1088 = 110; + li_1144 = 10; + l_fontsize_1132 = 45; + li_1092 = 90; + li_1148 = 10; + l_fontsize_1132 = 45; + li_1096 = 70; + li_1152 = 10; + l_fontsize_1132 = 45; + li_1100 = 50; + li_1156 = 10; + l_fontsize_1132 = 45; + li_1104 = 30; + li_1160 = 10; + l_fontsize_1132 = 45; + li_1108 = 10; + li_1164 = 10; + l_fontsize_1132 = 45; + if (No_of_TFs >= 1) { + li_1108 = 10; + li_1084 = 82; + li_1120 = 26; + li_1124 = 42; + li_1128 = 58; + } + if (No_of_TFs >= 2) { + li_1104 = 60; + li_1108 = 10; + li_1084 = 85; + li_1116 = 45; + li_1120 = 25; + } + if (No_of_TFs >= 3) { + li_1100 = 66; + li_1104 = 38; + li_1108 = 10; + li_1084 = 97; + li_1112 = 74; + li_1116 = 46; + li_1120 = 18; + } + if (No_of_TFs >= 4) { + li_1100 = 50; + li_1104 = 30; + li_1108 = 10; + li_1084 = 95; + li_1112 = 50; + li_1116 = 30; + li_1120 = 10; + } + if (No_of_TFs >= 5) li_1084 = 115; + if (No_of_TFs >= 6) li_1084 = 135; + } + if (Show_Smaller_Size == TRUE) { + li_1084 = 120; + li_1140 = 43; + l_fontsize_1136 = 6; + li_1088 = 100; + li_1144 = 13; + l_fontsize_1132 = 40; + li_1092 = 82; + li_1148 = 13; + l_fontsize_1132 = 40; + li_1096 = 64; + li_1152 = 13; + l_fontsize_1132 = 40; + li_1100 = 46; + li_1156 = 13; + l_fontsize_1132 = 40; + li_1104 = 28; + li_1160 = 13; + l_fontsize_1132 = 40; + li_1108 = 10; + li_1164 = 13; + l_fontsize_1132 = 40; + if (No_of_TFs >= 1) { + li_1108 = 10; + li_1084 = 82; + li_1120 = 25; + li_1124 = 40; + li_1128 = 55; + } + if (No_of_TFs >= 2) { + li_1104 = 58; + li_1108 = 10; + li_1084 = 85; + li_1116 = 43; + li_1120 = 25; + } + if (No_of_TFs >= 3) { + li_1100 = 58; + li_1104 = 33; + li_1108 = 10; + li_1084 = 85; + li_1112 = 63; + li_1116 = 40; + li_1120 = 15; + } + if (No_of_TFs >= 4) { + li_1100 = 46; + li_1104 = 28; + li_1108 = 10; + li_1084 = 85; + li_1112 = 46; + li_1116 = 28; + li_1120 = 10; + } + if (No_of_TFs >= 5) li_1084 = 103; + if (No_of_TFs >= 6) li_1084 = 120; + } + if (Show_Indicator_Bars) { + if (No_of_TFs >= 3) { + ObjectDelete("SignalSTRM30tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRM30tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRM30tf" + SIGBARS_Multi_No + "", l_text_1012, l_fontsize_1132, "Tahoma Narrow", l_color_1060); + ObjectSet("SignalSTRM30tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM30tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1112 + Adjust_Side_to_side); + ObjectSet("SignalSTRM30tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1156 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SignalSTRH1tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH1tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH1tf" + SIGBARS_Multi_No + "", l_text_972, l_fontsize_1132, "Tahoma Narrow", l_color_1064); + ObjectSet("SignalSTRH1tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH1tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1116 + Adjust_Side_to_side); + ObjectSet("SignalSTRH1tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1160 + Shift_UP_DN); + } + ObjectDelete("SignalSTRH4tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH4tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH4tf" + SIGBARS_Multi_No + "", l_text_1004, l_fontsize_1132, "Tahoma Narrow", l_color_1068); + ObjectSet("SignalSTRH4tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH4tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1120 + Adjust_Side_to_side); + ObjectSet("SignalSTRH4tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1164 + Shift_UP_DN); + if (No_of_TFs < 2) { + ObjectDelete("SignalSTRH4tfx" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH4tfx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH4tfx" + SIGBARS_Multi_No + "", l_text_1004, l_fontsize_1132, "Tahoma Narrow", l_color_1068); + ObjectSet("SignalSTRH4tfx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH4tfx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1124 + Adjust_Side_to_side); + ObjectSet("SignalSTRH4tfx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1164 + Shift_UP_DN); + ObjectDelete("SignalSTRH4tfxx" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH4tfxx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH4tfxx" + SIGBARS_Multi_No + "", l_text_1004, l_fontsize_1132, "Tahoma Narrow", l_color_1068); + ObjectSet("SignalSTRH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1128 + Adjust_Side_to_side); + ObjectSet("SignalSTRH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1164 + Shift_UP_DN); + } + ObjectDelete("SignalSTR_TEXT" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTR_TEXT" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + if (Switch_STR_to_RSI == FALSE) ObjectSetText("SignalSTR_TEXT" + SIGBARS_Multi_No + "", "STR", l_fontsize_1136, "Tahoma Narrow", BarLabel_color); + else ObjectSetText("SignalSTR_TEXT" + SIGBARS_Multi_No + "", "RSI", l_fontsize_1136, "Tahoma Narrow", BarLabel_color); + ObjectSet("SignalSTR_TEXT" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTR_TEXT" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1084 + Adjust_Side_to_side); + ObjectSet("SignalSTR_TEXT" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1140 + Shift_UP_DN); + if (No_of_TFs >= 6) { + ObjectDelete("SignalSTRM1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRM1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRM1" + SIGBARS_Multi_No + "", l_text_996, l_fontsize_1132, "Tahoma Narrow", l_color_1048); + ObjectSet("SignalSTRM1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1088 + Adjust_Side_to_side); + ObjectSet("SignalSTRM1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1144 + Shift_UP_DN); + } + if (No_of_TFs >= 5) { + ObjectDelete("SignalSTRM5" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRM5" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRM5" + SIGBARS_Multi_No + "", l_text_988, l_fontsize_1132, "Tahoma Narrow", l_color_1052); + ObjectSet("SignalSTRM5" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM5" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1092 + Adjust_Side_to_side); + ObjectSet("SignalSTRM5" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1148 + Shift_UP_DN); + } + if (No_of_TFs >= 4) { + ObjectDelete("SignalSTRM15" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRM15" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRM15" + SIGBARS_Multi_No + "", l_text_980, l_fontsize_1132, "Tahoma Narrow", l_color_1056); + ObjectSet("SignalSTRM15" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM15" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1096 + Adjust_Side_to_side); + ObjectSet("SignalSTRM15" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1152 + Shift_UP_DN); + } + if (No_of_TFs >= 3) { + ObjectDelete("SignalSTRM30" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRM30" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRM30" + SIGBARS_Multi_No + "", l_text_1012, l_fontsize_1132, "Tahoma Narrow", l_color_1060); + ObjectSet("SignalSTRM30" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM30" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1100 + Adjust_Side_to_side); + ObjectSet("SignalSTRM30" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1156 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SignalSTRH1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH1" + SIGBARS_Multi_No + "", l_text_972, l_fontsize_1132, "Tahoma Narrow", l_color_1064); + ObjectSet("SignalSTRH1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1104 + Adjust_Side_to_side); + ObjectSet("SignalSTRH1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1160 + Shift_UP_DN); + } + if (No_of_TFs >= 1) { + ObjectDelete("SignalSTRH4" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalSTRH4" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalSTRH4" + SIGBARS_Multi_No + "", l_text_1004, l_fontsize_1132, "Tahoma Narrow", l_color_1068); + ObjectSet("SignalSTRH4" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRH4" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1108 + Adjust_Side_to_side); + ObjectSet("SignalSTRH4" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1164 + Shift_UP_DN); + } + } + double l_ima_1168 = iMA(symbol, TF1, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1176 = iMA(symbol, TF1, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1184 = iMA(symbol, TF2, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1192 = iMA(symbol, TF2, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1200 = iMA(symbol, TF3, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1208 = iMA(symbol, TF3, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1216 = iMA(symbol, TF4, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1224 = iMA(symbol, TF4, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1232 = iMA(symbol, TF5, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1240 = iMA(symbol, TF5, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1248 = iMA(symbol, TF6, MA_Fast, 0, MA_MODE, MA_PRICE_TYPE, 0); + double l_ima_1256 = iMA(symbol, TF6, MA_Slow, 0, MA_MODE, MA_PRICE_TYPE, 0); + string l_text_1264 = ""; + string l_text_1272 = ""; + string l_text_1280 = ""; + string l_text_1288 = ""; + string l_text_1296 = ""; + string l_text_1304 = ""; + string ls_unused_1312 = ""; + string ls_unused_1320 = ""; + string ls_unused_1328 = ""; + if (l_ima_1168 > l_ima_1176) { + l_text_1264 = "-"; + l_color_1344 = MA_UP; + ld_252 = 1; + ld_396 = 0; + } + if (l_ima_1168 <= l_ima_1176) { + l_text_1264 = "-"; + l_color_1344 = MA_DN; + ld_252 = 0; + ld_396 = 1; + } + if (l_ima_1184 > l_ima_1192) { + l_text_1272 = "-"; + l_color_1348 = MA_UP; + ld_260 = 1; + ld_404 = 0; + } + if (l_ima_1184 <= l_ima_1192) { + l_text_1272 = "-"; + l_color_1348 = MA_DN; + ld_260 = 0; + ld_404 = 1; + } + if (l_ima_1200 > l_ima_1208) { + l_text_1280 = "-"; + l_color_1352 = MA_UP; + ld_268 = 1; + ld_412 = 0; + } + if (l_ima_1200 <= l_ima_1208) { + l_text_1280 = "-"; + l_color_1352 = MA_DN; + ld_268 = 0; + ld_412 = 1; + } + if (l_ima_1216 > l_ima_1224) { + l_text_1288 = "-"; + l_color_1356 = MA_UP; + ld_276 = 1; + ld_420 = 0; + } + if (l_ima_1216 <= l_ima_1224) { + l_text_1288 = "-"; + l_color_1356 = MA_DN; + ld_276 = 0; + ld_420 = 1; + } + if (l_ima_1232 > l_ima_1240) { + l_text_1296 = "-"; + l_color_1360 = MA_UP; + ld_284 = 1; + ld_428 = 0; + } + if (l_ima_1232 <= l_ima_1240) { + l_text_1296 = "-"; + l_color_1360 = MA_DN; + ld_284 = 0; + ld_428 = 1; + } + if (l_ima_1248 > l_ima_1256) { + l_text_1304 = "-"; + l_color_1364 = MA_UP; + ld_292 = 1; + ld_436 = 0; + } + if (l_ima_1248 <= l_ima_1256) { + l_text_1304 = "-"; + l_color_1364 = MA_DN; + ld_292 = 0; + ld_436 = 1; + } + if (Show_Smaller_Size == FALSE) { + li_1380 = 135; + li_1436 = 51; + l_fontsize_1432 = 6; + li_1384 = 110; + li_1440 = 18; + l_fontsize_1428 = 45; + li_1388 = 90; + li_1444 = 18; + l_fontsize_1428 = 45; + li_1392 = 70; + li_1448 = 18; + l_fontsize_1428 = 45; + li_1396 = 50; + li_1452 = 18; + l_fontsize_1428 = 45; + li_1400 = 30; + li_1456 = 18; + l_fontsize_1428 = 45; + li_1404 = 10; + li_1460 = 18; + l_fontsize_1428 = 45; + if (No_of_TFs >= 1) { + li_1404 = 10; + li_1380 = 82; + li_1416 = 26; + li_1420 = 42; + li_1424 = 58; + } + if (No_of_TFs >= 2) { + li_1400 = 60; + li_1404 = 10; + li_1380 = 85; + li_1412 = 45; + li_1416 = 25; + } + if (No_of_TFs >= 3) { + li_1396 = 66; + li_1400 = 38; + li_1404 = 10; + li_1380 = 97; + li_1408 = 74; + li_1412 = 46; + li_1416 = 18; + } + if (No_of_TFs >= 4) { + li_1396 = 50; + li_1400 = 30; + li_1404 = 10; + li_1380 = 95; + li_1408 = 50; + li_1412 = 30; + li_1416 = 10; + } + if (No_of_TFs >= 5) li_1380 = 115; + if (No_of_TFs >= 6) li_1380 = 135; + } + if (Show_Smaller_Size == TRUE) { + li_1380 = 120; + li_1436 = 51; + l_fontsize_1432 = 6; + li_1384 = 100; + li_1440 = 20; + l_fontsize_1428 = 40; + li_1388 = 82; + li_1444 = 20; + l_fontsize_1428 = 40; + li_1392 = 64; + li_1448 = 20; + l_fontsize_1428 = 40; + li_1396 = 46; + li_1452 = 20; + l_fontsize_1428 = 40; + li_1400 = 28; + li_1456 = 20; + l_fontsize_1428 = 40; + li_1404 = 10; + li_1460 = 20; + l_fontsize_1428 = 40; + if (No_of_TFs >= 1) { + li_1404 = 10; + li_1380 = 82; + li_1416 = 25; + li_1420 = 40; + li_1424 = 55; + } + if (No_of_TFs >= 2) { + li_1400 = 58; + li_1404 = 10; + li_1380 = 85; + li_1412 = 43; + li_1416 = 25; + } + if (No_of_TFs >= 3) { + li_1396 = 58; + li_1400 = 33; + li_1404 = 10; + li_1380 = 85; + li_1408 = 63; + li_1412 = 40; + li_1416 = 15; + } + if (No_of_TFs >= 4) { + li_1396 = 46; + li_1400 = 28; + li_1404 = 10; + li_1380 = 85; + li_1408 = 46; + li_1412 = 28; + li_1416 = 10; + } + if (No_of_TFs >= 5) li_1380 = 103; + if (No_of_TFs >= 6) li_1380 = 120; + } + if (Show_Indicator_Bars) { + if (No_of_TFs >= 3) { + ObjectDelete("SignalEMAM30tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAM30tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAM30tf" + SIGBARS_Multi_No + "", l_text_1288, l_fontsize_1428, "Tahoma Narrow", l_color_1356); + ObjectSet("SignalEMAM30tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM30tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1408 + Adjust_Side_to_side); + ObjectSet("SignalEMAM30tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1452 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SignalEMAH1tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH1tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH1tf" + SIGBARS_Multi_No + "", l_text_1296, l_fontsize_1428, "Tahoma Narrow", l_color_1360); + ObjectSet("SignalEMAH1tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH1tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1412 + Adjust_Side_to_side); + ObjectSet("SignalEMAH1tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1456 + Shift_UP_DN); + } + ObjectDelete("SignalEMAH4tf" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH4tf" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH4tf" + SIGBARS_Multi_No + "", l_text_1304, l_fontsize_1428, "Tahoma Narrow", l_color_1364); + ObjectSet("SignalEMAH4tf" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH4tf" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1416 + Adjust_Side_to_side); + ObjectSet("SignalEMAH4tf" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1460 + Shift_UP_DN); + if (No_of_TFs < 2) { + ObjectDelete("SignalEMAH4tfx" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH4tfx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH4tfx" + SIGBARS_Multi_No + "", l_text_1304, l_fontsize_1428, "Tahoma Narrow", l_color_1364); + ObjectSet("SignalEMAH4tfx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH4tfx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1420 + Adjust_Side_to_side); + ObjectSet("SignalEMAH4tfx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1460 + Shift_UP_DN); + ObjectDelete("SignalEMAH4tfxx" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH4tfxx" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH4tfxx" + SIGBARS_Multi_No + "", l_text_1304, l_fontsize_1428, "Tahoma Narrow", l_color_1364); + ObjectSet("SignalEMAH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1424 + Adjust_Side_to_side); + ObjectSet("SignalEMAH4tfxx" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1460 + Shift_UP_DN); + } + ObjectDelete("SignalEMA_TEXT" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMA_TEXT" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMA_TEXT" + SIGBARS_Multi_No + "", "EMA", l_fontsize_1432, "Tahoma Narrow", BarLabel_color); + ObjectSet("SignalEMA_TEXT" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMA_TEXT" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1380 + Adjust_Side_to_side); + ObjectSet("SignalEMA_TEXT" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1436 + Shift_UP_DN); + if (No_of_TFs >= 6) { + ObjectDelete("SignalEMAM1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAM1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAM1" + SIGBARS_Multi_No + "", l_text_1264, l_fontsize_1428, "Tahoma Narrow", l_color_1344); + ObjectSet("SignalEMAM1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1384 + Adjust_Side_to_side); + ObjectSet("SignalEMAM1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1440 + Shift_UP_DN); + } + if (No_of_TFs >= 5) { + ObjectDelete("SignalEMAM5" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAM5" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAM5" + SIGBARS_Multi_No + "", l_text_1272, l_fontsize_1428, "Tahoma Narrow", l_color_1348); + ObjectSet("SignalEMAM5" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM5" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1388 + Adjust_Side_to_side); + ObjectSet("SignalEMAM5" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1444 + Shift_UP_DN); + } + if (No_of_TFs >= 4) { + ObjectDelete("SignalEMAM15" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAM15" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAM15" + SIGBARS_Multi_No + "", l_text_1280, l_fontsize_1428, "Tahoma Narrow", l_color_1352); + ObjectSet("SignalEMAM15" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM15" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1392 + Adjust_Side_to_side); + ObjectSet("SignalEMAM15" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1448 + Shift_UP_DN); + } + if (No_of_TFs >= 3) { + ObjectDelete("SignalEMAM30" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAM30" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAM30" + SIGBARS_Multi_No + "", l_text_1288, l_fontsize_1428, "Tahoma Narrow", l_color_1356); + ObjectSet("SignalEMAM30" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM30" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1396 + Adjust_Side_to_side); + ObjectSet("SignalEMAM30" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1452 + Shift_UP_DN); + } + if (No_of_TFs >= 2) { + ObjectDelete("SignalEMAH1" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH1" + SIGBARS_Multi_No + "", l_text_1296, l_fontsize_1428, "Tahoma Narrow", l_color_1360); + ObjectSet("SignalEMAH1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1400 + Adjust_Side_to_side); + ObjectSet("SignalEMAH1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1456 + Shift_UP_DN); + } + if (No_of_TFs >= 1) { + ObjectDelete("SignalEMAH4" + SIGBARS_Multi_No + ""); + ObjectCreate("SignalEMAH4" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SignalEMAH4" + SIGBARS_Multi_No + "", l_text_1304, l_fontsize_1428, "Tahoma Narrow", l_color_1364); + ObjectSet("SignalEMAH4" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAH4" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_1404 + Adjust_Side_to_side); + ObjectSet("SignalEMAH4" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_1460 + Shift_UP_DN); + } + } + double ld_1468 = ld_156 + ld_164 + ld_172 + ld_180 + ld_188 + ld_196 + ld_204 + ld_212 + ld_220 + ld_228 + ld_236 + ld_244 + ld_252 + ld_260 + ld_268 + ld_276 + ld_284 + + ld_292; + double ld_1476 = ld_300 + ld_308 + ld_316 + ld_324 + ld_332 + ld_340 + ld_348 + ld_356 + ld_364 + ld_372 + ld_380 + ld_388 + ld_396 + ld_404 + ld_412 + ld_420 + ld_428 + + ld_436; + if (No_of_TFs == 6) { + li_1464 = 18; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + ld_1468 = ld_164 + ld_236 + ld_260 + ld_172 + ld_228 + ld_268 + ld_180 + ld_220 + ld_276 + ld_188 + ld_212 + ld_284 + ld_196 + ld_204 + ld_292; + ld_1476 = ld_308 + ld_380 + ld_404 + ld_316 + ld_372 + ld_412 + ld_324 + ld_364 + ld_420 + ld_332 + ld_356 + ld_428 + ld_340 + ld_348 + ld_436; + if (No_of_TFs == 5) { + li_1464 = 15; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + ld_1468 = ld_172 + ld_228 + ld_268 + ld_180 + ld_220 + ld_276 + ld_188 + ld_212 + ld_284 + ld_196 + ld_204 + ld_292; + ld_1476 = ld_316 + ld_372 + ld_412 + ld_324 + ld_364 + ld_420 + ld_332 + ld_356 + ld_428 + ld_340 + ld_348 + ld_436; + if (No_of_TFs == 4) { + li_1464 = 12; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + ld_1468 = ld_180 + ld_220 + ld_276 + ld_188 + ld_212 + ld_284 + ld_196 + ld_204 + ld_292; + ld_1476 = ld_324 + ld_364 + ld_340 + ld_332 + ld_356 + ld_428 + ld_340 + ld_348 + ld_436; + if (No_of_TFs == 3) { + li_1464 = 9; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + ld_1468 = ld_188 + ld_212 + ld_284 + ld_196 + ld_204 + ld_292; + ld_1476 = ld_332 + ld_356 + ld_428 + ld_340 + ld_348 + ld_436; + if (No_of_TFs == 2) { + li_1464 = 6; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + ld_1468 = ld_196 + ld_204 + ld_292; + ld_1476 = ld_340 + ld_348 + ld_436; + if (No_of_TFs == 1) { + li_1464 = 3; + l_dbl2str_1484 = DoubleToStr(100.0 * (ld_1468 / li_1464), 0); + l_dbl2str_1492 = DoubleToStr(100 - StrToDouble(l_dbl2str_1484), 0); + } + string ls_unused_1500 = ""; + if (POPUP_Alert_ON) { + if (StrToDouble(l_dbl2str_1484) > AlertLevel) + if (BarChanged()) Alert("" + symbol + " : Signal Bars - Alert Level " + AlertLevel + "% UP TREND @ " + l_dbl2str_1484 + "%"); + if (StrToDouble(l_dbl2str_1492) > AlertLevel) + if (BarChanged()) Alert("" + symbol + " : Signal Bars - Alert Level " + AlertLevel + "% DN TREND @ " + l_dbl2str_1492 + "%"); + } + if (Sound_Limited_Alert_ON == TRUE) { + if (StrToDouble(l_dbl2str_1484) > AlertLevel) + if (BarChanged()) PlaySound("alert2"); + if (StrToDouble(l_dbl2str_1492) > AlertLevel) + if (BarChanged()) PlaySound("alert2"); + } + if (Sound_Constant_Alert_ON == TRUE) { + if (StrToDouble(l_dbl2str_1484) >= AlertLevel) PlaySound("alert"); + if (StrToDouble(l_dbl2str_1492) >= AlertLevel) PlaySound("alert"); + } + if (Show_Visual_Alert) { + l_color_1508 = Alert_col_NEUTRAL; + l_color_1512 = Alert_col_NEUTRAL; + if (StrToDouble(l_dbl2str_1484) > AlertLevel) l_color_1508 = Alert_col_UP; + if (StrToDouble(l_dbl2str_1492) > AlertLevel) l_color_1512 = Alert_col_DN; + if (Show_Smaller_Size == TRUE) li_1516 = 140; + if (Show_Smaller_Size == TRUE) li_1520 = 68; + if (Show_Smaller_Size == TRUE) l_fontsize_1524 = 9; + if (Show_Smaller_Size == FALSE) li_1516 = 160; + if (Show_Smaller_Size == FALSE) li_1520 = 70; + if (Show_Smaller_Size == FALSE) l_fontsize_1524 = 11; + if (Show_Xtra_Details == FALSE) li_1516 = 105; + if (Show_Xtra_Details == FALSE && Show_Smaller_Size == TRUE) li_1516 = 85; + if (Show_Xtra_Details == FALSE && Show_Price == FALSE && Show_Smaller_Size == TRUE) li_1516 = 60; + if (Show_Xtra_Details == TRUE && Show_Price == FALSE && Show_Smaller_Size == TRUE) li_1516 = 120; + if (Show_Xtra_Details == FALSE && Show_Smaller_Size == FALSE) li_1516 = 97; + if (Show_Xtra_Details == FALSE && Show_Price == FALSE && Show_Smaller_Size == FALSE) li_1516 = 62; + if (Show_Xtra_Details == TRUE && Show_Price == FALSE && Show_Smaller_Size == FALSE) li_1516 = 125; + if (Show_Indicator_Bars == FALSE) li_1528 = -30; + ObjectDelete("SigAlert" + SIGBARS_Multi_No); + ObjectCreate("SigAlert" + SIGBARS_Multi_No, OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SigAlert" + SIGBARS_Multi_No, "UP " + l_dbl2str_1484 + "%", l_fontsize_1524, "Arial Bold", l_color_1508); + ObjectSet("SigAlert" + SIGBARS_Multi_No, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SigAlert" + SIGBARS_Multi_No, OBJPROP_XDISTANCE, Adjust_Side_to_side + 10); + ObjectSet("SigAlert" + SIGBARS_Multi_No, OBJPROP_YDISTANCE, li_1516 + Shift_UP_DN + li_1528); + ObjectDelete("SigAlert1" + SIGBARS_Multi_No); + ObjectCreate("SigAlert1" + SIGBARS_Multi_No, OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SigAlert1" + SIGBARS_Multi_No, "DN " + l_dbl2str_1492 + "%", l_fontsize_1524, "Arial Bold", l_color_1512); + ObjectSet("SigAlert1" + SIGBARS_Multi_No, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SigAlert1" + SIGBARS_Multi_No, OBJPROP_XDISTANCE, li_1520 + Adjust_Side_to_side); + ObjectSet("SigAlert1" + SIGBARS_Multi_No, OBJPROP_YDISTANCE, li_1516 + Shift_UP_DN + li_1528); + } + if (Show_Header) { + if (Show_Smaller_Size == FALSE) { + ObjectDelete("Signalcurr" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalcurr" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalcurr" + SIGBARS_Multi_No + "", "Signal Bars " + symbol, 11, "Tahoma", Title_Color); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 12); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 7); + if (Show_Indicator_Bars == FALSE) { + ObjectDelete("Signalcurr" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalcurr" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalcurr" + SIGBARS_Multi_No + "", "Signal Bars " + symbol, 11, "Tahoma", Title_Color); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 12); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 43 + li_1528); + } + } + if (Show_Smaller_Size == TRUE) { + ObjectDelete("Signalcurr" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalcurr" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalcurr" + SIGBARS_Multi_No + "", "Signal Bars " + symbol, 9, "Tahoma", Title_Color); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 12); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 12); + if (Show_Indicator_Bars == FALSE) { + ObjectDelete("Signalcurr" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalcurr" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalcurr" + SIGBARS_Multi_No + "", "Signal Bars " + symbol, 9, "Tahoma", Title_Color); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 12); + ObjectSet("Signalcurr" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 44 + li_1528); + } + } + } + if (Digit_Switch == TRUE) { + if (StringFind(symbol, "JPY", 0) != -1) { + gi_588 = 3; + gi_584 = 100; + gi_580 = 3; + } else { + gi_588 = 5; + gi_584 = 10000; + gi_580 = 5; + } + } + if (Digit_Switch == FALSE) { + if (StringFind(symbol, "JPY", 0) != -1) { + gi_588 = 2; + gi_584 = 100; + gi_580 = 2; + } else { + gi_588 = 4; + gi_584 = 10000; + gi_580 = 4; + } + } + double ld_1532 = NormalizeDouble(MarketInfo(symbol, MODE_BID), gi_580); + double l_ima_1540 = iMA(symbol, PERIOD_M1, 1, 0, MODE_EMA, PRICE_CLOSE, 1); + string ls_unused_1548 = ""; + if (l_ima_1540 > ld_1532) l_color_1556 = Price_DN; + if (l_ima_1540 < ld_1532) l_color_1556 = Price_UP; + if (l_ima_1540 == ld_1532) l_color_1556 = Price_Neutral; + double ld_1560 = iHigh(symbol, PERIOD_D1, 1) - iLow(symbol, PERIOD_D1, 1); + double ld_1568 = iHigh(symbol, PERIOD_D1, 2) - iLow(symbol, PERIOD_D1, 2); + double ld_1576 = iHigh(symbol, PERIOD_D1, 3) - iLow(symbol, PERIOD_D1, 3); + double ld_1584 = iHigh(symbol, PERIOD_D1, 4) - iLow(symbol, PERIOD_D1, 4); + double ld_1592 = iHigh(symbol, PERIOD_D1, 5) - iLow(symbol, PERIOD_D1, 5); + double ld_1600 = iHigh(symbol, PERIOD_D1, 6) - iLow(symbol, PERIOD_D1, 6); + double ld_1608 = iHigh(symbol, PERIOD_D1, 7) - iLow(symbol, PERIOD_D1, 7); + double ld_1616 = iHigh(symbol, PERIOD_D1, 8) - iLow(symbol, PERIOD_D1, 8); + double ld_1624 = iHigh(symbol, PERIOD_D1, 9) - iLow(symbol, PERIOD_D1, 9); + double ld_1632 = iHigh(symbol, PERIOD_D1, 10) - iLow(symbol, PERIOD_D1, 10); + double ld_1640 = iHigh(symbol, PERIOD_D1, 11) - iLow(symbol, PERIOD_D1, 11); + double ld_1648 = iHigh(symbol, PERIOD_D1, 12) - iLow(symbol, PERIOD_D1, 12); + double ld_1656 = iHigh(symbol, PERIOD_D1, 13) - iLow(symbol, PERIOD_D1, 13); + double ld_1664 = iHigh(symbol, PERIOD_D1, 14) - iLow(symbol, PERIOD_D1, 14); + double ld_1672 = iHigh(symbol, PERIOD_D1, 15) - iLow(symbol, PERIOD_D1, 15); + double ld_1680 = iHigh(symbol, PERIOD_D1, 16) - iLow(symbol, PERIOD_D1, 16); + double ld_1688 = iHigh(symbol, PERIOD_D1, 17) - iLow(symbol, PERIOD_D1, 17); + double ld_1696 = iHigh(symbol, PERIOD_D1, 18) - iLow(symbol, PERIOD_D1, 18); + double ld_1704 = iHigh(symbol, PERIOD_D1, 19) - iLow(symbol, PERIOD_D1, 19); + double ld_1712 = iHigh(symbol, PERIOD_D1, 20) - iLow(symbol, PERIOD_D1, 20); + double ld_1720 = iHigh(symbol, PERIOD_D1, 21) - iLow(symbol, PERIOD_D1, 21); + double ld_1728 = iHigh(symbol, PERIOD_D1, 22) - iLow(symbol, PERIOD_D1, 22); + double ld_1736 = iHigh(symbol, PERIOD_D1, 23) - iLow(symbol, PERIOD_D1, 23); + double ld_1744 = iHigh(symbol, PERIOD_D1, 24) - iLow(symbol, PERIOD_D1, 24); + double ld_1752 = iHigh(symbol, PERIOD_D1, 25) - iLow(symbol, PERIOD_D1, 25); + double ld_1760 = iHigh(symbol, PERIOD_D1, 26) - iLow(symbol, PERIOD_D1, 26); + double ld_1768 = iHigh(symbol, PERIOD_D1, 27) - iLow(symbol, PERIOD_D1, 27); + double ld_1776 = iHigh(symbol, PERIOD_D1, 28) - iLow(symbol, PERIOD_D1, 28); + double ld_1784 = iHigh(symbol, PERIOD_D1, 29) - iLow(symbol, PERIOD_D1, 29); + double ld_1792 = iHigh(symbol, PERIOD_D1, 30) - iLow(symbol, PERIOD_D1, 30); + double ld_1800 = iHigh(symbol, PERIOD_D1, 31) - iLow(symbol, PERIOD_D1, 31); + double ld_1808 = iHigh(symbol, PERIOD_D1, 32) - iLow(symbol, PERIOD_D1, 32); + double ld_1816 = iHigh(symbol, PERIOD_D1, 33) - iLow(symbol, PERIOD_D1, 33); + double ld_1824 = iHigh(symbol, PERIOD_D1, 34) - iLow(symbol, PERIOD_D1, 34); + double ld_1832 = iHigh(symbol, PERIOD_D1, 35) - iLow(symbol, PERIOD_D1, 35); + double ld_1840 = iHigh(symbol, PERIOD_D1, 36) - iLow(symbol, PERIOD_D1, 36); + double ld_1848 = iHigh(symbol, PERIOD_D1, 37) - iLow(symbol, PERIOD_D1, 37); + double ld_1856 = iHigh(symbol, PERIOD_D1, 38) - iLow(symbol, PERIOD_D1, 38); + double ld_1864 = iHigh(symbol, PERIOD_D1, 39) - iLow(symbol, PERIOD_D1, 39); + double ld_1872 = iHigh(symbol, PERIOD_D1, 40) - iLow(symbol, PERIOD_D1, 40); + double ld_1880 = iHigh(symbol, PERIOD_D1, 41) - iLow(symbol, PERIOD_D1, 41); + double ld_1888 = iHigh(symbol, PERIOD_D1, 42) - iLow(symbol, PERIOD_D1, 42); + double ld_1896 = iHigh(symbol, PERIOD_D1, 43) - iLow(symbol, PERIOD_D1, 43); + double ld_1904 = iHigh(symbol, PERIOD_D1, 44) - iLow(symbol, PERIOD_D1, 44); + double ld_1912 = iHigh(symbol, PERIOD_D1, 45) - iLow(symbol, PERIOD_D1, 45); + double ld_1920 = iHigh(symbol, PERIOD_D1, 46) - iLow(symbol, PERIOD_D1, 46); + double ld_1928 = iHigh(symbol, PERIOD_D1, 47) - iLow(symbol, PERIOD_D1, 47); + double ld_1936 = iHigh(symbol, PERIOD_D1, 48) - iLow(symbol, PERIOD_D1, 48); + double ld_1944 = iHigh(symbol, PERIOD_D1, 49) - iLow(symbol, PERIOD_D1, 49); + double ld_1952 = iHigh(symbol, PERIOD_D1, 50) - iLow(symbol, PERIOD_D1, 50); + double ld_1960 = iHigh(symbol, PERIOD_D1, 51) - iLow(symbol, PERIOD_D1, 51); + double ld_1968 = iHigh(symbol, PERIOD_D1, 52) - iLow(symbol, PERIOD_D1, 52); + double ld_1976 = iHigh(symbol, PERIOD_D1, 53) - iLow(symbol, PERIOD_D1, 53); + double ld_1984 = iHigh(symbol, PERIOD_D1, 54) - iLow(symbol, PERIOD_D1, 54); + double ld_1992 = iHigh(symbol, PERIOD_D1, 55) - iLow(symbol, PERIOD_D1, 55); + double ld_2000 = iHigh(symbol, PERIOD_D1, 56) - iLow(symbol, PERIOD_D1, 56); + double ld_2008 = iHigh(symbol, PERIOD_D1, 57) - iLow(symbol, PERIOD_D1, 57); + double ld_2016 = iHigh(symbol, PERIOD_D1, 58) - iLow(symbol, PERIOD_D1, 58); + double ld_2024 = iHigh(symbol, PERIOD_D1, 59) - iLow(symbol, PERIOD_D1, 59); + double ld_2032 = iHigh(symbol, PERIOD_D1, 60) - iLow(symbol, PERIOD_D1, 60); + double ld_2040 = iHigh(symbol, PERIOD_D1, 61) - iLow(symbol, PERIOD_D1, 61); + double ld_2048 = iHigh(symbol, PERIOD_D1, 62) - iLow(symbol, PERIOD_D1, 62); + double ld_2056 = iHigh(symbol, PERIOD_D1, 63) - iLow(symbol, PERIOD_D1, 63); + double ld_2064 = iHigh(symbol, PERIOD_D1, 64) - iLow(symbol, PERIOD_D1, 64); + double ld_2072 = iHigh(symbol, PERIOD_D1, 65) - iLow(symbol, PERIOD_D1, 65); + double ld_2080 = iHigh(symbol, PERIOD_D1, 66) - iLow(symbol, PERIOD_D1, 66); + double ld_2088 = iHigh(symbol, PERIOD_D1, 67) - iLow(symbol, PERIOD_D1, 67); + double ld_2096 = iHigh(symbol, PERIOD_D1, 68) - iLow(symbol, PERIOD_D1, 68); + double ld_2104 = iHigh(symbol, PERIOD_D1, 69) - iLow(symbol, PERIOD_D1, 69); + double ld_2112 = iHigh(symbol, PERIOD_D1, 70) - iLow(symbol, PERIOD_D1, 70); + double ld_2120 = iHigh(symbol, PERIOD_D1, 71) - iLow(symbol, PERIOD_D1, 71); + double ld_2128 = iHigh(symbol, PERIOD_D1, 72) - iLow(symbol, PERIOD_D1, 72); + double ld_2136 = iHigh(symbol, PERIOD_D1, 73) - iLow(symbol, PERIOD_D1, 73); + double ld_2144 = iHigh(symbol, PERIOD_D1, 74) - iLow(symbol, PERIOD_D1, 74); + double ld_2152 = iHigh(symbol, PERIOD_D1, 75) - iLow(symbol, PERIOD_D1, 75); + double ld_2160 = iHigh(symbol, PERIOD_D1, 76) - iLow(symbol, PERIOD_D1, 76); + double ld_2168 = iHigh(symbol, PERIOD_D1, 77) - iLow(symbol, PERIOD_D1, 77); + double ld_2176 = iHigh(symbol, PERIOD_D1, 78) - iLow(symbol, PERIOD_D1, 78); + double ld_2184 = iHigh(symbol, PERIOD_D1, 79) - iLow(symbol, PERIOD_D1, 79); + double ld_2192 = iHigh(symbol, PERIOD_D1, 80) - iLow(symbol, PERIOD_D1, 80); + double ld_2200 = iHigh(symbol, PERIOD_D1, 81) - iLow(symbol, PERIOD_D1, 81); + double ld_2208 = iHigh(symbol, PERIOD_D1, 82) - iLow(symbol, PERIOD_D1, 82); + double ld_2216 = iHigh(symbol, PERIOD_D1, 83) - iLow(symbol, PERIOD_D1, 83); + double ld_2224 = iHigh(symbol, PERIOD_D1, 84) - iLow(symbol, PERIOD_D1, 84); + double ld_2232 = iHigh(symbol, PERIOD_D1, 85) - iLow(symbol, PERIOD_D1, 85); + double ld_2240 = iHigh(symbol, PERIOD_D1, 86) - iLow(symbol, PERIOD_D1, 86); + double ld_2248 = iHigh(symbol, PERIOD_D1, 87) - iLow(symbol, PERIOD_D1, 87); + double ld_2256 = iHigh(symbol, PERIOD_D1, 88) - iLow(symbol, PERIOD_D1, 88); + double ld_2264 = iHigh(symbol, PERIOD_D1, 89) - iLow(symbol, PERIOD_D1, 89); + double ld_2272 = iHigh(symbol, PERIOD_D1, 90) - iLow(symbol, PERIOD_D1, 90); + double ld_2280 = iHigh(symbol, PERIOD_D1, 91) - iLow(symbol, PERIOD_D1, 91); + double ld_2288 = iHigh(symbol, PERIOD_D1, 92) - iLow(symbol, PERIOD_D1, 92); + double ld_2296 = iHigh(symbol, PERIOD_D1, 93) - iLow(symbol, PERIOD_D1, 93); + double ld_2304 = iHigh(symbol, PERIOD_D1, 94) - iLow(symbol, PERIOD_D1, 94); + double ld_2312 = iHigh(symbol, PERIOD_D1, 95) - iLow(symbol, PERIOD_D1, 95); + double ld_2320 = iHigh(symbol, PERIOD_D1, 99) - iLow(symbol, PERIOD_D1, 96); + double ld_2328 = iHigh(symbol, PERIOD_D1, 99) - iLow(symbol, PERIOD_D1, 97); + double ld_2336 = iHigh(symbol, PERIOD_D1, 99) - iLow(symbol, PERIOD_D1, 98); + double ld_2344 = iHigh(symbol, PERIOD_D1, 98) - iLow(symbol, PERIOD_D1, 99); + double ld_2352 = iHigh(symbol, PERIOD_D1, 100) - iLow(symbol, PERIOD_D1, 100); + if (Select_Average == 1) ld_2360 = ld_1560; + if (Select_Average == 2) ld_2360 = (ld_1560 + ld_1568) / 2.0; + if (Select_Average == 3) ld_2360 = (ld_1560 + ld_1568 + ld_1576) / 3.0; + if (Select_Average == 4) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584) / 4.0; + if (Select_Average == 5) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592) / 5.0; + if (Select_Average == 6) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600) / 6.0; + if (Select_Average == 7) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608) / 7.0; + if (Select_Average == 8) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616) / 8.0; + if (Select_Average == 9) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624) / 9.0; + if (Select_Average == 10) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632) / 10.0; + if (Select_Average == 15) ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672) / 15.0; + if (Select_Average == 20) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712) / 20.0; + } + if (Select_Average == 25) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752) / 25.0; + } + if (Select_Average == 30) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792) / 30.0; + } + if (Select_Average == 35) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832) / 35.0; + } + if (Select_Average == 40) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872) / 40.0; + } + if (Select_Average == 45) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912) / 45.0; + } + if (Select_Average == 50) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952) / 50.0; + } + if (Select_Average == 60) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_2000 + ld_2008 + ld_2016 + ld_2024 + ld_2032) / 60.0; + } + if (Select_Average == 70) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_2000 + ld_2008 + ld_2016 + ld_2024 + ld_2032 + ld_2040 + ld_2048 + ld_2056 + ld_2064 + ld_2072 + ld_2080 + ld_2088 + + ld_2096 + ld_2104 + ld_2112) / 70.0; + } + if (Select_Average == 80) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_2000 + ld_2008 + ld_2016 + ld_2024 + ld_2032 + ld_2040 + ld_2048 + ld_2056 + ld_2064 + ld_2072 + ld_2080 + ld_2088 + + ld_2096 + ld_2104 + ld_2112 + ld_2120 + ld_2128 + ld_2136 + ld_2144 + ld_2152 + ld_2160 + ld_2168 + ld_2176 + ld_2184 + ld_2192) / 80.0; + } + if (Select_Average == 90) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_2000 + ld_2008 + ld_2016 + ld_2024 + ld_2032 + ld_2040 + ld_2048 + ld_2056 + ld_2064 + ld_2072 + ld_2080 + ld_2088 + + ld_2096 + ld_2104 + ld_2112 + ld_2120 + ld_2128 + ld_2136 + ld_2144 + ld_2152 + ld_2160 + ld_2168 + ld_2176 + ld_2184 + ld_2192 + ld_2200 + ld_2208 + ld_2216 + ld_2224 + + ld_2232 + ld_2240 + ld_2248 + ld_2256 + ld_2264 + ld_2272) / 90.0; + } + if (Select_Average == 100) { + ld_2360 = (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + + ld_1688 + ld_1696 + ld_1704 + ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_2000 + ld_2008 + ld_2016 + ld_2024 + ld_2032 + ld_2040 + ld_2048 + ld_2056 + ld_2064 + ld_2072 + ld_2080 + ld_2088 + + ld_2096 + ld_2104 + ld_2112 + ld_2120 + ld_2128 + ld_2136 + ld_2144 + ld_2152 + ld_2160 + ld_2168 + ld_2176 + ld_2184 + ld_2192 + ld_2200 + ld_2208 + ld_2216 + ld_2224 + + ld_2232 + ld_2240 + ld_2248 + ld_2256 + ld_2264 + ld_2272 + ld_2280 + ld_2288 + ld_2296 + ld_2304 + ld_2312 + ld_2320 + ld_2328 + ld_2344 + ld_2336 + ld_2352) / 100.0; + } + if (Select_Average == 0) { + ld_2360 = (ld_1560 + (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592) / 5.0 + (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + + ld_1632) / 10.0 + (ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + ld_1688 + ld_1696 + ld_1704 + ld_1712) / 20.0) / 4.0; + } + string ls_unused_2376 = ""; + string ls_unused_2384 = ""; + double l_iopen_2400 = iOpen(symbol, PERIOD_D1, 0); + double l_iclose_2408 = iClose(symbol, PERIOD_D1, 0); + if (Spread_Digit_Shift == TRUE) Spread_Digit_Shift = TRUE; + else Spread_Digit_Shift = 10; + if (Digit_Switch == TRUE) ld_2368 = MarketInfo(symbol, MODE_SPREAD) / Spread_Digit_Shift; + if (Digit_Switch == FALSE) ld_2368 = NormalizeDouble(MarketInfo(symbol, MODE_SPREAD), gi_580); + double l_ihigh_2416 = iHigh(symbol, PERIOD_D1, 0); + double l_ilow_2424 = iLow(symbol, PERIOD_D1, 0); + double ld_2432 = (iClose(symbol, PERIOD_D1, 0) - iOpen(symbol, PERIOD_D1, 0)) * gi_584; + double ld_2440 = ld_2360 * gi_584; + double ld_2448 = (iHigh(symbol, PERIOD_D1, 1) - iLow(symbol, PERIOD_D1, 1)) * gi_584; + double ld_2456 = (MarketInfo(symbol, MODE_HIGH) - MarketInfo(symbol, MODE_LOW)) * gi_584; + if (l_iclose_2408 >= l_iopen_2400) l_color_2392 = Pips_UP; + if (l_iclose_2408 < l_iopen_2400) l_color_2392 = Pips_DN; + if (ld_2440 >= ld_2448) l_color_2396 = Daily_AV_UP; + if (ld_2440 < ld_2448) l_color_2396 = Daily_AV_DN; + if (Show_Smaller_Size == FALSE) { + if (Show_Price == TRUE) { + ObjectDelete("Signalprice" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalprice" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalprice" + SIGBARS_Multi_No + "", DoubleToStr(ld_1532, gi_580), 30, "Arial", l_color_1556); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 10); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 58 + li_1528); + li_2476 = 45; + li_2512 = 98; + l_fontsize_2464 = 11; + li_2480 = 10; + li_2516 = 96; + l_fontsize_2468 = 12; + li_2484 = 45; + li_2520 = 113; + l_fontsize_2464 = 11; + li_2488 = 10; + li_2524 = 111; + l_fontsize_2468 = 12; + li_2492 = 45; + li_2528 = 128; + l_fontsize_2464 = 11; + li_2496 = 10; + li_2532 = 126; + l_fontsize_2468 = 12; + li_2500 = 45; + li_2536 = 143; + l_fontsize_2464 = 11; + li_2504 = 10; + li_2540 = 141; + l_fontsize_2468 = 12; + li_2508 = 10; + li_2544 = 160; + l_fontsize_2472 = 9; + if (Show_Visual_Alert) li_2544 = 175; + } + } + if (Show_Smaller_Size == FALSE) { + if (Show_Price == FALSE) { + li_2476 = 45; + li_2512 = 62; + l_fontsize_2464 = 11; + li_2480 = 10; + li_2516 = 60; + l_fontsize_2468 = 12; + li_2484 = 45; + li_2520 = 77; + l_fontsize_2464 = 11; + li_2488 = 10; + li_2524 = 75; + l_fontsize_2468 = 12; + li_2492 = 45; + li_2528 = 92; + l_fontsize_2464 = 11; + li_2496 = 10; + li_2532 = 90; + l_fontsize_2468 = 12; + li_2500 = 45; + li_2536 = 107; + l_fontsize_2464 = 11; + li_2504 = 10; + li_2540 = 105; + l_fontsize_2468 = 12; + li_2508 = 10; + li_2544 = 124; + l_fontsize_2472 = 9; + if (Show_Visual_Alert) li_2544 = 140; + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Price == TRUE) { + ObjectDelete("Signalprice" + SIGBARS_Multi_No + ""); + ObjectCreate("Signalprice" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("Signalprice" + SIGBARS_Multi_No + "", DoubleToStr(ld_1532, gi_580), 20, "Arial", l_color_1556); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, Adjust_Side_to_side + 10); + ObjectSet("Signalprice" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, Shift_UP_DN + 56 + li_1528); + li_2476 = 38; + li_2512 = 82; + l_fontsize_2464 = 9; + li_2480 = 10; + li_2516 = 82; + l_fontsize_2468 = 9; + li_2484 = 38; + li_2520 = 96; + l_fontsize_2464 = 9; + li_2488 = 10; + li_2524 = 96; + l_fontsize_2468 = 9; + li_2492 = 38; + li_2528 = 110; + l_fontsize_2464 = 9; + li_2496 = 10; + li_2532 = 110; + l_fontsize_2468 = 9; + li_2500 = 38; + li_2536 = 124; + l_fontsize_2464 = 9; + li_2504 = 10; + li_2540 = 124; + l_fontsize_2468 = 9; + li_2508 = 10; + li_2544 = 140; + l_fontsize_2472 = 8; + if (Show_Visual_Alert) li_2544 = 155; + } + } + if (Show_Smaller_Size == TRUE) { + if (Show_Price == FALSE) { + li_2476 = 38; + li_2512 = 62; + l_fontsize_2464 = 9; + li_2480 = 10; + li_2516 = 62; + l_fontsize_2468 = 9; + li_2484 = 38; + li_2520 = 76; + l_fontsize_2464 = 9; + li_2488 = 10; + li_2524 = 76; + l_fontsize_2468 = 9; + li_2492 = 38; + li_2528 = 90; + l_fontsize_2464 = 9; + li_2496 = 10; + li_2532 = 90; + l_fontsize_2468 = 9; + li_2500 = 38; + li_2536 = 104; + l_fontsize_2464 = 9; + li_2504 = 10; + li_2540 = 104; + l_fontsize_2468 = 9; + li_2508 = 10; + li_2544 = 120; + l_fontsize_2472 = 8; + if (Show_Visual_Alert) li_2544 = 135; + } + } + if (Show_Xtra_Details == TRUE) { + ObjectDelete("SIG_DETAIL_1" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_1" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_1" + SIGBARS_Multi_No + "", "Spread", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + ObjectSet("SIG_DETAIL_1" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_1" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2476 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_1" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2512 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_2" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_2" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_2" + SIGBARS_Multi_No + "", "" + DoubleToStr(ld_2368, gi_580 - gi_588 + 1) + "", l_fontsize_2468, "Arial Bold", Spread_color); + ObjectSet("SIG_DETAIL_2" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_2" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2480 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_2" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2516 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_3" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_3" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_3" + SIGBARS_Multi_No + "", "Pips to Open", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + ObjectSet("SIG_DETAIL_3" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_3" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2484 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_3" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2520 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_4" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_4" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_4" + SIGBARS_Multi_No + "", "" + DoubleToStr(ld_2432, gi_580 - gi_588) + "", l_fontsize_2468, "Arial Bold", l_color_2392); + ObjectSet("SIG_DETAIL_4" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_4" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2488 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_4" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2524 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_5" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_5" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_5" + SIGBARS_Multi_No + "", "Hi to Low", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + ObjectSet("SIG_DETAIL_5" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_5" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2492 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_5" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2528 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_6" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_6" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_6" + SIGBARS_Multi_No + "", "" + DoubleToStr(ld_2456, gi_580 - gi_588) + "", l_fontsize_2468, "Arial Bold", HI_LO_color); + ObjectSet("SIG_DETAIL_6" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_6" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2496 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_6" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2532 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_7" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_7" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_7" + SIGBARS_Multi_No + "", "" + Select_Average + " Day Av", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + if (Select_Average == 1) ObjectSetText("SIG_DETAIL_7" + SIGBARS_Multi_No + "", "Prev " + Select_Average + " Day Av", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + else + if (Select_Average == 0) ObjectSetText("SIG_DETAIL_7" + SIGBARS_Multi_No + "", "Day Av", l_fontsize_2464, "Tahoma Narrow", CommentLabel_color); + ObjectSet("SIG_DETAIL_7" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_7" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2500 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_7" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2536 + Shift_UP_DN + li_1528); + ObjectDelete("SIG_DETAIL_8" + SIGBARS_Multi_No + ""); + ObjectCreate("SIG_DETAIL_8" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("SIG_DETAIL_8" + SIGBARS_Multi_No + "", "" + DoubleToStr(ld_2440, gi_580 - gi_588) + "", l_fontsize_2468, "Arial Bold", l_color_2396); + ObjectSet("SIG_DETAIL_8" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SIG_DETAIL_8" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2504 + Adjust_Side_to_side); + ObjectSet("SIG_DETAIL_8" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2540 + Shift_UP_DN + li_1528); + if (StringFind(symbol, "JPY", 0) != -1) gi_576 = 2; + else gi_576 = 2; + if (Show_BrokerTime == TRUE) { + ObjectDelete("BrokerTime" + SIGBARS_Multi_No + ""); + ObjectCreate("BrokerTime" + SIGBARS_Multi_No + "", OBJ_LABEL, Sig_Bars_Window, 0, 0); + ObjectSetText("BrokerTime" + SIGBARS_Multi_No + "", "Broker Time " + TimeToStr(TimeCurrent(), gi_576), l_fontsize_2472, "Tahoma Narrow", CommentLabel_color); + ObjectSet("BrokerTime" + SIGBARS_Multi_No + "", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("BrokerTime" + SIGBARS_Multi_No + "", OBJPROP_XDISTANCE, li_2508 + Adjust_Side_to_side); + ObjectSet("BrokerTime" + SIGBARS_Multi_No + "", OBJPROP_YDISTANCE, li_2544 + Shift_UP_DN + li_1528); + } + } + if (Show_Indicator_Instructions == TRUE) { + Comment("\n INSTRUCTION MANUAL for Signal Bars Multi-Currency by cja" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n SIGBARS_Multi_No = 12345" + + "\n EXTREMELY IMPORTANT - This number MUST be DIFFERENT for every Signal Bars loaded onto the same Chart" + + "\n to avoid code conflict between the Signal Bars Indicators" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Currency Pairs :" + + "\n NOTE : Currencies must be typed in as - EURUSD - not - eurusd - or the indicator will not recognise the instruction." + + "\n Symbol = EURUSD or GBPUSD / USDJPY / USDCHF etc - if the Window is left BLANK the indicator will default to the" + + "\n Current Chart Currency that the Indicator is loaded onto." + + "\n NOTE : Several different Currencies can be loaded onto the same Chart - or the same Currency can be loaded as many" + + "\n times as required. This can be useful if you wish to monitor the full range of TimeFrames or different internal Indicator settings." + + "\n" + + "\n Digit_Switch = true - for 5 digit platforms, Digit_Switch = false - for standard 4 digit platforms" + + "\n Spread_Digit_Shift = true / false - Allows the Trader to SHIFT the Spread DECIMAL POINT to allow for spreads of 0.8 to 150" + + "\n false = DECIMAL POINT shifts 1 point to the LEFT - example 34.0 becomes 3.4 - true = the reverse happens." + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Chart Position Settings :" + + "\n Corner_of_Chart_RIGHT_TOP - true = Indicator in TOP RIGHT of Chart - false = Indicator in TOP LEFT of Chart." + + "\n Shift_UP_DN - Shifts the Indicator UP & DOWN the chart, To load another Signal Bars BELOW another allow 200." + + "\n Adjust_Side_to_side - Shifts the Indicator LEFT & RIGHT, To load another Signal Bars BESIDE each other allow 150." + + "\n Sig_Bars_Window - Alows the Indicator to be loaded into separate indicator windows - For example 1 = the 1st Window," + + "\n 2 = the 2nd Window 3 = the 3rd Window etc. The indicator windows number from the 1st on the Chart is number 1 etc" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Adjustable TimeFrames : " + + "\n Select any combination of Timeframes between M1 to MONTHLY as required, The Timeframes are set by their numerical value " + + "\n M1 = 1 / M5 = 5 / M15 = 15 / M30 = 30 / H1 = 60 / H4 = 240 / DI = 1440 / W1 = 10080 / MN1 = 42300" + + "\n The Number of TimeFrames can be selected from a Maximum of 6 to a Minimum of 1 Displayed" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Alert & Sound Settings : " + + "\n AlertLevel - This would be typically set to around 60% to 75% and Alerts if the bars are ABOVE the set Percentage " + + "\n POPUP_Alert_ON = true turns ON the Alert & false turns OFF the Alert" + + "\n Sound_Constant_Alert_ON = true turns ON the Alert & false turns OFF the Alert - This Alert sounds a CONSTANT ALERT SOUND " + + "\n Sound_Limited_Alert_ON = true turns ON the Alert & false turns OFF the Alert - This Alert sounds every MINUTE" + + "\n Show_Visual_Alert = true Shows a visual read out of the percentage levels - false turns this function OFF" + + "\n Alert_Frequency_Minutes = 1 = Default - This setting sets how often the SOUND or POP UP WINDOW Alerts, it can be set to any" + + "\n TimeFrame number such as 1 / 5 / 15 / 30 / 60 and so on " + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Comments Settings" + + "\n Show_Price - true = Price is Displayed false = Price is not Displayed." + + "\n Show_Xtra_Details - true = extra details like SPREAD / PIPS to OPEN / Hi to Low & Currency Average are Displayed" + + "\n Show_Smaller_Size - true = The entire Signal Bars Indicator Displays SMALLER - false = the LARGER size is Displayed" + + "\n Show_Indicator_Bars - true = Indicator Bars are displayed - false = indicator Bars are removed" + + "\n Select_Average - This setting allows the user to select a Daily Average of " + + "\n 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 / 10 / 15 / 20 / 25 / 30 / 35 / 40 / 45 / 50 / 60 / 70 / 80 / 90 / 100 Days" + + "\n NOTE: 0 ( ZERO ) gives the AVERAGE DAILY RANGE of 1 Day + 1 to 5 Days + 1 to 10 days + 1 to 20 Days / 4 " + + "\n Which gives an AVERAGE RANGE weighted towards the CURRENT DAY but with an HISTORICAL FILTER." + + "\n" + + "\n The following 12 COLOR Functions allow the user to select colors for DETAILS / PRICE / LABELS & TEXT as required" + + "\n Show_BrokerTime - true Displays the Broker time - false turns this function OFF" + + "\n --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"); + } + if (Show_Indicator_Instructions_2 == TRUE) { + Comment("\n INSTRUCTION MANUAL #2 for Signal Bars Multi-Currency by cja" + + "\n ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Indicator Settings for the COLORED BARS" + + "\n" + + "\n Switch_STR_to_RSI = true / false :" + + "\n true = switches STR to RSI indicators only - false = STR indicators displayed " + + "\n If Switch set to true - set all 3 RSI to the same PERIOD to display only 1 RSI or set the 3 RSI PERIODS" + + "\n to different PERIODS and monitor 3 RSI at the same time - for example -- RSI_Period1 = 5 / RSI_Period2 = 9 / RSI_Period3 = 18" + + "\n" + + "\n MACD Settings :" + + "\n MACD FAST / MACD SLOW / MACD SIGNAL / MACD PRICE can be altered to suit your trading style" + + "\n MACD Colors - The MACD Colors for LEVELS Above or Below the Zero line and CROSS OVER can be selected here" + + "\n" + + "\n STR Settings :" + + "\n The STR Bars consist of 3 Indicators - each Bar requires all 3 of the indicators to be in agreement before" + + "\n an UP or DOWN Signal is given - the 3 indicators are RSI / CCI / STOCH - All these indicators are individually adjustable" + + "\n STR Colors - The Colors for the STR Bars can be selected here for UP / DOWN / NUETRAL " + + "\n" + + "\n MA Settings :" + + "\n MA Fast / MA Slow / MA Mode / MA Price can all be altered here - Followed by the MA UP / DOWN Color selections" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n Currency Pairs :" + + "\n Symbol = EURUSD / GBPUSD / EURJPY / GBPJPY / USDJPY / USDCHF / AUSUSD / NZDUSD / USDCAD / EURGBP and you will find other" + + "\n Currency Pairs under the Symbol tab on your MT4 platform" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n TimeFrames :" + + "\n M1 = 1 / M5 = 5 / M15 = 15 / M30 = 30 / H1 = 60 / H4 = 240 / D1 = 1440 / W1 = 10080 / MN1 = 42300" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" + + "\n MA selections : " + + "\n MODE_SMA = 0 = Simple moving average " + + "\n MODE_EMA = 1 = Exponential moving average" + + "\n MODE_SMMA = 2 = Smoothed moving average" + + "\n MODE_LWMA = 3 = Linear weighted moving average" + + "\n" + + "\n PRICE selections" + + "\n PRICE_CLOSE = 0 = Close price" + + "\n PRICE_OPEN = 1 = Open price" + + "\n PRICE_HIGH = 2 = High price" + + "\n PRICE_LOW = 3 = Low price" + + "\n PRICE_MEDIAN = 4 = Median price (high+low) / 2" + + "\n PRICE_TYPICAL = 5 = Typical price (high+low+close) / 3" + + "\n PRICE_WEIGHTED = 6 = Weighted close price (high+low+close+close) / 4" + + "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"); + } + return (0); +} + +bool BarChanged() { + if (g_datetime_600 != iTime(NULL, Alert_Frequency_Minutes, 0)) { + g_datetime_600 = iTime(NULL, Alert_Frequency_Minutes, 0); + return (TRUE); + } + return (FALSE); +} \ No newline at end of file diff --git a/Signal_Bars_v3_Daily.mq4 b/Signal_Bars_v3_Daily.mq4 new file mode 100644 index 0000000..73df829 --- /dev/null +++ b/Signal_Bars_v3_Daily.mq4 @@ -0,0 +1,749 @@ +//+------------------------------------------------------------------+ +//| #Signal_Bars_v3_Daily.mq4 | +//| Copyright © 2006, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2006, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" +#property link " cja " +#property indicator_chart_window + +extern bool Corner_of_Chart_RIGHT_TOP = true; +extern bool Show_Price = true; +extern bool Show_Xtra_Details = true; +extern bool Show_Smaller_Size = false; +extern int Shift_UP_DN =0; +extern int Adjust_Side_to_side = 20; +extern color BarLabel_color = LightSteelBlue; +extern color CommentLabel_color = LightSteelBlue; + + +//**************************************** +extern int MACD_Fast = 8; +extern int MACD_Slow = 17; +extern int MACD_Signal = 9; +extern int MACD_PRICE_TYPE = 0; + +extern int RSI_Period = 9; +extern int RSI_PRICE_TYPE = 0; + +extern int CCI_Period = 13; +extern int CCI_PRICE_TYPE = 0; + +extern int STOCH_K_Period = 5; +extern int STOCH_D_Period = 3; +extern int STOCH_Slowing = 3; +extern int STOCH_MA_MODE = 1; + +extern int MA_Fast = 5; +extern int MA_Slow = 9; +extern int MA_MODE = 1; +extern int MA_PRICE_TYPE = 0; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + ObjectsDeleteAll(0,OBJ_LABEL); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { + //*********************************************************************************************************************** + //MACD Signals + int counted_bars=IndicatorCounted(); +//---- + string SSignalMACDD1="",SSignalMACDH1="",SSignalMACDH4="",SSignalMACDM1="", SSignalMACDM5="",SSignalMACDM15="",SSignalMACDM30=""; + color colMACDD1,colMACDH1,colMACDH4,colMACDM1,colMACDM5,colMACDM15,colMACDM30; + + double MACDM1=iMACD(NULL,1,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGM1=iMACD(NULL,1,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDM5=iMACD(NULL,5,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGM5=iMACD(NULL,5,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDM15=iMACD(NULL,15,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGM15=iMACD(NULL,15,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDM30=iMACD(NULL,30,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGM30=iMACD(NULL,30,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDH1=iMACD(NULL,60,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGH1=iMACD(NULL,60,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDH4=iMACD(NULL,240,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGH4=iMACD(NULL,240,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + double MACDD1=iMACD(NULL,1440,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_MAIN,0); + double MACD_SIGD1=iMACD(NULL,1440,MACD_Fast,MACD_Slow,MACD_Signal,MACD_PRICE_TYPE,MODE_SIGNAL,0); + + if (MACDM1>MACD_SIGM1){SSignalMACDM1 = "-"; colMACDM1 = Green;} + if (MACDM1<=MACD_SIGM1){SSignalMACDM1 = "-"; colMACDM1 = Tomato;} + if ((MACDM1>MACD_SIGM1)&&(MACDM1>0)){SSignalMACDM1 = "-"; colMACDM1 = Lime;} + if ((MACDM1<=MACD_SIGM1)&&(MACDM1<0)){SSignalMACDM1 = "-"; colMACDM1 = Red;} + + if (MACDM5>MACD_SIGM5){SSignalMACDM5 = "-"; colMACDM5 = Green;} + if (MACDM5<=MACD_SIGM5){SSignalMACDM5 = "-"; colMACDM5 = Tomato;} + if ((MACDM5>MACD_SIGM5)&&(MACDM5>0)){SSignalMACDM5 = "-"; colMACDM5 = Lime;} + if ((MACDM5<=MACD_SIGM5)&&(MACDM5<0)){SSignalMACDM5 = "-"; colMACDM5 = Red;} + + if (MACDM15>MACD_SIGM15){SSignalMACDM15 = "-"; colMACDM15 = Green;} + if (MACDM15<=MACD_SIGM15){SSignalMACDM15 = "-"; colMACDM15 = Tomato;} + if ((MACDM15>MACD_SIGM15)&&(MACDM15>0)){SSignalMACDM15 = "-"; colMACDM15 = Lime;} + if ((MACDM15<=MACD_SIGM15)&&(MACDM15<0)){SSignalMACDM15 = "-"; colMACDM15 = Red;} + + if (MACDM30>MACD_SIGM30){SSignalMACDM30 = "-"; colMACDM30 = Green;} + if (MACDM30<=MACD_SIGM30){SSignalMACDM30 = "-"; colMACDM30 = Tomato;} + if ((MACDM30>MACD_SIGM30)&&(MACDM30>0)){SSignalMACDM30 = "-"; colMACDM30 = Lime;} + if ((MACDM30<=MACD_SIGM30)&&(MACDM30<0)){SSignalMACDM30 = "-"; colMACDM30 = Red;} + + if (MACDH1>MACD_SIGH1){SSignalMACDH1 = "-"; colMACDH1 = Green;} + if (MACDH1<=MACD_SIGH1){SSignalMACDH1 = "-"; colMACDH1 = Tomato;} + if ((MACDH1>MACD_SIGH1)&&(MACDH1>0)){SSignalMACDH1 = "-"; colMACDH1 = Lime;} + if ((MACDH1<=MACD_SIGH1)&&(MACDH1<0)){SSignalMACDH1 = "-"; colMACDH1 = Red;} + + if (MACDH4>MACD_SIGH4){SSignalMACDH4 = "-"; colMACDH4 = Green;} + if (MACDH4<=MACD_SIGH4){SSignalMACDH4 = "-"; colMACDH4 = Tomato;} + if ((MACDH4>MACD_SIGH4)&&(MACDH4>0)){SSignalMACDH4 = "-"; colMACDH4 = Lime;} + if ((MACDH4<=MACD_SIGH4)&&(MACDH4<0)){SSignalMACDH4 = "-"; colMACDH4 = Red;} + + if (MACDD1>MACD_SIGD1){SSignalMACDD1 = "-"; colMACDD1 = Green;} + if (MACDD1<=MACD_SIGD1){SSignalMACDD1 = "-"; colMACDD1 = Tomato;} + if ((MACDD1>MACD_SIGD1)&&(MACDD1>0)){SSignalMACDD1 = "-"; colMACDD1 = Lime;} + if ((MACDD1<=MACD_SIGD1)&&(MACDD1<0)){SSignalMACDD1 = "-"; colMACDD1 = Red;} + + + if (Corner_of_Chart_RIGHT_TOP == true) + { + ObjectCreate("Numbers", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Numbers", " M1 M5 M15 M30 H1 H4 D1", 6, "Tahoma Narrow", BarLabel_color); + ObjectSet("Numbers", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Numbers", OBJPROP_XDISTANCE, 19+Adjust_Side_to_side); + ObjectSet("Numbers", OBJPROP_YDISTANCE, 25+Shift_UP_DN); + } + if (Corner_of_Chart_RIGHT_TOP == false) + { + ObjectCreate("Numbers", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Numbers", "D1 H4 H1 M30 M15 M5 M1", 6, "Tahoma Narrow", BarLabel_color); + ObjectSet("Numbers", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Numbers", OBJPROP_XDISTANCE, 15+Adjust_Side_to_side); + ObjectSet("Numbers", OBJPROP_YDISTANCE, 25+Shift_UP_DN); + } + ObjectCreate("SSignalMACDM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM1t", "MACD", 6, "Tahoma Narrow", BarLabel_color); + ObjectSet("SSignalMACDM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM1t", OBJPROP_XDISTANCE, 155+Adjust_Side_to_side); + ObjectSet("SSignalMACDM1t", OBJPROP_YDISTANCE, 35+Shift_UP_DN); + + ObjectCreate("SSignalMACDM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM1", SSignalMACDM1, 45, "Tahoma Narrow", colMACDM1); + ObjectSet("SSignalMACDM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM1", OBJPROP_XDISTANCE, 130+Adjust_Side_to_side); + ObjectSet("SSignalMACDM1", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + + ObjectCreate("SSignalMACDM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM5", SSignalMACDM5, 45, "Tahoma Narrow", colMACDM5); + ObjectSet("SSignalMACDM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM5", OBJPROP_XDISTANCE, 110+Adjust_Side_to_side); + ObjectSet("SSignalMACDM5", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + + ObjectCreate("SSignalMACDM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM15", SSignalMACDM15, 45, "Tahoma Narrow", colMACDM15); + ObjectSet("SSignalMACDM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM15", OBJPROP_XDISTANCE, 90+Adjust_Side_to_side); + ObjectSet("SSignalMACDM15", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + + ObjectCreate("SSignalMACDM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDM30", SSignalMACDM30, 45, "Tahoma Narrow", colMACDM30); + ObjectSet("SSignalMACDM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDM30", OBJPROP_XDISTANCE, 70+Adjust_Side_to_side); + ObjectSet("SSignalMACDM30", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + + ObjectCreate("SSignalMACDH1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDH1", SSignalMACDH1, 45, "Tahoma Narrow", colMACDH1); + ObjectSet("SSignalMACDH1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH1", OBJPROP_XDISTANCE, 50+Adjust_Side_to_side); + ObjectSet("SSignalMACDH1", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + ObjectCreate("SSignalMACDH4", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDH4", SSignalMACDH4, 45, "Tahoma Narrow", colMACDH4); + ObjectSet("SSignalMACDH4", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDH4", OBJPROP_XDISTANCE, 30+Adjust_Side_to_side); + ObjectSet("SSignalMACDH4", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + ObjectCreate("SSignalMACDD1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SSignalMACDD1", SSignalMACDD1, 45, "Tahoma Narrow", colMACDD1); + ObjectSet("SSignalMACDD1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SSignalMACDD1", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("SSignalMACDD1", OBJPROP_YDISTANCE, 2+Shift_UP_DN); + + + + //*************************************************************************************************************** + //STR Signals + double rsi_d1 = iRSI(NULL, PERIOD_D1, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_h4 = iRSI(NULL, PERIOD_H4, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_h1 = iRSI(NULL, PERIOD_H1, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_m30 = iRSI(NULL, PERIOD_M30, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_m15 = iRSI(NULL, PERIOD_M15, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_m5 = iRSI(NULL, PERIOD_M5, RSI_Period , RSI_PRICE_TYPE, 0); + double rsi_m1 = iRSI(NULL, PERIOD_M1, RSI_Period , RSI_PRICE_TYPE, 0); + + double stoc_D1 = iStochastic(NULL, PERIOD_D1, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double stoc_H4 = iStochastic(NULL, PERIOD_H4, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double stoc_H1 = iStochastic(NULL, PERIOD_H1, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double stoc_M30 = iStochastic(NULL, PERIOD_M30, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double stoc_M15 = iStochastic(NULL, PERIOD_M15, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0);//sto was 15,5,5 + double stoc_M5 = iStochastic(NULL, PERIOD_M5, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0); + double stoc_M1 = iStochastic(NULL, PERIOD_M1, STOCH_K_Period,STOCH_D_Period,STOCH_Slowing, STOCH_MA_MODE, 0, MODE_MAIN, 0);// was mode signal now gets value off main line + + double cci_DD1 = iCCI(NULL, PERIOD_D1,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_HH4 = iCCI(NULL, PERIOD_H4,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_HH1 = iCCI(NULL, PERIOD_H1,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_MM30 = iCCI(NULL, PERIOD_M30,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_MM15 = iCCI(NULL, PERIOD_M15,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_MM5 = iCCI(NULL, PERIOD_M5,CCI_Period , CCI_PRICE_TYPE, 0); + double cci_MM1 = iCCI(NULL, PERIOD_M1,CCI_Period , CCI_PRICE_TYPE, 0); + + + string STR_h1 = "", STR_m15 = "", STR_m5 = "", STR_m1 = "", STR_h4 ="",STR_m30= "",STR_d1= "",STR_w1= ""; + + color color_signal,color_m1,color_m5,color_m15,color_m30,color_m60,color_m240,color_m1440; + + if ((rsi_d1 > 50) && (stoc_D1 > 40) && (cci_DD1 > 0)) { STR_d1 = "-";color_m1440 = Lime;} + if ((rsi_h4 > 50) && (stoc_H4 > 40) && (cci_HH4 > 0)) { STR_h4 = "-";color_m240 = Lime;} + if ((rsi_h1 > 50) && (stoc_H1 > 40) && (cci_HH1 > 0)) { STR_h1 = "-";color_m60 = Lime;} + if ((rsi_m30 > 50) && (stoc_M30 > 40) && (cci_MM30 > 0)) { STR_m30 = "-";color_m30 = Lime; } + if ((rsi_m15 > 50) && (stoc_M15 > 40) && (cci_MM15 > 0)) { STR_m15 = "-";color_m15 = Lime; } + if ((rsi_m5 > 50) && (stoc_M5 > 40) && (cci_MM5 > 0)) { STR_m5 = "-"; color_m5 = Lime;} + if ((rsi_m1 > 50) && (stoc_M1 > 40) && (cci_MM1 > 0)) { STR_m1 = "-"; color_m1 = Lime;} + + + if ((rsi_d1 < 50) && (stoc_D1 < 60) && (cci_DD1 < 0)) { STR_d1 = "-";color_m1440 = Red;} + if ((rsi_h4 < 50) && (stoc_H4 < 60) && (cci_HH4 < 0)) { STR_h4 = "-";color_m240 = Red;} + if ((rsi_h1 < 50) && (stoc_H1 < 60) && (cci_HH1 < 0)) { STR_h1 = "-";color_m60 = Red;} + if ((rsi_m30 < 50) && (stoc_M30 < 60) && (cci_MM30 < 0)) { STR_m30 = "-";color_m30 = Red;} + if ((rsi_m15 < 50) && (stoc_M15 < 60) && (cci_MM15 < 0)) { STR_m15 = "-";color_m15 = Red;} + if ((rsi_m5 < 50) && (stoc_M5 < 60) && (cci_MM5 < 0)) { STR_m5 = "-";color_m5 = Red;} + if ((rsi_m1 < 50) && (stoc_M1 < 60) && (cci_MM1 < 0)) { STR_m1 = "-"; color_m1 = Red;} + + + if ((rsi_m1 < 50) && (stoc_M1 > 40) && (cci_MM1 > 0)) { STR_m1 = "-"; color_m1 = Orange;} + if ((rsi_m1 > 50) && (stoc_M1 < 60) && (cci_MM1 < 0)) { STR_m1 = "-"; color_m1 = Orange;} + if ((rsi_m1 < 50) && (stoc_M1 > 40) && (cci_MM1 < 0)) { STR_m1 = "-"; color_m1 = Orange;} + if ((rsi_m1 > 50) && (stoc_M1 < 60) && (cci_MM1 > 0)) { STR_m1 = "-"; color_m1 = Orange;} + if ((rsi_m1 > 50) && (stoc_M1 > 40) && (cci_MM1 < 0)) { STR_m1 = "-"; color_m1 = Orange;} + if ((rsi_m1 > 50) && (stoc_M1 < 60) && (cci_MM1 < 0)) { STR_m1 = "-"; color_m1 = Orange;} + + + if ((rsi_m5 < 50) && (stoc_M5 > 40) && (cci_MM5 > 0)) { STR_m5 = "-"; color_m5 = Orange;} + if ((rsi_m5 > 50) && (stoc_M5 < 60) && (cci_MM5 < 0)) { STR_m5 = "-"; color_m5 = Orange;} + if ((rsi_m5 < 50) && (stoc_M5 > 40) && (cci_MM5 < 0)) { STR_m5 = "-"; color_m5 = Orange;} + if ((rsi_m5 > 50) && (stoc_M5 < 60) && (cci_MM5 > 0)) { STR_m5 = "-"; color_m5 = Orange;} + if ((rsi_m5 > 50) && (stoc_M5 > 40) && (cci_MM5 < 0)) { STR_m5 = "-"; color_m5 = Orange;} + if ((rsi_m5 > 50) && (stoc_M5 < 60) && (cci_MM5 < 0)) { STR_m5 = "-"; color_m5 = Orange;} + + if ((rsi_m15 < 50) && (stoc_M15 > 40) && (cci_MM15 > 0)) { STR_m15 = "-"; color_m15 = Orange;} + if ((rsi_m15 > 50) && (stoc_M15 < 60) && (cci_MM15 < 0)) { STR_m15 = "-"; color_m15 = Orange;} + if ((rsi_m15 < 50) && (stoc_M15 > 40) && (cci_MM15 < 0)) { STR_m15 = "-"; color_m15 = Orange;} + if ((rsi_m15 > 50) && (stoc_M15 < 60) && (cci_MM15 > 0)) { STR_m15 = "-"; color_m15 = Orange;} + if ((rsi_m15 > 50) && (stoc_M15 > 40) && (cci_MM15 < 0)) { STR_m15 = "-"; color_m15 = Orange;} + if ((rsi_m15 > 50) && (stoc_M15 < 60) && (cci_MM15 < 0)) { STR_m15 = "-"; color_m15 = Orange;} + + if ((rsi_m30 < 50) && (stoc_M30 > 40) && (cci_MM30 > 0)) { STR_m30 = "-"; color_m30 = Orange;} + if ((rsi_m30 > 50) && (stoc_M30 < 60) && (cci_MM30 < 0)) { STR_m30 = "-"; color_m30 = Orange;} + if ((rsi_m30 < 50) && (stoc_M30 > 40) && (cci_MM30 < 0)) { STR_m30 = "-"; color_m30 = Orange;} + if ((rsi_m30 > 50) && (stoc_M30 < 60) && (cci_MM30 > 0)) { STR_m30 = "-"; color_m30 = Orange;} + if ((rsi_m30 > 50) && (stoc_M30 > 40) && (cci_MM30 < 0)) { STR_m30 = "-"; color_m30 = Orange;} + if ((rsi_m30 > 50) && (stoc_M30 < 60) && (cci_MM30 < 0)) { STR_m30 = "-"; color_m30 = Orange;} + + if ((rsi_h1 < 50) && (stoc_H1 > 40) && (cci_HH1 > 0)) { STR_h1 = "-"; color_m60 = Orange;} + if ((rsi_h1 > 50) && (stoc_H1 < 60) && (cci_HH1 < 0)) { STR_h1 = "-"; color_m60 = Orange;} + if ((rsi_h1 < 50) && (stoc_H1 > 40) && (cci_HH1 < 0)) { STR_h1 = "-"; color_m60 = Orange;} + if ((rsi_h1 > 50) && (stoc_H1 < 60) && (cci_HH1 > 0)) { STR_h1 = "-"; color_m60 = Orange;} + if ((rsi_h1 > 50) && (stoc_H1 > 40) && (cci_HH1 < 0)) { STR_h1 = "-"; color_m60 = Orange;} + if ((rsi_h1 > 50) && (stoc_H1 < 60) && (cci_HH1 < 0)) { STR_h1 = "-"; color_m60 = Orange;} + + if ((rsi_h4 < 50) && (stoc_H4 > 40) && (cci_HH4 > 0)) { STR_h4 = "-"; color_m240 = Orange;} + if ((rsi_h4 > 50) && (stoc_H4 < 60) && (cci_HH4 < 0)) { STR_h4 = "-"; color_m240 = Orange;} + if ((rsi_h4 < 50) && (stoc_H4 > 40) && (cci_HH4 < 0)) { STR_h4 = "-"; color_m240 = Orange;} + if ((rsi_h4 > 50) && (stoc_H4 < 60) && (cci_HH4 > 0)) { STR_h4 = "-"; color_m240 = Orange;} + if ((rsi_h4 > 50) && (stoc_H4 > 40) && (cci_HH4 < 0)) { STR_h4 = "-"; color_m240 = Orange;} + if ((rsi_h4 > 50) && (stoc_H4 < 60) && (cci_HH4 < 0)) { STR_h4 = "-"; color_m240 = Orange;} + + if ((rsi_d1 < 50) && (stoc_D1 > 40) && (cci_DD1 > 0)) { STR_d1 = "-"; color_m1440 = Orange;} + if ((rsi_d1 > 50) && (stoc_D1 < 60) && (cci_DD1 < 0)) { STR_d1 = "-"; color_m1440 = Orange;} + if ((rsi_d1 < 50) && (stoc_D1 > 40) && (cci_DD1 < 0)) { STR_d1 = "-"; color_m1440 = Orange;} + if ((rsi_d1 > 50) && (stoc_D1 < 60) && (cci_DD1 > 0)) { STR_d1 = "-"; color_m1440 = Orange;} + if ((rsi_d1 > 50) && (stoc_D1 > 40) && (cci_DD1 < 0)) { STR_d1 = "-"; color_m1440 = Orange;} + if ((rsi_d1 > 50) && (stoc_D1 < 60) && (cci_DD1 < 0)) { STR_d1 = "-"; color_m1440 = Orange;} + + + + ObjectCreate("SignalSTRM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1t","STR", 6, "Tahoma Narrow", BarLabel_color); + ObjectSet("SignalSTRM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1t", OBJPROP_XDISTANCE, 155+Adjust_Side_to_side); + ObjectSet("SignalSTRM1t", OBJPROP_YDISTANCE, 43+Shift_UP_DN); + + ObjectCreate("SignalSTRM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1", STR_m1, 45, "Tahoma Narrow", color_m1); + ObjectSet("SignalSTRM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1", OBJPROP_XDISTANCE, 130+Adjust_Side_to_side); + ObjectSet("SignalSTRM1", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM5", STR_m5, 45, "Tahoma Narrow", color_m5); + ObjectSet("SignalSTRM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM5", OBJPROP_XDISTANCE, 110+Adjust_Side_to_side); + ObjectSet("SignalSTRM5", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM15", STR_m15, 45, "Tahoma Narrow", color_m15); + ObjectSet("SignalSTRM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM15", OBJPROP_XDISTANCE, 90+Adjust_Side_to_side); + ObjectSet("SignalSTRM15", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM30", STR_m30, 45, "Tahoma Narrow", color_m30); + ObjectSet("SignalSTRM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM30", OBJPROP_XDISTANCE, 70+Adjust_Side_to_side); + ObjectSet("SignalSTRM30", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM60", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM60", STR_h1, 45, "Tahoma Narrow", color_m60); + ObjectSet("SignalSTRM60", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM60", OBJPROP_XDISTANCE, 50+Adjust_Side_to_side); + ObjectSet("SignalSTRM60", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM240", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM240", STR_h4, 45, "Tahoma Narrow", color_m240); + ObjectSet("SignalSTRM240", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM240", OBJPROP_XDISTANCE, 30+Adjust_Side_to_side); + ObjectSet("SignalSTRM240", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + ObjectCreate("SignalSTRM1440", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalSTRM1440", STR_d1, 45, "Tahoma Narrow", color_m1440); + ObjectSet("SignalSTRM1440", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalSTRM1440", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("SignalSTRM1440", OBJPROP_YDISTANCE, 10+Shift_UP_DN); + + //****************************************************************************************************************** + //EMA Signals + + + double EMA_M1 = iMA(Symbol(),1,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_m1 = iMA(Symbol(),1,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_M5 = iMA(Symbol(),5,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_m5 = iMA(Symbol(),5,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_M15 = iMA(Symbol(),15,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_m15 = iMA(Symbol(),15,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_M30 = iMA(Symbol(),30,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_m30 = iMA(Symbol(),30,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_H1 = iMA(Symbol(),60,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_h1 = iMA(Symbol(),60,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_H4 = iMA(Symbol(),240,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_h4 = iMA(Symbol(),240,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + double EMA_D1 = iMA(Symbol(),1440,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + double ema_d1 = iMA(Symbol(),1440,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + // double EMA_W1 = iMA(Symbol(),10080,MA_Fast,0,MA_MODE,MA_PRICE_TYPE,0); + // double ema_w1 = iMA(Symbol(),10080,MA_Slow,0,MA_MODE,MA_PRICE_TYPE,0); + + string M1_EMA= "",M5_EMA= "", M15_EMA= "", M30_EMA= "", H1_EMA= "", H4_EMA= "", D1_EMA= "",PRC1; + color color_EMAm1,color_EMAm5,color_EMAm15,color_EMAm30,color_EMAm60,color_EMAm240,color_EMAm1440; + + + if (EMA_M1 > ema_m1) {M1_EMA= "-";color_EMAm1 = Lime; } + if (EMA_M1 <= ema_m1) {M1_EMA= "-";color_EMAm1 = Red; } + + if (EMA_M5 > ema_m5) {M5_EMA= "-";color_EMAm5 = Lime; } + if (EMA_M5 <= ema_m5) {M5_EMA= "-";color_EMAm5 = Red; } + + if (EMA_M15 > ema_m15) {M15_EMA= "-";color_EMAm15 = Lime; } + if (EMA_M15 <= ema_m15) {M15_EMA= "-";color_EMAm15 = Red; } + + if (EMA_M30 > ema_m30) {M30_EMA= "-";color_EMAm30 = Lime; } + if (EMA_M30 <= ema_m30) {M30_EMA= "-";color_EMAm30 = Red; } + + if (EMA_H1 > ema_h1) {H1_EMA= "-";color_EMAm60 = Lime; } + if (EMA_H1 <= ema_h1) {H1_EMA= "-";color_EMAm60 = Red; } + + if (EMA_H4 > ema_h4) {H4_EMA= "-";color_EMAm240 = Lime; } + if (EMA_H4 <= ema_h4) {H4_EMA= "-";color_EMAm240 = Red; } + + if (EMA_D1 > ema_d1) {D1_EMA= "-";color_EMAm1440 = Lime; } + if (EMA_D1 <= ema_d1) {D1_EMA= "-";color_EMAm1440 = Red; } + + + ObjectCreate("SignalEMAM1t", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1t","EMA", 6, "Tahoma Narrow", BarLabel_color); + ObjectSet("SignalEMAM1t", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1t", OBJPROP_XDISTANCE, 155+Adjust_Side_to_side); + ObjectSet("SignalEMAM1t", OBJPROP_YDISTANCE, 51+Shift_UP_DN); + + ObjectCreate("SignalEMAM1", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1", M1_EMA, 45, "Tahoma Narrow", color_EMAm1); + ObjectSet("SignalEMAM1", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1", OBJPROP_XDISTANCE, 130+Adjust_Side_to_side); + ObjectSet("SignalEMAM1", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM5", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM5", M5_EMA, 45, "Tahoma Narrow", color_EMAm5); + ObjectSet("SignalEMAM5", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM5", OBJPROP_XDISTANCE, 110+Adjust_Side_to_side); + ObjectSet("SignalEMAM5", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM15", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM15", M15_EMA, 45, "Tahoma Narrow", color_EMAm15); + ObjectSet("SignalEMAM15", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM15", OBJPROP_XDISTANCE, 90+Adjust_Side_to_side); + ObjectSet("SignalEMAM15", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM30", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM30", M30_EMA, 45, "Tahoma Narrow", color_EMAm30); + ObjectSet("SignalEMAM30", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM30", OBJPROP_XDISTANCE, 70+Adjust_Side_to_side); + ObjectSet("SignalEMAM30", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM60", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM60", H1_EMA, 45, "Tahoma Narrow", color_EMAm60); + ObjectSet("SignalEMAM60", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM60", OBJPROP_XDISTANCE, 50+Adjust_Side_to_side); + ObjectSet("SignalEMAM60", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM240", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM240", H4_EMA, 45, "Tahoma Narrow", color_EMAm240); + ObjectSet("SignalEMAM240", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM240", OBJPROP_XDISTANCE, 30+Adjust_Side_to_side); + ObjectSet("SignalEMAM240", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + ObjectCreate("SignalEMAM1440", OBJ_LABEL, 0, 0, 0); + ObjectSetText("SignalEMAM1440", D1_EMA, 45, "Tahoma Narrow", color_EMAm1440); + ObjectSet("SignalEMAM1440", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("SignalEMAM1440", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("SignalEMAM1440", OBJPROP_YDISTANCE, 18+Shift_UP_DN); + + //***************************************************************************************************** + //Info + + double Price1 = iMA(Symbol(),0,1,0,MODE_EMA,PRICE_CLOSE,0); + PRC1 = DoubleToStr(Price1,Digits); + + + if (Show_Smaller_Size == false) + { + + if (Show_Price == true) + { + ObjectCreate("Signalprice", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Signalprice",""+PRC1+"", 33, "Arial", Gray); + ObjectSet("Signalprice", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("Signalprice", OBJPROP_YDISTANCE, 58+Shift_UP_DN); + }} + + if (Show_Smaller_Size == true) + { + if (Show_Price == true) + { + ObjectCreate("Signalprice", OBJ_LABEL, 0, 0, 0); + ObjectSetText("Signalprice",""+PRC1+"", 15, "Arial", color_m30); + ObjectSet("Signalprice", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("Signalprice", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("Signalprice", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + }} + int R1=0,R5=0,R10=0,R20=0,RAvg=0,i=0; + R1 = (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point; + for(i=1;i<=5;i++) + R5 = R5 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point; + for(i=1;i<=10;i++) + R10 = R10 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point; + for(i=1;i<=20;i++) + R20 = R20 + (iHigh(NULL,PERIOD_D1,i)-iLow(NULL,PERIOD_D1,i))/Point; + + R5 = R5/5; + R10 = R10/10; + R20 = R20/20; + RAvg = (R1+R5+R10+R20)/4; + + string HI="",LO="",SPREAD="",PIPS="",DAV="",HILO="",PRC,Pips="",Av="",AV_Yest=""; + color color_pip,color_av; + double OPEN = iOpen(NULL,1440,0); + double CLOSE = iClose(NULL,1440,0); + double SPRD = (Ask - Bid)/Point; + double High_Today = iHigh(NULL,1440,0); + double Low_Today = iLow(NULL,1440,0); + PIPS = DoubleToStr((CLOSE-OPEN)/Point,0); + SPREAD = (DoubleToStr(SPRD,Digits-4)); + DAV = (DoubleToStr(RAvg,Digits-4)); + AV_Yest = (iHigh(NULL,PERIOD_D1,1)-iLow(NULL,PERIOD_D1,1))/Point; + HILO = DoubleToStr((High_Today-Low_Today)/Point,0); + + if (CLOSE >= OPEN) {Pips= "-";color_pip = Lime; } + if (CLOSE < OPEN) {Pips= "-";color_pip = OrangeRed; } + if (DAV > AV_Yest) {Av= "-";color_av = Lime; } + if (DAV < AV_Yest) {Av= "-";color_av = OrangeRed; } + + + if (Show_Smaller_Size == false) + { + if (Show_Xtra_Details == true) + { + if (Show_Price == true) + { + + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7","Spread", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, 100+Shift_UP_DN); + + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8",""+SPREAD+"", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, 100+Shift_UP_DN); + + + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9","Pips to Open", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, 115+Shift_UP_DN); + + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10",""+PIPS+"", 12, "Arial Bold", color_pip); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, 115+Shift_UP_DN); + + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11","Hi to Low", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, 130+Shift_UP_DN); + + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12",""+HILO+"", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, 130+Shift_UP_DN); + + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13","Daily Av", 12, "Arial",CommentLabel_color); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, 145+Shift_UP_DN); + + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14",""+DAV+"", 12, "Arial Bold", color_av); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, 145+Shift_UP_DN); + }}} + //***************************************************************** + //Shift if price not wanted + if (Show_Smaller_Size == false) + { + if (Show_Xtra_Details == true) + { + if (Show_Price == false) + { + + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7","Spread", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8",""+SPREAD+"", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7","Spread", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8",""+SPREAD+"", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9","Pips to Open", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, 75+Shift_UP_DN); + + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10",""+PIPS+"", 12, "Arial Bold", color_pip); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, 75+Shift_UP_DN); + + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11","Hi to Low", 12, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, 90+Shift_UP_DN); + + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12",""+HILO+"", 12, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, 90+Shift_UP_DN); + + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13","Daily Av", 12, "Arial",CommentLabel_color); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, 45+Adjust_Side_to_side); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, 105+Shift_UP_DN); + + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14",""+DAV+"", 12, "Arial Bold", color_av); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, 105+Shift_UP_DN); + }}} + + //*********************************************************************** + //Smaller type option + if (Show_Smaller_Size == true) + { + if (Show_Xtra_Details == true) + { + if (Show_Price == true) + { + + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7","Spread", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, 80+Shift_UP_DN); + + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8",""+SPREAD+"", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, 80+Shift_UP_DN); + + + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9","Pips to Open", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, 95+Shift_UP_DN); + + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10",""+PIPS+"", 9, "Arial Bold", color_pip); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, 95+Shift_UP_DN); + + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11","Hi to Low", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, 110+Shift_UP_DN); + + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12",""+HILO+"", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, 110+Shift_UP_DN); + + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13","Daily Av", 9, "Arial",CommentLabel_color); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, 125+Shift_UP_DN); + + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14",""+DAV+"", 9, "Arial Bold", color_av); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, 125+Shift_UP_DN); + }}} + + //**************************************************************** + // Shift if Price not needed + if (Show_Smaller_Size == true) + { + if (Show_Xtra_Details == true) + { + if (Show_Price == false) + { + + ObjectCreate("MMLEVELS7", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS7","Spread", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS7", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS7", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS7", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + ObjectCreate("MMLEVELS8", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS8",""+SPREAD+"", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS8", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS8", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS8", OBJPROP_YDISTANCE, 60+Shift_UP_DN); + + ObjectCreate("MMLEVELS9", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS9","Pips to Open", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS9", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS9", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS9", OBJPROP_YDISTANCE, 75+Shift_UP_DN); + + ObjectCreate("MMLEVELS10", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS10",""+PIPS+"", 9, "Arial Bold", color_pip); + ObjectSet("MMLEVELS10", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS10", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS10", OBJPROP_YDISTANCE, 75+Shift_UP_DN); + + ObjectCreate("MMLEVELS11", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS11","Hi to Low", 9, "Arial", CommentLabel_color); + ObjectSet("MMLEVELS11", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS11", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS11", OBJPROP_YDISTANCE, 90+Shift_UP_DN); + + ObjectCreate("MMLEVELS12", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS12",""+HILO+"", 9, "Arial Bold", Gold); + ObjectSet("MMLEVELS12", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS12", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS12", OBJPROP_YDISTANCE, 90+Shift_UP_DN); + + ObjectCreate("MMLEVELS13", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS13","Daily Av", 9, "Arial",CommentLabel_color); + ObjectSet("MMLEVELS13", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS13", OBJPROP_XDISTANCE, 40+Adjust_Side_to_side); + ObjectSet("MMLEVELS13", OBJPROP_YDISTANCE, 105+Shift_UP_DN); + + ObjectCreate("MMLEVELS14", OBJ_LABEL, 0, 0, 0); + ObjectSetText("MMLEVELS14",""+DAV+"", 9, "Arial Bold", color_av); + ObjectSet("MMLEVELS14", OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP); + ObjectSet("MMLEVELS14", OBJPROP_XDISTANCE, 10+Adjust_Side_to_side); + ObjectSet("MMLEVELS14", OBJPROP_YDISTANCE, 105+Shift_UP_DN); + + + }}} + //---- + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Spread.mq4 b/Spread.mq4 new file mode 100644 index 0000000..16d3a16 --- /dev/null +++ b/Spread.mq4 @@ -0,0 +1,70 @@ +//+------------------------------------------------------------------+ +//| Spread.mq4 | +//| Copyright © 2009, Andriy Moraru | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2009, Andriy Moraru" +#property link "http://www.earnforex.com" + +#property indicator_chart_window + +extern color font_color = Red; +extern int font_size = 14; +extern string font_face = "Arial"; +extern int corner = 0; //0 - for top-left corner, 1 - top-right, 2 - bottom-left, 3 - bottom-right +extern int spread_distance_x = 10; +extern int spread_distance_y = 130; +extern bool normalize = false; //If true then the spread is normalized to traditional pips + +double Poin; +int n_digits = 0; +double divider = 1; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() +{ + //Checking for unconvetional Point digits number + if (Point == 0.00001) Poin = 0.0001; //5 digits + else if (Point == 0.001) Poin = 0.01; //3 digits + else Poin = Point; //Normal + + ObjectCreate("Spread", OBJ_LABEL, 0, 0, 0); + ObjectSet("Spread", OBJPROP_CORNER, corner); + ObjectSet("Spread", OBJPROP_XDISTANCE, spread_distance_x); + ObjectSet("Spread", OBJPROP_YDISTANCE, spread_distance_y); + double spread = MarketInfo(Symbol(), MODE_SPREAD); + + if ((Poin > Point) && (normalize)) + { + divider = 10.0; + n_digits = 1; + } + + ObjectSetText("Spread", "Spread: " + DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) + " points.", font_size, font_face, font_color); + + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() +{ + ObjectDelete("Spread"); + return(0); +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ + RefreshRates(); + + double spread = (Ask - Bid) / Point; + ObjectSetText("Spread", "Spread: " + DoubleToStr(NormalizeDouble(spread / divider, 1), n_digits) + " points.", font_size, font_face, font_color); + + return(0); +} +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Swing line histo.mq4 b/Swing line histo.mq4 new file mode 100644 index 0000000..536c826 --- /dev/null +++ b/Swing line histo.mq4 @@ -0,0 +1,315 @@ +//+------------------------------------------------------------------+ +//| Swing line.mq4 | +//| | +//| September 2010 issue | +//| Technical Analysis of Stocks and Commodities | +//| Ron Black's article “Getting Clear With Short-Term Swings” | +//+------------------------------------------------------------------+ +#property copyright "mladen" +#property link "mladenfx@gmail.com" + +#property indicator_separate_window +#property indicator_buffers 2 +#property indicator_color1 DeepSkyBlue +#property indicator_color2 Red +#property indicator_width1 2 +#property indicator_width2 2 +#property indicator_minimum 0 + +// +// +// +// +// + +extern string TimeFrame = "current time frame"; +extern bool alertsOn = False; +extern bool alertsOnCurrent = true; +extern bool alertsMessage = true; +extern bool alertsSound = false; +extern bool alertsEmail = false; + +// +// +// +// +// + +double buffer1[]; +double buffer2[]; +double trend[]; + +// +// +// +// +// + +string indicatorFileName; +bool returnBars; +bool calculateValue; +int timeFrame; + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +// +// +// +// +// + +int init() +{ + IndicatorBuffers(3); + indicatorFileName = WindowExpertName(); + returnBars = TimeFrame=="returnBars"; if (returnBars) { SetIndexBuffer(0,trend); return(0); } + calculateValue = TimeFrame=="calculateValue"; if (calculateValue) { SetIndexBuffer(0,trend); return(0); } + + SetIndexBuffer(0,buffer1); SetIndexStyle(0,DRAW_HISTOGRAM); + SetIndexBuffer(1,buffer2); SetIndexStyle(1,DRAW_HISTOGRAM); + SetIndexBuffer(2,trend); + + // + // + // + // + // + + timeFrame = stringToTimeFrame(TimeFrame); + IndicatorShortName("Swing line "+timeFrameToString(timeFrame)); + return(0); +} + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +// +// +// +// +// + +double work[][4]; +#define hHi 0 +#define hLo 1 +#define lHi 2 +#define lLo 3 + +// +// +// +// +// + +int start() +{ + int counted_bars=IndicatorCounted(); + int i,r,limit; + + if(counted_bars<0) return(-1); + if(counted_bars>0) counted_bars--; + limit=MathMin(Bars-counted_bars,Bars-1); + if (returnBars) { trend[0] = limit+1; return(0); } + + // + // + // + // + // + + if (calculateValue || timeFrame==Period()) + { + if (ArrayRange(work,0)!=Bars) ArrayResize(work,Bars); + + // + // + // + // + // + + for(i=limit,r=Bars-limit-1; i>=0; i--,r++) + { + if (i==Bars-1) + { + work[r][hHi] = High[i]; work[r][hLo] = Low[i]; + work[r][lHi] = High[i]; work[r][lLo] = Low[i]; + trend[i] = -1; + continue; + } + + // + // + // + // + // + + trend[i] = trend[i+1]; + work[r][hHi] = work[r-1][hHi]; work[r][hLo] = work[r-1][hLo]; + work[r][lHi] = work[r-1][lHi]; work[r][lLo] = work[r-1][lLo]; + + if (trend[i+1] == 1) + { + work[r][hHi] = MathMax(work[r-1][hHi],High[i]); + work[r][hLo] = MathMax(work[r-1][hLo],Low[i]); + if (High[i]work[r][lHi]) { trend[i] = 1; work[r][hHi] = High[i]; work[r][hLo] = Low[i]; } + } + + if (!calculateValue) manageBar(i); + } + + if (!calculateValue) manageAlerts(); + return(0); + } + + // + // + // + // + // + + limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period())); + for(i=limit; i>=0; i--) + { + int y = iBarShift(NULL,timeFrame,Time[i]); + trend[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",0,y); manageBar(i); + } + + // + // + // + // + // + + manageAlerts(); + return(0); +} + +//+------------------------------------------------------------------- +//| +//+------------------------------------------------------------------- +// +// +// +// +// + +void manageBar(int i ) +{ + + if (trend[i]==1) + { buffer1[i] = 1; buffer2[i] = EMPTY_VALUE; } + else { buffer1[i] = EMPTY_VALUE; buffer2[i] = 1; } +} + +//+------------------------------------------------------------------- +//| +//+------------------------------------------------------------------- +// +// +// +// +// + +void manageAlerts() +{ + if (alertsOn) + { + if (alertsOnCurrent) + int whichBar = 0; + else whichBar = 1; whichBar = iBarShift(NULL,0,iTime(NULL,timeFrame,whichBar)); + if (trend[whichBar] != trend[whichBar+1]) + { + if (trend[whichBar] == 1) doAlert(whichBar,"up"); + if (trend[whichBar] ==-1) doAlert(whichBar,"down"); + } + } +} + +// +// +// +// +// + +void doAlert(int forBar, string doWhat) +{ + static string previousAlert="nothing"; + static datetime previousTime; + string message; + + if (previousAlert != doWhat || previousTime != Time[forBar]) { + previousAlert = doWhat; + previousTime = Time[forBar]; + + // + // + // + // + // + + message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," "+timeFrameToString(timeFrame)+" Swing line changed to ",doWhat); + if (alertsMessage) Alert(message); + if (alertsEmail) SendMail(StringConcatenate(Symbol(),"Swing line "),message); + if (alertsSound) PlaySound("alert2.wav"); + } +} + +//+------------------------------------------------------------------- +//| +//+------------------------------------------------------------------- +// +// +// +// +// + +string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"}; +int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200}; + +// +// +// +// +// + +int stringToTimeFrame(string tfs) +{ + tfs = StringUpperCase(tfs); + for (int i=ArraySize(iTfTable)-1; i>=0; i--) + if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period())); + return(Period()); +} +string timeFrameToString(int tf) +{ + for (int i=ArraySize(iTfTable)-1; i>=0; i--) + if (tf==iTfTable[i]) return(sTfTable[i]); + return(""); +} + +// +// +// +// +// + +string StringUpperCase(string str) +{ + string s = str; + + for (int length=StringLen(str)-1; length>=0; length--) + { + int char = StringGetChar(s, length); + if((char > 96 && char < 123) || (char > 223 && char < 256)) + s = StringSetChar(s, length, char - 32); + else if(char > -33 && char < 0) + s = StringSetChar(s, length, char + 224); + } + return(s); +} \ No newline at end of file diff --git a/T3_2ColorHisto.mq4 b/T3_2ColorHisto.mq4 new file mode 100644 index 0000000..71e880e --- /dev/null +++ b/T3_2ColorHisto.mq4 @@ -0,0 +1,238 @@ +//+-------------------------------------------------------------------+ +//| T3 2Color.mq4 | +//| 2012 04 14 Cody_r | +//| Derived from T3 clean.mq4 | +//| mladen | +//| Modified to use one buffer for T3, and 2 more for color change | +//| 2012 05 02 Corrected the sign of the histo assignment +//| Corrected a limit in the histo assignment -3 to -1 +//+-------------------------------------------------------------------+ + +#property indicator_separate_window +#property indicator_buffers 3 +#property indicator_color1 C'0,90,255' +#property indicator_color2 Red +#property indicator_width1 2 +#property indicator_width2 2 +#property indicator_minimum 0 +#property indicator_maximum 1 + +extern int T3Period = 8; +extern int T3Price = PRICE_CLOSE; + double b = 0.618; + string TimeFrame = "current time frame"; +extern int BarCount = 1500; + +double Uptrend[]; +double Dntrend[]; +double t3Array[]; + +double e1,e2,e3,e4,e5,e6; +double c1,c2,c3,c4; +double w1,w2,b2,b3; +int t3.period; +double ae1[]; +double ae2[]; +double ae3[]; +double ae4[]; +double ae5[]; +double ae6[]; +double trend[]; +datetime OldTime = -999999; +int OldBars = -999999; // + +int timeFrame; +string IndicatorFileName; + + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ + +int init() +{ + SetIndexBuffer(0, Uptrend); + SetIndexBuffer(1, Dntrend); + SetIndexBuffer(2, t3Array); + SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2); + SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2); + SetIndexStyle(2,DRAW_NONE); + + ArrayResize(ae1, BarCount); ArraySetAsSeries(ae1, true); + ArrayResize(ae2, BarCount); ArraySetAsSeries(ae2, true); + ArrayResize(ae3, BarCount); ArraySetAsSeries(ae3, true); + ArrayResize(ae4, BarCount); ArraySetAsSeries(ae4, true); + ArrayResize(ae5, BarCount); ArraySetAsSeries(ae5, true); + ArrayResize(ae6, BarCount); ArraySetAsSeries(ae6, true); + ArrayResize(trend, BarCount); ArraySetAsSeries(trend, true); + + OldTime = Time[0]; + + SetIndexLabel(0,NULL); + SetIndexLabel(1,NULL); + SetIndexLabel(2,("T3 Price "+TimeFrameToString(timeFrame)+"("+T3Period+")")); + + timeFrame = stringToTimeFrame(TimeFrame); + IndicatorShortName("T3 Price "+TimeFrameToString(timeFrame)+"("+T3Period+")"); + IndicatorFileName = WindowExpertName(); + if (t3.period != T3Period) + { + t3.period = T3Period; + b2 = b*b; + b3 = b2*b; + + c1 = -b3; + c2 = (3*(b2+b3)); + c3 = -3*(2*b2+b+b3); + c4 = (1+3*b+b3+3*b2); + + w1 = 2 / (2 + 0.5*(MathMax(1,T3Period)-1)); + w2 = 1 - w1; + } + return(0); +} + + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ + +int start() +{ + int counted_bars=IndicatorCounted(); + int i,limit; + + if (Time[0] != OldTime) SyncExtraBuffers(); + + if(counted_bars<0) return(-1); + if(counted_bars>0) counted_bars--; + limit = MathMin(BarCount, Bars - 1 - counted_bars); + + for(i=limit; i>=0; i--) + { + double price = iMA(NULL,0,1,0,MODE_SMA, T3Price, i); + e1 = w1*price + w2*ae1[i+1]; + e2 = w1*e1 + w2*ae2[i+1]; + e3 = w1*e2 + w2*ae3[i+1]; + e4 = w1*e3 + w2*ae4[i+1]; + e5 = w1*e4 + w2*ae5[i+1]; + e6 = w1*e5 + w2*ae6[i+1]; + t3Array[i]=c1*e6 + c2*e5 + c3*e4 + c4*e3; + ae1[i] = e1; + ae2[i] = e2; + ae3[i] = e3; + ae4[i] = e4; + ae5[i] = e5; + ae6[i] = e6; + } + + for (int x = limit-1; x >= 0; x--) + { + trend[x] = trend[x+1]; + if (t3Array[x]> t3Array[x+1]) trend[x] = 1; + if (t3Array[x]< t3Array[x+1]) trend[x] =-1; + + if (trend[x]>0) + { + Uptrend[x] = trend[x]; + //if (trend[x+1]<0) Uptrend[x+1]=trend[x+1]; + Dntrend[x] = EMPTY_VALUE; + } + else + if (trend[x]<0) + { + Dntrend[x] = -trend[x]; + //if (trend[x+1]>0) Dntrend[x+1]=-trend[x+1]; + Uptrend[x] = EMPTY_VALUE; + } + + //Print( " trend=",trend[x]); + } + + return(0); +} + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ + +//+------------------------------------------------------------------+ +//| +//+------------------------------------------------------------------+ + +int stringToTimeFrame(string tfs) +{ + int tf=0; + tfs = StringTrimLeft(StringTrimRight(StringUpperCase(tfs))); + if (tfs=="M1" || tfs=="1") tf=PERIOD_M1; + if (tfs=="M5" || tfs=="5") tf=PERIOD_M5; + if (tfs=="M15"|| tfs=="15") tf=PERIOD_M15; + if (tfs=="M30"|| tfs=="30") tf=PERIOD_M30; + if (tfs=="H1" || tfs=="60") tf=PERIOD_H1; + if (tfs=="H4" || tfs=="240") tf=PERIOD_H4; + if (tfs=="D1" || tfs=="1440") tf=PERIOD_D1; + if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1; + if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1; + if (tf= 0) + { + char = StringGetChar(s, lenght); + + if((char > 96 && char < 123) || (char > 223 && char < 256)) + s = StringSetChar(s, lenght, char - 32); + else + if(char > -33 && char < 0) + s = StringSetChar(s, lenght, char + 224); + lenght--; + } + + return(s); +} + +//+------------------------------------------------------------------+ +//| Shift array elements on new bar | +//+------------------------------------------------------------------+ +void SyncExtraBuffers() + { + for (int i = BarCount - 1; i >= 0; i--) + { + ae1[i + 1] = ae1[i]; + ae2[i + 1] = ae2[i]; + ae3[i + 1] = ae3[i]; + ae4[i + 1] = ae4[i]; + ae5[i + 1] = ae5[i]; + ae6[i + 1] = ae6[i]; + trend[i + 1] = trend[i]; + } +//---- reset counter + OldTime = Time[0]; + } + diff --git a/THV3 Trix called.mq4 b/THV3 Trix called.mq4 new file mode 100644 index 0000000..604d37f --- /dev/null +++ b/THV3 Trix called.mq4 @@ -0,0 +1,893 @@ +//+------------------------------------------------------------------+ +//| Shared by www.cobraforex.com | +//+------------------------------------------------------------------+ + +//+------------------------------------------------------------------+ +//| THV3 trix.mq4 | +//| orginal by Luis Damiani | +//|Modified by Cobraforex and team for THV System, www.cobraforex.com| +//+------------------------------------------------------------------+ + +/*-------------------------------------------------------------------- +THV T3 Trix_v2: + +On the Inputs tab of the Indicator Window, only one number representing +the absolute value for the High and Low lines, needs to be entered for +these two lines to be created. A Zero line has been added also. In the +Colors tab these three lines can be separately colored and styled. The +lines truncate at the current candle instead of continuing to the right +margin of the chart. Default values for the High and Low lines are in +the code for each chart timeframe. The user only needs to enter input +a value in the indicator window if the default does not produce the +desired span between these two lines. Any value other than zero that +exists in the indicator window overrides the default for that timeframe. + + - Traderathome December 8, 2008 +THV T3 Trix_v3: +Revised to add Alert when the trix signal line crosses the zero line +and to add text in the indicator window. + + - Traderathome, December 15, 2008 +THV T3 Trix_v4: +Revised so that the Trix line will now change colour depending on slope +Also added in alert code for when Trix crosses its signal line + - Hiachiever, January 22, 2009 + +THV T3 Trix_v4_Divergence: +Divergence lines were added to show divergences between Trixes and Prices. +Modified based on FX5_MACD_Divergence v.1.1 + +Trix Divergence: +This indicator will plot divergence lines on the Fast Trix indicator and +will give buy and sell signal by displaying green and red arrows. +It also has a built-in alert function. As the original indicator, +bullish divergence is plotted in blue lines while bearish divergence is +plotted in red. If the divergence is classic the line will be solid and +if the type is reversed the line will be drawn in dots. + - PeterD, February 02, 2009 + +this indicator we will use for the THV EA and the MTF indicators of MissPips. +It has no external variants. +Cobra + +Added time variable to shortname and line name so that each windowname line namewill be unique because +it will include the time it was initialized. This way the o/b and o/s lines +won't get overwritten + +----------------------------------------------------------------------*/ + + +#property copyright "basic version by Luis Damiani" +#property link "www.cobraforex.com" + +#property indicator_separate_window + +#property indicator_buffers 6 + +#property indicator_color1 Green //TRIX Up line +#property indicator_color2 Crimson //TRIX Dn line +#property indicator_color3 Lime //Signal Up line +#property indicator_color4 Red //Signal Dn line +#property indicator_color5 Lime //Signal Up line +#property indicator_color6 Red //Signal Dn line + +#property indicator_width1 2 +#property indicator_width2 2 + +#define iName "THVTrix V" +#define vers "17.March.2009" +#define major "5" +#define minor "00" +#define Prefix "Trix_called" + +//---- input parameters + extern int A_t3_period = 20; + extern int B_t3_period_ac = 35; + extern bool EA_mode = false; + + string note1="Trix level colors"; + color HighLine_Color = FireBrick; + color ZeroLine_Color = DimGray; + color LowLine_Color = DarkGreen; + int Line_Style = STYLE_DOT; + string note2="Cobra Label colors"; + color text1Color = C'119,119,0'; + color text2Color = C'119,119,0'; + color text3Color = Green; + +string Alerts = "===== Alert Settings ====="; + bool MsgAlerts = false; + bool SoundAlerts = false; + bool eMailAlerts= false; + bool AlertOnTrixCross = false; + bool AlertOnTrixSigCross = false; + bool AlertOnSlopeChange = false; + string TrixCrossSound = "trixcross.wav"; + int AnalyzeLabelWindow = 1; + bool AnalyzeLabelonoff = false; +int Shift_UP_DN = 0; +int Shift_Left_Right = 0; + +double HighLow_Levels_Override_Value = 0; + +int Trixnum_bars = 750; +int is_A_open_price = 0; +int diferential = 0; +double hot = 0.7; + +//---- buffers +double TrixBuffer[]; +double TrixUpBuffer[]; +double TrixDnBuffer[]; + +double TrixSigBuffer[]; +double TrixSigUpBuffer[]; +double TrixSigDnBuffer[]; + +double AL1, AL2; +int LastAlert; +string ShortName; + +//==========================================================================================// +// Added Monday, February 02, 2009 - by PeterD based on FX5_MACD Divergence// +// Divergence variables // +#define arrowsDisplacement 0.0001 +static string indicatorName; +static datetime lastAlertTime; +static datetime lastSoundAlertTime; + + string separator2 = "*** Divergence Settings ***"; + int NumberOfDivergenceBars = 500; + bool drawPriceTrendLines = false; + bool drawIndicatorTrendLines = false; + bool ShowIn1MChart = true; + + string _ = "--- Divergence Alert Settings ---"; + bool EnableAlerts = false; + string _Info1 = ""; + string _Info2 = "------------------------------------"; + string _Info3 = "SoundAlertOnDivergence only works"; + string _Info4 = "when EnableAlerts is true."; + string _Info5 = ""; + string _Info6 = "If SoundAlertOnDivergence is true,"; + string _Info7 = "then sound alert will be generated,"; + string _Info8 = "otherwise a pop-up alert will be"; + string _Info9 = "generated."; + string _Info10 = "------------------------------------"; + string _Info11 = ""; + bool SoundAlertOnDivergence = false; + bool EmailDivergenceAlerts = false; + + string __ = "--- Divergence Color Settings ---"; + color BullishDivergenceColor = DodgerBlue; + color BearishDivergenceColor = FireBrick; + + string ___ = "--- Divergence Sound Files ---"; + string ClassicBullDivSound = "CBullishDiv.wav"; + string ReverseBullDivSound = "RBullishDiv.wav"; + string ClassicBearDivSound = "CBearishDiv.wav"; + string ReverseBearDivSound = "RBearishDiv.wav"; + +double bullishDivergence[]; +double bearishDivergence[]; +datetime t; +string t1; +// Divergence variables // +//==========================================================================================// + + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +//---- indicators + t=TimeLocal( ) ; + t1=TimeToStr(t,TIME_SECONDS); + IndicatorBuffers(8); + + SetIndexStyle(0,DRAW_LINE); //draw Trix Up line + SetIndexBuffer(0,TrixUpBuffer); + SetIndexStyle(1,DRAW_LINE); //draw Trix Down line + SetIndexBuffer(1,TrixDnBuffer); + + SetIndexStyle(2,DRAW_LINE); //draw Trix Sig Up line + SetIndexBuffer(2,TrixSigUpBuffer); + SetIndexStyle(3,DRAW_LINE); //draw Trix Sig Down line + SetIndexBuffer(3,TrixSigDnBuffer); + +// Modified for Convergence / Divergence // +// SetIndexBuffer(4,TrixSigBuffer); +// SetIndexBuffer(5,TrixBuffer); + + +//==========================================================================================// +// Added Monday, February 02, 2009 - by PeterD based on FX5_MACD Divergence// +// Convergence / Divergence buffers // + SetIndexBuffer(4, bullishDivergence); + SetIndexBuffer(5, bearishDivergence); +//---- + SetIndexStyle(4, DRAW_ARROW); + SetIndexStyle(5, DRAW_ARROW); +//---- + SetIndexArrow(4, 233); + SetIndexArrow(5, 234); + SetIndexDrawBegin(5, 9); + IndicatorDigits(Digits + 2); + + SetIndexBuffer(6,TrixSigBuffer); + SetIndexBuffer(7,TrixBuffer); +//==========================================================================================// + + + //---- name for DataWindow and indicator subwindow label + ShortName = t1+iName + major + "." + minor; + + indicatorName = ShortName; + IndicatorShortName(ShortName); + + return(0); + } + +//+------------------------------------------------------------------+ +//| Custor indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() +{ + DeleteObjects(Prefix); + Comment (""); + return(0); +} + +void drawLine(string name, double price, color Col, int LvlStyle) +{ + if (WindowFind(ShortName) != -1 && !EA_mode) + { + ObjectDelete(name); + ObjectCreate(name, OBJ_HLINE,WindowFind(ShortName),Time[0],price); + ObjectSet(name, OBJPROP_STYLE, LvlStyle); + ObjectSet(name, OBJPROP_COLOR, Col); + ObjectSet(name, OBJPROP_WIDTH,1); + } +} + +//+------------------------------------------------------------------+ +//| Delete Objects that match ObjName | +//+------------------------------------------------------------------+ +void DeleteObjects(string ObjName) +{ + for (int i=ObjectsTotal()-1; i >= 0; i--) + { + string name = ObjectName(i); + if (StringFind(name, ObjName) > -1) ObjectDelete(name); + } +} + +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() +{ +if (!EA_mode) +{ +//---- + ObjectCreate("text1", OBJ_LABEL,AnalyzeLabelWindow, 0, 0); + ObjectSetText("text1","THV V 3",14, "Arial Black", text1Color); + ObjectSet("text1", OBJPROP_CORNER, 1); + ObjectSet("text1", OBJPROP_XDISTANCE,Shift_Left_Right +13); + ObjectSet("text1", OBJPROP_YDISTANCE,Shift_UP_DN +1); +//---- +//---- + ObjectCreate("text2", OBJ_LABEL,AnalyzeLabelWindow, 0, 0); + ObjectSetText("text2","System",9, "Batang", text2Color); + ObjectSet("text2", OBJPROP_CORNER, 1); + ObjectSet("text2", OBJPROP_XDISTANCE,Shift_Left_Right +32); + ObjectSet("text2", OBJPROP_YDISTANCE,Shift_UP_DN +26); +//---- +//---- + ObjectCreate("text3", OBJ_LABEL,AnalyzeLabelWindow, 0, 0); + ObjectSetText("text3","© By Cobraforex",8, "Arial", text3Color); + ObjectSet("text3", OBJPROP_CORNER, 1); + ObjectSet("text3", OBJPROP_XDISTANCE,Shift_Left_Right +18); + ObjectSet("text3", OBJPROP_YDISTANCE,Shift_UP_DN +41); +//---- +} + double ZHL; + if (Period()==1)ZHL = 0.00011; + if (Period()==5)ZHL = 0.00022; + if (Period()==15)ZHL = 0.00045; + if (Period()==30)ZHL = 0.0007; + if (Period()==60)ZHL = 0.0009; + if (Period()==240)ZHL = 0.002; + if (Period()==1440)ZHL = 0.005; + if (Period()==10080)ZHL = 0.0075; + if (Period()==43200)ZHL = 0.015; + if(HighLow_Levels_Override_Value > 0) {ZHL = HighLow_Levels_Override_Value;} + double ZH = ZHL; double ZL = -1* ZHL; +if (!EA_mode) +{ + drawLine(Prefix + t1+"line_HL", ZH, HighLine_Color, Line_Style); + drawLine(Prefix + t1+ "line_ZL", 0, ZeroLine_Color, Line_Style); + drawLine(Prefix + t1+ "line_LL", ZL, LowLine_Color, Line_Style); +} + int shift=0; + double A_t3=0,A_t3_1=0,max_per=0; + double B_t3=0,B_t3_1=0; + double e1=0,e2=0,e3=0,e4=0,e5=0,e6=0,c1=0,c2=0,c3=0,c4=0; + double e1x=0,e2x=0,e3x=0,e4x=0,e5x=0,e6x=0; + double d1=0,d2=0,d3=0,d4=0,d5=0,d6=0; + double d1x=0,d2x=0,d3x=0,d4x=0,d5x=0,d6x=0; + double n=0,A_w1=0,A_w2=0,B_w1=0,B_w2=0,b2=0,b3=0; + double init=true; + double bar=0, prevbars=0, start=0, cs=0, prevcs=0,frame=0; + string AlertTxt, commodt="nonono"; + int counted_bars=IndicatorCounted(); + bool blnShowDiv = true; + cs = Trixnum_bars+A_t3_period+is_A_open_price+B_t3_period_ac+diferential+hot; + if (cs==prevcs && commodt==Symbol() && frame==Time[4]-Time[5] && Bars-prevbars<2) + start=Bars-prevbars; + else start=-1; + commodt=Symbol(); + frame=Time[4]-Time[5]; + prevbars = Bars; + prevcs = cs; + if (start==1 || start==0) bar=start; else init=true; + + // Modified for Divergence/convergence // + if (!ShowIn1MChart && Period() == 1) blnShowDiv=false; + // Modified for Divergence/convergence // + + if (init==true) + { + b2=hot*hot; + b3=b2*hot; + c1=-b3; + c2=(3*(b2+b3)); + c3=-3*(2*b2+hot+b3); + c4=(1+3*hot+b3+3*b2); + n=A_t3_period; + if (n<1) n=1; + n = 1 + 0.5*(n-1); + A_w1 = 2 / (n + 1); + A_w2 = 1 - A_w1; + n=B_t3_period_ac; + if (n<1) n=1; + n = 1 + 0.5*(n-1); + B_w1 = 2 / (n + 1); + B_w2 = 1 - B_w1; + + TrixBuffer[Trixnum_bars-1]=0; + d1x=0;d2x=0;d3x=0;d4x=0;d5x=0;d6x=0; + TrixSigBuffer[Trixnum_bars-1]=0; + e1x=0;e2x=0;e3x=0;e4x=0;e5x=0;e6x=0; + + // max_per=max(A_t3_period,B_t3_period_ac); + bar=Trixnum_bars-2; + + init=false; + } + + //SetLoopCount(0); + shift=bar; + + while(shift>=0) + { + if ( is_A_open_price==1 ) d1 = A_w1*Open[shift] + A_w2*d1x; + else d1 = A_w1*Close[shift] + A_w2*d1x; + d2 = A_w1*d1 + A_w2*d2x; + d3 = A_w1*d2 + A_w2*d3x; + d4 = A_w1*d3 + A_w2*d4x; + d5 = A_w1*d4 + A_w2*d5x; + d6 = A_w1*d5 + A_w2*d6x; + A_t3 = c1*d6 + c2*d5 + c3*d4 + c4*d3; + + if ((start==1 && shift==1) || start==-1 ) + { + d1x=d1; + d2x=d2; + d3x=d3; + d4x=d4; + d5x=d5; + d6x=d6; + } + + e1 = B_w1*Close[shift] + B_w2*e1x; + e2 = B_w1*e1 + B_w2*e2x; + e3 = B_w1*e2 + B_w2*e3x; + e4 = B_w1*e3 + B_w2*e4x; + e5 = B_w1*e4 + B_w2*e5x; + e6 = B_w1*e5 + B_w2*e6x; + B_t3 = c1*e6 + c2*e5 + c3*e4 + c4*e3; + + if(diferential==1) + { + TrixBuffer[shift]=(A_t3-A_t3_1)/A_t3_1+(B_t3-B_t3_1)/B_t3_1; + TrixSigBuffer[shift]=(A_t3-A_t3_1)/A_t3_1; + AL2= TrixSigBuffer[shift]; + } + else + { + if ( B_t3_1 >0 && A_t3_1>0) + { + TrixBuffer[shift]=(B_t3-B_t3_1)/B_t3_1; + TrixSigBuffer[shift]=(A_t3-A_t3_1)/A_t3_1; + AL2= TrixSigBuffer[shift]; + } + } + + TrixUpBuffer[shift] = EMPTY_VALUE; + TrixDnBuffer[shift] = EMPTY_VALUE; + + //Colour Coding Trix line + if(TrixBuffer[shift+1]TrixBuffer[shift]) + { + if(TrixDnBuffer[shift+1] == EMPTY_VALUE) TrixDnBuffer[shift+1] = TrixBuffer[shift+1]; + TrixDnBuffer[shift] = TrixBuffer[shift]; + } + + TrixSigUpBuffer[shift] = EMPTY_VALUE; + TrixSigDnBuffer[shift] = EMPTY_VALUE; + + if(TrixSigBuffer[shift+1]TrixSigBuffer[shift]) + { + if(TrixSigDnBuffer[shift+1] == EMPTY_VALUE) TrixSigDnBuffer[shift+1] = TrixSigBuffer[shift+1]; + TrixSigDnBuffer[shift] = TrixSigBuffer[shift]; + } + + // Comment(" start: ",start," bar: ",bar,"\n", + // "frame: ",frame," Trixnum_bars:" ,Trixnum_bars," commodity: ",commodt ,"\n",(B_t3-B_t3_1)/B_t3_1); + if ((start==1 && shift==1) || start==-1) + { + //Comment("Bar=ghfghfgh"); + A_t3_1=A_t3; + B_t3_1=B_t3; + e1x=e1; + e2x=e2; + e3x=e3; + e4x=e4; + e5x=e5; + e6x=e6; + } + + // Modified for Divergence/convergence // + if (shift <= NumberOfDivergenceBars && blnShowDiv) + { + CatchBullishDivergence(shift+2); + CatchBearishDivergence(shift+2); + } + // Modified for Divergence/convergence // + + shift--; + } + //----Alert code start---- + + string text; + if (!EA_mode) + {if (AL2>0) //Signal line is above axis + + + {if (AnalyzeLabelonoff) + text = "Bull cross"; + ObjectDelete("Trix_Crossing_Label"); + ObjectCreate("Trix_Crossing_Label", OBJ_LABEL, AnalyzeLabelWindow, 0, 0); + ObjectSet("Trix_Crossing_Label", OBJPROP_CORNER, 3); + ObjectSet("Trix_Crossing_Label", OBJPROP_XDISTANCE, 7); + ObjectSet("Trix_Crossing_Label", OBJPROP_YDISTANCE, 95); + ObjectSet("Trix_Crossing_Label", OBJPROP_COLOR, LimeGreen); + ObjectSetText("Trix_Crossing_Label", text, 14, "Arial Black", LimeGreen); + + } + + if (AL2<0) //Signal line is below axis + {if (AnalyzeLabelonoff) + text = "Bear cross"; + ObjectDelete("Trix_Crossing_Label"); + ObjectCreate("Trix_Crossing_Label", OBJ_LABEL, AnalyzeLabelWindow, 0, 0); + ObjectSet("Trix_Crossing_Label", OBJPROP_CORNER, 3); + ObjectSet("Trix_Crossing_Label", OBJPROP_XDISTANCE, 2); + ObjectSet("Trix_Crossing_Label", OBJPROP_YDISTANCE, 95); + ObjectSet("Trix_Crossing_Label", OBJPROP_COLOR, Red); + ObjectSetText("Trix_Crossing_Label", text, 14, "Arial Black", Red); + } + if(AL1<0 && AL2>0)if (AlertOnTrixCross)if (SoundAlerts) PlaySound(TrixCrossSound); + + AL1 = AL2; + + if( AlertOnTrixSigCross ) + { + if ( TrixSigBuffer[2]TrixBuffer[1] && LastAlertTrixBuffer[2] && TrixSigBuffer[1]TrixBuffer[1] && TrixSigUpBuffer[2]!=EMPTY_VALUE && TrixSigUpBuffer[1]==EMPTY_VALUE && LastAlert TrixSigBuffer[lastTrough] && + Low[currentTrough] < Low[lastTrough]) + { + bullishDivergence[currentTrough] = TrixSigBuffer[currentTrough] - + arrowsDisplacement; + //---- + if(drawPriceTrendLines == true) + DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], + Low[currentTrough], + Low[lastTrough], BullishDivergenceColor, STYLE_SOLID); + //---- + if(drawIndicatorTrendLines == true) + DrawIndicatorTrendLine(Time[currentTrough], + Time[lastTrough], + TrixSigBuffer[currentTrough], + TrixSigBuffer[lastTrough], + BullishDivergenceColor, STYLE_SOLID); + //---- + if(EnableAlerts == true) + { + if (SoundAlertOnDivergence == true) + { + SoundAlert(ClassicBullDivSound, currentTrough); + } + else + { + DisplayAlert("Classical bullish divergence on: ", currentTrough); + } + } + //---- + } +//---- + if(TrixSigBuffer[currentTrough] < TrixSigBuffer[lastTrough] && + Low[currentTrough] > Low[lastTrough]) + { + bullishDivergence[currentTrough] = TrixSigBuffer[currentTrough] - + arrowsDisplacement; + //---- + if(drawPriceTrendLines == true) + DrawPriceTrendLine(Time[currentTrough], Time[lastTrough], + Low[currentTrough], + Low[lastTrough], BullishDivergenceColor, STYLE_DOT); + //---- + if(drawIndicatorTrendLines == true) + DrawIndicatorTrendLine(Time[currentTrough], + Time[lastTrough], + TrixSigBuffer[currentTrough], + TrixSigBuffer[lastTrough], + BullishDivergenceColor, STYLE_DOT); + //---- + if(EnableAlerts == true) + { + if (SoundAlertOnDivergence == true) + { + SoundAlert(ReverseBullDivSound, currentTrough); + } + else + { + DisplayAlert("Reverse bullish divergence on: ", currentTrough); + } + } + } +} +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void CatchBearishDivergence(int shift) + { + if(IsIndicatorPeak(shift) == false) + return; + int currentPeak = shift; + int lastPeak = GetIndicatorLastPeak(shift); +//---- + if(TrixSigBuffer[currentPeak] < TrixSigBuffer[lastPeak] && + High[currentPeak] > High[lastPeak]) + { + bearishDivergence[currentPeak] = TrixSigBuffer[currentPeak] + + arrowsDisplacement; + + if(drawPriceTrendLines == true) + DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], + High[currentPeak], + High[lastPeak], BearishDivergenceColor, STYLE_SOLID); + + if(drawIndicatorTrendLines == true) + DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], + TrixSigBuffer[currentPeak], + TrixSigBuffer[lastPeak], BearishDivergenceColor, STYLE_SOLID); + if(EnableAlerts == true) + { + if (SoundAlertOnDivergence == true) + { + SoundAlert(ClassicBearDivSound, currentPeak); + } + else + { + DisplayAlert("Classical bearish divergence on: ", currentPeak); + } + } + } + if(TrixSigBuffer[currentPeak] > TrixSigBuffer[lastPeak] && + High[currentPeak] < High[lastPeak]) + { + bearishDivergence[currentPeak] = TrixSigBuffer[currentPeak] + + arrowsDisplacement; + //---- + if(drawPriceTrendLines == true) + DrawPriceTrendLine(Time[currentPeak], Time[lastPeak], + High[currentPeak], + High[lastPeak], BearishDivergenceColor, STYLE_DOT); + //---- + if(drawIndicatorTrendLines == true) + DrawIndicatorTrendLine(Time[currentPeak], Time[lastPeak], + TrixSigBuffer[currentPeak], + TrixSigBuffer[lastPeak], BearishDivergenceColor, STYLE_DOT); + //---- + if(EnableAlerts == true) + { + if (SoundAlertOnDivergence == true) + { + SoundAlert(ReverseBearDivSound, currentPeak); + } + else + { + DisplayAlert("Reverse bearish divergence on: ", currentPeak); + } + } + } + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +bool IsIndicatorTrough(int shift) + { + if(TrixSigBuffer[shift] <= TrixSigBuffer[shift+1] && TrixSigBuffer[shift] < TrixSigBuffer[shift+2] && + TrixSigBuffer[shift] < TrixSigBuffer[shift-1]) + return(true); + else + return(false); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +int GetIndicatorLastTrough(int shift) + { + for(int i = shift + 5; i < Bars; i++) + { + if(TrixBuffer[i] <= TrixBuffer[i+1] && TrixBuffer[i] <= TrixBuffer[i+2] && + TrixBuffer[i] <= TrixBuffer[i-1] && TrixBuffer[i] <= TrixBuffer[i-2]) + { + for (int j = i; j < Bars; j++) + { + if(TrixSigBuffer[j] <= TrixSigBuffer[j+1] && TrixSigBuffer[j] < TrixSigBuffer[j+2] && + TrixSigBuffer[j] <= TrixSigBuffer[j-1] && TrixSigBuffer[j] < TrixSigBuffer[j-2]) + return(j); + } + } + } + return(-1); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void DrawPriceTrendLine(datetime x1, datetime x2, double y1, + double y2, color lineColor, double style) + {if (!EA_mode) + {string label = iName + major + "_Trix_DivergenceLine_# " + DoubleToStr(x1, 0); + ObjectDelete(label); + ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0); + ObjectSet(label, OBJPROP_RAY, 0); + ObjectSet(label, OBJPROP_COLOR, lineColor); + ObjectSet(label, OBJPROP_STYLE, style); + }} +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void DrawIndicatorTrendLine(datetime x1, datetime x2, double y1, + double y2, color lineColor, double style) + {if (!EA_mode) + {int indicatorWindow = WindowFind(indicatorName); + if(indicatorWindow < 0) + return; + string label = iName + major + "_Trix_DivergenceLine_$# " + DoubleToStr(x1, 0); + ObjectDelete(label); + ObjectCreate(label, OBJ_TREND, indicatorWindow, x1, y1, x2, y2, + 0, 0); + ObjectSet(label, OBJPROP_RAY, 0); + ObjectSet(label, OBJPROP_COLOR, lineColor); + ObjectSet(label, OBJPROP_STYLE, style); + }} +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void DisplayAlert(string message, int shift) + { + string strMsg; + if(shift <= 2 && Time[shift] != lastAlertTime) + { + lastAlertTime = Time[shift]; + Alert(message, Symbol(), " , ", TF2Str(Period()), " minutes chart"); + + string strSubject = "Divergence on " + TF2Str(Period()); + if (EmailDivergenceAlerts) SendMail(strSubject, message); + } + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +void SoundAlert(string strSoundFile, int shift) +{ + if(shift <= 2 && Time[shift] != lastSoundAlertTime) + { + lastSoundAlertTime = Time[shift]; + PlaySound(strSoundFile); + } +} +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +bool IsIndicatorPeak(int shift) + { + if(TrixSigBuffer[shift] >= TrixSigBuffer[shift+1] && TrixSigBuffer[shift] > TrixSigBuffer[shift+2] && + TrixSigBuffer[shift] > TrixSigBuffer[shift-1]) + return(true); + else + return(false); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +int GetIndicatorLastPeak(int shift) + { + for(int i = shift + 5; i < Bars; i++) + { + if(TrixBuffer[i] >= TrixBuffer[i+1] && TrixBuffer[i] >= TrixBuffer[i+2] && + TrixBuffer[i] >= TrixBuffer[i-1] && TrixBuffer[i] >= TrixBuffer[i-2]) + { + for(int j = i; j < Bars; j++) + { + if(TrixSigBuffer[j] >= TrixSigBuffer[j+1] && TrixSigBuffer[j] > TrixSigBuffer[j+2] && + TrixSigBuffer[j] >= TrixSigBuffer[j-1] && TrixSigBuffer[j] > TrixSigBuffer[j-2]) + return(j); + } + } + } + return(-1); + } +//==========================================================================================// + diff --git a/Trend_all_period.mq4 b/Trend_all_period.mq4 new file mode 100644 index 0000000..1765495 --- /dev/null +++ b/Trend_all_period.mq4 @@ -0,0 +1,207 @@ +//+------------------------------------------------------------------+ +//| Trend_all_period.mq4 | +//| Copyright © 2009, Хлыстов Владимир | +//| | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2009, Хлыстов Владимир" +#property link "cmillion@narod.ru" + +#property indicator_chart_window +//------------------------------------------------------------- +extern int size_font=10;//размер шрифта +extern int corner=3;//угол вывода данных +extern color color_UP = OrangeRed; +extern color color_DN = MediumBlue; +extern color color_0 = DimGray; +extern int period_TR=8;//период (только для "offset") +extern int offset_TR=5;//смещение (только для "offset") +//------------------------------------------------------------- +string typetrend[4] = {"offset","offset2","5 13 34","MACD 5 34 5"}; +string string_per[9] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN1"}; +int per[9] = {1,5,15,30,60,240,1440,10080,43200}; +int trend[9], + trendALL=0, + sim,i,d; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { + if (corner==1 || corner==2) {d = size_font*1.5;} else d = 0; + int Х = size_font*9; + double Y = 10*(size_font+2); + ObjectCreate ("All Period", OBJ_LABEL, 0, 0, 0); + ObjectSet ("All Period", OBJPROP_CORNER, corner); + ObjectSet ("All Period", OBJPROP_XDISTANCE, 10 ); + ObjectSet ("All Period", OBJPROP_YDISTANCE, 5); + for (i=0; i<9; i++) + { + ObjectCreate (string_per[i]+" Period", OBJ_LABEL, 0, 0, 0); + ObjectSetText(string_per[i]+" Period",string_per[i]+" ",size_font,"Arial",color_0); + ObjectSet (string_per[i]+" Period", OBJPROP_CORNER, corner); + ObjectSet (string_per[i]+" Period", OBJPROP_XDISTANCE, Х ); + ObjectSet (string_per[i]+" Period", OBJPROP_YDISTANCE, Y-i*(size_font+2)); + + ObjectCreate (string_per[i]+" MACD", OBJ_LABEL, 0, 0, 0); + ObjectSet (string_per[i]+" MACD", OBJPROP_CORNER, corner); + ObjectSet (string_per[i]+" MACD", OBJPROP_XDISTANCE, Х-size_font*2 ); + ObjectSet (string_per[i]+" MACD", OBJPROP_YDISTANCE, Y-i*(size_font+2)); + + ObjectCreate (string_per[i]+" MA5/13/34", OBJ_LABEL, 0, 0, 0); + ObjectSet (string_per[i]+" MA5/13/34", OBJPROP_CORNER, corner); + ObjectSet (string_per[i]+" MA5/13/34", OBJPROP_XDISTANCE, Х-size_font*4 ); + ObjectSet (string_per[i]+" MA5/13/34", OBJPROP_YDISTANCE, Y-i*(size_font+2)); + + ObjectCreate (string_per[i]+" offset2", OBJ_LABEL, 0, 0, 0); + ObjectSet (string_per[i]+" offset2", OBJPROP_CORNER, corner); + ObjectSet (string_per[i]+" offset2", OBJPROP_XDISTANCE, Х-size_font*6 ); + ObjectSet (string_per[i]+" offset2", OBJPROP_YDISTANCE, Y-i*(size_font+2)); + + ObjectCreate (string_per[i]+" offset", OBJ_LABEL, 0, 0, 0); + ObjectSet (string_per[i]+" offset", OBJPROP_CORNER, corner); + ObjectSet (string_per[i]+" offset", OBJPROP_XDISTANCE, Х-size_font*8 ); + ObjectSet (string_per[i]+" offset", OBJPROP_YDISTANCE, Y-i*(size_font+2)); + } + ObjectCreate (" MACD", OBJ_LABEL, 0, 0, 0); + ObjectSet (" MACD", OBJPROP_CORNER, corner); + ObjectSet (" MACD", OBJPROP_XDISTANCE, Х-size_font*2+d ); + ObjectSet (" MACD", OBJPROP_YDISTANCE, Y+size_font*6-d*2); + ObjectSet (" MACD", OBJPROP_ANGLE, 90); + ObjectSetText(" MACD", "MACD ",size_font,"Arial",color_0); + + ObjectCreate (" MA5/13/34", OBJ_LABEL, 0, 0, 0); + ObjectSet (" MA5/13/34", OBJPROP_CORNER, corner); + ObjectSet (" MA5/13/34", OBJPROP_XDISTANCE, Х-size_font*4+d ); + ObjectSet (" MA5/13/34", OBJPROP_YDISTANCE, Y+size_font*6-d*2); + ObjectSet (" MA5/13/34", OBJPROP_ANGLE, 90); + ObjectSetText(" MA5/13/34", "5/13/34",size_font,"Arial",color_0); + + ObjectCreate (" offset2", OBJ_LABEL, 0, 0, 0); + ObjectSet (" offset2", OBJPROP_CORNER, corner); + ObjectSet (" offset2", OBJPROP_XDISTANCE, Х-size_font*6+d ); + ObjectSet (" offset2", OBJPROP_YDISTANCE, Y+size_font*6-d*2); + ObjectSet (" offset2", OBJPROP_ANGLE, 90); + ObjectSetText(" offset2", "offset2 ",size_font,"Arial",color_0); + + ObjectCreate (" offset", OBJ_LABEL, 0, 0, 0); + ObjectSet (" offset", OBJPROP_CORNER, corner); + ObjectSet (" offset", OBJPROP_XDISTANCE, Х-size_font*8+d ); + ObjectSet (" offset", OBJPROP_YDISTANCE, Y+size_font*6-d*2); + ObjectSet (" offset", OBJPROP_ANGLE, 90); + ObjectSetText(" offset", "offset ",size_font,"Arial",color_0); + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { + ObjectDelete("All Period"); + ObjectDelete(" MACD"); + ObjectDelete(" MA5/13/34"); + ObjectDelete(" offset"); + ObjectDelete(" offset2"); + for (i=0; i<9; i++) + { + ObjectDelete(string_per[i]+" Period"); + ObjectDelete(string_per[i]+" MACD"); + ObjectDelete(string_per[i]+" MA5/13/34"); + ObjectDelete(string_per[i]+" offset"); + ObjectDelete(string_per[i]+" offset2"); + } + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { + if (ObjectFind("All Period")!=0) + { + init(); + //выбор типа + } + string str; + color colortrend; + //---------------------------------- + TR_R(0);//offset + for (i=0; i<9; i++) + { + trendALL = trendALL + trend[i]; + if (trend[i]==0){colortrend=color_0;str="";} + if (trend[i]>0) {colortrend=color_UP;str="UP";} + if (trend[i]<0) {colortrend=color_DN;str="DN";} + ObjectSetText(string_per[i]+" offset",str,size_font,"Arial",colortrend); + } + TR_R(1);//offset2 + for (i=0; i<9; i++) + { + trendALL = trendALL + trend[i]; + if (trend[i]==0){colortrend=color_0;str="";} + if (trend[i]>0) {colortrend=color_UP;str="UP";} + if (trend[i]<0) {colortrend=color_DN;str="DN";} + ObjectSetText(string_per[i]+" offset2",str,size_font,"Arial",colortrend); + } + TR_R(2);//MA5/13/34 + for (i=0; i<9; i++) + { + trendALL = trendALL + trend[i]; + if (trend[i]==0){colortrend=color_0;str="";} + if (trend[i]>0) {colortrend=color_UP;str="UP";} + if (trend[i]<0) {colortrend=color_DN;str="DN";} + ObjectSetText(string_per[i]+" MA5/13/34",str,size_font,"Arial",colortrend); + } + TR_R(3);//macd + for (i=0; i<9; i++) + { + trendALL = trendALL + trend[i]; + if (trend[i]==0){colortrend=color_0;str="";} + if (trend[i]>0) {colortrend=color_UP;str="UP";} + if (trend[i]<0) {colortrend=color_DN;str="DN";} + ObjectSetText(string_per[i]+" MACD",str,size_font,"Arial",colortrend); + } + if (trendALL==0){colortrend=color_0;str="";} + if (trendALL>0) {colortrend=Red; str="UP ";} + if (trendALL<0) {colortrend=Green;str="DN ";} + ObjectSetText("All Period","All "+str,size_font,"Arial",colortrend); +return(0); +} +//+------------------------------------------------------------------+ + //тип определения тренда + //0 - только по offset индикатору + //1 - если средняя больше = 1 и по colortrendу + //2 - по Вильямсу 5 13 34 + //3 - способ определения тренда по MACD 5 34 5 +//+------------------------------------------------------------------+ +void TR_R(int t) +{ + switch(t) + { + case 0 ://offset опережающий метод + for (i=0; i<9; i++) trend[i] = iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],2,0); + break; + case 1 ://offset устоявшийся тренд + for (i=0; i<9; i++) trend[i] = iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],2,0) + iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],5,0); + break; + case 2 : //способ определения тренда по методу Билла Вильямса на основе MA 5 13 34 + double MA5,MA13,MA34; + for (i=0; i<9; i++) + { + MA5 = iMA(NULL,per[i],5 ,0,MODE_SMA,PRICE_CLOSE,0); + MA13 = iMA(NULL,per[i],13,0,MODE_SMA,PRICE_CLOSE,0); + MA34 = iMA(NULL,per[i],34,0,MODE_SMA,PRICE_CLOSE,0); + trend[i] = 0; if (MA5 > MA13 && MA5 > MA34) trend[i] = 1; if (MA5 < MA13 && MA5 < MA34) trend[i] = -1; + } + break; + case 3 ://способ определения тренда по MACD 5 34 5 + for (i=0; i<9; i++) + { + trend[i] = 0; + if (iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,0) > iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,1)) trend[i] = 1; + if (iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,0) < iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,1)) trend[i] = -1; + } + break; + } +} +//+------------------------------------------------------------------+ + diff --git a/Uranus v0.2.mq4 b/Uranus v0.2.mq4 new file mode 100644 index 0000000..9732422 --- /dev/null +++ b/Uranus v0.2.mq4 @@ -0,0 +1,556 @@ +#property copyright "Copyright © 2009, xux99" +#property link "http://www.forexfactory.com/showthread.php?t=202556" + +extern string Entry_and_exit_conditions="----------------------------------------------------------------------"; +extern string DSSBressert = "1100"; +extern double DSSBressertLevel = 0; +extern string NonLagMA = "0000"; +extern string PriceChannelStop = "0000"; +extern string COGDirection = "0000"; +extern string COGDistance = "0000"; +extern double COGPercent = 50; +extern bool OppositeSignalExit = false; +extern string Order_settings="----------------------------------------------------------------------"; +extern int MaxOrders = 3; +extern int MagicNumber = 700000; +extern string TradeComment = "Uranus"; +extern bool ClassicSL = true; +extern bool HighLowSL = false; +extern int BarsBack = 3; +extern double MinimumSLPips = 0; +extern double StopLossPips = 20; +extern double StopLossAtrMultiplier = 0; +extern double VisibleSL = 0; +extern double TakeProfitPips1 = 20; +extern double TakeProfitPips2 = 0; +extern double TakeProfitAtrMultiplier1 = 0; +extern double TakeProfitAtrMultiplier2 = 0; +extern double VisibleTP = 0; +extern double BreakEvenPips = 0; +extern double BreakEvenAtrMultiplier = 0; +extern double LockPips = 0; +extern double LockAtrMultiplier = 0; +extern double TrailingStopPips = 0; +extern double TrailingStopAtrMultiplier = 0; +extern double TrailingStopStartPips = 0; +extern double TrailingStepPips = 0; +extern double Slippage = 4; +extern double MaxSpread = 0; +extern bool CloseIfProfit = false; +extern bool Hedge = false; +extern double MinOrdersDistance = 0; +extern bool NewHighLow = false; +extern string CandleTimeFrame = "0"; +extern bool ScreenShots = false; +extern int Alerts = 0; +extern string AlertSound = "alert.wav"; +extern color LongColour = 7451452; +extern color ShortColour = 6053069; +extern string Trading_hours_settings="----------------------------------------------------------------------"; +extern string TradingSession1 = "00002400"; +extern string TradingSession2 = "00000000"; +extern string TradingSession3 = "00000000"; +extern bool NewsFilter = false; +extern int MinutesBeforeNews = 10; +extern int MinutesAfterNews = 10; +extern string FridayCloseHour = "2250"; +extern string Money_management_settings="----------------------------------------------------------------------"; +extern double Lots = 0.1; +extern double PartialClose1 = 100; +extern double PartialClose2 = 0; +extern double PartialClose3 = 0; +extern bool MoneyManagement = false; +extern double LeveragePercent = 1.0; +extern double LotPercent = 0; +extern int StartProgression = 3; +extern int MaxProgression = 5; +extern double CloseAllProfit = 0; +extern double CloseAllLoss = 0; +extern bool CloseOneDirection = false; +extern string ATR_settings="----------------------------------------------------------------------"; +extern double ATRPeriod = 14; +extern string DSS_Bressert_settings="----------------------------------------------------------------------"; +extern int EMA_period = 8; +extern int Stochastic_period = 13; +extern string NonLagMA_settings="----------------------------------------------------------------------"; +extern int Price = 0; +extern int Length = 15; +extern int Displace = 0; +extern double PctFilter = 0; +extern double Deviation = 0; +extern string PriceChannelStop_settings="----------------------------------------------------------------------"; +extern int ChannelPeriod = 9; +extern double Risk = 0.30; +extern int Signal = 1; +extern int Line = 1; +extern int Nbars = 1000; +extern string Center_of_Gravity_settings="----------------------------------------------------------------------"; +extern int bars_back = 125; +extern int m = 2; +extern int i = 0; +extern double kstd = 2.0; +extern int sName = 1102; +extern string FFCal_settings="----------------------------------------------------------------------"; +extern bool IncludeHigh = true; +extern bool IncludeMedium = true; +extern bool IncludeLow = false; +extern bool IncludeSpeaks = true; +extern bool ReportAllForUSD = false; + +// Variables *********************************************************************************************************** +double Vardouble[40][40],Temp[40][40],Ind[40][9][9],Distance[19],OProfit[200][9],PartialClose[19],Timi[9],d0,d1,d2,d3,d4,d5,d6,d7,d8,d9; +int Varint[40][40],In[40][200],Trade[19],Arrow[3],OTicket[200][9],OOTime[200][9],OCTime[200][9],OType[200][9],MinutesUntilNextEvent,MinutesAfterPrevEvent,mult,tf,i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,e1,e2,z0,z1,z2,k0; +int TF[]={0,1,5,15,30,60,240,1440,10080,43200}; +bool Varbool[40][40],EntrySignal[9][40][9],ExitSignal[9][40][9],Dot[9][40][10],TradingTime[19]; +string Varstring[40][40],Str[40][40],ScreenComment[420],Screen[9][40][420],OComment[200][9],gvoso[200][9],gvosc[200][9],gvoti[200][9],gvopc[200][20],gvosl[200][9],gvotp[200][9],gvova[20][9]; +string TimeFrame[]={"0","M1","M5","M15","M30","H1","H4","D1","W1","MN"}; +datetime OTime[19]; + +// Initialization *************************************************************************************************************** +int init() +{Varint[0][0]=(MarketInfo(Symbol(),MODE_LOTSTEP)==0.01)*2+(MarketInfo(Symbol(),MODE_LOTSTEP)==0.1); +mult=(Digits==3 || Digits==5)*10+(Digits==2 || Digits==4); TF[0]=Period(); +tf=(Period()==1)+(Period()==5)*2+(Period()==15)*3+(Period()==30)*4+(Period()==60)*5+(Period()==240)*6+(Period()==1440)*7+(Period()==10080)*8+(Period()==43200)*9; + +if (!ClassicSL && !HighLowSL) {StopLossPips=0; StopLossAtrMultiplier=0;} +if (ClassicSL || BarsBack<=0) {HighLowSL=false;} +if (StopLossPips==0 && StopLossAtrMultiplier==0) {ClassicSL=false;} +if (StopLossPips>0 && StopLossAtrMultiplier>0) {StopLossPips=0;} +if (BreakEvenPips>0 && BreakEvenAtrMultiplier>0) {BreakEvenPips=0;} +if (LockPips>0 && LockAtrMultiplier>0) {LockPips=0;} +if (TrailingStopPips>0 && TrailingStopAtrMultiplier>0) {TrailingStopPips=0;} +if (TakeProfitAtrMultiplier1>0 && TakeProfitAtrMultiplier2>0) {TakeProfitPips1=0; TakeProfitPips2=0;} +if (TakeProfitPips1>0 && TakeProfitPips2>0) {TakeProfitAtrMultiplier1=0; TakeProfitAtrMultiplier2=0;} +if (TakeProfitPips20) +{Temp[0][1]=TakeProfitPips1; Temp[0][2]=TakeProfitPips2; TakeProfitPips1=Temp[0][2]; TakeProfitPips2=Temp[0][1];} +if (TakeProfitPips1==0 && TakeProfitPips2>0) {TakeProfitPips1=TakeProfitPips2; TakeProfitPips2=0;} +if (TakeProfitAtrMultiplier20) +{Temp[0][1]=TakeProfitAtrMultiplier1; Temp[0][2]=TakeProfitAtrMultiplier2; TakeProfitAtrMultiplier1=Temp[0][2]; TakeProfitAtrMultiplier2=Temp[0][1];} +if (TakeProfitAtrMultiplier1==0 && TakeProfitAtrMultiplier2>0) {TakeProfitAtrMultiplier1=TakeProfitAtrMultiplier2; TakeProfitAtrMultiplier2=0;} +Varint[0][3]=(TakeProfitPips1>0)+(TakeProfitPips2>0)+(TakeProfitAtrMultiplier1>0)+(TakeProfitAtrMultiplier2>0); + +Slippage=NormalizeDouble(mult*Slippage,0); +Distance[1]=NormalizeDouble(Point*mult,Digits); +Distance[2]=NormalizeDouble(VisibleTP*Point*mult,Digits); +Distance[3]=NormalizeDouble(VisibleSL*Point*mult,Digits); +Distance[4]=NormalizeDouble(TakeProfitPips1*Point*mult,Digits); +Distance[5]=NormalizeDouble(TakeProfitPips2*Point*mult,Digits); +Distance[6]=NormalizeDouble(StopLossPips*Point*mult,Digits); +Distance[7]=NormalizeDouble(MinimumSLPips*Point*mult,Digits); +Distance[8]=NormalizeDouble(BreakEvenPips*Point*mult,Digits); +Distance[9]=NormalizeDouble(LockPips*Point*mult,Digits); +Distance[10]=NormalizeDouble(TrailingStopPips*Point*mult,Digits); +Distance[11]=NormalizeDouble(TrailingStopStartPips*Point*mult,Digits); +Distance[12]=NormalizeDouble(TrailingStepPips*Point*mult,Digits); +Distance[13]=NormalizeDouble(MinOrdersDistance*Point*mult,Digits); +Distance[15]=NormalizeDouble(MaxSpread*Point*mult,Digits); +Arrow[1]=LongColour; Arrow[2]=ShortColour; MaxOrders=MathMin(MaxOrders,99); MaxOrders=MathMax(MaxOrders,1); +Lots=MathMin(MathMax(NormalizeDouble(Lots,Varint[0][0]),MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT)); +Varstring[30][1]=StringSubstr(Symbol(),0,6); +TradeComment=StringConcatenate(TradeComment," ",Varstring[30][1]," ",TimeFrame[tf]); +e1=6; e2=7; Str[1][1]=DSSBressert; Str[2][1]="0010"; +if (DSSBressertLevel>0) {Str[2][1]=StringConcatenate(StringSubstr(DSSBressert,0,1),"01",StringSubstr(DSSBressert,3,3));} +Str[3][1]=NonLagMA; Str[4][1]=PriceChannelStop; Str[5][1]=COGDirection; Str[6][1]=COGDistance; +i1=1; while(i1<=e1) {i2=1; while(i2<=3) {Varint[i1][i2]=StrToInteger(StringSubstr(Str[i1][1],i2-1,1)); Varint[i1][i2]*=(Varint[i1][i2]<=2); i2++;} i1++;} +i1=1; while(i1<=e1) {i2=1; while(i2<=4) {i3=1; while(i3<=2) +{i4=(i2<=2)*i3+(i2==4)*2; i5=(i2<=3)*i2+(i2==4)*3; Dot[2-i3][i1][i2]=(Varint[i1][i5]==i4 && !(i2>=3 && !Dot[2-i3][i1][1])); +i3++;} i2++;} i1++;} +i1=1; while(i1<=e1) {Str[0][0]=StringSubstr(Str[i1][1],3,3); Varint[i1][5]=0; +i2=0; while(i2<=9 && Varint[i1][5]==0) {Varint[i1][5]=(Str[0][0]==TimeFrame[i2] && (Varint[i1][1]>0 || Varint[i1][2]>0))*TF[i2]; i2++;} +Varint[i1][5]+=(Varint[i1][5]==0)*Period(); i1++;} +Varint[0][5]=Period(); Varint[0][6]=Period(); i1=1; while(i1<=e1) {Varint[0][5]=MathMin(Varint[0][5],Varint[i1][5]); i1++;} +Varint[0][6]=0; i1=0; while(i1<=9 && Varint[0][6]==0) {Varint[0][6]=(CandleTimeFrame==TimeFrame[i1])*TF[i1]; i1++;} +i1=1; while(i1<=2) {i2=3; while(i2<=4) {i3=1; while(i3<=e1+1) +{Dot[i1-1][0][i2]=(Dot[i1-1][0][i2] || Dot[i1-1][i3][i2]); +Dot[i1-1][0][i2-2]=(Dot[i1-1][0][i2-2] || Dot[i1-1][i3][i2-2]); +i3++;} i2++;} i1++;} +i1=1; while(i1<=2) {i2=1; while(i2<=e1+1) {Dot[i1-1][i2][7]=(Dot[i1-1][i2][1] || Dot[i1-1][i2][2]); i2++;} i1++;} +Dot[0][1][8]=(StopLossAtrMultiplier>0 || TakeProfitAtrMultiplier1>0 || TakeProfitAtrMultiplier2>0 || BreakEvenAtrMultiplier>0 || LockAtrMultiplier>0 || TrailingStopAtrMultiplier>0); +Dot[0][2][8]=Dot[0][1][7]; Dot[1][2][8]=(Dot[0][1][7] || Dot[1][1][7]); +Dot[0][3][8]=Dot[0][3][7]; Dot[1][3][8]=(Dot[0][3][7] || Dot[1][3][7]); +Dot[0][4][8]=Dot[0][4][7]; Dot[1][4][8]=(Dot[0][4][7] || Dot[1][4][7]); +Dot[0][5][8]=Dot[0][5][7]; Dot[1][5][8]=(Dot[0][5][7] || Dot[1][5][7]); +Dot[0][6][8]=Dot[0][6][7]; Dot[1][6][8]=(Dot[0][6][7] || Dot[1][6][7]); +Dot[0][e2][2]=OppositeSignalExit; Dot[1][e2][2]=OppositeSignalExit; +Dot[0][1][9]=true; Dot[0][3][9]=true; Dot[0][4][9]=true; Dot[0][5][9]=true; Dot[0][6][9]=true; + +PartialClose[1]=PartialClose1; PartialClose[2]=PartialClose2; PartialClose[3]=PartialClose3; +if (PartialClose[1]>=100) {PartialClose[1]=100; PartialClose[2]=0; PartialClose[3]=0;} +if (PartialClose[2]>=100) {PartialClose[2]=100; PartialClose[3]=0;} +if (PartialClose[3]>=100) {PartialClose[3]=100;} PartialClose[4]=100; +if (PartialClose[1]+PartialClose[2]>100) {PartialClose[2]=100-PartialClose[1]; PartialClose[3]=0;} +if (PartialClose[2]+PartialClose[3]>100) {PartialClose[3]=100-PartialClose[2];} +if (PartialClose[1]+PartialClose[3]>100) {PartialClose[3]=100-PartialClose[1]-PartialClose[2]; PartialClose[3]*=(PartialClose[3]>0);} +if (PartialClose[2]>0) {PartialClose[2]/=(100-PartialClose[1])*0.01;} +if (PartialClose[3]>0) {PartialClose[3]/=(100-PartialClose[1]-PartialClose[2])*0.01;} +Str[0][1]=TradingSession1; Str[0][2]=TradingSession2; Str[0][3]=TradingSession3; +i1=1; while(i1<=3) {if (Str[0][i1]=="00002400") {i2=1; while(i2<=3) {Str[0][i2]="00002400"; i2++;}} +if (StringSubstr(Str[0][i1],0,2)=="24") {Str[0][i1]="00000000";} +if (StrToInteger(StringSubstr(Str[0][i1],0,2))>24 || StrToInteger(StringSubstr(Str[0][i1],4,2))>24) {Str[0][i1]="00000000";} +if (StringSubstr(Str[0][i1],0,4)==StringSubstr(Str[0][i1],4,4)) {Str[0][i1]="00000000";} i1++;} +TradingTime[9]=(Str[0][1]!="00002400"); i1=1; while(i1<=3) {i2=1; while(i2<=2) +{Varstring[i1][i2]=StringConcatenate(StringSubstr(Str[0][i1],(i2-1)*4,2),":",StringSubstr(Str[0][i1],(i2-1)*4+2,2)); +i2++;} i1++;} +Varstring[1][3]=StringConcatenate(StringSubstr(FridayCloseHour,0,2),":",StringSubstr(FridayCloseHour,2,2)); +if (TradingTime[9]) {Screen[0][0][3]="Trading hours "; i1=1; while(i1<=3) +{if (Str[0][i1]!="00000000") {Screen[0][0][3]=StringConcatenate(Screen[0][0][3],Varstring[i1][1]," to ",Varstring[i1][2],", ");} +i1++;}} Screen[0][0][3]=StringSubstr(Screen[0][0][3],0,StringLen(Screen[0][0][3])-2); +i1=0; while(i1<=200) {i2=0; while(i2<=40) +{gvosl[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"osl",i1,i2); +gvotp[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"otp",i1,i2); +gvoti[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"oti",i1,i2); +gvoso[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"oso",i1,i2); +gvosc[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"osc",i1,i2); +gvopc[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"opc",i1,i2); +gvova[i1][i2]=StringConcatenate(Symbol(),MagicNumber,"ova",i1,i2); +i2++;} i1++;} +if (IsTesting()) {ScreenShots=false; Alerts=0; NewsFilter=false; +i1=0; while(i1<=200) {GlobalVariableDel(gvoti[i1][0]); i1++;}} +i1=0; while(i1<=20+(Hedge+1)*2*MaxOrders) {ScreenComment[i1]=StringConcatenate("Comment",i1); ObjectCreate(ScreenComment[i1],23,0,0,0); +if (i1!=3) {Screen[0][0][i1]="";} i1++;} +Screen[0][30][1]="DSS Bressert"; Screen[0][30][3]="NonLagMA"; Screen[0][30][4]="PriceChannelStop"; +Screen[0][30][e2]="opposite signal"; Screen[0][30][31]="take profit"; +Screen[0][30][32]="stop loss"; Screen[0][30][33]="Friday close"; +Screen[0][31][1]=" profit is "; Screen[0][31][2]=" loss is "; +Screen[0][31][3]="Long order"; Screen[0][31][4]="Short order"; +TradingTime[1]=true; TradingTime[3]=true; TradingTime[4]=true; +OTime[2]=0; OTime[4]=0; OTime[10]=0; StartProgression=MathMax(StartProgression,2); +MaxProgression=MathMax(MaxProgression,2); MaxProgression=MathMin(MaxProgression,99); +Varbool[0][0]=(!IsTesting() || IsVisualMode()); +Varbool[0][2]=(TrailingStopPips>0 || TrailingStopAtrMultiplier>0); +Varbool[0][3]=(BreakEvenPips>0 || BreakEvenAtrMultiplier>0); +return(0);} + +int deinit() {return(0);} + +int start() +{// Entry and exit signals ************************************************************************************** +if (OTime[1]!=iTime(Symbol(),Varint[0][5],0)) {OTime[1]=iTime(Symbol(),Varint[0][5],0); +i1=1; while(i1<=3) {i2=0; while(i2<=7) +{if (Dot[1][2][8] && i2>=1 && i2<=2) +{Ind[i1][i2][2]=iCustom(Symbol(),Varint[1][5],"DSS Bressert",EMA_period,Stochastic_period,i2,i1);} +if (Dot[1][3][8] && i2==0) +{Ind[i1][i2][3]=iCustom(Symbol(),Varint[3][5],"NonLagMA_v7.1",Price,Length,Displace,PctFilter,1,1,Deviation,i2,i1);} +if (Dot[1][4][8] && i2>=0 && i2<=3) +{Ind[i1][i2][4]=iCustom(Symbol(),Varint[4][5],"PriceChannel_Stop_v1.2",ChannelPeriod,Risk,Signal,Line,0,0,1,Nbars,i2,i1);} +if (Dot[1][5][8] && i2>=0 && i2<=2) +{Ind[i1][i2][5]=iCustom(Symbol(),Varint[5][5],"Center of Gravity",false,"","","",false,0,bars_back,m,i,kstd,sName,i2,i1);} +if (Dot[1][6][8] && i2>=0 && i2<=2) +{Ind[i1][i2][6]=iCustom(Symbol(),Varint[6][5],"Center of Gravity",false,"","","",false,0,bars_back,m,i,kstd,sName,i2,i1);} +i2++;} i1++;} + +i1=1; while(i1<=2) {i5=3-2*i1; i2=1; while(i2<=2) +{EntrySignal[i2][1][i1]=(Ind[i2][i1][2]>0); +EntrySignal[i2][2][i1]=(i5*((2-i1)*100-Ind[i2][i1][2])-DSSBressertLevel>0); +EntrySignal[i2][3][i1]=(i5*(Ind[i2][0][3]-Ind[i2+1][0][3])>0); +EntrySignal[i2][4][i1]=(Ind[i2][i1-1][4]>0 || Ind[i2][i1+1][4]>0); +EntrySignal[i2][5][i1]=(i5*(Ind[i2][0][5]-Ind[i2+1][0][5])>0); +EntrySignal[i2][6][i1]=(i5*(Ind[i2][0][6]-Close[i2])>COGPercent*0.01*MathAbs(Ind[i2][0][6]-Ind[i2][3-i1][6])); +i2++;} i1++;} + +i1=1; while (i1<=2) {i3=1; while (i3<=2) +{EntrySignal[i1][0][i3+2]=(Dot[i1-1][0][1] && (Dot[i1-1][0][3] || Dot[i1-1][0][4])); +EntrySignal[i1][0][i3]=true; Temp[i1][i3]=0; Temp[i1][i3+2]=0; i2=1; while (i2<=e1) +{EntrySignal[i1][i2][i3+2]=(EntrySignal[i1][i2][i3] || !Dot[i1-1][i2][1] || (!Dot[i1-1][i2][3] && !Dot[i1-1][i2][4])); +Temp[i1][i3]+=((!EntrySignal[i1][i2][i3] && Dot[i1-1][i2][1] && Dot[i1-1][i2][3]) || !Dot[i1-1][0][3]); +Temp[i1][i3+2]+=(EntrySignal[i1][i2][i3] && Dot[i1-1][i2][1] && Dot[i1-1][i2][4] && Dot[i1-1][0][4]); +EntrySignal[i1][i2][i3]=(EntrySignal[i1][i2][i3] || !Dot[1][i2][1]); +EntrySignal[i1][0][i3]*=EntrySignal[i1][i2][i3]; EntrySignal[i1][0][i3+2]*=EntrySignal[i1][i2][i3+2]; +i2++;} +EntrySignal[i1][0][i3+2]=(EntrySignal[i1][0][i3+2] || Temp[i1][i3]==0 || Temp[i1][i3+2]>0); i3++;} i1++;} + +i1=1; while (i1<=2) {i5=3-2*i1; +ExitSignal[1][1][i1]=(Ind[1][3-i1][2]>0); +ExitSignal[1][3][i1]=(i5*(Ind[2][0][3]-Ind[1][0][3])>0); +ExitSignal[1][4][i1]=(Ind[1][2-i1][4]>0 || Ind[1][4-i1][4]>0); +ExitSignal[1][5][i1]=(i5*(Ind[2][0][5]-Ind[1][0][5])>0); +ExitSignal[1][6][i1]=(i5*(Close[1]-Ind[1][0][6])>COGPercent*0.01*MathAbs(Ind[1][0][6]-Ind[1][i1][6])); +i1++;} + +i1=1; while (i1<=2) {ExitSignal[1][0][i1]=false; i2=1; while (i2<=e2-1) +{ExitSignal[1][i2][i1]=(ExitSignal[1][i2][i1] && Dot[1][i2][2]); +ExitSignal[1][0][i1]=(ExitSignal[1][0][i1] || ExitSignal[1][i2][i1]); i2++;} i1++;} + +} + +i2=0; while(i2<=7) +{if (Dot[0][1][8] && i2==0) {Ind[0][i2][1]=iATR(Symbol(),0,ATRPeriod,0);} +if (Dot[0][2][8] && i2>=1 && i2<=2) +{Ind[0][i2][2]=iCustom(Symbol(),Varint[1][5],"DSS Bressert",EMA_period,Stochastic_period,i2,0);} +if (Dot[0][3][8] && i2==0) +{Ind[0][i2][3]=iCustom(Symbol(),Varint[3][5],"NonLagMA_v7.1",Price,Length,Displace,PctFilter,1,1,Deviation,i2,0);} +if (Dot[0][4][8] && i2>=0 && i2<=3) +{Ind[0][i2][4]=iCustom(Symbol(),Varint[4][5],"PriceChannel_Stop_v1.2",ChannelPeriod,Risk,Signal,Line,0,0,1,Nbars,i2,0);} +if (Dot[0][5][8] && i2>=0 && i2<=2) +{Ind[0][i2][5]=iCustom(Symbol(),Varint[5][5],"Center of Gravity",false,"","","",false,0,bars_back,m,i,kstd,sName,i2,0); +Ind[1][i2][5]=iCustom(Symbol(),Varint[5][5],"Center of Gravity",false,"","","",false,0,bars_back,m,i,kstd,sName,i2,1);} +if (Dot[0][6][8] && i2>=0 && i2<=2) +{Ind[0][i2][6]=iCustom(Symbol(),Varint[6][5],"Center of Gravity",false,"","","",false,0,bars_back,m,i,kstd,sName,i2,0);} +i2++;} +i1=1; while (i1<=2) +{i5=3-2*i1; EntrySignal[0][1][i1]=(Ind[0][i1][2]>0); +EntrySignal[0][2][i1]=(i5*((2-i1)*100-Ind[0][i1][2])-DSSBressertLevel>0); +EntrySignal[0][3][i1]=(i5*(Ind[0][0][3]-Ind[1][0][3])>0); +EntrySignal[0][4][i1]=(Ind[0][i1-1][4]>0 || Ind[0][i1+1][4]>0); +EntrySignal[0][5][i1]=(i5*(Ind[0][0][5]-Ind[1][0][5])>0); +EntrySignal[0][6][i1]=(i5*(Ind[0][0][6]-Bid)>COGPercent*0.01*MathAbs(Ind[0][0][6]-Ind[0][3-i1][6])); +i1++;} + +i1=1; while (i1<=2) {EntrySignal[0][0][i1]=true; i2=1; while (i2<=e1) +{EntrySignal[0][i2][i1]=(EntrySignal[0][i2][i1] || !Dot[0][i2][1]); EntrySignal[0][0][i1]*=(EntrySignal[0][i2][i1]); +i2++;} i1++;} + +EntrySignal[0][0][1]*=(EntrySignal[1][0][1] && !EntrySignal[1][0][3] && !EntrySignal[2][0][3]); +EntrySignal[0][0][2]*=(EntrySignal[1][0][2] && !EntrySignal[1][0][4] && !EntrySignal[2][0][4]); + +i1=1; while (i1<=2) +{ExitSignal[0][0][i1]=false; ExitSignal[0][30][i1]=false; ExitSignal[0][e2][i1]=false; i5=3-2*i1; +if (Trade[i1]>0) +{ExitSignal[0][1][i1]=(Ind[0][3-i1][2]>0); +ExitSignal[0][3][i1]=(i5*(Ind[1][0][3]-Ind[0][0][3])>0); +ExitSignal[0][4][i1]=(Ind[0][2-i1][4]>0 || Ind[0][4-i1][4]>0); +ExitSignal[0][5][i1]=(i5*(Ind[1][0][5]-Ind[0][0][5])>0); +ExitSignal[0][6][i1]=(i5*(Bid-Ind[0][0][6])>COGPercent*0.01*MathAbs(Ind[0][0][6]-Ind[0][i1][6])); +ExitSignal[0][e2][i1]=EntrySignal[0][0][3-i1]; +i2=1; while (i2<=e2) +{ExitSignal[0][i2][i1]=(ExitSignal[1][i2][i1] || (ExitSignal[0][i2][i1] && Dot[0][i2][2])); +ExitSignal[0][0][i1]=(ExitSignal[0][0][i1] || ExitSignal[0][i2][i1]); +ExitSignal[0][30][i1]=(ExitSignal[0][30][i1] || (ExitSignal[0][i2][i1] && Dot[0][i2][9])); i2++;} +ExitSignal[0][0][i1]=(ExitSignal[0][0][i1] || ExitSignal[1][0][i1]);} i1++;} + +// Order management ************************************************************************************************ +i1=0; while (i1<=4) {Trade[i1]=0; i1++;} i1=1; while (i1<=Varint[0][2]) {OTicket[i1][0]=0; i1++;} +Varint[0][2]=0; OProfit[0][1]=0; OProfit[0][2]=0; +i9=OrdersTotal()-1; while(i9>=0) +{if (OrderSelect(i9,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) +{i0=OrderType()+1; Timi[1]=Bid; Timi[2]=Ask; z0=(i0==1)-(i0==2); +FindSeat(OrderTicket()); VisibleTPSL(); Trade[i0]++; Trade[i0+2]+=(OrderOpenTime()>=iTime(Symbol(),Varint[0][6],0)); +OComment[k0][0]=OrderComment(); OType[k0][0]=i0; OOTime[k0][0]=OrderOpenTime(); OTicket[k0][0]=OrderTicket(); +OProfit[k0][0]=OrderProfit()+OrderSwap()+OrderCommission(); OProfit[0][i0]+=OProfit[k0][0]; + +// Stop loss calculation *********************************************************************************************** +if (ClassicSL || HighLowSL) +{Temp[1][0]=Distance[6]+StopLossAtrMultiplier*Ind[0][0][1]; +if (GlobalVariableGet(gvosl[k0][0])==0) +{if (ClassicSL) {Temp[1][1]=OrderOpenPrice();} +if (HighLowSL) +{Temp[1][1]=(i0==1)*Low[iLowest(Symbol(),0,1,BarsBack,1)]+(i0==2)*High[iHighest(Symbol(),0,2,BarsBack,1)]; +if (z0*(OrderOpenPrice()-Temp[1][1])+Temp[1][0]=0 && (z0*(OrderOpenPrice()-GlobalVariableGet(gvosl[k0][0]))+Temp[0][2]>0 || GlobalVariableGet(gvosl[k0][0])==0)) +{GlobalVariableSet(gvosl[k0][0],NormalizeDouble(OrderOpenPrice()+z0*Temp[0][2],Digits));}} + +// Trailing stop ******************************************************************************************************** +if (Varbool[0][2]) {Temp[0][0]=Distance[10]+TrailingStopAtrMultiplier*Ind[0][0][1]; +if (z0*(Timi[i0]-OrderOpenPrice())-Temp[0][0]>=0 && z0*(Timi[i0]-OrderOpenPrice())-Distance[11]>=0 && (z0*(Timi[i0]-GlobalVariableGet(gvosl[k0][0]))-Temp[0][0]-Distance[12]>=0 || GlobalVariableGet(gvosl[k0][0])==0)) +{GlobalVariableSet(gvosl[k0][0],NormalizeDouble(Timi[i0]-z0*Temp[0][0],Digits));}} + +// Order close at signal *************************************************************************************** +if (GlobalVariableGet(gvopc[k0][8])==OrderTicket() && !IsTradeContextBusy()) +{if (OrderClose(OrderTicket(),GlobalVariableGet(gvopc[k0][7]),Timi[i0],Slippage,Arrow[i0])) +{if (GlobalVariableGet(gvopc[k0][7])!=OrderLots()) {FindSeat(0-OrderTicket());}}} +ExitSignal[0][31][i0]=(CalcTP()>0 && z0*(Timi[i0]-GlobalVariableGet(gvotp[k0][0]))>=0); +ExitSignal[0][32][i0]=(GlobalVariableGet(gvosl[k0][0])>0 && z0*(GlobalVariableGet(gvosl[k0][0])-Timi[i0])>=0); +ExitSignal[0][33][i0]=(!TradingTime[3]); +ExitSignal[0][30][i0+2]=(ExitSignal[0][30][i0] && GlobalVariableGet(gvopc[k0][4])==0 && Time[0]>OOTime[k0][0] && (OProfit[k0][0]>=0 || !CloseIfProfit)); +ExitSignal[0][e2][i0+2]=(ExitSignal[0][e2][i0] && (OProfit[k0][0]>=0 || !CloseIfProfit)); +if (ExitSignal[0][31][i0] || ExitSignal[0][32][i0] || ExitSignal[0][33][i0] || ExitSignal[0][e2][i0+2] || ExitSignal[0][30][i0+2]) +{if (ExitSignal[0][33][i0]) {ExitSignal[0][32][i0]=false; ExitSignal[0][31][i0]=false; ExitSignal[0][30][i0+2]=false; ExitSignal[0][e2][i0+2]=false;} +if (ExitSignal[0][32][i0] || ExitSignal[0][31][i0]) {ExitSignal[0][30][i0+2]=false; ExitSignal[0][e2][i0+2]=false;} +if (ExitSignal[0][e2][i0+2]) {ExitSignal[0][30][i0+2]=false;} + +i6=GlobalVariableGet(gvopc[k0][1])+1; GlobalVariableSet(gvopc[k0][1],i6); +i7=ExitSignal[0][e2][i0+2]*e2+ExitSignal[0][31][i0]*31+ExitSignal[0][32][i0]*32+ExitSignal[0][33][i0]*33; +if (ExitSignal[0][30][i0+2]) +{GlobalVariableSet(gvopc[k0][4],1); i7=0; i1=1; while(i1<=e2-1 && i7==0) +{i7=(ExitSignal[0][i1][i0] && Dot[0][i1][9])*i1; i1++;}} +if (ExitSignal[0][31][i0]) +{i5=GlobalVariableGet(gvopc[k0][3])+1; GlobalVariableSet(gvopc[k0][3],i5); GlobalVariableSet(gvotp[k0][0],0);} + +GlobalVariableSet(gvopc[k0][10+i6],i7); if (PartialClose[i6]>0) +{Temp[0][0]=MathMax(MarketInfo(Symbol(),MODE_MINLOT),NormalizeDouble(OrderLots()*PartialClose[i6]*0.01,Varint[0][0])); +Temp[0][0]=MathMin(Temp[0][0],OrderLots());} +if (ExitSignal[0][e2][i0+2] || ExitSignal[0][32][i0] || ExitSignal[0][33][i0]) {Temp[0][0]=OrderLots();} +if (Temp[0][0]>0) {if (OrderClose(OrderTicket(),Temp[0][0],Timi[i0],Slippage,Arrow[i0])) +{if (Temp[0][0]!=OrderLots()) {FindSeat(0-OrderTicket());}} +GlobalVariableSet(gvopc[k0][8],OrderTicket()); GlobalVariableSet(gvopc[k0][7],Temp[0][0]);}} + +} i9--;} +Trade[0]=Trade[1]+Trade[2]; +// Close all trades **************************************************************************************** +i1=1; while(i1<=2) +{i7=CloseOneDirection*i1; Temp[0][0]=OProfit[0][i1]+(!CloseOneDirection)*OProfit[0][3-i1]; +i6=(CloseAllLoss<=MathAbs(Temp[0][0]*100/AccountBalance()) && Temp[0][0]<0 && CloseAllLoss>0); +i6+=(CloseAllProfit<=Temp[0][0]*100/AccountBalance() && CloseAllProfit>0); +if (i6>0) {CloseAll(i7);} i1++;} + +// Order opening at signal **************************************************************************************** +if (TradingHours()) {i1=1; while(i1<=2) +{if (EntrySignal[0][0][i1] && (Trade[3-i1]==0 || Hedge) && Trade[i1]=(Distance[15]>0)*(Ask-Bid)) +{if (CandleOrder(i1) && OrderDistance(i1)) {RefreshRates(); Timi[1]=Bid; Timi[2]=Ask; +OrderSend(Symbol(),i1-1,CalcLots(i1),Timi[3-i1],Slippage,0,0,TradeComment,MagicNumber,0,Arrow[i1]);}} +i1++;}} +ScreenAlerts(); ScreenInfo(); return(0);} +//Functions ********************************************************************************************************************* + +bool TradingHours() +{if (TimeCurrent()>OTime[4] && NewsFilter) +{MinutesUntilNextEvent=iCustom(Symbol(),0,"FFCal",IncludeHigh,IncludeMedium,IncludeLow,IncludeSpeaks,true,0,true,-1,-1,ReportAllForUSD,1,1); +MinutesAfterPrevEvent=iCustom(Symbol(),0,"FFCal",IncludeHigh,IncludeMedium,IncludeLow,IncludeSpeaks,true,0,true,-1,-1,ReportAllForUSD,1,0); +if (MinutesUntilNextEvent!=99999 || MinutesAfterPrevEvent!=99999) +{OTime[2]=iTime(Symbol(),1,0)-(MinutesAfterPrevEvent-MinutesAfterNews)*60; +OTime[3]=iTime(Symbol(),1,0)+(MinutesUntilNextEvent-MinutesBeforeNews)*60; +OTime[4]=iTime(Symbol(),1,0)+(MinutesUntilNextEvent+MinutesAfterNews)*60;}} +TradingTime[2]=(TimeCurrent()>OTime[2] && (TimeCurrent()OTime[4])); +if (TradingTime[9] && TimeCurrent()>=OTime[10]) +{TradingTime[1]=false; t1=1; while(t1<=3 && !TradingTime[1]) +{In[t1][1]=StrToTime(Varstring[t1][1]); In[t1][2]=StrToTime(Varstring[t1][2]); +In[t1][1]-=(In[t1][2]=In[t1][2])*86400; +TradingTime[1]=(TimeCurrent()>=In[t1][1] && TimeCurrent()TimeCurrent() && t5=StrToTime(Varstring[1][3]) && Varstring[1][3]!=":"); +t5=(TradingTime[1] && TradingTime[2] && TradingTime[3]); return(t5);} + +bool CandleOrder(int t8) +{t5=0; t9=OrdersHistoryTotal()-1; while(t9>=0 && t5==0) +{t5+=(OrderSelect(t9,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==t8-1 && OrderOpenTime()>=iTime(Symbol(),Varint[0][6],0)); +t9--;} return(1-t5);} + +double CalcLots(int t8) +{d1=Lots; if (MoneyManagement) +{d1=NormalizeDouble(AccountEquity()*LeveragePercent/((MarketInfo(Symbol(),MODE_LOTSIZE)==100000)*100000+(MarketInfo(Symbol(),MODE_LOTSIZE)==10000)*10000),Varint[0][0]);} +if (Trade[t8]==0) {GlobalVariableSet(gvova[1][t8],0);} +if (LotPercent!=0) {t7=GlobalVariableGet(gvova[1][t8]); +if (t7>0) +{t3=(t7-StartProgression+2); t3=(t3>0)*MathMin(t3,MaxProgression-StartProgression+1); +d2=GlobalVariableGet(gvova[2][t8]); +d1=NormalizeDouble(d2*(1+t3*LotPercent*0.01),Varint[0][0]);}} +d1=MathMin(MathMax(d1,MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT)); +if (Trade[t8]==0) {GlobalVariableSet(gvova[2][t8],d1);} +return(d1);} + +double CalcTP() +{if (Varint[0][3]>0) +{if (GlobalVariableGet(gvotp[k0][5])==0) +{Temp[0][1]=Distance[4]+TakeProfitAtrMultiplier1*Ind[0][0][1]; Temp[0][2]=0; +if (Distance[4]>0 && Distance[5]>0) {Temp[0][1]=Distance[4]; Temp[0][2]=Distance[5];} +if (TakeProfitAtrMultiplier1>0 && TakeProfitAtrMultiplier2>0) +{Temp[0][1]=TakeProfitAtrMultiplier1*Ind[0][0][1]; Temp[0][2]=TakeProfitAtrMultiplier2*Ind[0][0][1];} +if (Distance[4]>0 && TakeProfitAtrMultiplier1>0) +{Temp[0][3]=Distance[4]; Temp[0][4]=TakeProfitAtrMultiplier1*Ind[0][0][1]; +Temp[0][1]=MathMin(Temp[0][3],Temp[0][4]); Temp[0][2]=MathMax(Temp[0][3],Temp[0][4]);} +GlobalVariableSet(gvotp[k0][1],Temp[0][1]); GlobalVariableSet(gvotp[k0][2],Temp[0][2]); GlobalVariableSet(gvotp[k0][5],1);} +if (GlobalVariableGet(gvotp[k0][0])==0 && GlobalVariableGet(gvopc[k0][3])0 || NewHighLow) {d1=0; t3=0; t4=0; t5=0; t9=OrdersTotal()-1; while(t9>=0) +{if (OrderSelect(t9,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()+1==t8 && OrderOpenTime()>t3) +{t3=OrderOpenTime(); d1=OrderOpenPrice();} t9--;} +RefreshRates(); Timi[1]=Bid; Timi[2]=Ask; t5=3-2*t8; t2=(MathAbs(d1-Timi[3-t8])>=Distance[13] || Distance[13]==0 || d1==0); +t2*=(t5*(d1-Timi[3-t8])>0 || !NewHighLow || d1==0);} +return(t2);} + +void FindSeat(int t7) +{if (t7>0) +{k0=0; t1=1; while (t1<=200 && k0==0) {k0=(t7==GlobalVariableGet(gvoti[t1][0]))*t1; t1++;} + +if (k0==0) {t5=OrderType()+1; t3=0; t9=OrdersTotal()-1; while(t9>=0) +{if (OrderSelect(t9,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) +{t3++; In[0][t3]=OrderTicket();} t9--;} +t1=1; while (t1<=200 && k0==0) {t4=0; t2=1; while (t2<=t3 && t4==0) +{t4=(In[0][t2]==GlobalVariableGet(gvoti[t1][0])); t2++;} +k0=(t4==0)*t1; t1++;} if (k0>0) {Variables(k0,t5); GlobalVariableSet(gvoti[k0][0],t7);}} +Varint[0][2]=MathMax(k0,Varint[0][2]);} + +if (t7<0) {t7=0-t7; t3=0; Str[0][0]=StringConcatenate("#",t7); +t9=OrdersTotal()-1; while(t9>=0 && t3==0) +{if (OrderSelect(t9,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderComment()!=TradeComment) +{t3=(StringFind(OrderComment(),Str[0][0],0)>=0)*OrderTicket();} t9--;} +GlobalVariableSet(gvoti[k0][0],t3);} +OrderSelect(t7,SELECT_BY_TICKET);} + +void Variables(int t8,int t6) +{GlobalVariableSet(gvosl[t8][0],0); +t1=0; while (t1<=20) {GlobalVariableSet(gvopc[t8][t1],0); GlobalVariableSet(gvotp[t8][t1],0); t1++;} +if (LotPercent!=0) {t1=GlobalVariableGet(gvova[1][t6]); GlobalVariableSet(gvova[1][t6],t1+1);}} + +void VisibleTPSL() +{if (OTicket[k0][1]!=OrderTicket()) +{OTicket[k0][1]=OrderTicket(); if (OrderStopLoss()==0 && OrderTakeProfit()==0 && (Distance[2]>0 || Distance[3]>0)) +{Temp[0][1]=OrderOpenPrice()-z0*Distance[3]; +Temp[0][3]=Timi[i0]-z0*(Distance[1]+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point); +Temp[0][5]=NormalizeDouble((Distance[3]>0)*MathMin(Temp[0][1],Temp[0][3]),Digits); +if (i0==2) {Temp[0][5]=NormalizeDouble((Distance[3]>0)*MathMax(Temp[0][1],Temp[0][3]),Digits);} +Temp[0][2]=OrderOpenPrice()+z0*Distance[2]; +Temp[0][4]=Timi[i0]+z0*(Distance[1]+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point); +Temp[0][6]=NormalizeDouble((Distance[2]>0)*MathMax(Temp[0][2],Temp[0][4]),Digits); +if (i0==2) {Temp[0][6]=NormalizeDouble((Distance[2]>0)*MathMin(Temp[0][2],Temp[0][4]),Digits);} +if (!OrderModify(OrderTicket(),OrderOpenPrice(),Temp[0][5],Temp[0][6],0,Arrow[i0])) +{OTicket[k0][1]=0;}}}} + +void CloseAll(int t8) +{t9=OrdersTotal()-1; while(t9>=0) +{if (OrderSelect(t9,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()+1==t8 || t8==0)) +{t0=OrderType()+1; RefreshRates(); Timi[1]=Bid; Timi[2]=Ask; +if (!OrderClose(OrderTicket(),OrderLots(),Timi[t0],Slippage,Arrow[t0])) {t9++;}} t9--;}} + +void ScreenAlerts() +{if (ScreenShots || Alerts>0) +{t1=1; while(t1<=Varint[0][2]) {t6=OTicket[t1][0]; t2=OType[t1][0]; +if (OTicket[t1][0]>0 && OComment[t1][0]==TradeComment && GlobalVariableGet(gvoso[t1][0])!=OTicket[t1][0]) +{if (ScreenShots) {WindowScreenShot(StringConcatenate(TimeFrame[tf],Varstring[30][1],t6,"Open.gif"),800,600,-1,-1,-1);} +GlobalVariableSet(gvoso[t1][0],t6); GlobalVariableSet(gvosc[t1][0],t6); OrderAlert(1,t2,t6);} +t7=GlobalVariableGet(gvosc[t1][0]); +if ((OTicket[t1][0]>0 && OComment[t1][0]!=TradeComment && t7!=OTicket[t1][0] && t7!=0) || (OTicket[t1][0]==0 && t7!=0)) +{if (ScreenShots) {WindowScreenShot(StringConcatenate(TimeFrame[tf],Varstring[30][1],t7,"Close.gif"),800,600,-1,-1,-1);} +GlobalVariableSet(gvosc[t1][0],OTicket[t1][0]); OrderAlert(2,t2,t7);} t1++;}}} + +void OrderAlert(int t3,int t4,int t5) +{if ((Alerts==1 || Alerts==3) && t3==1) {Alert(StringConcatenate(Screen[0][31][t4+2]," #",t5," has been opened")); +if (AlertSound!="") {PlaySound(AlertSound);}} +if ((Alerts==2 || Alerts==3) && t3==2) {Alert(StringConcatenate(Screen[0][31][t4+2]," #",t5," has been closed")); +if (AlertSound!="") {PlaySound(AlertSound);}}} + +void ScreenInfo() +{if (Varbool[0][0]) +{if (TradingTime[9]) {Screen[0][0][2]=StringConcatenate("Server time ",TimeToStr(TimeCurrent(),2)); +Screen[0][0][4]="We are outside trading hours"; if (TradingTime[1]) {Screen[0][0][4]="We are inside trading hours";}} +if (NewsFilter) {Screen[0][0][5]="We are outside news period"; +if (!TradingTime[2]) {Screen[0][0][5]="We are inside news period";} +if (MinutesUntilNextEvent==99999 && MinutesAfterPrevEvent==99999) +{Screen[0][0][5]="No news data received from FFCal indicator";}} +t1=7; while(t1<=11+(Hedge+1)*2*MaxOrders) {Screen[0][0][t1]=""; t1++;} + +if ((CloseAllProfit>0 || CloseAllLoss>0) && Trade[1]+Trade[2]>0) +{d1=(OProfit[0][1]+OProfit[0][2])*100/AccountBalance(); t1=(d1<0); +Screen[0][0][8]=StringConcatenate("Total",Screen[0][31][t1+1],DoubleToStr(d1,2),"%"); +if (CloseOneDirection) {Screen[0][0][8]=""; t1=1; while(t1<=2) +{if (Trade[t1]>0) {d1=OProfit[0][t1]*100/AccountBalance(); +Screen[0][0][8]=StringConcatenate(Screen[0][0][8],Screen[0][31][t1+2],"s",Screen[0][31][(d1<0)+1],DoubleToStr(d1,2),"% ,");} +t1++;} +Screen[0][0][8]=StringSubstr(Screen[0][0][8],0,StringLen(Screen[0][0][8])-2);}} + +t8=9; t1=1; while(t1<=Varint[0][2] && Trade[0]>0) +{if (OTicket[t1][0]>0) +{t8+=2; t5=OType[t1][0]; t3=(GlobalVariableGet(gvotp[t1][0])>0); t4=(GlobalVariableGet(gvosl[t1][0])>0); +Screen[0][0][t8]=StringConcatenate(Screen[0][31][2+t5]," #",OTicket[t1][0]," take profit ",DoubleToStr(GlobalVariableGet(gvotp[t1][0]),t3*Digits),", stop loss ",DoubleToStr(GlobalVariableGet(gvosl[t1][0]),t4*Digits)); +Screen[0][0][t8+1]=""; if (OComment[t1][0]!=TradeComment) {t2=1; while(t2<=4) {t6=GlobalVariableGet(gvopc[t1][10+t2]); +if (t6>0) {Screen[0][0][t8+1]=StringConcatenate(Screen[0][0][t8+1],Screen[0][30][t6],", ");} t2++;} +Screen[0][0][t8+1]=StringConcatenate("Exits: ",Screen[0][0][t8+1]); +Screen[0][0][t8+1]=StringSubstr(Screen[0][0][t8+1],0,StringLen(Screen[0][0][t8+1])-2);}} t1++;} + +t2=12; t1=1; while(t1<=11+(Hedge+1)*2*MaxOrders) +{ObjectSetText(ScreenComment[t1],Screen[0][0][t1],8,"Verdana",White); ObjectSet(ScreenComment[t1],OBJPROP_CORNER,0); +ObjectSet(ScreenComment[t1],OBJPROP_XDISTANCE,2); ObjectSet(ScreenComment[t1],OBJPROP_YDISTANCE,t2); +if (Screen[0][0][t1]!="") {t2+=10;} t1++;} }} + + diff --git a/Woodie_Trend.mq4 b/Woodie_Trend.mq4 new file mode 100644 index 0000000..1b93402 --- /dev/null +++ b/Woodie_Trend.mq4 @@ -0,0 +1,505 @@ +//+------------------------------------------------------------------+ +//| Woodie_Trend.mq4 | +//| AndreiFX | +//| AndreiFX@mail.ru, TradersWELL.COM | +//+------------------------------------------------------------------+ +#property copyright "AndreiFX" +#property link "AndreiFX@mail.ru, TradersWELL.COM" +#property indicator_separate_window +#property indicator_buffers 5 +#property indicator_color1 LimeGreen +#property indicator_color2 Green +#property indicator_color3 White +#property indicator_color4 Red +#property indicator_color5 Lime +#property indicator_level1 0 +extern int TrendCCI_Period = 50; +extern int EntryCCI_Period = 14; +extern int TurboCCI_Period = 6; +extern int ЗонаРазворота=50; +extern int ЗавалЗаZL=5; +extern int БаровДляРазворота=5; +extern int ВеличинаОтскока=3; +extern int БаровДляПересечения=5; +extern int Баров_ДоСигнала=20; +extern double Уровень1Вершины=100; +extern double ЛинияДо=50; +extern double СигналДо=50; +extern double ЗонаКрюка=150; +extern int Баров=50; +extern int buf=3; +double Trend[]; +double ZLR[]; +double CrossZL[]; +double MAXBuffer[]; +double KRBuff[]; +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { + + + SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); + SetIndexBuffer(0, Trend); + SetIndexEmptyValue(0, EMPTY_VALUE); + SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2); + SetIndexBuffer(1, ZLR); + SetIndexEmptyValue(1, EMPTY_VALUE); + SetIndexStyle(2, DRAW_HISTOGRAM, 0, 2); + SetIndexBuffer(2, CrossZL); + SetIndexEmptyValue(2, EMPTY_VALUE); + + SetIndexStyle(3, DRAW_HISTOGRAM, 0, 1); + SetIndexBuffer(3, MAXBuffer); + SetIndexEmptyValue(3, EMPTY_VALUE); + + SetIndexStyle(4, DRAW_HISTOGRAM, 0, 2); + SetIndexBuffer(4, KRBuff); + SetIndexEmptyValue(4, EMPTY_VALUE); + // SetIndexEmptyValue(1, 0); + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator deinitialization function | +//+------------------------------------------------------------------+ +int deinit() + { +//---- + Затираем(); +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +int start() + { +int limit; + int counted_bars=IndicatorCounted(); + //---- последний посчитанный бар будет пересчитан + if(counted_bars>0) counted_bars--; + limit=Bars-counted_bars; + //---- основной цикл + for(int i=0; i<Баров; i++) + { + if(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,0,i)!=0) Trend[i]=1; + if(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,1,i)!=0) Trend[i]=-1; + if((iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,0,i)==0)&&(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,1,i)==0)) Trend[i]=BligishiiTrend(i,limit); + + KRBuff[i]=Крюк(i); + + + + ZLR[i]=0; + if(ZLRPatternBuy(i)==1) ZLR[i]=1; + if(ZLRPatternSell(i)==1) ZLR[i]=-1; + //CrossZL[i]=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + + if(ZLCrossBuy(i)==1) CrossZL[i]=1; + if(ZLCrossSell(i)==1) CrossZL[i]=-1; + + // if(E_Max(i,Баров_ДоСигнала,Уровень1Вершины)!=0) MAXBuffer[E_Max(i,Баров_ДоСигнала,Уровень1Вершины)]=1; + if(buf==3){//Чтобы не грузить лишний раз + if(TrendLineDn(i)==1) MAXBuffer[i]=-1; + if(TrendLineUp(i)==1) MAXBuffer[i]=1; + } + } +//---- + return(0); + } +//+------------------------------------------------------------------+ +int BligishiiTrend(int shift, int l) + { + double BufferDown=0; + double BufferUp=0; + while(BufferUp==0&&BufferDown==0&&shiftMin+ВеличинаОтскока)) return(1); + } + + + + return(0); + } + + //1-сигнал на селл +//0-нет сигнала +int ZLRPatternSell(int shift) + { + bool ТрендВниз=true; + double Max=-1000; + //Для сигналов к покупке + for (int i=shift;i ЗавалЗаZL )ТрендВниз=false; + if(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i)>Max) Max=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + } + if(ТрендВниз&&Max>-ЗонаРазворота) + { + if((iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift+1)==Max)&&(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift)=max) max=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + if(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i)<=min) min=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + } + if(ТрендВверх&&max>0&&min<0&&max==iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift)&&iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift+1)<=0) return(1); + return(0); + } + + int ZLCrossSell(int shift) + { + double max=-10000; + double min=10000; + bool ТрендВниз=true; + for (int i=shift;i=max) max=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + if(iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i)<=min) min=iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,i); + } + if(ТрендВниз&&max>0&&min<0&&min==iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift)&&iCustom(Symbol(),0,"TripleCCI",TrendCCI_Period,EntryCCI_Period,TurboCCI_Period,4,shift+1)>=0) return(1); + return(0); + } + +int E_Max(int shift,int number,double limit) + { + int res=0; + + for (int i=shift;iИндюк(i+1,4))&&(Индюк(i,4)>Индюк(i-1,4)+2)&&(Индюк(i,4)>0)&&(Индюк(i+1,4)>0)&&(Индюк(i-1,4)>0)&&(Индюк(i,4)>limit)) return(i); + if((Индюк(i,6)>Индюк(i+1,6))&&(Индюк(i,6)>Индюк(i-1,6)+2)&&(Индюк(i,6)>0)&&(Индюк(i+1,6)>0)&&(Индюк(i-1,6)>0)&&(Индюк(i,6)>limit)) return(i); + } + + // if(max!=-10000) res=1; + + return(res); + } +int E_Min(int shift,int number,double limit) + { + int res=0; + + for (int i=shift;iMathMin(Индюк(Бар1,4),Индюк(Бар1,6))) Уровень=-MathMin(Индюк(Бар1,4),Индюк(Бар1,6)); + m=E_Min(j,shift+Баров_ДоСигнала-j,Уровень); + if(m!=0) Бар2=m; + //Здесь нужно проверить есть ли выше данной линии какие либо значения индюка + if(Бар2!=0) + { + ct=CrossTrendDn(Бар1,Бар2,shift); + if(ct!=0&&Trend[ct]==-1) {ЛТ(ct,Бар2);return(1);} + } + } + + + } + return(0); + } + +int CrossTrend(int b1,int b2,int s) +//Возвратит 1 если уровень не пересекали +//0 если пересекали + { + if(b1==s) return(0); + int res=1; + int res1=1; + double p1,p2,b,k,znach,p; + + if(b1==b2) return(0); + if(Индюк(b1,4)>Индюк(b1,6)) {p1=Индюк(b1,4);} + else {p1=Индюк(b1,6);} + if(Индюк(b2,4)>Индюк(b2,6)) {p2=Индюк(b2,4);} + else {p2=Индюк(b2,6);} + b=(p1*b2-b1*p2)/(b2-b1); + k=(p2-b)/b2; + //res=b1; + + if(p1>ЛинияДо) + { + p1=ЛинияДо; + b1=(p1-b)/k; + if(b1<0) b1=0; + } + res=b1; + + + for (int i=b1;i<=b2;i++) + { + znach=k*i+b; + if(Индюк(i,4)>znach+2) res=0; + if(Индюк(i,6)>znach+2) res=0; + if(znach<0) res=0; + if(res==0) return(0); + } + + if(res!=0) + + { + znach=k*res+b; + p=Индюк(res,4); + + res1=res; + res=1; + for(i=res1;i>s;i--) + { + znach=k*i+b; + p=Индюк(i,4); + if(znachИндюк(s+1,4)) {res=s;} + else {res=0;} + + } + + + + return(res); + } + +int CrossTrendDn(int b1,int b2,int s) +//Возвратит 1 если уровень не пересекали +//0 если пересекали + { + if(b1==s) return(0); + int res=1; + int res1=1; + double p1,p2,b,k,znach,p; + + if(b1==b2) return(0); + if(Индюк(b1,4)<Индюк(b1,6)) {p1=Индюк(b1,4);} + else {p1=Индюк(b1,6);} + if(Индюк(b2,4)<Индюк(b2,6)) {p2=Индюк(b2,4);} + else {p2=Индюк(b2,6);} + b=(p1*b2-b1*p2)/(b2-b1); + k=(p2-b)/b2; + //res=b1; + + if(p1<-ЛинияДо) + { + p1=-ЛинияДо; + b1=(p1-b)/k; + if(b1<0) b1=0; + } + res=b1; + + + for (int i=b1;i<=b2;i++) + { + znach=k*i+b; + if(Индюк(i,4)0) res=0; + if(res==0) return(0); + } + //до сюда дошел + if(res!=0) + + { + znach=k*res+b; + p=Индюк(res,4); + + res1=res; + res=1; + for(i=res1;i>s;i--) + { + znach=k*i+b; + p=Индюк(i,4); + if(znach>p) res=0; + if(znach>0) res=0; + if(res==0) return(0); + } + znach=k*s+b; + p=Индюк(s,4); + + if(res!=0&&znach>p&&Индюк(s+1,4)>-СигналДо&&p<Индюк(s+1,4)) {res=s;} + else {res=0;} + + } + + + + return(res); + } + + + + + +void ЛТ(int b1,int b2) + { + + ObjectCreate("LT"+b1+b2,OBJ_TREND,0,0,0,0,0); + ObjectSet("LT"+b1+b2,OBJPROP_PRICE1,High[b1]); + ObjectSet("LT"+b1+b2,OBJPROP_PRICE2,High[b2]); + ObjectSet("LT"+b1+b2,OBJPROP_TIME1,Time[b1]); + ObjectSet("LT"+b1+b2,OBJPROP_TIME2,Time[b2]); + ObjectSet("LT"+b1+b2,OBJPROP_RAY,false); + } + void Затираем(){ +for (int i = ObjectsTotal(); i >= 0; i--) if (StringFind(ObjectName(i),"LT",0) >=0){ ObjectDelete(ObjectName(i));} + + + + } + + + +int Крюк(int shift) +{ +int res=0; +//Смотрим баи +//Надо чтобы последние 3 бара были в зеленой зоне-0 буфер и +//на прошлом баре был лоу ниже ЗонаКрюка в 5 буфере и позапрошлый бар с текущим были выше прошлого +if(Индюк(shift,0)!=0) + { + if(Индюк(shift+1,0)!=0) + { + if(Индюк(shift+2,0)!=0) + { + if(Индюк(shift+1,5)<-ЗонаКрюка) + { + + if(Индюк(shift,5)>Индюк(shift+1,5)&&Индюк(shift+2,5)>Индюк(shift+1,5)) res=1; + } + } + } + } +//Селы наоборот +if(Индюк(shift,1)!=0) + { + if(Индюк(shift+1,1)!=0) + { + if(Индюк(shift+2,1)!=0) + { + if(Индюк(shift+1,5)>ЗонаКрюка) + { + if(Индюк(shift,5)<Индюк(shift+1,5)&&Индюк(shift+2,5)<Индюк(shift+1,5)) res=-1; + } + } + } + } + + + + + + +return(res); +} \ No newline at end of file diff --git a/ZUP_v82.mq4 b/ZUP_v82.mq4 new file mode 100644 index 0000000..6ea2b74 --- /dev/null +++ b/ZUP_v82.mq4 @@ -0,0 +1,9448 @@ +//|----------------------------------------------------------------------| +//| | +//| | +//| Посвящается памяти моего друга | +//| Денисова Владимира Николаевича | +//| сентябрь 2007, г. Новокуйбышевск | +//| | +//| | +//|----------------------------------------------------------------------| +//|ZigZag универсальный с паттернами Песавенто | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for ZigZag" | +//| | +//|----------------------------------------------------------------------| +//|ExtIndicator - выбор варианта индикатора, на основе которого | +//| строятся паттерны Песавенто | +//| 0 - Zigzag из метатрейдера, стандартный, немного | +//| оптимизированный | +//| 1 - Zigzag Алекса, | +//| 2 - индикатор подобный встроенному в Ensign | +//| 3 - ZigZag Ensign с переменным значением minBars | +//| 4 - ZigZag, разработал tauber | +//| 5 - вариация на тему свингов Ганна | +//| 6 - DT-ZigZag с внешним ZigZag_new_nen3.mq4. В его основе | +//| стандартный ZigZag | +//| 7 - DT-ZigZag с внешним DT_ZZ.mq4 (разработал klot) | +//| 8 - DT-ZigZag с внешним CZigZag.mq4 (разработал Candid) | +//| 10 - DT-ZigZag с внешним Swing_zz - это ExtIndicator=5 | +//| в режиме DT | +//| 11 - включает поиск паттернов Gartley на основе стандартного| +//| ZigZag | +//| 12 - ZigZag, разработал Talex | +//| 13 - SQZZ зигзаг, разработал Товаровед | +//| 14 - ZZ_2L_nen, разработал wellx (авторасчет уровней - nen) | +//| | +//|minBars - фильтр баровый (задается количество баров) | +//|minSize - фильтр по количеству пунктов (задается количество пунктов) | +//| | +//|ExtDeviation и ExtBackstep - параметры оставшиеся от ZigZag из MT4 | +//| | +//|GrossPeriod - значение таймфрейма, выраженное в минутах (число минут),| +//| данные с которого берутся для построения ZigZag в режиме DT-ZigZag | +//| | +//|minPercent - процентный фильтр (задается процент, например 0.5) | +//| Если используются проценты - ставите число, а minSize=0; | +//| | +//|ExtPoint=11 - количество точек зигзага для зигзага Talex | +//| | +//|StLevel - первый уровень зигзага (wellx) | +//|BigLevel - второй уровень зигзага (wellx) | +//|auto - задание автоматического расчета уровней StLevel и BigLevel | +//|minBar - значение % для расчета StLevel | +//|maxBar - значение % для расчета BigLevel | +//| | +//| | +//|ExtStyleZZ - = true - задает стиль линий ZigZag через вкладку ЦВЕТА | +//| = false - Zigzag выводится точками у экстремумов | +//| | +//|ExtMaxBar - задает количество баров, участвующих в расчете зигзага | +//| 0 - зигзаги рассчитываются на всей истории | +//|ExtMinBar - задает минимальный номер бара, до которого рассчитывается | +//| зигзаг | +//| | +//|ExtNumberPeak - включает нумерацию переломов ZigZag начиная с 1 | +//|ExtNumberPeak10 - разрешает вывод номеров только у первых 10 переломов| +//|ExtNumberPeakLow - вывод чисел только у Low или у High и Low | +//|ExtNumberPeakColor - цвет чисел | +//|ExtNumberPeakFontSize - размер чисел | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for fibo Levels" | +//| | +//|----------------------------------------------------------------------| +//|ExtFiboDinamic - разрешает вывод днамических уровней фибо. | +//| Динамические уровни фибо выводятся на первом луче | +//| ZigZag-a. | +//| | +//|ExtFiboStatic - разрешает вывод статических уровней фибо | +//| | +//|ExtFiboStaticNum - номер луча ZigZag-a, на котором будут выводиться | +//| статические уровни Фибоначчи. 10.14 и <5. | +//| 2 - показывает только те линии, где процент восстано- | +//| вления равен числам Песавенто (и 0.447, 0.886, 2.236, | +//| 3.14, 3,618 для построения паттернов Gartley) | +//| 3 - показывает числа, перечисленные в пункте 2 | +//| и соответствующие линии | +//| 4 - показывает числа не Песавенто и соответствующие линии | +//| 5 - скрывает всю оснастку. Остается только ZigZag | +//| и вывод паттернов Gartley | +//| | +//|ExtFractal - количество фракталов (максимумов, минимумов), | +//| от которых идут линии к другим фракталам | +//| | +//|ExtFractalEnd - количество фракталов, к которым идут линии | +//| дальше этого фрактала соединяющих линий не будет | +//| Если ExtFractalEnd=0 то последний фрактал равен | +//| максимальному числу фракталов. | +//| Минимальное значение ExtFractalEnd=1 | +//| | +//|ExtFiboChoice - выбор набора чисел чисел для построения паттернов | +//| Песавенто. Параметр задается числами от 0 до 11 | +//| | +//|ExtFiboZigZag - разрешает вывод "ZiaZag Fibonacci" | +//| | +//|ExtDelta - (допуск) отклонение в расчете. Задает величину | +//| потенциальной разворотной зоны. | +//| должно быть 00 разрешает показ зоны развития точки D | +//| =2 дополнительно выводятся линии потенциальных | +//| уровней точки D | +//| | +//|ExtColorRangeForPointD - цвет рамки зоны развития точки D | +//|ExtLineForPointD_AB - задает цвет потенциального уровня точки D | +//|ExtLineForPointD_BC - задает цвет потенциального уровня точки D | +//| | +//|ExtColorPatterns - цвет треугольников паттернов | +//| | +//|ExtColorPatternList - задается список цветов для закраски крыльев | +//| паттернов Gartley. Названия цветов перечислены | +//| через запятую. Если какой либо цвет будет | +//| записан с ошибкой, то для этого цвета выбирается| +//| красный цвет | +//| | +//|ExtDeltaGartley - допуск на отклонение цены для поиска паттернов | +//| по умолчанию 9% - 0.09 | +//| | +//|ExtCD - величина луча CD паттерна относительно луча BC после которой | +//| начинается поиск паттернов (возможно - это лишний параметр) | +//| | +//|Equilibrium - включает вывод линий Equilibrium, Reaction1 и Reaction2 | +//|ReactionType - задает тип линий реакции | +//|EquilibriumStyle - задает стиль линий | +//|EquilibriumWidth - задает толщину линий | +//|ColorEquilibrium - задает цвет для Equilibrium | +//|ColorReaction - задает цвет для Reaction1 и Reaction2 | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for Andrews Pitchfork" | +//| | +//|----------------------------------------------------------------------| +//|ExtPitchforkDinamic > 0 (=1) выводятся динамические вилы Эндрюса от | +//| последних двух экстремумов ZigZag | +//| =2 50% медиана | +//| =3 50% вилы | +//| =4 линии Шиффа | +//| | +//|ExtPitchforkStatic > 0 (=1) выводятся статические вилы Эндрюса от | +//| экстремума ZigZag с номером ExtPitchforkStaticNum | +//| =2 50% медиана | +//| =3 50% вилы | +//| =4 линии Шиффа | +//| | +//|32 и <=9 статические расширения Фибоначчи | +//| | +//|ExtFiboExpansionColor - задает цвет линий расширений Фибоначчи | +//| | +//|ExtExpansionStyle - устанавливает стиль линий уровней расширений | +//| Фибоначчи | +//| | +//|ExtExpansionWidth - устанавливает толщину линий уровней расширений | +//| Фибоначчи | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for versum Levels" | +//| | +//|----------------------------------------------------------------------| +//|ExtVLDinamicColor - включае Versum Levels динамические выбором цвета | +//| | +//|ExtVLStaticColor - включает Versum Levels статические выбором цвета | +//| | +//|ExtVLStaticNum - задает номер вершины, от которой выводятся | +//| Versum Levels | +//| | +//|ExtVLStyle - устанавливает стиль линий уровней Versum Levels | +//| | +//|ExtVLWidth - устанавливает толщину линий уровней Versum Levels | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for fibo Arc" | +//| | +//|----------------------------------------------------------------------| +//|ExtArcDinamicNum - задает номер переломов ZigZag до которых | +//| строятся динамические фибо дуги | +//| | +//|ExtArcStaticNum - задает номер переломов ZigZag на которых | +//| строятся статические фибо дуги | +//| | +//|ExtArcDinamicColor - задает цвет динамических фибо дуг | +//| | +//|ExtArcStaticColor - задает цвет статических фибо дуг | +//| | +//|ExtArcDinamicScale - задает масштаб динамических фибо дуг | +//| 0 - автомасштаб; >0 - масштаб задается пользователем | +//| | +//|ExtArcStaticScale задает масштаб стамических фибо дуг | +//| 0 - автомасштаб; >0 - масштаб задается пользователем | +//| | +//|ExtArcStyle - устанавливает стиль линий уровней фибо дуг | +//| | +//|ExtArcWidth - устанавливает толщину линий уровней фибо дуг | +//|----------------------------------------------------------------------| +//| | +//| "Golden Spiral" | +//| | +//|----------------------------------------------------------------------| +//|ExtSpiralNum - задает номер переломов ZigZag, на которых | +//| строится золотая спираль | +//| | +//|goldenSpiralCycle - задает расстояние между витками. Чем больше число,| +//| тем меньше расстояние между витками спирали. | +//| | +//|accurity - задает длину отрезков прямых линий, которыми строится | +//| спираль | +//| | +//|NumberOfLines задает количество отрезков прямых линий, из которых | +//| строится спираль | +//| | +//|clockWiseSpiral - задает направление закручивания спирали | +//| true - спираль закручивается по часовой стрелке | +//| false - спираль закручивается против часовой стрелки| +//| | +//|spiralColor1 - задает первый цвет линии спирали | +//| | +//|spiralColor2 - задает второй цвет линии спирали | +//| | +//|ExtSpiralStyle - устанавливает стиль линии спирали | +//| | +//|ExtSpiralWidth - устанавливает толщину линии спирали | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for Pivot ZigZag" | +//| | +//|----------------------------------------------------------------------| +//|ExtPivotZZ1Color - задает цвет Pivot ZigZag 1 | +//| | +//|ExtPivotZZ2Color - задает цвет Pivot ZigZag 2 | +//| | +//|ExtPivotZZ1Num - задает номера луча, на котором рассчитывается 1 | +//| Pivot ZigZag | +//| | +//|ExtPivotZZ2Num - задает номера луча, на котором рассчитывается 2 | +//| Pivot ZigZag | +//| | +//|ExtPivotZZStyle - устанавливает стиль линий уровней Pivot ZigZag | +//| | +//|ExtPivotZZWidth - устанавливает толщину линий уровней Pivot ZigZag | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for Channels" | +//| | +//|----------------------------------------------------------------------| +//|ExtTypeChannels - Задает тип канала. | +//| 1 - линия тренда проходит через перелом зигзага и | +//| по касательной к рынку. Линия целей проходит | +//| параллельно линии тренда. Этот канал строится | +//| или на одном луче, или на двух последовательных | +//| | +//| 2 - линия тренда и линия целей проходят параллельно | +//| лучу зигзага по касательной к рынку. Луч зигзага| +//| может проходить между любыми переломами от 1 до | +//| 9 | +//| | +//|ExtTypeLineChannels - задает тип линий тренда и целей. Может | +//| принимать значения от 0 до 3 | +//| | +//|ExtChannelsNum - задает номера переломов зигзага, между которыми | +//| строится канал. | +//| | +//|ExtLTColor - задает цвет линии тренда | +//|ExtLCColor - задает цвет линии целей | +//|ExtLTChannelsStyle - задает стиль линии тренда | +//|ExtLTChannelsWidth - задает толщину линии тренда | +//|ExtLCChannelsStyle - задает стиль линии целей | +//|ExtLCChannelsWidth - задает толщину линии целей | +//|----------------------------------------------------------------------| +//| | +//| "Parameters for Fibo Time" | +//| | +//|----------------------------------------------------------------------| +//|ExtFiboTimeNum - задает переломы зигзага, от которых строятся | +//| ExtFiboTime, не привязанные к вилам Эндрюса | +//| | +//|ExtFiboTime1x- включает временные зоны фибо 1. | +//| | +//|ExtFiboTime2x- включает временные зоны фибо 2. | +//| | +//|ExtFiboTime3x- включает временные зоны фибо 3. | +//| | +//|ExtFiboTime1Cx- задает цвет линий временной зоны 1. | +//| | +//|ExtFiboTime2Cx- задает цвет линий временной зоны 2. | +//| | +//|ExtFiboTime3Cx- задает цвет линий временной зоны 3. | +//| | +//|ExtVisibleDateTimex- включает показ значений даты и времени временных | +//| зон | +//| | +//|ExtVisibleNumberFiboTimex- позволяет выделить те Fibo Time, у которых | +//| необходимо показать значение даты и времени | +//| | +//| 1 - выводится значение даты и времени | +//| 0 - не выводится | +//| | +//| первая цифра - для Fibo Time 1 | +//| вторая цифра - для Fibo Time 2 | +//| третья цифра - для Fibo Time 3 | +//|----------------------------------------------------------------------| +//| | +//| "Parameters Exp" | +//| | +//|----------------------------------------------------------------------| +//|chHL = true - выводит уровни подтверждения для режимов | +//| ExtIdicator=1, ExtIdicator=2, ExtIdicator=3 | +//| | +//|PeakDet = true - выводит уровни предыдущих максимумов для всех | +//| режимов ExtIndicator | +//| | +//|chHL_PeakDet_or_vts - true - По умолчанию разрешает вывод линий | +//| подтверждения (ценовой канал) и уровни предыдущих максимумов ZigZag. | +//| false - выводится индикатор i-vts. | +//| | +//|ExtLabel =0 обычный режим вывода зигзагов | +//| =1 вывод меток в расчетном месте появления нового луча | +//| для редима DT - в виде полосок символов | +//| =3 вывод меток в расчетном месте появления нового луча | +//| для режима DT - в виде одного символа | +//| | +//|ExtCodLabel - код символа для вывода метки | +//| | +//|NumberOfBars - Количество баров обсчёта (0-все) для i-vts. | +//| | +//|NumberOfVTS - это, я так понимаю, параметр сглаживания для i-vts. | +//| | +//|NumberOfVTS1 - параметр сглаживания для второй копии i-vts. | +//|----------------------------------------------------------------------| +//| | +//| "Common Parameters" | +//| | +//|----------------------------------------------------------------------| +//|ExtFiboType - задает, на какие значения фиб настроены фибо инструменты| +//| | +//| 0 - стандартные фибы | +//| 1 - фибы с числами Песавенто и т.д. | +//| 2 - фибы, заданные пользователем | +//| | +//|ExtFiboTypeFree - задание пользовательских фиб для: | +//| 1) фибо вееров вдоль медианы вил Эндрюса | +//| 2) произвольных фибо вееров | +//| 3) уровней фибо | +//| 4) расширений фибоначчи | +//| 6) фибо дуг | +//| | +//|ExtObjectColor - задает цвет линии, соединяющей базовые точки объектов| +//| | +//|ExtObjectStyle - задает cтиль линии, | +//| соединяющей базовые точки объектов| +//| | +//|ExtObjectWidth - задает толщину линии, | +//| соединяющей базовые точки объектов| +//| | +//|ExtDinamic - разрешает вывод статических инструментов как динамических| +//| при этом при появлении нового луча статические | +//| инструменты перемещаются на другие переломы зигзага | +//| | +//|ExtVisibleDinamic - позволяет выделить, какие статические | +//| инструменты выводить в динамическом режиме | +//| | +//| Всего 11 инструментов. | +//| | +//| Перечислю их по порядку следования в списке: | +//| 1 - нумерация переломов зигзага | +//| 2 - статические фибо уровни и первый тип расширений фибо | +//| 3 - статические вилы Эндрюса и все, что связано с вилами | +//| 4 - статические фибо вееры | +//| 5 - статические фибо расширения | +//| 6 - статические Versum Levels | +//| 7 - статические фибо дуги | +//| 8 - статическая фибо спираль | +//| 9 - статический Pivot ZigZag | +//| 10 - каналы | +//| 11 - Fibo Time | +//| | +//| По умолчанию ExtVisibleDinamic = "01000000000" | +//| 0 - выводится в статическом режиме | +//| 1 - выводится в динамическом режиме | +//| | +//| | +//|ZigZagHighLow - задает, от каких точек делать построение | +//| паттернов Песавенто, вил Эндрюса и т.д. | +//|true - от экстремумов баров | +//|false - от переломов ZigZag, когда они висят в "воздухе" | +//| | +//|ExtSendMail - отправка сообщения на email о появившемся паттерне. | +//| | +//|ExtAlert - разрешает вывод сообщения и звукового сигнала при | +//| возникновении нового луча ZigZag | +//| | +//|ExtPlayAlert - разрешает вывод сообщения и звукового сигнала при | +//| появлении нового паттерна | +//| | +//|ExtBack - задает вывод всех объектов в виде фона | +//| | +//|ExtSave - разрешает сохранение комплекта статических вил и | +//| Fibo Time | +//| | +//|info_comment - позволяет выделить группу параметров для вывода этой | +//| группы в информационной строке. | +//| Всего 4 группы параметров. | +//| 0 - группа параметров не выводится | +//| 1 - группа параметров выводится | +//| | +//| Группы параметров: | +//| 1 - информация о свечах со старших таймфреймов | +//| 2 - % изменения луча для лучевой тактики | +//| 3 - параметры зигзагов | +//| 4 - информация о найденном паттерне Gartley | +//| 5 - вывод расчетных значений RL, если правую границу | +//| RedZone вил Эндрюса проводить по касательной к рынку | +//| | +//|infoTF - включает информацию по 5 старшим таймфреймам. | +//| Выводится наименование таймфрейма. Размер свечи в пунктах. | +//| Текущее положение цены относительно минимума. | +//| Также показывает Высоту луча зигзага выраженную в процентах. | +//| Показывает режим работы индикатора и параметры зигзагов. | +//| Показывает названия паттернов Gartley и ценовой размер зоны | +//| возможного развития точки D для паттернов Gartley. | +//| | +//|ExtComplekt - задает номер индикатора. При выводе на график нескольких| +//| индикаторов через этот параметр задается номер копии. | +//| При этом все копии индикатора будут работать корректно. | +//+----------------------------------------------------------------------+ +#property copyright "nen" +#property link "http://www.onix-trade.net/forum/index.php?s=&showtopic=118&view=findpost&p=350614" +// описание http://onix-trade.net/forum/index.php?s=&showtopic=373&view=findpost&p=72865 + +#property stacksize 65535 +#property indicator_chart_window +#property indicator_buffers 6 +#property indicator_color1 Magenta //Red +//#property indicator_width6 5 +#property indicator_color2 Green +#property indicator_color3 Orange +#property indicator_color4 LightSkyBlue +#property indicator_color5 LemonChiffon +//#property indicator_color4 Chartreuse +//#property indicator_color5 Red +#property indicator_color6 Magenta //Yellow +#import "user32.dll" +int GetClientRect(int hWnd,int lpRect[]); +#import + +#define pi 3.14159265 +#define phi 1.61803399 + +//=================================== +//---- indicator parameters +extern string ______________0_____________ = "Parameters for ZigZag"; +extern int ExtIndicator = 11; +extern int minBars = 12; +extern int minSize = 50; +// Переменные от ZigZag из МТ +extern int ExtDeviation = 8; +extern int ExtBackstep = 3; +// Переменная для nen-ZigZag +extern int GrossPeriod = 1440; +//---- +extern double minPercent = 0; +extern int ExtPoint=11; // количество точек зигзага для зигзага Talex +// Параметры для зигзага, разработанного wellx +extern int StLevel = 28; +extern int BigLevel = 32; +extern bool auto = true; +extern double minBar=38.2, maxBar=61.8; + +extern bool ExtStyleZZ = true; + +extern int ExtMaxBar = 300; // Количество баров обсчёта (0-все) +extern int ExtMinBar = 0; +// вывод номеров переломов зигзагов +extern bool ExtNumberPeak = false; +extern bool ExtNumberPeak10 = true; +extern bool ExtNumberPeakLow = true; +extern color ExtNumberPeakColor = Red; +extern int ExtNumberPeakFontSize = 11; + +extern string ______________1_____________ = "Parameters for fibo Levels"; +extern bool ExtFiboDinamic = false; +extern bool ExtFiboStatic = false; +extern int ExtFiboStaticNum = 2; +extern bool ExtFiboCorrectionExpansion = false; +extern color ExtFiboD = Sienna; +extern color ExtFiboS = Teal; +extern int ExtFiboStyle = 2; +extern int ExtFiboWidth = 0; +//------------------------------------- + +extern string ______________2_____________ = "Parameters for Pesavento Patterns"; +extern int ExtPPWithBars = 0; +extern int ExtHidden = 1; +extern int ExtFractal = 7; +extern int ExtFractalEnd = 7; +extern int ExtFiboChoice = 2; +extern bool ExtFiboZigZag = false; +extern double ExtDelta = 0.04; +extern int ExtDeltaType = 2; +extern int ExtSizeTxt = 7; +extern color ExtLine = DarkBlue; +extern color ExtLine886 = Purple; +extern color ExtNotFibo = SlateGray; +extern color ExtPesavento = Yellow; +extern color ExtGartley886 = GreenYellow; + color colorPPattern; + +// Паттерны Gartley +extern string ______________3_____________ = "Parameters for Gartley Patterns"; +extern int maxDepth = 33; +extern int minDepth = 3; +extern bool DirectionOfSearchMaxMin = true; +extern int NumberPattern = 1; // Номер паттерна, по которому калибруется зигзаг и параметры которого выводятся через InfoTF +extern int ExtGartleyTypeSearch = 0; +extern int ExtHiddenPP = 1; +extern bool ExtGartleyOnOff = false; +//extern int VarDisplay=0; +extern int maxBarToD = 15; +extern int RangeForPointD = 2; +extern color ExtColorRangeForPointD = Red; +extern color ExtLineForPointD_AB = Aqua; +extern color ExtLineForPointD_BC = Gold; +extern color ExtColorPatterns = Blue; +extern string ExtColorPatternList = "Blue,DarkGreen,Navy,Sienna,MediumBlue,RoyalBlue,DodgerBlue,CornflowerBlue,LightSkyBlue,SlateBlue,MediumSlateBlue,SlateGray,LightSteelBlue"; +extern double ExtDeltaGartley = 0.09; +extern double ExtCD = 0.886; +//--------------- +extern bool Equilibrium = true; +extern bool ReactionType = false; +extern int EquilibriumStyle = 1; +extern int EquilibriumWidth = 0; +extern color ColorEquilibrium = Red; +extern color ColorReaction = Yellow; + + +//---------------------------------------------------------------------- +// Комплект инструментов, работающих совместно с вилами Эндрюса. Начало. +//---------------------------------------------------------------------- +// Переменные для вил Эндрюса +extern string ______________4_____________ = "Parameters for Andrews Pitchfork"; +extern int ExtPitchforkDinamic = 0; +extern int ExtPitchforkStatic = 0; +extern int ExtPitchforkStaticNum = 3; +extern color ExtLinePitchforkD = MediumSlateBlue; +extern color ExtLinePitchforkS = MediumBlue; +extern color ExtPitchforkStaticColor = CLR_NONE; +extern int ExtPitchforkStyle = 1; +extern int ExtPitchforkWidth = 0; +extern int ExtISLStyle = 1; +extern int ExtISLWidth = 0; + +// Переменные для фибовееров +extern bool ExtFiboFanDinamic = false; // может выводиться самостоятельно +extern bool ExtFiboFanStatic = false; // выводится только совместно со статическими вилами +extern bool ExtFiboFanExp = true; +extern bool ExtFiboFanHidden = false; +extern color ExtFiboFanD = Sienna; +extern color ExtFiboFanS = Teal; + +extern color ExtFiboFanMedianaDinamicColor = CLR_NONE; +extern color ExtFiboFanMedianaStaticColor = CLR_NONE; + +// Временные зоны Фибо в составе вил Эндрюса +extern bool ExtFiboTime1 = false; +extern bool ExtFiboTime2 = false; +extern bool ExtFiboTime3 = false; +extern color ExtFiboTime1C = Teal; +extern color ExtFiboTime2C = Sienna; +extern color ExtFiboTime3C = Aqua; +extern bool ExtVisibleDateTime = false; +extern string ExtVisibleNumberFiboTime = "111"; + +// Pivot Zone +extern color ExtPivotZoneDinamicColor = CLR_NONE; +extern color ExtPivotZoneStaticColor = CLR_NONE; +extern bool ExtPivotZoneFramework = false; + +// Включение предупреждающих и контрольных линий +extern bool ExtUTL = false; +extern bool ExtLTL = false; +extern bool ExtUWL = false; +extern bool ExtVisibleUWL = false; +extern bool ExtLWL = false; +extern bool ExtVisibleLWL = false; +extern bool ExtLongWL = false; +extern bool ExtISLDinamic = false; +extern bool ExtISLStatic = false; +extern bool ExtVisibleISL = false; + +// Включение линий реакции +extern bool ExtRL146 = true; +extern bool ExtRLDinamic = true; +extern bool ExtRLStatic = true; +extern bool ExtVisibleRL = true; +extern bool ExtRLineBase = true; +// Включение RedZone для линий реакции +extern bool ExtRedZoneDinamic = false; +extern bool ExtRedZoneStatic = false; +extern double ExtRZDinamicValue = 0.146; +extern double ExtRZStaticValue = 0.146; +extern color ExtRZDinamicColor = Salmon; +extern color ExtRZStaticColor = Salmon; + +//---------------------------------------------------------------------- +//extern datetime ExtDateTimePitchfork_1 = D'11.07.2006 00:00'; +//extern datetime ExtDateTimePitchfork_2 = D'19.07.2006 00:00'; +//extern datetime ExtDateTimePitchfork_3 = D'09.08.2006 00:00'; +//---------------------------------------------------------------------- +// Ниже выбраны временные параметры для построения вил Эндрюса для всей истории eurusd для дневок +//---------------------------------------------------------------------- +extern bool ExtPitchforkCandle = false; +extern datetime ExtDateTimePitchfork_1 = D'15.06.1989 00:00'; +extern datetime ExtDateTimePitchfork_2 = D'08.03.1995 00:00'; +extern datetime ExtDateTimePitchfork_3 = D'26.10.2000 00:00'; +extern bool ExtPitchfork_1_HighLow = false; +//---------------------------------------------------------------------- +// Задание пользовательских уровней фибо для инструментов, встроенных в вилы Эндрюса +extern string ExtFiboFreeFT1 = "0.382,0.618,1.0,1.236,1.618"; +extern string ExtFiboFreeFT2 = "0.382,0.618,1.0,1.236,1.618"; +extern string ExtFiboFreeFT3 = "0.382,0.618,1.0,1.236,1.618"; +extern string ExtFiboFreeRL = "0.382,0.618,1,1.618,2.618,3.618"; +extern string ExtFiboFreeUWL = "0.382,0.618,1,1.618,2.618,3.618"; +extern string ExtFiboFreeLWL = "0.382,0.618,1,1.618,2.618,3.618"; +extern string ExtFiboFreeISL = "0.25,0.75"; +//---------------------------------------------------------------------- + +// Каналы micmed'a +extern string ________________5_____________ = "Parameters for micmed Channels"; +extern int ExtCM_0_1A_2B_Dinamic = 0, ExtCM_0_1A_2B_Static = 0; +extern double ExtCM_FiboDinamic = 0.618, ExtCM_FiboStatic = 0.618; +//---------------------------------------------------------------------- +// Комплект инструментов, работающих совместно с вилами Эндрюса. Конец. +//---------------------------------------------------------------------- + +// Фибовееры дополнительные +extern string ______________6_____________ = "Parameters for fibo Fan"; +extern color ExtFiboFanColor = CLR_NONE; +extern int ExtFiboFanNum = 0; +extern int ExtFanStyle = 1; +extern int ExtFanWidth = 0; + +// Расширения Фибоначчи +extern string ______________7_____________ = "Parameters for fibo Expansion"; +extern int ExtFiboExpansion = 0; +extern color ExtFiboExpansionColor = Yellow; +extern int ExtExpansionStyle = 2; +extern int ExtExpansionWidth = 0; +//-------------------------------------- + +extern string ______________8_____________ = "Parameters for versum Levels"; +extern color ExtVLDinamicColor = CLR_NONE; +extern color ExtVLStaticColor = CLR_NONE; +extern int ExtVLStaticNum = 0; +extern int ExtVLStyle = 0; +extern int ExtVLWidth = 0; +//-------------------------------------- + +extern string ______________9_____________ = "Parameters for fibo Arc"; +extern int ExtArcDinamicNum = 0; +extern int ExtArcStaticNum = 0; +extern color ExtArcDinamicColor = Sienna; +extern color ExtArcStaticColor = Teal; +extern double ExtArcDinamicScale = 0; +extern double ExtArcStaticScale = 0; +extern int ExtArcStyle = 0; +extern int ExtArcWidth = 0; + +extern string ______________10_____________ = "Golden Spiral"; +extern int ExtSpiralNum = 0; +extern double goldenSpiralCycle = 1; +extern double accurity = 0.2; +extern int NumberOfLines = 200; +extern bool clockWiseSpiral = true; +extern color spiralColor1 = Blue; +extern color spiralColor2 = Red; +extern int ExtSpiralStyle = 0; +extern int ExtSpiralWidth = 0; + +extern string ______________11_____________ = "Pivot ZigZag"; +extern color ExtPivotZZ1Color = Blue; +extern color ExtPivotZZ2Color = Red; +extern int ExtPivotZZ1Num = 0; +extern int ExtPivotZZ2Num = 0; +extern int ExtPivotZZStyle = 0; +extern int ExtPivotZZWidth = 2; + +extern string ______________12_____________ = "Parameters for Channels"; +extern int ExtTypeChannels = 0; +extern int ExtTypeLineChannels = 1; +extern int ExtChannelsNum = 2; +extern color ExtLTColor = Red; +extern color ExtLCColor = Green; +extern int ExtLTChannelsStyle = 0; +extern int ExtLTChannelsWidth = 1; +extern int ExtLCChannelsStyle = 2; +extern int ExtLCChannelsWidth = 0; + +extern string ______________13_____________ = "Parameters Fibo Time"; +// Временные зоны Фибо +extern int ExtFiboTimeNum = 0; +extern bool ExtFiboTime1x = false; +extern bool ExtFiboTime2x = false; +extern bool ExtFiboTime3x = false; +extern color ExtFiboTime1Cx = Teal; +extern color ExtFiboTime2Cx = Sienna; +extern color ExtFiboTime3Cx = Aqua; +extern bool ExtVisibleDateTimex = false; +extern string ExtVisibleNumberFiboTimex = "111"; + +extern string ______________14_____________ = "Parameters Exp"; +extern bool chHL = false; +extern bool PeakDet = false; +// Переменные для i-vts +extern bool chHL_PeakDet_or_vts = true; +extern int ExtLabel = 0; +extern int ExtCodLabel = 116; +extern int NumberOfBars = 1000; // Количество баров обсчёта (0-все) +extern int NumberOfVTS = 13; +extern int NumberOfVTS1 = 1; + +extern string ______________15_____________ = "Common Parameters"; +//-------------------------------------- +extern int ExtFiboType = 1; +extern string ExtFiboTypeFree = "0,0.382,0.618,0.764,1,1.236,1.618"; // пользовательские уровни фибо +extern color ExtObjectColor = CLR_NONE; +extern int ExtObjectStyle = 1; +extern int ExtObjectWidth = 0; +// вывод статических объектов в режиме динамических +extern bool ExtDinamic = false; +extern string ExtVisibleDinamic = "01000000000"; + +extern bool ZigZagHighLow = true; +// -------------------------------- +// Дополнительные финкции +extern bool ExtSendMail = false; +extern bool ExtAlert = false; +extern bool ExtPlayAlert = false; +// Вывод объектов в виде фона +extern bool ExtBack = true; +// Сохранение статических вил Эндрюса, Fibo Time и т.д. +extern bool ExtSave = false; +extern string info_comment = "11111"; +extern bool infoTF = true; +extern int ExtComplekt = 0; +//=================================== + +// Массивы для ZigZag +// Массив для отрисовки ZigZag +double zz[]; +// Массив минимумов ZigZag +double zzL[]; +// Массив максимумов ZigZag +double zzH[]; +// Массивы для nen-ZigZag +double nen_ZigZag[]; + +int _maxbarZZ; // количество баров, участвующих в расчете зигзагов. + +// Массив для оптимизированного ZigZag +//double TempBuffer[1],ZigZagBuffer[1]; +// Переменные для оснастки +// Массив чисел Песавенто (Фибы и модифицированные Фибы) +//double fi[]={0.146, 0.236, 0.382, 0.447, 0.5, 0.618, 0.707, 0.786, 0.841, 0.886, 1.0, 1.128, 1.272, 1.414, 1.5, 1.618, 1.732, 1.902, 2.0, 2.236, 2.414, 2.618, 3.14, 3.618, 4.0}; +//string fitxt[]={"0.146", "0.236", ".382", ".447", ".5", ".618", ".707", ".786", ".841", ".886", "1.0", "1.128", "1.272", "1.414", "1.5", "1.618", "1.732", "1.902", "2.0", "2.236", "2.414", "2.618", "3.14", "3.618", "4.0"}; +//double fi1[]={0.146, 0.236, 0.382, 0.5, 0.618, 0.764, 0.854, 1.0, 1.236, 1.618}; +//string fitxt1[]={"0.146", "0.236", ".382", ".5", ".618", ".764", ".854", "1.0", "1.236", "1.618"}; +// Массив чисел, заданных пользователем +double fi[]; +string fitxt[]; +string fitxt100[]; +int Sizefi=0,Sizefi_1=0; + +color ExtLine_; + +double number[64]; +string numbertxt[64]; +int numberFibo[64]; +int numberPesavento[64]; +int numberGartley[64]; +int numberMix[64]; +int numberGilmorQuality[64]; +int numberGilmorGeometric[64]; +int numberGilmorHarmonic[64]; +int numberGilmorArithmetic[64]; +int numberGilmorGoldenMean[64]; +int numberSquare[64]; +int numberCube[64]; +int numberRectangle[64]; +int numberExt[64]; + +string nameObj,nameObjtxt,save; +// +bool descript_b=false; +// PPWithBars - текст, выводимый у соединительной линии +// descript - описание объектов +string PPWithBars, descript; +// Матрица для поиска исчезнувших баров afr - массив значений времени пяти последних фракталов и отрисовки динамических и статических фиб +// afrl - минимумы, afrh - максимумы +int afr[]={0,0,0,0,0,0,0,0,0,0}; +double afrl[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}, afrh[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}, afrx[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; +// Параметры таймфрймов +double openTF[]={0.0,0.0,0.0,0.0,0.0}, closeTF[]={0.0,0.0,0.0,0.0,0.0}, lowTF[]={0.0,0.0,0.0,0.0,0.0}, highTF[]={0.0,0.0,0.0,0.0,0.0}; +double close_TF=0; +string TF[]={"MN","W1","D1","H4","H1","m30","m15","m5","m1"}; +string Period_tf; +bool afrm=true; +double ExtHL; +double HL,HLp,kk,kj,Angle; +// LowPrim,HighPrim,LowLast,HighLast - значения минимумов и максимумов баров +double LowPrim,HighPrim,LowLast,HighLast; +// numLowPrim,numHighPrim,numLowLast,numHighLast -номера баров +int numLowPrim,numHighPrim,numLowLast,numHighLast,k,k1,k2,ki,kiPRZ=0,countLow1,countHigh1,shift,shift1; +string txtkk; +// Время свечи с первым от нулевого бара фракталом +int timeFr1new; +// Счетчик фракталов +int countFr; +// Бар, до которого надо рисовать соединительные линии от нулевого бара +int countBarEnd=0,TimeBarEnd; +// Бар, до которого надо пересчитывать от нулевого бара +int numBar=0; +// Номер объекта +int numOb; +// flagFrNew=true - образовался новый фрактал или первый фрактал сместился на другой бар. =false - по умолчанию. +bool flagFrNew=false; +// идентификатор нового луча +bool newRay=true; +// flagGartle - появление нового паттерна Gartley или исчезновение паттерна Gartley +bool flagGartle=false; +// Период текущего графика +int perTF; +bool Demo; +// Переменные для зигзага, разработанного wellx +bool first=true; +int NewBarTime=0, countbars=0; +int lasthighpos,lastlowpos,realcnt=0; +double lasthigh,lastlow; + +double int_to_d=0, int_to_d1=0, int_to_d2=0; + +int counted_bars, cbi, iBar; + +// средний размер бара текущего таймфрейма +// The average size of a bar +double ASBar; + +// Переменные для ZigZag Алекса и индикатора подобного встроенному в Ensign +double ha[],la[],hi,li,si,sip,di,hm,lm,ham[],lam[],him,lim,lLast=0,hLast=0; +int fs=0,fsp,countBar; +int ai,bi,ai0,bi0,aim,bim; +datetime tai,tbi,ti,tmh,tml; +// fcount0 - при обнулении счетчика пропущенных баров на 0 баре fcount0=true. +// На следующем баре =false и можно определять точку перелома +bool fh=false,fl=false,fcount0,PeakDetIni; + +/* +// Переменные для Свингов Ганна +double lLast_m=0, hLast_m=0; +int countBarExt; // счетчик внешних баров +int countBarl,countBarh; +*/ +// Переменные для nen-ZigZag +bool hi_nen; +bool init_zz=true; + +// Переменные для расширенного режима работы индикатора +int mFibo[]={0,0}, mPitch[]={0,0,0}, mFan[]={0,0}, mExpansion[]={0,0,0}, mVL[]={0,0,0}, mArcS[]={0,0}, mArcD[]={0,0}, mSpiral[]={0,0},mChannels[]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; +// Переменные для построения вил Эндрюса по свечам +int mPitchTime[]={0,0,0}; +int mPitchTimeSave; +double mPitchCena[]={0.0,0.0,0.0}; + +// переменные для vts +double ms[2]; +// Переменные для паттернов Gartley +string vBullBear = ""; // переменная для обозначения бычий или медвежий паттерн +string vNamePattern = ""; // переменная для обозначения наименования паттерна +string vBullBearToNumberPattern = ""; +string vNamePatternToNumberPattern = ""; +int maxPeak, vPatOnOff, vPatNew=0; +int Depth; +double hBar, lBar; +datetime tiZZ; +bool FlagForD = true; // Разрешение на поиск момента образования точки D паттерна (Gartley) +datetime TimeForDmin = 0, TimeForDminToNumberPattern; +datetime TimeForDmax = 0, TimeForDmaxToNumberPattern; +double LevelForDmin = 0, LevelForDminToNumberPattern; +double LevelForDmax = 0, LevelForDmaxToNumberPattern; +double PeakCenaX[1],PeakCenaA[1],PeakCenaB[1],PeakCenaC[1],PeakCenaD[1]; +datetime PeakTimeX[1],PeakTimeA[1],PeakTimeB[1],PeakTimeC[1],PeakTimeD[1]; +int countGartley = 0; // Счетчик паттернов +int minBarsToNumberPattern; +color ColorList[]; +int ColorSize=0; +int countColor = 0; +bool flagExtGartleyTypeSearch2=false; +int minBarsSave, minBarsX; +string info_RZS_RL="",info_RZD_RL=""; + +// Переменные для зигзага Talex +static int endbar = 0; +static double endpr = 0; + +// Переменные для расчета размеров окна в пикселях для Golden Spiral +static int GPixels,VPixels; +int rect[4],hwnd; +int f=1; + +// Переменные для каналов +int DinamicChannels=-1; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { + string aa,aa1; + int aa2, i; + + hwnd=WindowHandle(Symbol(),Period()); + if(hwnd>0) + { + GetClientRect(hwnd,rect); + GPixels=rect[2]; // здесь функция возвращает кол-во пикселов по горизонтали + VPixels=rect[3]; // здесь функция возвращает кол-во пикселов по вертикали + } + + minBarsSave=minBars; + + IndicatorBuffers(8); + +// ------- +// Gartley Patterns + + if (ExtGartleyTypeSearch<0) ExtGartleyTypeSearch=0; + if (ExtGartleyTypeSearch>2) ExtGartleyTypeSearch=2; + + if (ExtHiddenPP<0) ExtHiddenPP=0; + if (ExtHiddenPP>2) ExtHiddenPP=2; + + if (NumberPattern<1) NumberPattern=1; + + if (ExtIndicator==14) + { + if (auto) + { + double wrmassiv[]; + + if (minBar>=100) minBar=61.8; + if (minBar<=0) minBar=61.8; + if (maxBar>=100) maxBar=38.2; + if (minBar<=0) minBar=38.2; + + ArrayResize(wrmassiv,Bars-1); + for (i=Bars-1;i>0;i--) {wrmassiv[i]=High[i]-Low[i]+Point;} + ArraySort (wrmassiv); + i=MathFloor(minBar*Bars/100); + StLevel=MathFloor(wrmassiv[i]/Point); + i=MathFloor(maxBar*Bars/100); + BigLevel=MathFloor(wrmassiv[i]/Point); +//Print ("StLevel=",StLevel); +//Print ("BigLevel=",BigLevel); + } + } + + if (ExtMaxBar>Bars) ExtMaxBar=Bars; + if (ExtMaxBar>0) _maxbarZZ=ExtMaxBar; else _maxbarZZ=Bars; + + if (ExtGartleyTypeSearch>0) // Подготовка списка значений цвета для бабочек Gartley, заданных пользователем + { + +//--------- + if (ExtMaxBar>0) + { + if (maxBarToD==0 || maxBarToD>ExtMaxBar) maxBarToD=ExtMaxBar-15; + } + else if (maxBarToD==0) maxBarToD=Bars-15; + if (ExtHiddenPP==0 || ExtHiddenPP==2) {ExtHidden=0; ExtStyleZZ=false;} + + if (RangeForPointD>2) RangeForPointD=2; + +//--------- + + i=-1; + aa2=0; + while (aa2>=0) + { + aa2=StringFind(ExtColorPatternList, ",",i+1); + if (aa2>=0) + {i=aa2;ColorSize++;} + else + { + if (StringLen(ExtColorPatternList)-i>0) + { + if (StrToDouble(StringSubstr(ExtColorPatternList,i+1))>0) ColorSize++; + ArrayResize(ColorList,ColorSize); + aa1=ExtColorPatternList; + for (i=0;i=0) aa1=StringSubstr(aa1,aa2+1); + } + aa2=-1; + } + } + } + } + +// ------- + + if (ExtStyleZZ) {SetIndexStyle(0,DRAW_SECTION);} + else {SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,158);} + + if (ExtLabel>0) + { + SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,ExtCodLabel); + SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,ExtCodLabel); + } + else + { + SetIndexStyle(3,DRAW_LINE,STYLE_DOT); + SetIndexStyle(4,DRAW_LINE,STYLE_DOT); + } + + SetIndexLabel(0,"ZUP"+ExtComplekt+" (zz"+ExtIndicator+")"); + if (ExtIndicator==6) SetIndexLabel(5,"ZUP"+ExtComplekt+" DT6_"+minBars+"/"+ExtDeviation+"/"+ExtBackstep+"/GP"+GrossPeriod+""); + else if (ExtIndicator==7) SetIndexLabel(5,"ZUP"+ExtComplekt+" DT7_"+minBars+"/GP"+GrossPeriod+""); + else if (ExtIndicator==8) SetIndexLabel(5,"ZUP"+ExtComplekt+" DT8_"+minBars+"/"+ExtDeviation+"/GP"+GrossPeriod+""); + + if (ExtLabel>0) + { + SetIndexLabel(1,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" H_PeakDet"); + SetIndexLabel(2,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" L_PeakDet"); + SetIndexLabel(3,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" UpTrend"); + SetIndexLabel(4,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" DownTrend"); + } + else + { + if (chHL_PeakDet_or_vts) + { + PeakDetIni=true; + SetIndexLabel(1,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" H_PeakDet"); + SetIndexLabel(2,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" L_PeakDet"); + SetIndexLabel(3,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" H_chHL"); + SetIndexLabel(4,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" L_chHL"); + } + else + { + SetIndexLabel(1,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" H_vts"); + SetIndexLabel(2,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" L_vts"); + SetIndexLabel(3,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" H_vts1"); + SetIndexLabel(4,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" L_vts1"); + } + } + +// Уровни предыдущих пиков + SetIndexStyle(1,DRAW_LINE,STYLE_DOT); + SetIndexStyle(2,DRAW_LINE,STYLE_DOT); + SetIndexBuffer(1,ham); + SetIndexBuffer(2,lam); +// Уровни подтверждения + SetIndexBuffer(3,ha); + SetIndexBuffer(4,la); + + SetIndexBuffer(0,zz); + SetIndexBuffer(5,nen_ZigZag); + SetIndexBuffer(6,zzL); + SetIndexBuffer(7,zzH); + + SetIndexStyle(5,DRAW_ARROW); + SetIndexArrow(5,159); + + SetIndexEmptyValue(0,0.0); + SetIndexEmptyValue(1,0.0); + SetIndexEmptyValue(2,0.0); + SetIndexEmptyValue(3,0.0); + SetIndexEmptyValue(4,0.0); + SetIndexEmptyValue(5,0.0); + SetIndexEmptyValue(6,0.0); + SetIndexEmptyValue(7,0.0); + + if (ExtIndicator<6 || ExtIndicator>10) + { + switch (Period()) + { + case 1 : {Period_tf=TF[8];break;} + case 5 : {Period_tf=TF[7];break;} + case 15 : {Period_tf=TF[6];break;} + case 30 : {Period_tf=TF[5];break;} + case 60 : {Period_tf=TF[4];break;} + case 240 : {Period_tf=TF[3];break;} + case 1440 : {Period_tf=TF[2];break;} + case 10080 : {Period_tf=TF[1];break;} + case 43200 : {Period_tf=TF[0];break;} + } + } + else + { + switch (GrossPeriod) + { + case 1 : {Period_tf=TF[8];break;} + case 5 : {Period_tf=TF[7];break;} + case 15 : {Period_tf=TF[6];break;} + case 30 : {Period_tf=TF[5];break;} + case 60 : {Period_tf=TF[4];break;} + case 240 : {Period_tf=TF[3];break;} + case 1440 : {Period_tf=TF[2];break;} + case 10080 : {Period_tf=TF[1];break;} + case 43200 : {Period_tf=TF[0];break;} + } + + if (GrossPeriod>43200) + { + if (MathMod(GrossPeriod,43200)>0) Period_tf=GrossPeriod; else Period_tf=TF[0]+GrossPeriod/43200 + ""; + } + else if (GrossPeriod<43200) + { + if (GrossPeriod>10080) + { + if (MathMod(GrossPeriod,10080)>0) Period_tf=GrossPeriod; else Period_tf="W"+GrossPeriod/10080 + ""; + } + else if (GrossPeriod<10080) + { + if (GrossPeriod>1440) + { + if (MathMod(GrossPeriod,1440)>0) Period_tf=GrossPeriod; else Period_tf="D"+GrossPeriod/1440 + ""; + } + else if (GrossPeriod<1440) + { + if (GrossPeriod!=60) + { + if (MathMod(GrossPeriod,60)>0) Period_tf=GrossPeriod; else Period_tf="H"+GrossPeriod/60 + ""; + } + } + } + } + } + + if (ExtIndicator==1) if (minSize!=0) di=minSize*Point/2; + if (ExtIndicator==2) {di=minSize*Point; countBar=minBars;} + if (ExtIndicator==3) {countBar=minBars;} + + if (ExtIndicator>5 && ExtIndicator<11 && GrossPeriod>Period()) + { + if (GrossPeriod==43200 && Period()==10080) maxBarToD=maxBarToD*5; else maxBarToD=maxBarToD*GrossPeriod/Period(); + } + + if (ExtIndicator<6 ||ExtIndicator>10) GrossPeriod=Period(); + + if (ExtFiboType<0) ExtFiboType=0; + if (ExtFiboType>2) ExtFiboType=2; + + if (ExtFiboType==2) // Подготовка списка фиб, заданных пользователем + { + i=-1; + aa2=0; + while (aa2>=0) + { + aa2=StringFind(ExtFiboTypeFree, ",",i+1); + if (aa2>=0) + {i=aa2;Sizefi++;} + else + { + if (StringLen(ExtFiboTypeFree)-i>0) + { + if (StrToDouble(StringSubstr(ExtFiboTypeFree,i+1))>0) Sizefi++; + arrResize(Sizefi); + aa1=ExtFiboTypeFree; + for (i=0;i=0) aa1=StringSubstr(aa1,aa2+1); + } +// aa2=-1; + } + } + } + } +// ------- + +// Проверка правильности введенных внешних переменных + if (ExtDelta<=0) ExtDelta=0.001; + if (ExtDelta>1) ExtDelta=0.999; + + if (ExtHidden<0) ExtHidden=0; + if (ExtHidden>5) ExtHidden=5; + + if (ExtDeltaType<0) ExtDeltaType=0; + if (ExtDeltaType>3) ExtDeltaType=3; + + if (ExtFiboChoice<0) ExtFiboChoice=0; + if (ExtFiboChoice>11) ExtFiboChoice=11; + + if (ExtPivotZZ1Num>9) ExtPivotZZ1Num=9; + if (ExtPivotZZ2Num>9) ExtPivotZZ2Num=9; + + if (ExtPivotZZ1Num==ExtPivotZZ2Num) + { + if (ExtPivotZZ1Num>0) ExtPivotZZ1Num=ExtPivotZZ2Num-1; + } + + if (ExtFractalEnd>0) + { + if (ExtFractalEnd<1) ExtFractalEnd=1; + } + + if (ExtPitchforkStatic>4) ExtPitchforkStatic=4; + if (ExtPitchforkDinamic>4) ExtPitchforkDinamic=4; + + if (ExtCM_0_1A_2B_Dinamic<0) ExtCM_0_1A_2B_Dinamic=0; + if (ExtCM_0_1A_2B_Dinamic>5) ExtCM_0_1A_2B_Dinamic=5; + if (ExtCM_0_1A_2B_Static<0) ExtCM_0_1A_2B_Static=0; + if (ExtCM_0_1A_2B_Static>5) ExtCM_0_1A_2B_Static=5; + if (ExtCM_FiboDinamic<0) ExtCM_FiboDinamic=0; + if (ExtCM_FiboDinamic>1) ExtCM_FiboDinamic=1; + if (ExtCM_FiboStatic<0) ExtCM_FiboStatic=0; + if (ExtCM_FiboStatic>1) ExtCM_FiboStatic=1; + +//-------------------------------------------- + if (ExtPitchforkStaticNum<3) ExtPitchforkStaticNum=3; + + if (ExtFiboStaticNum<2) ExtFiboStaticNum=2; + + if (ExtFiboStaticNum>9) + { + aa=DoubleToStr(ExtFiboStaticNum,0); + aa1=StringSubstr(aa,0,1); + mFibo[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,1,1); + mFibo[1]=StrToInteger(aa1); + } + else + { + mFibo[0]=ExtFiboStaticNum; + mFibo[1]=ExtFiboStaticNum-1; + } + + if (ExtFiboFanNum<1) ExtFiboFanNum=1; + + if (ExtFiboFanNum>9) + { + aa=DoubleToStr(ExtFiboFanNum,0); + aa1=StringSubstr(aa,0,1); + mFan[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,1,1); + mFan[1]=StrToInteger(aa1); + } + else + { + mFan[0]=ExtFiboFanNum; + mFan[1]=ExtFiboFanNum-1; + } + + if (ExtPitchforkStaticNum>99) + { + aa=DoubleToStr(ExtPitchforkStaticNum,0); + aa1=StringSubstr(aa,0,1); + mPitch[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,1,1); + mPitch[1]=StrToInteger(aa1); + aa1=StringSubstr(aa,2,1); + mPitch[2]=StrToInteger(aa1); + } + else + { + mPitch[0]=ExtPitchforkStaticNum; + mPitch[1]=ExtPitchforkStaticNum-1; + mPitch[2]=ExtPitchforkStaticNum-2; + } + + if (ExtFiboExpansion<2) ExtFiboExpansion=0; + + if (ExtFiboExpansion>0) + { + if (ExtFiboExpansion>99) + { + aa=DoubleToStr(ExtFiboExpansion,0); + aa1=StringSubstr(aa,0,1); + mExpansion[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,1,1); + mExpansion[1]=StrToInteger(aa1); + aa1=StringSubstr(aa,2,1); + mExpansion[2]=StrToInteger(aa1); + } + else + { + mExpansion[0]=ExtFiboExpansion; + mExpansion[1]=ExtFiboExpansion-1; + mExpansion[2]=ExtFiboExpansion-2; + } + } + + if (ExtPitchforkCandle) + { + mPitchTime[0]=ExtDateTimePitchfork_1; + mPitchTime[1]=ExtDateTimePitchfork_2; + mPitchTime[2]=ExtDateTimePitchfork_3; + + if (ExtPitchfork_1_HighLow) + { + mPitchCena[0]=High[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_1,true)]; + mPitchCena[1]=Low[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_2,true)]; + mPitchCena[2]=High[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3,true)]; + } + else + { + mPitchCena[0]=Low[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_1,true)]; + mPitchCena[1]=High[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_2,true)]; + mPitchCena[2]=Low[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3,true)]; + } + + if (mPitchCena[0]<=0 || mPitchCena[1]<=0 || mPitchCena[2]<=0) {ExtPitchforkCandle=false;ExtPitchforkStatic=0;} + } + + if (ExtFiboTimeNum<=2) ExtFiboTimeNum=0; + if (ExtFiboTimeNum>999) ExtFiboTimeNum=0; + + if (ExtVLStaticNum>0) + { + if (ExtVLStaticNum<2) ExtVLStaticNum=2; + + if (ExtVLStaticNum>99) + { + aa=DoubleToStr(ExtVLStaticNum,0); + aa1=StringSubstr(aa,0,1); + mVL[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,1,1); + mVL[1]=StrToInteger(aa1); + aa1=StringSubstr(aa,2,1); + mVL[2]=StrToInteger(aa1); + } + else + { + mVL[0]=ExtVLStaticNum; + mVL[1]=ExtVLStaticNum-1; + mVL[2]=ExtVLStaticNum-2; + } + } + + if (ExtArcStaticNum>0) + { + if (ExtArcStaticNum<2) ExtArcStaticNum=2; + if (ExtArcStaticNum<12 && ExtArcStaticNum>9) ExtArcStaticNum=9; + if (ExtArcStaticNum>98) ExtArcStaticNum=98; + + if (ExtArcStaticNum>=12) + { + aa=DoubleToStr(ExtArcStaticNum,0); + aa1=StringSubstr(aa,1,1); + mArcS[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,0,1); + mArcS[1]=StrToInteger(aa1); + if (mArcS[0]==0) {ExtArcStaticNum=0; mArcS[1]=0;} + } + else + { + mArcS[1]=ExtArcStaticNum; + mArcS[0]=ExtArcStaticNum-1; + } + } + + if (ExtArcDinamicNum>0) + { + if (ExtArcDinamicNum>90) ExtArcStaticNum=90; + + if (ExtArcDinamicNum>9) + { + aa=DoubleToStr(ExtArcDinamicNum,0); + aa1=StringSubstr(aa,1,1); + mArcD[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,0,1); + mArcD[1]=StrToInteger(aa1); + if (mArcD[0]>0) mArcD[0]=0; + } + else + { + mArcD[1]=0; + mArcD[0]=ExtArcDinamicNum; + } + } + + // Золотая спираль + if (ExtSpiralNum>0) + { + if(goldenSpiralCycle <= 0) goldenSpiralCycle = 1; + if(accurity <= 0) accurity = 0.2; + if (ExtSpiralNum<2) ExtSpiralNum=2; + if (ExtSpiralNum>98) ExtSpiralNum=98; + + if (ExtSpiralNum>9) + { + aa=DoubleToStr(ExtSpiralNum,0); + aa1=StringSubstr(aa,1,1); + mSpiral[0]=StrToInteger(aa1); + aa1=StringSubstr(aa,0,1); + mSpiral[1]=StrToInteger(aa1); + if (mSpiral[0]==0) {ExtSpiralNum=0; mSpiral[1]=0;} + } + else + { + mSpiral[1]=ExtSpiralNum; + mSpiral[0]=ExtSpiralNum-1; + } + + } + + + // каналы + if (ExtChannelsNum>9876543210) ExtChannelsNum=0; + + if (ExtChannelsNum>0) + { + aa=DoubleToStr(ExtChannelsNum,0); + aa2=StringLen(aa); + + for (i=0;i=0) {mChannels[i]=-1; ArraySort(mChannels,WHOLE_ARRAY,0,MODE_DESCEND); i--;} + } + + for (i=1;i<=9;i++) + { + if (mChannels[i]==0) {DinamicChannels=i; break;} +// Print("mChannels["+i+"]=",mChannels[i]); + } + + } + + + if (ExtSave) + { + MathSrand(LocalTime()); + save=MathRand(); + } + + if (ExtCM_0_1A_2B_Static==4 || ExtCM_0_1A_2B_Dinamic==4) + { + for (i=Bars-1; i>-1; i--) + { + ASBar=ASBar + iHigh(NULL,GrossPeriod,i) - iLow(NULL,GrossPeriod,i) + Point; + } + ASBar=ASBar/Bars; + } + + array_(); + perTF=Period(); + Demo=IsDemo(); + delete_objects1(); + return(0); + } +//+------------------------------------------------------------------+ +//| Деинициализация. Удаление всех трендовых линий и текстовых объектов +//+------------------------------------------------------------------+ +int deinit() + { + int i; + delete_objects_dinamic(); + delete_objects1(); + delete_objects3(); + delete_objects4(); + delete_objects5(); + delete_objects_spiral(); + delete_objects_number(); + + ObjectDelete("fiboS" + ExtComplekt+"_"); + ObjectDelete("fiboFanS" + ExtComplekt+"_"); + ObjectDelete("RLineS" + ExtComplekt+"_"); + ObjectDelete("pitchforkS" + ExtComplekt+"_"); + ObjectDelete("pmedianaS" + ExtComplekt+"_"); + ObjectDelete("1-2pmedianaS" + ExtComplekt+"_"); + ObjectDelete("fiboTime1" + ExtComplekt+"_");ObjectDelete("fiboTime2" + ExtComplekt+"_");ObjectDelete("fiboTime3" + ExtComplekt+"_"); + ObjectDelete("fiboTime1Free" + ExtComplekt+"_");ObjectDelete("fiboTime2Free" + ExtComplekt+"_");ObjectDelete("fiboTime3Free" + ExtComplekt+"_"); + ObjectDelete("UTL" + ExtComplekt+"_");ObjectDelete("LTL" + ExtComplekt+"_"); + ObjectDelete("UWL" + ExtComplekt+"_");ObjectDelete("LWL" + ExtComplekt+"_"); + ObjectDelete("ISL_S" + ExtComplekt+"_"); + ObjectDelete("RZS" + ExtComplekt+"_"); + ObjectDelete("CL" + ExtComplekt+"_"); + ObjectDelete("PivotZoneS" + ExtComplekt+"_"); + ObjectDelete("FanMedianaStatic" + ExtComplekt+"_"); + ObjectDelete("FiboFan" + ExtComplekt+"_"); + ObjectDelete("FiboArcS" + ExtComplekt+"_"); + ObjectDelete("LinePivotZZ" + "1" + ExtComplekt+"_"); + ObjectDelete("LinePivotZZ" + "2" + ExtComplekt+"_"); + + for (i=0;i<9; i++) + { + nameObj="LCChannel" + i + ExtComplekt+"_"; + ObjectDelete(nameObj); + nameObj="LTChannel" + i + ExtComplekt+"_"; + ObjectDelete(nameObj); + } + + for (i=0; i<7; i++) + { + nameObj="VLS"+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + } + + Comment(""); + return(0); + } +//******************************************************** + +// НАЧАЛО +int start() + { + if ((ExtIndicator==6 || ExtIndicator==7 || ExtIndicator==8 || ExtIndicator==10) && Period()>GrossPeriod) + { + ArrayInitialize(zz,0);ArrayInitialize(zzL,0);ArrayInitialize(zzH,0);ArrayInitialize(nen_ZigZag,0); + init_zz=true; + return; + } + + counted_bars=IndicatorCounted(); + + if (perTF!=Period()) + { + delete_objects1(); + perTF=Period(); + } + + if (Demo!=IsDemo()) + { + delete_objects1(); + Demo=IsDemo(); + counted_bars=0; + } + +//----------------------------------------- +// +// 1. +// +// Блок заполнения буферов. Начало. +//----------------------------------------- +// zz[] - буфер, данные из которого берутся для отрисовки самого ZigZag-a +// zzL[] - массив минимумов черновой +// zzH[] - массив максимумов черновой +// +//----------------------------------------- + +if (Bars-IndicatorCounted()>2) + { + if (ExtMaxBar>0) cbi=ExtMaxBar; else cbi=Bars-1; + tiZZ=0; + if (ExtIndicator==1) {ti=0; ai=0; bi=0; tai=0; tbi=0; fs=0; si=0; sip=0;} lBar=0; hBar=0; + ArrayInitialize(zz,0);ArrayInitialize(zzL,0);ArrayInitialize(zzH,0);ArrayInitialize(nen_ZigZag,0); + init_zz=true; afrm=true; delete_objects_dinamic(); delete_objects1(); delete_objects3(); + flagExtGartleyTypeSearch2=false; vPatOnOff=0; PeakDetIni=true; + } +else + { + if (ExtIndicator==1) cbi=Bars-IndicatorCounted()-1; + else cbi=Bars-IndicatorCounted(); + + if (ExtMinBar>0&&(ExtIndicator==0||ExtIndicator==1||ExtIndicator==2||ExtIndicator==3||ExtIndicator==5||ExtIndicator==6||ExtIndicator==7||ExtIndicator==8||ExtIndicator==10||ExtIndicator==11) + && tiZZ==iTime(NULL,GrossPeriod,0)) return (0); + else if (lBar<=iLow(NULL,GrossPeriod,0) && hBar>=iHigh(NULL,GrossPeriod,0) && tiZZ==iTime(NULL,GrossPeriod,0)) return(0); + else + { + if (tiZZ0) PivotZZ(ExtPivotZZ1Color, ExtPivotZZ1Num, 1); + if (ExtPivotZZ2Num==1 && ExtPivotZZ2Color>0) PivotZZ(ExtPivotZZ2Color, ExtPivotZZ2Num, 2); + } + } + lBar=iLow(NULL,GrossPeriod,0); hBar=iHigh(NULL,GrossPeriod,0); tiZZ=iTime(NULL,GrossPeriod,0); + } + + } + + switch (ExtIndicator) + { + case 0 : {ZigZag_(); break;} + case 1 : {ang_AZZ_(); break;} + case 2 : {Ensign_ZZ(); break;} + case 3 : {Ensign_ZZ(); break;} + case 4 : {ZigZag_tauber();break;} + case 5 : {GannSwing(); break;} + case 6 : {nenZigZag(); break;} // DT-ZigZag - с исправленным, оптимизированным зигзагом ZigZag_new_nen3.mq4 + case 7 : {nenZigZag(); break;} // DT-ZigZag - вариант зигзага, который любезно предоставил klot - DT_ZZ.mq4 + case 8 : {nenZigZag(); break;} // DT-ZigZag - вариант зигзага, который любезно предоставил Candid - CZigZag.mq4 + case 10 : {nenZigZag(); break;} // DT-ZigZag - вариант зигзага ExtIndicator=5 в режиме DT - внешний зигзаг Swing_zz.mq4 +// Поиск паттернов + case 11 : + { + if (ExtGartleyTypeSearch<2) vPatOnOff = 0; + ZigZag_(); + if (ExtGartleyTypeSearch==2 && vPatOnOff == 1) flagExtGartleyTypeSearch2=true; + + if (vPatOnOff==1 && vPatNew==0) + { + vPatNew=1; flagGartle=true; + if(ExtPlayAlert) + { + Alert (Symbol()," ",Period()," появился новый Паттерн"); + PlaySound("alert.wav"); + } + if (ExtSendMail) _SendMail("There was a pattern","on " + Symbol() + " " + Period() + " pattern " + vBullBear + " " + vNamePattern); + } + else if (vPatOnOff==0 && vPatNew==1) + { + vPatNew=0; flagGartle=true; FlagForD=true; + } + + if (minBarsSave!=minBarsX) + { + afrm=true; delete_objects_dinamic(); delete_objects1(); counted_bars=0; minBarsSave=minBarsX; PeakDetIni=true; + } + break; + } + + case 12 : {ZZTalex(minBars);break;} + case 13 : {ZigZag_SQZZ();break;} // ZigZag товароведа + case 14 : {ZZ_2L_nen();break;} // ZigZag wellx + } + +if (ExtHidden<5) // Разрешение на вывод оснастки. Начало. + { + if(!chHL_PeakDet_or_vts) + { + if (ExtLabel==0) {i_vts(); i_vts1();} + } + else if (PeakDetIni && PeakDet) + { + PeakDetIni=false; + double kl=0,kh=0; // kl - min; kh - max + + for (shift=Bars; shift>0; shift--) + { + if (zzH[shift]>0) {kh=zzH[shift];} + if (zzL[shift]>0) {kl=zzL[shift];} + + lam[shift]=kl; + ham[shift]=kh; + } + } + // Инициализация матрицы + matriza(); + if (infoTF) if (close_TF!=Close[0]) info_TF(); + + } + + +//----------------------------------------- +// Блок заполнения буферов. Конец. +//----------------------------------------- + +if (ExtHidden<5) // Разрешение на вывод оснастки. Начало. + { +//====================== +//====================== +//====================== + +//----------------------------------------- +// +// 2. +// +// Блок подготовки данных. Начало. +//----------------------------------------- + + if (Bars - counted_bars>2 || flagFrNew) + { + + // Поиск времени и номера бара, до которого будут рисоваться соединительные линии + if (countBarEnd==0) + { + if (ExtFractalEnd>0) + { + k=ExtFractalEnd; + for (shift=0; shift0; shift++) + { + if (zz[shift]>0 && zzH[shift]>0) {countBarEnd=shift; TimeBarEnd=Time[shift]; k--;} + } + } + else + { + countBarEnd=Bars-3; + TimeBarEnd=Time[Bars-3]; + } + } + else + { + countBarEnd=iBarShift(Symbol(),Period(),TimeBarEnd); + } + + } +//----------------------------------------- +// Блок подготовки данных. Конец. +//----------------------------------------- + + +//----------------------------------------- +// +// 3. +// +// Блок проверок и удаления линий, +// потерявших актуальность. Начало. +//----------------------------------------- +// Коррекция соединяющих линий и чисел. Начало. + +if (Bars - counted_bars<3) + { + // Поиск времени бара первого экстремума, считая от нулевого бара + for (shift1=0; shift10.0 && (zzH[shift1]==zz[shift1] || zzL[shift1]==zz[shift1])) + { + timeFr1new=Time[shift1]; + break; + } + } + // Поиск бара, на котором первый экстремум был ранее. + shift=iBarShift(Symbol(),Period(),afr[0]); + + + // Появился новый луч ZigZag + if ((zzH[shift1]>0 && afrl[0]>0) || (zzL[shift1]>0 && afrh[0]>0)) + { + newRay=true; + if (!ExtDinamic) + { + ExtNumberPeak=false; + ExtFiboStatic=false; + ExtPitchforkStatic=0; + ExtFiboFanNum=0; + ExtFiboExpansion=0; + ExtVLStaticNum=0; + ExtArcStaticNum=0; + ExtSpiralNum=0; + ExtPivotZZ2Num=0; + ExtChannelsNum=0; + ExtFiboTimeNum=0; + } + else + { + if (StringSubstr(ExtVisibleDinamic,0,1)!="1") ExtNumberPeak=false; + if (StringSubstr(ExtVisibleDinamic,1,1)!="1") ExtFiboStatic=false; + if (StringSubstr(ExtVisibleDinamic,2,1)!="1") ExtPitchforkStatic=0; + if (StringSubstr(ExtVisibleDinamic,3,1)!="1") ExtFiboFanNum=0; + if (StringSubstr(ExtVisibleDinamic,4,1)!="1") ExtFiboExpansion=0; + if (StringSubstr(ExtVisibleDinamic,5,1)!="1") ExtVLStaticNum=0; + if (StringSubstr(ExtVisibleDinamic,6,1)!="1") ExtArcStaticNum=0; + if (StringSubstr(ExtVisibleDinamic,7,1)!="1") ExtSpiralNum=0; + if (StringSubstr(ExtVisibleDinamic,8,1)!="1") ExtPivotZZ2Num=0; + if (StringSubstr(ExtVisibleDinamic,9,1)!="1") ExtChannelsNum=0; + if (StringSubstr(ExtVisibleDinamic,10,1)!="1") ExtFiboTimeNum=0; + } + + if (ExtAlert) + { + Alert (Symbol()," ",Period()," появился новый луч ZigZag"); + PlaySound("alert.wav"); + } + } + + // Сравнение текущего значения экстремума с тем, который был ранее + + // Образовался новый экстремум + if (timeFr1new!=afr[0]) + { + flagFrNew=true; + if (shift>=shift1) numBar=shift; else numBar=shift1; + afrm=true; + } + + // Экстремум на максимуме сдвинулся на другой бар + if (afrh[0]>0 && zz[shift]==0.0) + { + flagFrNew=true; + if (numBar0 && zz[shift]==0.0) + { + flagFrNew=true; + if (numBar0) + { + flagFrNew=true; + numBar=0; + delete_objects2(afr[0]); + afrx[0]=High[shift]; + afrh[0]=High[shift]; + if (ExtFiboFanDinamic) screenFiboFanD(); + if (mFibo[1]==0 && ExtFiboStatic) screenFiboS(); + if (ExtFiboDinamic) screenFiboD(); + if (ExtPitchforkDinamic>0) screenPitchforkD(); + if (ExtVLDinamicColor>0) VLD(); + if (mVL[2]==0 && ExtVLStaticNum>0) VLS(); + if (ExtFiboTimeNum>2) fiboTimeX (); + if (ExtPitchforkStatic>0) + { + if (ExtPitchforkCandle) + { + if (iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)==0) screenPitchforkS(); + } + else + { + if (mPitch[2]==0) screenPitchforkS(); + } + } + if (mExpansion[2]==0 && ExtFiboExpansion>0) FiboExpansion(); + if (mFan[1]==0 && ExtFiboFanNum>0 && ExtFiboFanColor>0) screenFiboFan(); + if (ExtArcDinamicNum>0) screenFiboArcD(); + if (ExtArcStaticNum>0) screenFiboArcS(); + } +//============= 1 сместился максимум. Конец. +// +//============= 1 сместился минимум. Начало. + if (afrl[0]-Low[shift]!=0 && afrl[0]>0) + { + flagFrNew=true; + numBar=0; + delete_objects2(afr[0]); + afrx[0]=Low[shift]; + afrl[0]=Low[shift]; + if (mFibo[1]==0 && ExtFiboStatic) screenFiboS(); + if (ExtFiboDinamic) screenFiboD(); + if (ExtPitchforkDinamic>0) screenPitchforkD(); + if (ExtFiboFanDinamic) screenFiboFanD(); + if (ExtVLDinamicColor>0) VLD(); + if (mVL[2]==0 && ExtVLStaticNum>0) VLS(); + if (ExtFiboTimeNum>2) fiboTimeX (); + if (ExtPitchforkStatic>0) + { + if (ExtPitchforkCandle) + { + if (iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)==0) screenPitchforkS(); + } + else + { + if (mPitch[2]==0) screenPitchforkS(); + } + } + if (mExpansion[2]==0 && ExtFiboExpansion>0) FiboExpansion(); + if (mFan[1]==0 && ExtFiboFanNum>0 && ExtFiboFanColor>0) screenFiboFan(); + if (ExtArcDinamicNum>0) screenFiboArcD(); + if (ExtArcStaticNum>0) screenFiboArcS(); + } +//============= 1 сместился минимум. Конец. +//-----------3 Сместился максимум или минимум, но остался на том же баре. Конец. + + // Поиск исчезнувших фракталов и удаление линий, исходящих от этих фракталов. Начало. + countBarEnd=iBarShift(Symbol(),Period(),TimeBarEnd); + for (k=0; k<5; k++) + { + + // Проверка максимумов. + if (afrh[k]>0) + { + // Поиск бара, на котором был этот фрактал + shift=iBarShift(Symbol(),Period(),afr[k]); + if (zz[shift]==0) + { + flagFrNew=true; + if (shift>numBar) numBar=shift; + afrm=true; + numHighPrim=shift; numHighLast=0;HighLast=0.0; + for (k1=shift+1; k1<=countBarEnd; k1++) + { + if (zzH[k1]>0) + { + if (ZigZagHighLow) HighLast=High[k1]; else HighLast=zzH[k1]; + numHighLast=k1; + + nameObj="_" + ExtComplekt + "ph" + Time[numHighPrim] + "_" + Time[numHighLast]; + + numOb=ObjectFind(nameObj); + if (numOb>-1) + { + ObjectDelete(nameObj); + + nameObjtxt="_" + ExtComplekt + "phtxt" + Time[numHighPrim] + "_" + Time[numHighLast]; + + ObjectDelete(nameObjtxt); + } + } + } + } + } + + // Проверка минимумов. + if (afrl[k]>0) + { + // Поиск бара, на котором был этот фрактал + shift=iBarShift(Symbol(),Period(),afr[k]); + if (zz[shift]==0) + { + flagFrNew=true; + if (shift>numBar) numBar=shift; + + afrm=true; + numLowPrim=shift; numLowLast=0;LowLast=10000000; + for (k1=shift+1; k1<=countBarEnd; k1++) + { + if (zzL[k1]>0) + { + if (ZigZagHighLow) LowLast=Low[k1]; else LowLast=zzL[k1]; + numLowLast=k1; + + nameObj="_" + ExtComplekt + "pl" + Time[numLowPrim] + "_" + Time[numLowLast]; + + numOb=ObjectFind(nameObj); + if (numOb>-1) + { + ObjectDelete(nameObj); + + nameObjtxt="_" + ExtComplekt + "pltxt" + Time[numLowPrim] + "_" + Time[numLowLast]; + + ObjectDelete(nameObjtxt); + } + } + } + } + } + } + // Поиск исчезнувших фракталов и удаление линий, исходящих от этих фракталов. Конец. + + // Перезапись матрицы. Начало. + matriza (); + // Перезапись матрицы. Конец. + + } +// Коррекция соединяющих линий и чисел. Конец. +//----------------------------------------- +// Блок проверок и удаления линий, +// потерявших актуальность. Конец. +//----------------------------------------- + + + // Подсчет количества фракталов. Начало. + countFractal(); + // Подсчет количества фракталов. Конец. + +//----------------------------------------- +// +// 4. +// +// Блок вывода соединительных линий. Начало. +//----------------------------------------- +if (Bars - counted_bars>2 && ExtHidden>0) + { +//-----------1 Отрисовка максимумов. Начало. +//+--------------------------------------------------------------------------+ +//| Вывод соединяющих линий и чисел Песавенто и 0.886 для максимумов ZigZag-a +//| Отрисовка начинается от нулевого бара +//+--------------------------------------------------------------------------+ + + numLowPrim=0; numLowLast=0; + numHighPrim=0; numHighLast=0; + + LowPrim=0.0; LowLast=0.0; + HighPrim=0.0; HighLast=0.0; + + Angle=-100; + + if (flagFrNew && !flagGartle) countFr=1; + else countFr=ExtFractal; + + for (k=0; (k0 && countFr>0); k++) + { + if (zzL[k]>0.0 && (zzL[k]0 && zzL[k]==zz[k]) + { + if (ZigZagHighLow) LowPrim=Low[k]; else LowPrim=zzL[k]; + numLowPrim=k; + } + if (zzH[k]>0.0 && zzH[k]==zz[k]) + { + if (HighPrim>0) + { + + if (ZigZagHighLow) HighLast=High[k]; else HighLast=zzH[k]; + numHighLast=k; + + HL=HighLast-LowPrim; + kj=(HighPrim-HighLast)*1000/(numHighLast-numHighPrim); + if (HL>0 && (Angle>=kj || Angle==-100)) // Проверка угла наклона линии + { + Angle=kj; + // Создание линии и текстового объекта + HLp=HighPrim-LowPrim; + k1=MathCeil((numHighPrim+numHighLast)/2); + kj=HLp/HL; + + + if (ExtPPWithBars==0) PPWithBars=""; + else if (ExtPPWithBars==1) PPWithBars=" ("+(numHighLast-numHighPrim)+")"; + else if (ExtPPWithBars==2) PPWithBars=" ("+(numHighLast-numLowPrim)+"-"+(numLowPrim-numHighPrim)+")"; + else if (ExtPPWithBars==3) + { + int_to_d1=(numLowPrim-numHighPrim); + int_to_d2=(numHighLast-numLowPrim); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==4) + { + int_to_d1=(Time[numLowPrim]-Time[numHighPrim]); + int_to_d2=(Time[numHighLast]-Time[numLowPrim]); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==5) + { + int_to_d1=(numLowPrim-numHighPrim)*(High[numHighPrim]-Low[numLowPrim]); + int_to_d2=(numHighLast-numLowPrim)*(High[numHighLast]-Low[numLowPrim]); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==7) + { + int_to_d1=((High[numHighLast]-Low[numLowPrim])/Point)/(numHighLast-numLowPrim); + int_to_d2=((High[numHighPrim]-Low[numLowPrim])/Point)/(numLowPrim-numHighPrim); + PPWithBars=" ("+DoubleToStr(int_to_d1,3)+"/"+DoubleToStr(int_to_d2,3)+")"; + } + else if (ExtPPWithBars==8) + { + int_to_d1=MathSqrt((numLowPrim-numHighPrim)*(numLowPrim-numHighPrim) + ((High[numHighPrim]-Low[numLowPrim])/Point)*((High[numHighPrim]-Low[numLowPrim])/Point)); + int_to_d2=MathSqrt((numHighLast-numLowPrim)*(numHighLast-numLowPrim) + ((High[numHighLast]-Low[numLowPrim])/Point)*((High[numHighLast]-Low[numLowPrim])/Point)); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==9) + { + int_to_d1=100-100*Low[numLowPrim]/High[numHighLast]; + int_to_d2=100*High[numHighPrim]/Low[numLowPrim]-100; + PPWithBars=" ("+DoubleToStr(int_to_d1,1)+"/"+DoubleToStr(int_to_d2,1)+")"; + } + +// ExtPPWithBars=6 Вычисляется количство пунктов и процент отклонения от ретресмента "Песавенто" + + ExtLine_=ExtLine; + if (kj>0.1 && kj<9.36) + { + // Создание текстового объекта (числа Песавенто). % восстановления между максимумами + kk=kj; + k2=1; + Pesavento_patterns(); + if (k2<0) + // процент восстановления числа Песавенто и 0.886 + { + ExtLine_=ExtLine886; + if (ExtHidden!=4) + { + nameObj="_" + ExtComplekt + "phtxt" + Time[numHighPrim] + "_" + Time[numHighLast]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(HighPrim+HighLast)/2); + + if (ExtPPWithBars==6) + { + int_to_d=MathAbs((kk-kj)/kk)*100; + PPWithBars=" ("+DoubleToStr((LowPrim+(HighLast-LowPrim)*kk-HighPrim)/Point,0)+"/"+DoubleToStr(int_to_d,2)+"%)"; + } + descript=txtkk; + ObjectSetText(nameObj,txtkk+PPWithBars,ExtSizeTxt,"Arial", colorPPattern); + if (ExtPPWithBars==6) PPWithBars=""; + } + } + else + // процент восстановления (не Песавенто и 0.886) + { + if (ExtHidden==1 || ExtHidden==4) + { + nameObj="_" + ExtComplekt + "phtxt" + Time[numHighPrim] + "_" + Time[numHighLast]; + + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(HighPrim+HighLast)/2); + + descript=DoubleToStr(kk,3); + if (ExtDeltaType==3) + { + ObjectSetText(nameObj,""+DoubleToStr(kk,3)+PPWithBars,ExtSizeTxt,"Arial",colorPPattern); + } + else + { + ObjectSetText(nameObj,""+DoubleToStr(kk,2)+PPWithBars,ExtSizeTxt,"Arial",colorPPattern); + } + } + } + + if ((ExtHidden==2 && k2<0) || ExtHidden!=2) + { + nameObj="_" + ExtComplekt + "ph" + Time[numHighPrim] + "_" + Time[numHighLast]; + ObjectCreate(nameObj,OBJ_TREND,0,Time[numHighLast],HighLast,Time[numHighPrim],HighPrim); + + if (descript_b) ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" PPesavento "+"Line High "+descript); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine_); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + } + if (ExtFiboZigZag) k=countBarEnd; + } + } + } + else + { + if (ZigZagHighLow) HighPrim=High[k]; else HighPrim=zzH[k]; + numHighPrim=k; + } + } + // Переход на следующий экстремум + if (k>countBarEnd) + { + k=numHighPrim+1; countHigh1--; countFr--; + + numLowPrim=0; numLowLast=0; + numHighPrim=0; numHighLast=0; + + LowPrim=0.0; LowLast=0.0; + HighPrim=0.0; HighLast=0.0; + + Angle=-100; + } + } +//-----------1 Отрисовка максимумов. Конец. + +//-----------2 Отрисовка минимумов. Начало. +//+-------------------------------------------------------------------------+ +//| Вывод соединяющих линий и чисел Песавенто и 0.886 для минимумов ZigZag-a +//| Отрисовка идет от нулевого бара +//+-------------------------------------------------------------------------+ + + numLowPrim=0; numLowLast=0; + numHighPrim=0; numHighLast=0; + + LowPrim=0.0; LowLast=0.0; + HighPrim=0.0; HighLast=0.0; + + Angle=-100; + + if (flagFrNew && !flagGartle) countFr=1; + else countFr=ExtFractal; + flagFrNew=false; + flagGartle=false; + + for (k=0; (k0 && countFr>0); k++) + { + if (zzH[k]>HighPrim && LowPrim>0) + { + if (ZigZagHighLow) HighPrim=High[k]; else HighPrim=zzH[k]; + numHighPrim=k; + } + + if (zzL[k]>0.0 && zzL[k]==zz[k]) + { + if (LowPrim>0) + { + + if (ZigZagHighLow) LowLast=Low[k]; else LowLast=zzL[k]; + numLowLast=k; + + // вывод соединяющих линий и процентов восстановления(чисел Песавенто) + HL=HighPrim-LowLast; + kj=(LowPrim-LowLast)*1000/(numLowLast-numLowPrim); + if (HL>0 && (Angle<=kj || Angle==-100)) // Проверка угла наклона линии + { + Angle=kj; + + HLp=HighPrim-LowPrim; + k1=MathCeil((numLowPrim+numLowLast)/2); + kj=HLp/HL; + + if (ExtPPWithBars==0) PPWithBars=""; + else if (ExtPPWithBars==1) PPWithBars=" ("+(numLowLast-numLowPrim)+")"; + else if (ExtPPWithBars==2) PPWithBars=" ("+(numLowLast-numHighPrim)+"-"+(numHighPrim-numLowPrim)+")"; + else if (ExtPPWithBars==3) + { + int_to_d1=(numHighPrim-numLowPrim); + int_to_d2=(numLowLast-numHighPrim); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==4) + { + int_to_d1=(Time[numHighPrim]-Time[numLowPrim]); + int_to_d2=(Time[numLowLast]-Time[numHighPrim]); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==5) + { + int_to_d1=(numHighPrim-numLowPrim)*(High[numHighPrim]-Low[numLowPrim]); + int_to_d2=(numLowLast-numHighPrim)*(High[numHighPrim]-Low[numLowLast]); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==7) + { + int_to_d1=((High[numHighPrim]-Low[numLowLast])/Point)/(numLowLast-numHighPrim); + int_to_d2=((High[numHighPrim]-Low[numLowPrim])/Point)/(numHighPrim-numLowPrim); + PPWithBars=" ("+DoubleToStr(int_to_d1,3)+"/"+DoubleToStr(int_to_d2,3)+")"; + } + else if (ExtPPWithBars==8) + { + int_to_d1=MathSqrt((numHighPrim-numLowPrim)*(numHighPrim-numLowPrim) + ((High[numHighPrim]-Low[numLowPrim])/Point)*((High[numHighPrim]-Low[numLowPrim])/Point)); + int_to_d2=MathSqrt((numLowLast-numHighPrim)*(numLowLast-numHighPrim) + ((High[numHighPrim]-Low[numLowLast])/Point)*((High[numHighPrim]-Low[numLowLast])/Point)); + int_to_d=int_to_d1/int_to_d2; + PPWithBars=" ("+DoubleToStr(int_to_d,2)+")"; + } + else if (ExtPPWithBars==9) + { + int_to_d1=100*High[numHighPrim]/Low[numLowLast]-100; + int_to_d2=100-100*Low[numLowPrim]/High[numHighPrim]; + PPWithBars=" ("+DoubleToStr(int_to_d1,1)+"/"+DoubleToStr(int_to_d2,1)+")"; + } + +// ExtPPWithBars=6 Вычисляется количство пунктов и процент отклонения от ретресмента "Песавенто" + + ExtLine_=ExtLine; + if ( kj>0.1 && kj<9.36) + { + // Создание текстового объекта (числа Песавенто). % восстановления между минимумами + kk=kj; + k2=1; + Pesavento_patterns(); + if (k2<0) + // процент восстановления числа Песавенто и 0.886 + { + ExtLine_=ExtLine886; + if (ExtHidden!=4) + { + nameObj="_" + ExtComplekt + "pltxt" + Time[numLowPrim] + "_" + Time[numLowLast]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(LowPrim+LowLast)/2); + + if (ExtPPWithBars==6) + { + int_to_d=MathAbs((kk-kj)/kk)*100; + PPWithBars=" ("+DoubleToStr((HighPrim-(HighPrim-LowLast)*kk-LowPrim)/Point,0)+"/"+DoubleToStr(int_to_d,2)+"%)"; + } + descript=txtkk; + ObjectSetText(nameObj,txtkk+PPWithBars,ExtSizeTxt,"Arial", colorPPattern); + if (ExtPPWithBars==6) PPWithBars=""; + } + } + else + // процент восстановления (не Песавенто и 0.886) + { + if (ExtHidden==1 || ExtHidden==4) + { + nameObj="_" + ExtComplekt + "pltxt" + Time[numLowPrim] + "_" + Time[numLowLast]; + + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(LowPrim+LowLast)/2); + + descript=DoubleToStr(kk,3); + if (ExtDeltaType==3) + { + ObjectSetText(nameObj,""+DoubleToStr(kk,3)+PPWithBars,ExtSizeTxt,"Arial",colorPPattern); + } + else + { + ObjectSetText(nameObj,""+DoubleToStr(kk,2)+PPWithBars,ExtSizeTxt,"Arial",colorPPattern); + } + } + } + + if ((ExtHidden==2 && k2<0) || ExtHidden!=2) + { + nameObj="_" + ExtComplekt + "pl" + Time[numLowPrim] + "_" + Time[numLowLast]; + + ObjectCreate(nameObj,OBJ_TREND,0,Time[numLowLast],LowLast,Time[numLowPrim],LowPrim); + + if (descript_b) ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" PPesavento "+"Line Low "+descript); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine_); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + } + if (ExtFiboZigZag) k=countBarEnd; + } + } + } + else + { + numLowPrim=k; + if (ZigZagHighLow) LowPrim=Low[k]; else LowPrim=zzL[k]; + } + } + // Переход на следующий экстремум + if (k>countBarEnd) + { + k=numLowPrim+1; countLow1--; countFr--; + + numLowPrim=0; numLowLast=0; + numHighPrim=0; numHighLast=0; + + LowPrim=0.0; LowLast=0.0; + HighPrim=0.0; HighLast=0.0; + + Angle=-100; + } + } + +//-----------2 Отрисовка минимумов. Конец. + + } +//----------------------------------------- +// Блок вывода соединительных линий. Конец. +//----------------------------------------- + +//====================== +//====================== +//====================== + } // Разрешение на вывод оснастки. Конец. +// КОНЕЦ + } // start + + +//---------------------------------------------------- +// Подпрограммы и функции +//---------------------------------------------------- + +//-------------------------------------------------------- +// Подсчет количества экстремумов. Минимумов и максимумов. Начало. +//-------------------------------------------------------- +void countFractal() + { + int shift; + countLow1=0; + countHigh1=0; + if (flagFrNew && !flagGartle) + { + for(shift=0; shift<=numBar; shift++) + { + if (zzL[shift]>0.0) {countLow1++;} + if (zzH[shift]>0.0) {countHigh1++;} + } + + numBar=0; + counted_bars=Bars-4; + } + else + { + if (flagGartle) {counted_bars=0;} + for(shift=0; shift<=countBarEnd; shift++) + { + if (zzL[shift]>0.0) {countLow1++;} + if (zzH[shift]>0.0) {countHigh1++;} + } + } + } +//-------------------------------------------------------- +// Подсчет количества экстремумов. Минимумов и максимумов. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Формирование матрицы. Начало. +// +// Матрица используется для поиска исчезнувших экстремумов. +// Это инструмент компенсации непредвиденных закидонов стандартного ZigZag-a. +// +// Также выводятся статические и динамические фибы и вееры Фибоначчи, +// вилы Эндрюса... +//------------------------------------------------------ +void matriza() + { + if (afrm && ExtHidden<5) + { + afrm=false; + int shift,k; + double kl=0,kh=0; + + if (ExtMaxBar>0) cbi=ExtMaxBar; else cbi=Bars; + + k=0; + for (shift=0; shift0) + { + afrx[k]=zz[shift]; + afr[k]=Time[shift]; + if (zz[shift]==zzL[shift]) + { + kl=zzL[shift]; + if (ZigZagHighLow) afrl[k]=Low[shift]; + else + { + if (k==0) afrl[k]=Low[shift]; else afrl[k]=zzL[shift]; + } + afrh[k]=0.0; + } + if (zz[shift]==zzH[shift]) + { + kh=zzH[shift]; + if (ZigZagHighLow) afrh[k]=High[shift]; + else + { + if (k==0) afrh[k]=High[shift]; else afrh[k]=zzH[shift]; + } + afrl[k]=0.0; + } + k++; + } + } + + if (PeakDet && chHL_PeakDet_or_vts) + { +// kl - min; kh - max + for (k=shift; k>0; k--) + { + if (zzH[k]>0) {kh=zzH[k];} + if (zzL[k]>0) {kl=zzL[k];} + + if (kl>0) lam[k]=kl; + if (kh>0) ham[k]=kh; + } + } + + // Вывод Fibo Time вне вил Эндрюса + if (ExtFiboTimeNum>2) fiboTimeX (); // должно вызываться раньше вызова статических вил Эндрюса + + // Вывод вил Эндрюса + if (ExtPitchforkStatic>0) + { + if (newRay && mPitch[2]>0) screenPitchforkS(); + if (ExtPitchforkCandle) + { + if (iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)==0) screenPitchforkS(); + } + else + { + if (mPitch[2]==0) screenPitchforkS(); + } + } + if (ExtPitchforkDinamic>0) screenPitchforkD(); + + // Вывод каналлов. + if (ExtChannelsNum>1 || DinamicChannels>0) Channels(); + + // Вывод статических и динамических фиб. + if (ExtFiboStatic) + { + if (newRay && mFibo[1]>0) screenFiboS(); + if (mFibo[1]==0) screenFiboS(); + } + if (ExtFiboDinamic) {screenFiboD();} + + // Расширения Фибоначчи + if (ExtFiboExpansion>0) + { + if (newRay && mExpansion[2]>0) FiboExpansion(); + if (mExpansion[2]==0) FiboExpansion(); + } + + // Вывод фибовееров + if (ExtFiboFanNum>0 && ExtFiboFanColor>0) + { + if (newRay && mFan[1]>0) screenFiboFan(); + if (mFan[1]==0) screenFiboFan(); + } + if (ExtFiboFanDinamic) screenFiboFanD(); + + // Вывод Versum Levels + if (ExtVLStaticColor>0) + { + if (newRay && mVL[2]>0 && ExtVLStaticNum>0) VLS(); + if (mVL[2]==0) VLS(); + } + if (ExtVLDinamicColor>0) {VLD();} + + // Вывод PivotZZ динамические + if (ExtPivotZZ1Num==1 && ExtPivotZZ1Color>0) PivotZZ(ExtPivotZZ1Color, ExtPivotZZ1Num, 1); + if (ExtPivotZZ2Num==1 && ExtPivotZZ2Color>0) PivotZZ(ExtPivotZZ2Color, ExtPivotZZ2Num, 2); + + // Вывод PivotZZ статические + if (newRay && ExtPivotZZ1Num>1 && ExtPivotZZ1Color>0) PivotZZ(ExtPivotZZ1Color, ExtPivotZZ1Num, 1); + if (newRay && ExtPivotZZ2Num>1 && ExtPivotZZ2Color>0) PivotZZ(ExtPivotZZ2Color, ExtPivotZZ2Num, 2); + + // Вывод фибодуг + if (ExtArcDinamicNum>0) screenFiboArcD(); + if (newRay && ExtArcStaticNum>0) screenFiboArcS(); + + // Вывод спирали + if (newRay && ExtSpiralNum>0) GoldenSpiral(afr[mSpiral[0]],afrx[mSpiral[0]],afr[mSpiral[1]],afrx[mSpiral[1]]); + + // Поиск паттернов Gartley + if (ExtGartleyOnOff) + { + switch (ExtIndicator) + { + case 0 : {_Gartley("ExtIndicator=0_" + minBars+"/"+ExtDeviation+"/"+ExtBackstep,0);break;} + case 1 : {_Gartley("ExtIndicator=1_" + minSize+"/"+minPercent,0);break;} + case 2 : {_Gartley("ExtIndicator=2_" + minBars+"/"+minSize,0);break;} + case 3 : {_Gartley("ExtIndicator=3_" + minBars,0);break;} + case 4 : {_Gartley("ExtIndicator=4_" + minSize,0);break;} + case 5 : {_Gartley("ExtIndicator=5_" + minBars,0);break;} + case 6 : {_Gartley("ExtIndicator=6_" + minBars+"/"+ExtDeviation+"/"+ExtBackstep,0);break;} + case 7 : {_Gartley("ExtIndicator=7_" + minBars,0);break;} + case 8 : {_Gartley("ExtIndicator=8_" + minBars+"/"+ExtDeviation,0);break;} + case 10 : {_Gartley("ExtIndicator=10_" + minBars,0);break;} + case 12 : {_Gartley("ExtIndicator=12_" + minBars,0);break;} + case 13 : {_Gartley("ExtIndicator=13_" + minBars+"/"+minSize,0);break;} + case 14 : {_Gartley("ExtIndicator=14_" + minBars,0);break;} + } + + if (vPatOnOff==1 && vPatNew==0) + { + vPatNew=1; + if (ExtSendMail) _SendMail("There was a pattern","on " + Symbol() + " " + Period() + " pattern " + vBullBear + " " + vNamePattern); + } + else if (vPatOnOff==0 && vPatNew==1) {vPatNew=0; FlagForD=true;} + } + + ExtSave=false; + } + if (newRay && ExtNumberPeak) NumberPeak(); + newRay=false; + } +//-------------------------------------------------------- +// Формирование матрицы. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод номеров переломов зигзагов. Начало +//-------------------------------------------------------- +void NumberPeak() + { + int n=0,i,endNumber; + string txt; + if (ExtNumberPeak10) endNumber=iBarShift(Symbol(),Period(),afr[9]); else endNumber=Bars-minBars; + + delete_objects_number(); + + for (i=iBarShift(Symbol(),Period(),afr[0])+1;i0) + { + n++; + if (ExtNumberPeakLow) + { + if (zzL[i]>0) + { + txt=DoubleToStr(n,0); + nameObj="NumberPeak" + "_" + ExtComplekt + "_" + n; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[i],zz[i]); + ObjectSetText(nameObj,txt,ExtNumberPeakFontSize,"Arial",ExtNumberPeakColor); + } + } + else + { + txt=DoubleToStr(n,0); + nameObj="NumberPeak" + "_" + ExtComplekt + "_" + n; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[i],zz[i]); + ObjectSetText(nameObj,txt,ExtNumberPeakFontSize,"Arial",ExtNumberPeakColor); + } + } + } + } +//-------------------------------------------------------- +// Вывод номеров переломов зигзагов. Конец +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Каналы. Начало. +//-------------------------------------------------------- +void Channels() + { + int i,j,k,m,n,nul,peakLeft,peakRight,peakBase; + double tangens, sdvigH, sdvigL, sdvigH_, sdvigL_, cenaLTLeft, cenaLTRight, cenaLCLeft, cenaLCRight, wrcenaL, wrcenaR; + datetime timeLTLeft, timeLTRight, timeLCLeft, timeLCRight; + int baseExtremum; // номер перелома зигзага (бар), от которого строится трендовая + bool fTrend=false; // =true - Bull проводим трендовую по минимумам, =false - Bear проводим трендовую по максимумам + bool dinamic=false; + + if (ExtChannelsNum==0 && DinamicChannels>0) dinamic=true; + +//int o; + k=0; + for (i=0;i<=9;i++) {if (mChannels[i]>=0) k++;} + + // Каналы с линией тренда, первая точка которой на переломе зигзага, + // вторая точка построена по касательной к рынку на участке, охватываемом каналом. Начало. + if (ExtTypeChannels==1) + { + if (dinamic) nul=DinamicChannels; + else nul=1; + + for (i=1;iafrx[mChannels[i-1]-2] && afrx[mChannels[i-1]-1]>afrx[mChannels[i]]) + { +o=2; +Print ("===2==="); + fTrend=false; + if (afrx[mChannels[i-1]]MathAbs(afrx[mChannels[i]]-afrx[mChannels[i]+1])) // сходящийся треугольник + { + if (MathAbs(afrx[mChannels[i-1]]-afrx[mChannels[i-1]-2])>MathAbs(afrx[mChannels[i]]-afrx[mChannels[i]+2])) + { + if (afrx[mChannels[i-1]]afrx[mChannels[i]+1]) baseExtremum=mChannels[i]+1; else baseExtremum=mChannels[i-1]; + } + else + { + fTrend=false; + if (afrx[mChannels[i-1]]>afrx[mChannels[i]+1]) baseExtremum=mChannels[i-1]; else baseExtremum=mChannels[i]+1; + } +o=3; +Print ("===3==="); + } + else + { + if (afrx[mChannels[i-1]]afrx[mChannels[i]]) baseExtremum=mChannels[i-1]-1; else baseExtremum=mChannels[i]; + } + else + { + fTrend=true; + if (afrx[mChannels[i-1]-1]>afrx[mChannels[i]]) baseExtremum=mChannels[i]; else baseExtremum=mChannels[i-1]-1; + } +o=4; +Print ("===4==="); + } + } + else // расходящийся треугольник или плоская (параллельная) коррекция, что очень редко + { + if (MathAbs(afrx[mChannels[i-1]]-afrx[mChannels[i-1]-2])>MathAbs(afrx[mChannels[i]]-afrx[mChannels[i]+2])) + { + if (afrx[mChannels[i-1]]afrx[mChannels[i]+2]) baseExtremum=mChannels[i]; else baseExtremum=mChannels[i]+2; + } + else + { +o=51; +Print ("===51==="); +Print (MathAbs(afrx[mChannels[i-1]]-afrx[mChannels[i-1]-2])-MathAbs(afrx[mChannels[i]]-afrx[mChannels[i]+2])); + fTrend=true; + if (afrx[mChannels[i]]>afrx[mChannels[i]+2]) baseExtremum=mChannels[i]; else baseExtremum=mChannels[i]+2; + } + } + else + { + if (afrx[mChannels[i-1]]afrx[mChannels[i-1]]) baseExtremum=mChannels[i-1]; else baseExtremum=mChannels[i]+1; + } + else + { +o=7; +Print (MathAbs(afrx[mChannels[i-1]]-afrx[mChannels[i-1]-2])-MathAbs(afrx[mChannels[i]]-afrx[mChannels[i]+2])); +Print ("===7==="); + fTrend=false; + if (afrx[mChannels[i]+1]>afrx[mChannels[i-1]]) baseExtremum=mChannels[i]+1; else baseExtremum=mChannels[i-1]; + } + } + } + } + } +//Print ("baseExtremum=",baseExtremum); +//Print ("o=",o); +*/ + peakBase=iBarShift(Symbol(),Period(),afr[baseExtremum]); + tangens=(afrx[mChannels[i]]-afrx[baseExtremum])/(peakBase-peakRight); + + for (j=peakBase;j>=peakRight;j--) // вычисляем tangens + { + if (fTrend) + { + if (afrx[baseExtremum] + tangens*(peakBase-j)-Low[j]>0) tangens=(Low[j]-afrx[baseExtremum])/(peakBase-j); + } + else + { + if (High[j] - (afrx[baseExtremum] + tangens*(peakBase-j))>0) tangens=(High[j]-afrx[baseExtremum])/(peakBase-j); + } + } + + for (j=peakLeft;j>=peakRight;j--) // вычисляем сдвиги + { + if (fTrend) + { + sdvigH_=High[j] - (afrx[baseExtremum] + tangens*(peakBase-j)); + if (sdvigH_>sdvigH) {sdvigH=sdvigH_; cenaLCRight=High[j]+tangens*(j-peakRight);} + } + else + { + sdvigL_=afrx[baseExtremum] + tangens*(peakBase-j)-Low[j]; + if (sdvigL_>sdvigL) {sdvigL=sdvigL_; cenaLCRight=Low[j]+tangens*(j-peakRight);} + } + } + timeLCRight=afr[mChannels[i]]; + + if (ExtTypeLineChannels==0) + { + while (j>0) + { + if (fTrend) + { + if (afrx[baseExtremum] + tangens*(peakBase-j)-Low[j]>sdvigL) break; + } + else + { + if (High[j] - (afrx[baseExtremum] + tangens*(peakBase-j))>sdvigH) break; + } + j--; + } + } + + if (j<0) j=0; + + nameObj="LTChannel" + i + ExtComplekt+"_"; + if (ExtSave) + { + if (i!=DinamicChannels) nameObj=nameObj + save; + } + ObjectDelete(nameObj); + + if (fTrend) + { + timeLTLeft=afr[mChannels[i-1]]; cenaLTLeft=afrx[baseExtremum]-tangens*(peakLeft-peakBase); + timeLTRight=Time[j]; cenaLTRight=afrx[baseExtremum] + tangens*(peakBase-j)-sdvigL; + } + else + { + timeLTLeft=afr[mChannels[i-1]]; cenaLTLeft=afrx[baseExtremum]-tangens*(peakLeft-peakBase); + timeLTRight=Time[j]; cenaLTRight=afrx[baseExtremum] + tangens*(peakBase-j)+sdvigH; + } + + if (ExtTypeLineChannels==1 || ExtTypeLineChannels==3) + { + n=j; + wrcenaR=cenaLTRight; + if (fTrend) + { + while (cenaLTRight<=afrx[mChannels[i]] && n>0) {n--; cenaLTRight=wrcenaR+tangens*(j-n);} + } + else + { + while (cenaLTRight>=afrx[mChannels[i]] && n>0) {n--; cenaLTRight=wrcenaR+tangens*(j-n);} + } + timeLTRight=Time[n]; + timeLTLeft=afr[baseExtremum]; cenaLTLeft=afrx[baseExtremum]; + } + + ObjectCreate(nameObj,OBJ_TREND,0,timeLTLeft,cenaLTLeft,timeLTRight,cenaLTRight); + if (ExtTypeLineChannels<2) ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLTColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtLTChannelsStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtLTChannelsWidth); + + nameObj="LCChannel" + i + ExtComplekt+"_"; + if (ExtSave) + { + if (i!=DinamicChannels) nameObj=nameObj + save; + } + ObjectDelete(nameObj); + + if (fTrend) + { + cenaLCLeft=afrx[baseExtremum]+sdvigH-tangens*(peakLeft-peakBase); + } + else + { + cenaLCLeft=afrx[baseExtremum]-sdvigL-tangens*(peakLeft-peakBase); + } + timeLCLeft=afr[mChannels[i-1]]; + + if (ExtTypeLineChannels==1 || ExtTypeLineChannels==3) + { + m=peakLeft; + wrcenaL=cenaLCLeft; + n=peakRight; + wrcenaR=cenaLCRight; + if (fTrend) + { + while (cenaLCLeft>=afrx[baseExtremum] && m<=Bars) {m++; cenaLCLeft=wrcenaL-tangens*(m-peakLeft);} + while (cenaLCRight>=afrx[mChannels[i]] && n<=peakLeft) {n++; cenaLCRight=wrcenaR-tangens*(n-peakRight);} + } + else + { + while (cenaLCLeft<=afrx[baseExtremum] && m<=Bars) {m++; cenaLCLeft=wrcenaL-tangens*(m-peakLeft);} + while (cenaLCRight<=afrx[mChannels[i]] && n<=peakLeft) {n++; cenaLCRight=wrcenaR-tangens*(n-peakRight);} + } + timeLCLeft=Time[m]; + cenaLCRight=wrcenaR-tangens*(n-1-peakRight); + timeLCRight=Time[n-1]; + } + + ObjectCreate(nameObj,OBJ_TREND,0,timeLCLeft,cenaLCLeft,timeLCRight,cenaLCRight); + if (ExtTypeLineChannels<2) ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLCColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtLCChannelsStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtLCChannelsWidth); + + if (dinamic) break; + } + } + // Каналы с линией тренда, первая точка которой на переломе зигзага, + // вторая точка построена по касательной к рынку на участке, охватываемом каналом. Конец. + + // Каналы, параллельные лучу зигзага. Начало. + if (ExtTypeChannels==2) + { + if (dinamic) nul=DinamicChannels; + else nul=1; + + for (i=1;i=peakRight;j--) // вычисляем сдвиги + { + sdvigH_=High[j] - (afrx[mChannels[i-1]] + tangens*(peakLeft-j)); + sdvigL_=afrx[mChannels[i-1]] + tangens*(peakLeft-j)-Low[j]; + if (sdvigH_>sdvigH) sdvigH=sdvigH_; + if (sdvigL_>sdvigL) sdvigL=sdvigL_; + } + + if (ExtTypeLineChannels==0) + { + while (j>=0) + { + if (fTrend) + { + if (afrx[mChannels[i-1]] + tangens*(peakLeft-j)-Low[j]>sdvigL) break; + } + else + { + if (High[j] - (afrx[mChannels[i-1]] + tangens*(peakLeft-j))>sdvigH) break; + } + j--; + } + } + + if (j<0) j=0; + + nameObj="LTChannel" + i + ExtComplekt+"_"; + if (ExtSave) + { + if (i!=DinamicChannels) nameObj=nameObj + save; + } + ObjectDelete(nameObj); + if (fTrend) + { + timeLTLeft=afr[mChannels[i-1]]; cenaLTLeft=afrx[mChannels[i-1]]-sdvigL; + timeLTRight=Time[j]; cenaLTRight=afrx[mChannels[i-1]] + tangens*(peakLeft-j)-sdvigL; + } + else + { + timeLTLeft=afr[mChannels[i-1]]; cenaLTLeft=afrx[mChannels[i-1]]+sdvigH; + timeLTRight=Time[j]; cenaLTRight=afrx[mChannels[i-1]] + tangens*(peakLeft-j)+sdvigH; + } + + if (ExtTypeLineChannels==1 || ExtTypeLineChannels==3) + { + if (fTrend) + { + m=peakLeft; + wrcenaL=cenaLTLeft; + while (cenaLTLeft=peakRight) {m--; cenaLTLeft=wrcenaL+tangens*(peakLeft-m);} + timeLTLeft=Time[m+1]; cenaLTLeft=wrcenaL+tangens*(peakLeft-m-1); + + n=peakRight; + wrcenaR=cenaLTRight; + while (cenaLTRight0) {n--; cenaLTRight=wrcenaL+tangens*(peakLeft-n);} + timeLTRight=Time[n]; + } + else + { + m=peakLeft; + wrcenaL=cenaLTLeft; + while (cenaLTLeft>=afrx[mChannels[i-1]] && m>=peakRight) {m--; cenaLTLeft=wrcenaL+tangens*(peakLeft-m);} + timeLTLeft=Time[m+1]; cenaLTLeft=wrcenaL+tangens*(peakLeft-m-1); + + n=peakRight; + wrcenaR=cenaLTRight; + while (cenaLTRight>afrx[mChannels[i]] && n>0) {n--; cenaLTRight=wrcenaL+tangens*(peakLeft-n);} + timeLTRight=Time[n]; + } + } + + ObjectCreate(nameObj,OBJ_TREND,0,timeLTLeft,cenaLTLeft,timeLTRight,cenaLTRight); + if (ExtTypeLineChannels<2) ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLTColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtLTChannelsStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtLTChannelsWidth); + + nameObj="LCChannel" + i + ExtComplekt+"_"; + if (ExtSave) + { + if (i!=DinamicChannels) nameObj=nameObj + save; + } + ObjectDelete(nameObj); + if (fTrend) + { + timeLCLeft=afr[mChannels[i-1]]; cenaLCLeft=afrx[mChannels[i-1]]+sdvigH; + timeLCRight=afr[mChannels[i]]; cenaLCRight=afrx[mChannels[i]]+sdvigH; + } + else + { + timeLCLeft=afr[mChannels[i-1]]; cenaLCLeft=afrx[mChannels[i-1]]-sdvigL; + timeLCRight=afr[mChannels[i]]; cenaLCRight=afrx[mChannels[i]]-sdvigL; + } + + if (ExtTypeLineChannels==1 || ExtTypeLineChannels==3) + { + if (fTrend) + { + m=peakLeft; + wrcenaL=cenaLCLeft; + while (cenaLCLeft>afrx[mChannels[i-1]] && mafrx[mChannels[i]] && n1) + { + cena=(zz[peak2]+zz[peak1]+Close[peak1-1])/3; + + tangens=(zz[peak2]-zz[peak1])/(peak2-peak1); + val=zz[peak1]; + for (shift=peak1; shiftzz[peak1]) + { + if (val>cena) break; + } + else + { + if (val0) + { + H_L=afrh[nb]-afrl[nc]; // высота отрезка ВС + + for (i=0; i<7; i++) + { + if (ExtFiboType==1) + { + mediana=line_pesavento[i]*H_L+afrl[nc]; + tangens=(mediana-afrl[na])/(c_bar1+(1-line_pesavento[i])*c_bar2); + cena=c_bar2*line_pesavento[i]*tangens+mediana; + nameObj=vl+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,afr[na],afrl[na],afr[nc],cena); + ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" "+vl+" "+DoubleToStr(line_pesavento[i]*100,1)+""); + } + else + { + mediana=line_fibo[i]*H_L+afrl[nc]; + tangens=(mediana-afrl[na])/(c_bar1+(1-line_fibo[i])*c_bar2); + cena=c_bar2*line_fibo[i]*tangens+mediana; + nameObj=vl+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,afr[na],afrl[na],afr[nc],cena); + ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" "+vl+" "+DoubleToStr(line_fibo[i]*100,1)+""); + } + ObjectSet(nameObj,OBJPROP_COLOR,color_line); + ObjectSet(nameObj,OBJPROP_STYLE,ExtVLStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtVLWidth); + } + } + else + { + H_L=afrh[nc]-afrl[nb]; // высота отрезка ВС + + for (i=0; i<7; i++) + { + if (ExtFiboType==1) + { + mediana=afrh[nc]-line_pesavento[i]*H_L; + tangens=(afrh[na]-mediana)/(c_bar1+(1-line_pesavento[i])*c_bar2); + cena=mediana-c_bar2*line_pesavento[i]*tangens; + nameObj=vl+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,afr[na],afrh[na],afr[nc],cena); + ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" "+vl+" "+DoubleToStr(line_pesavento[i]*100,1)+""); + } + else + { + mediana=afrh[nc]-line_fibo[i]*H_L; + tangens=(afrh[na]-mediana)/(c_bar1+(1-line_fibo[i])*c_bar2); + cena=mediana-c_bar2*line_fibo[i]*tangens; + nameObj=vl+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,afr[na],afrh[na],afr[nc],cena); + ObjectSetText(nameObj,"ZUP"+ExtComplekt+" zz"+ExtIndicator+" "+vl+" "+DoubleToStr(line_fibo[i]*100,1)+""); + } + ObjectSet(nameObj,OBJPROP_COLOR,color_line); + ObjectSet(nameObj,OBJPROP_STYLE,ExtVLStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtVLWidth); + } + } + } +//-------------------------------------------------------- +// Versum Levels. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод вил Эндрюса статических. Начало. +//-------------------------------------------------------- +void screenPitchforkS() + { + int i; + double a1,b1,c1,ab1,bc1,ab2,bc2,tangens,n1,cl1,ch1,cena; + datetime ta1,tb1,tc1,tab2,tbc2,tcl1,tch1; + int pitch_time[]={0,0,0}; + double pitch_cena[]={0,0,0}; + double TLine, m618=0.618, m382=0.382; + + if (ExtPitchforkCandle) + { + if (iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)==0) + { + if (ExtPitchfork_1_HighLow) + { + mPitchCena[2]=High[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)]; + } + else + { + mPitchCena[2]=Low[iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)]; + } + } + } + + if (ExtPitchforkCandle) + { + cena=mPitchCena[0]; + if (ExtPitchfork_1_HighLow) + { + if (ExtCM_0_1A_2B_Static==1) + { + cena=mPitchCena[0]-(mPitchCena[0]-mPitchCena[1])*ExtCM_FiboStatic; + } + else if (ExtCM_0_1A_2B_Static==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Static==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Static>1) + { + if (ExtCM_0_1A_2B_Static==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*ExtCM_FiboStatic; + } + } + else + { + if (ExtCM_0_1A_2B_Static==1) + { + cena=mPitchCena[0]+(mPitchCena[1]-mPitchCena[0])*ExtCM_FiboStatic; + } + else if (ExtCM_0_1A_2B_Static==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Static==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Static>1) + { + if (ExtCM_0_1A_2B_Static==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*ExtCM_FiboStatic; + } + } + } + else + { + mPitchTime[0]=afr[mPitch[0]]; mPitchTime[1]=afr[mPitch[1]]; mPitchTime[2]=afr[mPitch[2]]; + + if (afrl[mPitch[0]]>0) + { + cena=afrl[mPitch[0]]; + mPitchCena[0]=afrl[mPitch[0]]; mPitchCena[1]=afrh[mPitch[1]]; mPitchCena[2]=afrl[mPitch[2]]; + if (ExtCM_0_1A_2B_Static==1) + { + cena=mPitchCena[0]+(mPitchCena[1]-mPitchCena[0])*ExtCM_FiboStatic; + } + else if (ExtCM_0_1A_2B_Static==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Static==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Static>1) + { + if (ExtCM_0_1A_2B_Static==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*ExtCM_FiboStatic; + } + } + else + { + cena=afrh[mPitch[0]]; + mPitchCena[0]=afrh[mPitch[0]]; mPitchCena[1]=afrl[mPitch[1]]; mPitchCena[2]=afrh[mPitch[2]]; + if (ExtCM_0_1A_2B_Static==1) + { + cena=mPitchCena[0]-(mPitchCena[0]-mPitchCena[1])*ExtCM_FiboStatic; + } + else if (ExtCM_0_1A_2B_Static==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Static==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Static>1) + { + if (ExtCM_0_1A_2B_Static==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*ExtCM_FiboStatic; + } + } + } + + mPitchCena[0]=cena; + + if (ExtFiboFanStatic) {ExtFiboFanStatic=false; screenFiboFanS();} + + nameObj="pmedianaS" + ExtComplekt+"_"; + ObjectDelete(nameObj); + + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + coordinaty_1_2_mediany_AP(mPitchCena[0], mPitchCena[1], mPitchCena[2], mPitchTime[0], mPitchTime[1], mPitchTime[2], tab2, tbc2, ab1, bc1); + + pitch_time[0]=tab2;pitch_cena[0]=ab1; + + if (ExtPitchforkStatic==2) + { + ObjectCreate(nameObj,OBJ_TREND,0,tab2,ab1,tbc2,bc1); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DASH); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + nameObj="1-2pmedianaS" + ExtComplekt+"_"; + + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TEXT,0,tab2,ab1+3*Point); + ObjectSetText(nameObj," 1/2 ML",9,"Arial", ExtLinePitchforkS); + } + + nameObj="pitchforkS" + ExtComplekt+"_"; + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + + if (ExtPitchforkStatic!=4) + { + pitch_time[0]=mPitchTime[0];pitch_cena[0]=mPitchCena[0]; + if (ExtPitchforkStatic==3) pitch_cena[0]=ab1; + } + pitch_time[1]=mPitchTime[1];pitch_cena[1]=mPitchCena[1]; + pitch_time[2]=mPitchTime[2];pitch_cena[2]=mPitchCena[2]; + + ObjectCreate(nameObj,OBJ_PITCHFORK,0,pitch_time[0],pitch_cena[0],pitch_time[1],pitch_cena[1],pitch_time[2],pitch_cena[2]); + ObjectSet(nameObj,OBJPROP_STYLE,ExtPitchforkStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtPitchforkWidth); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtFiboFanMedianaStaticColor>0) + { + coordinaty_mediany_AP(pitch_cena[0], pitch_cena[1], pitch_cena[2], pitch_time[0], pitch_time[1], pitch_time[2], tb1, b1); + + nameObj="FanMedianaStatic" + ExtComplekt+"_"; +/* + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } +*/ + ObjectDelete(nameObj); + + ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE); + ObjectCreate(nameObj,OBJ_FIBOFAN,0,pitch_time[0],pitch_cena[0],tb1,b1); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DASH); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboFanMedianaStaticColor); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtFiboType==0) + { + screenFibo_st(); + } + else if (ExtFiboType==1) + { + screenFibo_Pesavento(); + } + else if (ExtFiboType==2) + { + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi); + for (i=0;i0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + if (pitch_cena[1]>pitch_cena[2]) + { + ObjectCreate(nameObj,OBJ_TREND,0,pitch_time[0],pitch_cena[0],pitch_time[1],pitch_cena[1]); + } + else + { + ObjectCreate(nameObj,OBJ_TREND,0,pitch_time[0],pitch_cena[0],pitch_time[2],pitch_cena[2]); + } + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_SOLID); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + } + + if (ExtPivotZoneStaticColor>0 && ExtPitchforkStatic<4) PivotZone(pitch_time, pitch_cena, ExtPivotZoneStaticColor, "PivotZoneS"); + + if (ExtLTL) + { + nameObj="LTL" + ExtComplekt+"_"; + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + if (pitch_cena[1]>pitch_cena[2]) + { + ObjectCreate(nameObj,OBJ_TREND,0,pitch_time[0],pitch_cena[0],pitch_time[2],pitch_cena[2]); + } + else + { + ObjectCreate(nameObj,OBJ_TREND,0,pitch_time[0],pitch_cena[0],pitch_time[1],pitch_cena[1]); + } + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_SOLID); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + } +//------------------------------------------------------- + + if (ExtUWL || ExtLWL) + { + n1=iBarShift(Symbol(),Period(),pitch_time[0])-(iBarShift(Symbol(),Period(),pitch_time[1])+iBarShift(Symbol(),Period(),pitch_time[2]))/2.0; + ta1=pitch_time[0]; + tb1=Time[0]; + a1=pitch_cena[0]; + tangens=(pitch_cena[0]-(pitch_cena[1]+pitch_cena[2])/2.0)/n1; + b1=pitch_cena[0]-tangens*iBarShift(Symbol(),Period(),pitch_time[0]); + + ML_RL400(tangens, pitch_cena, pitch_time, tb1, b1, false); + + if (pitch_cena[1]>pitch_cena[2]) + { + if (ExtUWL) + { + ch1=pitch_cena[1]; + tch1=pitch_time[1]; + } + if (ExtLWL) + { + cl1=pitch_cena[2]; + tcl1=pitch_time[2]; + } + } + else + { + if (ExtUWL) + { + ch1=pitch_cena[2]; + tch1=pitch_time[2]; + } + if (ExtLWL) + { + cl1=pitch_cena[1]; + tcl1=pitch_time[1]; + } + } + + if (ExtUWL) + { + nameObj="UWL" + ExtComplekt+"_"; + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOCHANNEL,0,ta1,a1,tb1,b1,tch1,ch1); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_RAY,ExtLongWL); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE); + + UWL_LWL(ExtVisibleUWL,"U W L ",ExtFiboFreeUWL); + } + + if (ExtLWL) + { + nameObj="LWL" + ExtComplekt+"_"; + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOCHANNEL,0,ta1,a1,tb1,b1,tcl1,cl1); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtLinePitchforkS); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_RAY,ExtLongWL); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE); + + UWL_LWL(ExtVisibleLWL,"L W L ",ExtFiboFreeLWL); + } + + } + +//------------------------------------------------------- + + if (ExtPitchforkStaticColor>0) + { + + n1=iBarShift(Symbol(),Period(),pitch_time[0])-(iBarShift(Symbol(),Period(),pitch_time[1])+iBarShift(Symbol(),Period(),pitch_time[2]))/2.0; + + TLine=pitch_cena[1]-iBarShift(Symbol(),Period(),pitch_time[1])*(pitch_cena[0]-(pitch_cena[2]+pitch_cena[1])/2)/n1; + + nameObj="CL" + ExtComplekt+"_"; +/* + if (ExtSave) + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } +*/ + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_CHANNEL,0,pitch_time[1],pitch_cena[1],Time[0],TLine,pitch_time[2],pitch_cena[2]); + ObjectSet(nameObj, OBJPROP_BACK, true); + ObjectSet(nameObj, OBJPROP_COLOR, ExtPitchforkStaticColor); + } +//------------------------------------------------------- + + if (ExtISLStatic) + { + _ISL("ISL_S", pitch_time, pitch_cena, ExtLinePitchforkS); + } + +//------------------------------------------------------- + + if (ExtRLStatic) + { + _RL("RLineS", pitch_time, pitch_cena, ExtLinePitchforkS); + } +//------------------------------------------------------- + + if (ExtRedZoneStatic) + { + _RZ("RZS", ExtRZStaticValue, ExtRZStaticColor, pitch_time, pitch_cena); + } +//-------------------------------------------------------- + // Временные зоны Фибо в составе статических вил Эндрюса + fiboTimeX (); + } +//-------------------------------------------------------- +// Вывод вил Эндрюса статических. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод UWL_LWL. Начало. +//-------------------------------------------------------- +void UWL_LWL (bool visible, string WL, string fiboFree) + { + int i,j,k; + string str; + double fi; + + if (ExtFiboType==2) + { + j=quantityFibo (fiboFree); + str=fiboFree; + } + else + { + j=12; + str="0.146,0.236,0.382,0.5,0.618,0.764,0.854,1,1.618,2.0,2.618,4.0"; + } + + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,j+1); + for (i=0;i<=j;i++) + { + k=StringFind(str, ",", 0); + fi=StrToDouble(StringTrimLeft(StringTrimRight(StringSubstr(str,0,k)))); + + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+i,fi); + if (visible) ObjectSetFiboDescription(nameObj, i, WL+DoubleToStr(fi*100,1)); + + if (k>=0) str=StringSubstr(str,k+1); + } + } +//-------------------------------------------------------- +// Вывод UWL_LWL. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// фибо-Time. Начало. +//-------------------------------------------------------- +void fiboTimeX () + { + bool ft1, ft2, ft3; + color ftc1, ftc2, ftc3; + + ft1=ExtFiboTime1; + ft2=ExtFiboTime2; + ft3=ExtFiboTime3; + ftc1=ExtFiboTime1C; + ftc2=ExtFiboTime2C; + ftc3=ExtFiboTime3C; + + if (ExtFiboTimeNum>2) + { + ft1=ExtFiboTime1x; + ft2=ExtFiboTime2x; + ft3=ExtFiboTime3x; + ftc1=ExtFiboTime1Cx; + ftc2=ExtFiboTime2Cx; + ftc3=ExtFiboTime3Cx; + + int mft[]={0,0,0}; + string aa=DoubleToStr(ExtFiboTimeNum,0); + double ftmincena; + + mft[0]=StrToInteger(StringSubstr(aa,0,1)); + mft[1]=StrToInteger(StringSubstr(aa,1,1)); + mft[2]=StrToInteger(StringSubstr(aa,2,1)); + ArraySort(mft,WHOLE_ARRAY,0,MODE_DESCEND); + + if (mft[0]<3) ExtFiboTimeNum=0; + else + { + if (mft[1]==1) mft[1]++; + if (mft[1]==0) {mft[1]=mft[0]-1; mft[2]=mft[1]-1;} + if (mft[2]==0) mft[2]=mft[1]-1; + } + + if (afrx[mft[0]]afrx[mft[2]]) ftmincena=afrx[mft[2]]; + + } + + if (ft1) + { + if (ExtFiboTimeNum>2) + { + nameObj="fiboTime1Free" + ExtComplekt+"_"; + } + else + { + nameObj="fiboTime1" + ExtComplekt+"_"; + } + + if (ExtSave) + { + if (ExtFiboTimeNum>2) + { + nameObj=nameObj + save; + } + else + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + } + + ObjectDelete(nameObj); + + if (ExtFiboTimeNum>2) + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,afr[mft[0]],ftmincena-5*Point,afr[mft[2]],ftmincena-5*Point); + } + else + { + if (ExtPitchforkCandle) + { + if (!ExtPitchfork_1_HighLow) + { + if (mPitchCena[0]>mPitchCena[2]) + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[2]-5*Point,mPitchTime[2],mPitchCena[2]-5*Point); + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[0]-5*Point,mPitchTime[2],mPitchCena[0]-5*Point); + } + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[1]-5*Point,mPitchTime[2],mPitchCena[1]-5*Point); + } + } + else + { + if (afrl[mPitch[0]]>0) + { + if (afrl[mPitch[0]]>afrl[mPitch[2]]) + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[2]-5*Point,mPitchTime[2],mPitchCena[2]-5*Point); + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[0]-5*Point,mPitchTime[2],mPitchCena[0]-5*Point); + } + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[0],mPitchCena[1]-5*Point,mPitchTime[2],afrl[mPitch[1]]-5*Point); + } + } + } + + + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ftc1); + + if (ExtFiboTimeNum>2) + { + fiboTime (nameObj, afr[mft[0]], afr[mft[2]]-afr[mft[0]], 0, "FT1_"); + } + else + { + fiboTime (nameObj, mPitchTime[0], mPitchTime[2]-mPitchTime[0], 0, "FT1 "); + } + } + + if (ft2) + { + if (ExtFiboTimeNum>2) + { + nameObj="fiboTime2Free" + ExtComplekt+"_"; + } + else + { + nameObj="fiboTime2" + ExtComplekt+"_"; + } + + if (ExtSave) + { + if (ExtFiboTimeNum>2) + { + nameObj=nameObj + save; + } + else + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + } + + ObjectDelete(nameObj); + + if (ExtFiboTimeNum>2) + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,afr[mft[1]],(afrx[mft[2]]+afrx[mft[1]])/2,afr[mft[2]],(afrx[mft[2]]+afrx[mft[1]])/2); + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[1],(mPitchCena[2]+mPitchCena[1])/2,mPitchTime[2],(mPitchCena[2]+mPitchCena[1])/2); + } + + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ftc2); + + if (ExtFiboTimeNum>2) + { + fiboTime (nameObj, afr[mft[1]], afr[mft[2]]-afr[mft[1]], 1, "FT2_"); + } + else + { + fiboTime (nameObj, mPitchTime[1], mPitchTime[2]-mPitchTime[1], 1, "FT2 "); + } + } + + if (ft3) + { + datetime shiftTime; + + if (ExtFiboTimeNum>2) + { + shiftTime=afr[mft[1]]-afr[mft[0]]; + nameObj="fiboTime3Free" + ExtComplekt+"_"; + } + else + { + shiftTime=mPitchTime[1]-mPitchTime[0]; + nameObj="fiboTime3" + ExtComplekt+"_"; + } + + if (ExtSave) + { + if (ExtFiboTimeNum>2) + { + nameObj=nameObj + save; + } + else + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + } + + ObjectDelete(nameObj); + + if (ExtFiboTimeNum>2) + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,afr[mft[2]]-shiftTime,(afrx[mft[2]]+afrx[mft[1]])/2-8*Point,afr[mft[2]],(afrx[mft[2]]+afrx[mft[1]])/2-8*Point); + } + else + { + ObjectCreate(nameObj,OBJ_FIBOTIMES,0,mPitchTime[2]-shiftTime,(mPitchCena[2]+mPitchCena[1])/2-8*Point,mPitchTime[2],(mPitchCena[2]+mPitchCena[1])/2-8*Point); + } + + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ftc3); + + if (ExtFiboTimeNum>2) + { + fiboTime (nameObj, afr[mft[2]]-shiftTime, shiftTime, 2, "FT3_"); + } + else + { + fiboTime (nameObj, mPitchTime[2]-shiftTime, shiftTime, 2, "FT3 "); + } + } + + } +//-------------------------------------------------------- +// фибо-Time. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// фибо-Time. Начало. +//-------------------------------------------------------- +void fiboTime (string nameObj, datetime t1, datetime t2, int number, string ftx) + { + string str, str1; + double fi; + int j,k; + + int ftvisibleDT; + string ftvisible; + + if (ExtFiboTimeNum>2) + { + ftvisibleDT=ExtVisibleDateTimex; + ftvisible=ExtVisibleNumberFiboTimex; + } + else + { + ftvisibleDT=ExtVisibleDateTime; + ftvisible=ExtVisibleNumberFiboTime; + } + + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + if (ExtFiboType==1) // Фибы фибо-Time с числами Песавенто. + { + str="0.382,0.5,0.618,0.707,0.786,0.886,1.0,1.272,1.414,1.618,2.0,2.414,2.618,3.0"; + } + else if (ExtFiboType==0) // Фибы фибо-Time со стандартными числами. + { + str="0.146,0.236,0.382,0.5,0.618,0.764,0.854,1.0,1.236,1.382,1.618,2.0,2.618,3.0,4.0"; + } + else if (ExtFiboType==2) // Фибы фибо-Time с пользовательскими числами. + { + + if (number==0) + { + str=ExtFiboFreeFT1; + } + else if (number==1) + { + str=ExtFiboFreeFT2; + } + else if (number==2) + { + str=ExtFiboFreeFT3; + } + + } + + j=quantityFibo (str); + ObjectSet(nameObj,OBJPROP_FIBOLEVELS, j+3); + + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+0,0.0); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+1,1.0); + if (ftvisibleDT && StringSubstr(ftvisible,number,1)=="1") + { + ObjectSetFiboDescription(nameObj, 0, ftx + "0" + " " + TimeToStr(t1,TIME_DATE|TIME_MINUTES)); + ObjectSetFiboDescription(nameObj, 1, ftx + "1.0" + " " + TimeToStr(t1 + t2,TIME_DATE|TIME_MINUTES)); + } + else + { + ObjectSetFiboDescription(nameObj, 0, ftx + "0"); + ObjectSetFiboDescription(nameObj, 1, ftx + "1.0"); + } + + for (int i=0; i<=j; i++) + { + k=StringFind(str, ",", 0); + str1=StringTrimLeft(StringTrimRight(StringSubstr(str,0,k))); + fi=StrToDouble(str1); + if (fi<1) str1=StringSubstr(str1,1); + + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+(i+2),fi+1); + if (ftvisibleDT && StringSubstr(ftvisible,number,1)=="1") + { + ObjectSetFiboDescription(nameObj, i+2, ftx + str1 + " " + TimeToStr(t1 + t2*(fi+1),TIME_DATE|TIME_MINUTES)); + } + else + { + ObjectSetFiboDescription(nameObj, i+2, ftx + str1); + } + if (k>=0) str=StringSubstr(str,k+1); + } + + } +//-------------------------------------------------------- +// фибо-Time. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Счетчик фиб. Начало. +//-------------------------------------------------------- +int quantityFibo (string sFibo) + { + int j=0,i,k; + + while (true) + { + k=StringFind(sFibo, ",",i+1); + if (k>0) {j++; i=k;} + else return (j); + } + } +//-------------------------------------------------------- +// Счетчик фиб. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод вил Эндрюса динамических. Начало. +//-------------------------------------------------------- +void screenPitchforkD() + { + int i; + double b1,ab1,bc1,ab2,bc2,d,cena,m618=0.618,m382=0.382; + datetime tb1,tab2,tbc2; + int pitch_time[]={0,0,0}; + double pitch_cena[]={0,0,0}; + + mPitchTime[0]=afr[2]; mPitchTime[1]=afr[1]; mPitchTime[2]=afr[0]; + mPitchCena[0]=afrx[2]; mPitchCena[1]=afrx[1]; mPitchCena[2]=afrx[0]; + + cena=afrx[2]; + + if (afrl[2]>0) + { + if (ExtCM_0_1A_2B_Dinamic==1) + { + cena=mPitchCena[0]+(mPitchCena[1]-mPitchCena[0])*ExtCM_FiboDinamic; + } + else if (ExtCM_0_1A_2B_Dinamic==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Dinamic==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m618; + } + else + { + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*m382; + } + } + else if (ExtCM_0_1A_2B_Dinamic>1) + { + if (ExtCM_0_1A_2B_Dinamic==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]-(mPitchCena[1]-mPitchCena[2])*ExtCM_FiboDinamic; + } + } + else + { + if (ExtCM_0_1A_2B_Dinamic==1) + { + cena=mPitchCena[0]-(mPitchCena[0]-mPitchCena[1])*ExtCM_FiboDinamic; + } + else if (ExtCM_0_1A_2B_Dinamic==4) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza4(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Dinamic==5) + { + mPitchTimeSave=mPitchTime[0]; + mPitchTime[0]=mPitchTime[1]; + if (maxGipotenuza5(mPitchTime,mPitchCena)) + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m618; + } + else + { + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*m382; + } + } + else if (ExtCM_0_1A_2B_Dinamic>1) + { + if (ExtCM_0_1A_2B_Dinamic==2) mPitchTime[0]=mPitchTime[1]; + cena=mPitchCena[1]+(mPitchCena[2]-mPitchCena[1])*ExtCM_FiboDinamic; + } + } + + mPitchCena[0]=cena; + + coordinaty_1_2_mediany_AP(mPitchCena[0], mPitchCena[1], mPitchCena[2], mPitchTime[0], mPitchTime[1], mPitchTime[2], tab2, tbc2, ab1, bc1); + + pitch_time[0]=tab2;pitch_cena[0]=ab1; + + nameObj="pmedianaD" + ExtComplekt+"_"; + ObjectDelete(nameObj); + + if (ExtPitchforkDinamic==2) + { + ObjectCreate(nameObj,OBJ_TREND,0,tab2,ab1,tbc2,bc1); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DASH); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkD); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + nameObj="1-2pmedianaD" + ExtComplekt+"_"; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TEXT,0,tab2,ab1+3*Point); + ObjectSetText(nameObj," 1/2 ML",9,"Arial", ExtLinePitchforkD); + } + + nameObj="pitchforkD" + ExtComplekt+"_"; + ObjectDelete(nameObj); + + if (ExtPitchforkDinamic!=4) + { + pitch_time[0]=mPitchTime[0];pitch_cena[0]=mPitchCena[0]; + if (ExtPitchforkDinamic==3) pitch_cena[0]=ab1; + } + pitch_time[1]=mPitchTime[1];pitch_cena[1]=mPitchCena[1]; + pitch_time[2]=mPitchTime[2];pitch_cena[2]=mPitchCena[2]; + + ObjectCreate(nameObj,OBJ_PITCHFORK,0,pitch_time[0],pitch_cena[0],pitch_time[1],pitch_cena[1],pitch_time[2],pitch_cena[2]); + ObjectSet(nameObj,OBJPROP_STYLE,ExtPitchforkStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtPitchforkWidth); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLinePitchforkD); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtPivotZoneDinamicColor>0 && ExtPitchforkDinamic<4) PivotZone(pitch_time, pitch_cena, ExtPivotZoneDinamicColor, "PivotZoneD"); + + if (ExtFiboFanMedianaDinamicColor>0) + { + coordinaty_mediany_AP(pitch_cena[0], pitch_cena[1], pitch_cena[2], pitch_time[0], pitch_time[1], pitch_time[2], tb1, b1); + + nameObj="FanMedianaDinamic" + ExtComplekt+"_"; + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOFAN,0,pitch_time[0],pitch_cena[0],tb1,b1); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DASH); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboFanMedianaDinamicColor); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtFiboType==0) + { + screenFibo_st(); + } + else if (ExtFiboType==1) + { + screenFibo_Pesavento(); + } + else if (ExtFiboType==2) + { + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi); + for (i=0;i0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOCHANNEL,0,ta1,a1,tb1,b1,tc1,c1); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,lineColor); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,ExtISLStyle); + ObjectSet(nameObj,OBJPROP_LEVELWIDTH,ExtISLWidth); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE); + + if (ExtFiboType==0) + { + str="0.854,0.764,0.618,0.382,0.236,0.146"; + } + else if (ExtFiboType==1) + { + str="0.886,0.786,0.618,0.382,0.236,0.146"; + } + else if (ExtFiboType==2) + { + str=ExtFiboFreeISL; + } + + j=quantityFibo (str); + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,j+1); + for (i=0;i<=j;i++) + { + k=StringFind(str, ",", 0); + fi=StrToDouble(StringTrimLeft(StringTrimRight(StringSubstr(str,0,k)))); + + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+i,-fi); + if (ExtVisibleISL) ObjectSetFiboDescription(nameObj, i," I S L "+DoubleToStr(fi*100,1)); + + if (k>=0) str=StringSubstr(str,k+1); + } + } +//-------------------------------------------------------- +// Вывод ISL. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод RLine. Начало. +//-------------------------------------------------------- +void _RL(string nameRL, datetime pitch_time[], double pitch_cena[], color lineColor) + { + string str; + double fi; + int i,j,k,n,nbase1,nbase2,mirror1,mirror2; + double a1,b1,c1; + datetime ta1,tb1,tc1; + + n=iBarShift(Symbol(),Period(),pitch_time[0])-(iBarShift(Symbol(),Period(),pitch_time[1])+iBarShift(Symbol(),Period(),pitch_time[2]))/2.0; + + nbase1=iBarShift(Symbol(),Period(),mPitchTime[1]); + nbase2=iBarShift(Symbol(),Period(),mPitchTime[2]); + + if (nbase1+n<=Bars) + { + mirror1=1; + mirror2=0; + + ta1=Time[nbase1+n]; + tb1=Time[nbase2+n]; + tc1=mPitchTime[1]; + + a1=(pitch_cena[0]-(mPitchCena[1]+mPitchCena[2])/2)+mPitchCena[1]; + b1=(pitch_cena[0]-(mPitchCena[1]+mPitchCena[2])/2)+mPitchCena[2]; + c1=mPitchCena[1]; + } + else + { + mirror1=-1; + mirror2=-1; + + ta1=mPitchTime[2]; + tb1=mPitchTime[1]; + tc1=Time[nbase2+n]; + + a1=mPitchCena[2]; + b1=mPitchCena[1]; + c1=(pitch_cena[0]-(mPitchCena[1]+mPitchCena[2])/2)+mPitchCena[2]; + } + + nameObj=nameRL + ExtComplekt+"_"; + if (ExtSave && nameRL=="RLineS") + { + if (ExtPitchforkCandle && iBarShift(Symbol(),Period(),ExtDateTimePitchfork_3)>0) + { + nameObj=nameObj + save; + } + else + { + if (mPitch[2]>0) + { + nameObj=nameObj + save; + } + } + } + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOCHANNEL,0,ta1,a1,tb1,b1,tc1,c1); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,lineColor); + + if (ExtRLineBase) + { + ObjectSet(nameObj,OBJPROP_COLOR,CLR_NONE); + } + else + { + ObjectSet(nameObj,OBJPROP_COLOR,lineColor); + } + + if (ExtFiboType==1) + { + if (ExtRL146) j=16; else j=14; + str="0.382,0.5,0.618,0.707,0.786,0.886,1,1.128,1.272,1.414,1.618,2.0,2.414,2.618,4.0,0.146,0.236"; + } + else if (ExtFiboType==0) + { + if (ExtRL146) j=12; else j=11; + str="0.236,0.382,0.5,0.618,0.764,0.854,1,1.236,1.618,2.0,2.618,4.0,0.146"; + } + else if (ExtFiboType==2) + { + j=quantityFibo (ExtFiboFreeRL); + str=ExtFiboFreeRL; + } + + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,j+1); + for (i=0;i<=j;i++) + { + k=StringFind(str, ",", 0); + fi=StrToDouble(StringTrimLeft(StringTrimRight(StringSubstr(str,0,k)))); + + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+i,mirror2+mirror1*fi); + if (ExtVisibleRL) ObjectSetFiboDescription(nameObj, i, " RL "+DoubleToStr(fi*100,1)); + + if (k>=0) str=StringSubstr(str,k+1); + } + } +//-------------------------------------------------------- +// Вывод RLine. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод RedZone. Начало. +//-------------------------------------------------------- +void _RZ(string nameRZ, double RZValue, color RZColor, datetime pitch_time[], double pitch_cena[]) + { + int i,j,k,n,_nbase1,_nbase2; + double b1,hRZ,delta,h=0,hbase,tangens23,tangensMediana,n1,nbase0,nbase1,nbase2; + datetime tb1; + + nbase0=iBarShift(Symbol(),Period(),pitch_time[0]); + nbase1=iBarShift(Symbol(),Period(),pitch_time[1]); + nbase2=iBarShift(Symbol(),Period(),pitch_time[2]); + _nbase1=iBarShift(Symbol(),Period(),pitch_time[1]); + _nbase2=iBarShift(Symbol(),Period(),pitch_time[2]); + + tangens23=(pitch_cena[2]-pitch_cena[1])/(nbase1-nbase2); + n1=nbase0-(nbase1+nbase2)/2; + tangensMediana=((pitch_cena[2]+pitch_cena[1])/2-pitch_cena[0])/n1; + + hbase=pitch_cena[0]-(pitch_cena[1]-(nbase0-nbase1)*tangens23); + hRZ=hbase*RZValue; + + if (pitch_cena[1]>pitch_cena[2]) + { + for (i=_nbase1-1;i>=_nbase2;i--) + { + delta=(pitch_cena[1]+(_nbase1-i)*tangens23)-High[i]; + if (delta=_nbase2;i--) + { + delta=(pitch_cena[1]+(_nbase1-i)*tangens23)-Low[i]; + if (delta>h) h=delta; + } + } + + if (infoTF) + { + if (nameRZ=="RZS") + { + info_RZS_RL=DoubleToStr(MathAbs(100*h/hbase),1); + } + else if (nameRZ=="RZD") + { + info_RZD_RL=DoubleToStr(MathAbs(100*h/hbase),1); + } + } + + if (MathAbs(hRZ)=0) tb1=Time[n]; + else tb1=Time[0]+MathAbs(n)*60*Period(); + + b1=pitch_cena[2]+i*tangens23-hRZ; + + nameObj=nameRZ + ExtComplekt+"_"; + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_CHANNEL,0,pitch_time[2],pitch_cena[2],tb1,b1,pitch_time[1],pitch_cena[1]); + ObjectSet(nameObj, OBJPROP_COLOR, RZColor); + ObjectSet(nameObj, OBJPROP_BACK, true); + ObjectSet(nameObj, OBJPROP_RAY, false); + + } +//-------------------------------------------------------- +// Вывод RedZone. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Подпрограмма расчета координат 1/2 медианы вил Эндрюса. Начало. +//-------------------------------------------------------- +// Передаваемые параметры цена и время трех точек вил Эндрюса +// а также ссылка на переменные - +// tAB2, tBC2 - время баров, через которые проводится 1/2 медиана +// AB2, BC2 - ценовое значение точек, через которые проводится 1/2 медиана +// +void coordinaty_1_2_mediany_AP(double A_1, double B_2, double C_3, datetime T_1, datetime T_2, datetime T_3, datetime& tAB2, datetime& tBC2, double& AB2, double& BC2) + { + double tangens; + int n1, n2, n3, nab2, nbc2; + + // номера баров, от которых строятся вилы Эндрюса + n1=iBarShift(Symbol(),Period(),T_1); + n2=iBarShift(Symbol(),Period(),T_2); + n3=iBarShift(Symbol(),Period(),T_3); + + // тангенс угла наклона 1/2 медианы вил Эндрюса + tangens=(C_3 - A_1)/(n1 - n3); + // номера баров, через которые будет построена 1/2 медиана + nab2=MathCeil((n1+n2)/2.0); + nbc2=MathCeil((n2+n3)/2.0); + + // значения цены точек, через которые будет построена 1/2 медиана + AB2=(A_1 + B_2)/2 - (nab2-(n1+n2)/2.0)*tangens; + BC2=(B_2 + C_3)/2 - (nbc2-(n2+n3)/2.0)*tangens; + // время баров, через которые будет построена 1/2 медиана + tAB2=Time[nab2]; + tBC2=Time[nbc2]; + } +//-------------------------------------------------------- +// Подпрограмма расчета координат 1/2 медианы вил Эндрюса. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Подпрограмма расчета координаты точки на медиане вил Эндрюса. Начало. +//-------------------------------------------------------- +// Передаваемые параметры цена и время трех точек вил Эндрюса +// а также ссылка на переменные - +// tAB2, tBC2 - время баров, через которые проводится 1/2 медиана +// AB2, BC2 - ценовое значение точек, через которые проводится 1/2 медиана +// +void coordinaty_mediany_AP(double A_1, double B_2, double C_3, datetime T_1, datetime T_2, datetime T_3, datetime& tB1, double& B1) + { + double tangens; + int n1, n2, n3, nbc2; + + // номера баров, от которых строятся вилы Эндрюса + n1=iBarShift(Symbol(),Period(),T_1); + n2=iBarShift(Symbol(),Period(),T_2); + n3=iBarShift(Symbol(),Period(),T_3); + + // тангенс угла наклона медианы вил Эндрюса + tangens=(A_1-(C_3+B_2)/2)/(n1 - (n3+n2)/2.0); + // номер бара, через который проходит медиана + nbc2=MathCeil((n2+n3)/2.0); + + // значения цены точки, через который проходит медиана + B1=(B_2 + C_3)/2 - ((n2+n3)/2.0-nbc2)*tangens; + + // время бара, через который проходит медиана + tB1=Time[nbc2]; + } +//-------------------------------------------------------- +// Подпрограмма расчета координаты точки на медиане вил Эндрюса. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Сравнение гипотенуз для ExtCM_0_1A_2B=4. Начало. +//------------------------------------------------------- +bool maxGipotenuza4(datetime pitch_time1[], double pitch_cena1[]) + { + double k2,k3; + datetime k4,k5; + + k2=MathAbs(pitch_cena1[0]-pitch_cena1[1])/ASBar; + k3=MathAbs(pitch_cena1[1]-pitch_cena1[2])/ASBar; + k4=iBarShift(NULL,GrossPeriod,mPitchTimeSave)-iBarShift(NULL,GrossPeriod,pitch_time1[1]); + k5=iBarShift(NULL,GrossPeriod,pitch_time1[1])-iBarShift(NULL,GrossPeriod,pitch_time1[2]); + + if (k2*k2+k4*k4>k3*k3+k5*k5) return(true); else return(false); + } +//-------------------------------------------------------- +// Сравнение гипотенуз для ExtCM_0_1A_2B=4. Конец. +//------------------------------------------------------- + + +//-------------------------------------------------------- +// Сравнение гипотенуз для ExtCM_0_1A_2B=5. Начало. +//------------------------------------------------------- +bool maxGipotenuza5(datetime pitch_time1[], double pitch_cena1[]) + { + double k2,k3; + datetime k4,k5; + + k2=MathAbs(pitch_cena1[0]-pitch_cena1[1])/Point; + k3=MathAbs(pitch_cena1[1]-pitch_cena1[2])/Point; + k4=iBarShift(NULL,GrossPeriod,mPitchTimeSave)-iBarShift(NULL,GrossPeriod,pitch_time1[1]); + k5=iBarShift(NULL,GrossPeriod,pitch_time1[1])-iBarShift(NULL,GrossPeriod,pitch_time1[2]); + + if (k2*k2+k4*k4>k3*k3+k5*k5) return(true); else return(false); + } +//-------------------------------------------------------- +// Сравнение гипотенуз для ExtCM_0_1A_2B=5. Конец. +//------------------------------------------------------- + + +//-------------------------------------------------------- +// Pivot Zone. Начало. +//------------------------------------------------------- +void PivotZone(datetime pitch_time1[], double pitch_cena1[], color PivotZoneColor, string name) + { + datetime ta1, tb1; + double a1, b1, d, n1; + int m, m1, m2; + + ta1=pitch_time1[2]; + a1=pitch_cena1[2]; + m1=iBarShift(Symbol(),Period(),pitch_time1[0])-iBarShift(Symbol(),Period(),pitch_time1[1]); + m2=iBarShift(Symbol(),Period(),pitch_time1[1])-iBarShift(Symbol(),Period(),pitch_time1[2]); + m=iBarShift(Symbol(),Period(),pitch_time1[2]); + n1=iBarShift(Symbol(),Period(),pitch_time1[0])-(iBarShift(Symbol(),Period(),pitch_time1[1])+iBarShift(Symbol(),Period(),pitch_time1[2]))/2.0; + d=(pitch_cena1[0]-(pitch_cena1[1]+pitch_cena1[2])/2.0)/n1; + + if (m1>m2) + { + if (m1>m) + { + tb1=Time[0]+(m1-m)*Period()*60; + } + else + { + tb1=Time[iBarShift(Symbol(),Period(),pitch_time1[2])-m1]; + } + b1=pitch_cena1[0]-d*(2*m1+m2); + } + else + { + if (m2>m) + { + tb1=Time[0]+(m2-m)*Period()*60; + } + else + { + tb1=Time[iBarShift(Symbol(),Period(),pitch_time1[2])-m2]; + } + b1=pitch_cena1[0]-d*(2*m2+m1); + } + + nameObj=name + ExtComplekt+"_"; + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_RECTANGLE,0,ta1,a1,tb1,b1); + ObjectSetText(nameObj,"PZ "+Period_tf+" "+TimeToStr(tb1,TIME_DATE|TIME_MINUTES)); + ObjectSet(nameObj, OBJPROP_BACK, ExtPivotZoneFramework); + ObjectSet(nameObj, OBJPROP_COLOR, PivotZoneColor); + } +//-------------------------------------------------------- +// Pivot Zone. Конец. +//------------------------------------------------------- + +//-------------------------------------------------------- +// Определение точки пересечения RL400 медианы. Начало. +//------------------------------------------------------- +// flag=true - рассчитывается ISL +// flag=false - рассчитывается UWL/LWL +void ML_RL400(double Tangens, double pitch_cena1[], datetime pitch_time1[], int& tB1, double& B1, bool flag) + { + int m, m1, m2; + + m1=iBarShift(Symbol(),Period(),pitch_time1[0]); + m2=MathCeil((iBarShift(Symbol(),Period(),pitch_time1[1])+iBarShift(Symbol(),Period(),pitch_time1[2]))/2.0); + m=(m1-m2)*4; + + if (m>m2) + { + tB1=Time[0]+(m-m2)*Period()*60; + if (tB1<0) tB1=2133648000; + if (flag) B1=pitch_cena1[1]-Tangens*(iBarShift(Symbol(),Period(),pitch_time1[1])+(tB1-Time[0])/(60*Period())); + else B1=pitch_cena1[0]-Tangens*(iBarShift(Symbol(),Period(),pitch_time1[0])+(tB1-Time[0])/(60*Period())); + } + else + { + tB1=Time[m2-m]; + if (flag) B1=pitch_cena1[1]-Tangens*(iBarShift(Symbol(),Period(),pitch_time1[1])-iBarShift(Symbol(),Period(),tB1)); + else B1=pitch_cena1[0]-Tangens*(iBarShift(Symbol(),Period(),pitch_time1[0])-iBarShift(Symbol(),Period(),tB1)); + } + } +//-------------------------------------------------------- +// Определение точки пересечения RL400 медианы. Конец. +//------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод произвольных фибовееров. Начало. +//-------------------------------------------------------- +void screenFiboFan() + { + int i; + double a1,b1; + + a1=afrx[mFan[0]]; b1=afrx[mFan[1]]; + + nameObj="FiboFan" + ExtComplekt+"_"; + + if (mFan[1]>0) + { + if (ExtSave) + { + nameObj=nameObj + save; + } + } + + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOFAN,0,afr[mFan[0]],a1,afr[mFan[1]],b1); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,ExtFanStyle); + ObjectSet(nameObj,OBJPROP_LEVELWIDTH,ExtFanWidth); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboFanColor); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + + if (ExtFiboType==0) + { + screenFibo_st(); + } + else if (ExtFiboType==1) + { + screenFibo_Pesavento(); + } + else if (ExtFiboType==2) + { + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi); + for (i=0;i0) + { + if (ExtSave) + { + nameObj=nameObj + save; + } + } + + screenFibo_(ExtFiboS, " ", mFibo[0], mFibo[1]); + } +//-------------------------------------------------------- +// Вывод фиб статических. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод фиб динамических. Начало. +//-------------------------------------------------------- +void screenFiboD() + { + nameObj="fiboD" + ExtComplekt+"_"; + screenFibo_(ExtFiboD, "", 1, 0); + } +//-------------------------------------------------------- +// Вывод фиб динамических. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Создание фиб. Начало. +//-------------------------------------------------------- +void screenFibo_(color colorFibo, string otstup, int a1, int a2) + { + double fibo_0, fibo_100, fiboPrice, fiboPrice1; + + ObjectDelete(nameObj); + + if (!ExtFiboCorrectionExpansion) + { + fibo_0=afrx[a1];fibo_100=afrx[a2]; + fiboPrice=afrx[a1]-afrx[a2];fiboPrice1=afrx[a2]; + } + else + { + fibo_100=afrx[a1];fibo_0=afrx[a2]; + fiboPrice=afrx[a2]-afrx[a1];fiboPrice1=afrx[a1]; + } + + if (!ExtFiboCorrectionExpansion) + { + ObjectCreate(nameObj,OBJ_FIBO,0,afr[a1],fibo_0,afr[a2],fibo_100); + } + else + { + ObjectCreate(nameObj,OBJ_FIBO,0,afr[a2],fibo_0,afr[a1],fibo_100); + } + + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,colorFibo); + + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,ExtFiboStyle); + ObjectSet(nameObj,OBJPROP_LEVELWIDTH,ExtFiboWidth); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtFiboType==0) + { + fibo_standart (fiboPrice, fiboPrice1,"-"+Period_tf+otstup); + } + else if (ExtFiboType==1) + { + fibo_patterns(fiboPrice, fiboPrice1,"-"+Period_tf+otstup); + } + else if (ExtFiboType==2) + { + fibo_custom (fiboPrice, fiboPrice1,"-"+Period_tf+otstup); + } + } +//-------------------------------------------------------- +// Создание фиб. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Фибы стандартные. Начало. +//-------------------------------------------------------- +void fibo_standart(double fiboPrice,double fiboPrice1,string fibo) + { + double fi_1[]={0, 0.146, 0.236, 0.382, 0.5, 0.618, 0.764, 0.854, 1.0, 1.236, phi, 2.618, 4.236, 6.854}; + string fitxt100_1[]={"0.0", "14.6", "23.6", "38.2", "50.0", "61.8", "76.4", "85.4", "100.0", "123.6", "161.8", "2.618", "423.6", "685.4"}; + int i; + Sizefi_1=14; + + if (!ExtFiboCorrectionExpansion) + { + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi_1); + for (i=0;i0) + { + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+i+2,1+fi[i]); + ObjectSetFiboDescription(nameObj, i+2, "Fe "+fitxt100[i]+" "+DoubleToStr(fiboPrice*(1+fi[i])+fiboPrice1, Digits)+fibo); + } + } + } + } +//-------------------------------------------------------- +// Фибы пользовательские. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод фибо-дуг статических. Начало. +//-------------------------------------------------------- +void screenFiboArcS() + { + double fibo_0, fibo_100, AutoScale; + + fibo_0=afrx[mArcS[0]];fibo_100=afrx[mArcS[1]]; + + if (ExtArcStaticScale>0) + { + AutoScale=ExtArcStaticScale; + } + else + { + AutoScale=(MathAbs(fibo_0-fibo_100)/Point)/MathAbs(iBarShift(Symbol(),Period(),afr[mArcS[1]])-iBarShift(Symbol(),Period(),afr[mArcS[0]])); + } + + nameObj="FiboArcS" + ExtComplekt+"_"; + if (ExtSave) + { + nameObj=nameObj + save; + } + ObjectDelete(nameObj); + + ObjectCreate(nameObj,OBJ_FIBOARC,0,afr[mArcS[0]],fibo_0,afr[mArcS[1]],fibo_100); + + fiboArc(AutoScale, ExtArcStaticColor); + } +//-------------------------------------------------------- +// Вывод фибо-дуг статических. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Вывод фибо-дуг динамических. Начало. +//-------------------------------------------------------- +void screenFiboArcD() + { + double fibo_0, fibo_100, AutoScale; + + fibo_0=afrx[mArcD[0]];fibo_100=afrx[mArcD[1]]; + + if (ExtArcDinamicScale>0) + { + AutoScale=ExtArcDinamicScale; + } + else + { + AutoScale=(MathAbs(fibo_0-fibo_100)/Point)/MathAbs(iBarShift(Symbol(),Period(),afr[mArcD[1]])-iBarShift(Symbol(),Period(),afr[mArcD[0]])); + } + + nameObj="FiboArcD" + ExtComplekt+"_"; + + ObjectDelete(nameObj); + + ObjectCreate(nameObj, OBJ_FIBOARC,0,afr[mArcD[0]],fibo_0,afr[mArcD[1]],fibo_100); + + fiboArc(AutoScale, ExtArcDinamicColor); + } +//-------------------------------------------------------- +// Вывод фибо-дуг динамических. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Фибы для фибо-дуг. Начало. +//-------------------------------------------------------- +void fiboArc(double AutoScale, color ArcColor) + { + ObjectSet(nameObj,OBJPROP_SCALE,AutoScale); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + ObjectSet(nameObj,OBJPROP_ELLIPSE,true); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ArcColor); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,ExtArcStyle); + ObjectSet(nameObj,OBJPROP_LEVELWIDTH,ExtArcWidth); + + + if (ExtFiboType==0) + { + fiboArc_st(); + } + else if (ExtFiboType==1) + { + fiboArc_Pesavento(); + } + else if (ExtFiboType==2) + { + fiboArc_custom(); + } + } +//-------------------------------------------------------- +// Фибы для фибо-дуг. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Фибы для стандартных фибо-дуг. Начало. +//-------------------------------------------------------- +void fiboArc_st() + { + double fi_1[]={0.0, 0.146, 0.236, 0.382, 0.5, 0.618, 0.764, 0.854, 1.0, 1.236, phi, 2.0, 2.618, 3.0, 4.236, 4.618}; + string fitxt100_1[]={"0.0", "14.6", "23.6", "38.2", "50.0", "61.8", "76.4", "85.4", "100.0", "123.6", "161.8", "200.0", "261.8", "300.0", "423.6", "461.8"}; + int i; + Sizefi_1=16; + + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi_1); + for (i=0;i= 0 && y2 >= 0) || (x2 <= 0 && y2 <= 0)) + color lineColor = spiralColor1; + else + lineColor = spiralColor2; + ObjectDelete(label); + ObjectCreate(label, OBJ_TREND, 0, GetTime(timeShift1), price1, GetTime(timeShift2), price2, 0, 0); + ObjectSet(label, OBJPROP_RAY, 0); + ObjectSet(label, OBJPROP_COLOR, lineColor); + ObjectSet(label, OBJPROP_STYLE, ExtSpiralStyle); + ObjectSet(label, OBJPROP_WIDTH, ExtSpiralWidth); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +datetime GetTime(int timeShift) + { + if(timeShift >= 0) + return(Time[timeShift]); + datetime time = Time[0] - Period()*timeShift*60; + return(time); + } +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +double Scale() +{ + double priceRange = WindowPriceMax(0) - WindowPriceMin(0); + double barsCount = WindowBarsPerChart(); + double chartScale = (priceRange / Point) / barsCount; + return(chartScale*GPixels/VPixels); +} +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +//-------------------------------------------------------- +// Функции для рисования золотой спирали. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод фибо-вееров статических. Начало. +//-------------------------------------------------------- +void screenFiboFanS() + { + double fiboPrice1, fiboPrice2; + + nameObj="fiboFanS" + ExtComplekt+"_"; + ObjectDelete(nameObj); + + if (ExtPitchforkCandle) + { + if (ExtPitchfork_1_HighLow) + { + fiboPrice1=mPitchCena[1];fiboPrice2=mPitchCena[2]; + } + else + { + fiboPrice1=mPitchCena[1];fiboPrice2=mPitchCena[2]; + } + ObjectCreate(nameObj,OBJ_FIBOFAN,0,mPitchTime[1],fiboPrice1,mPitchTime[2],fiboPrice2); + } + else + { + if (afrl[mPitch[1]]>0) + { + fiboPrice1=afrl[mPitch[1]];fiboPrice2=afrh[mPitch[2]]; + } + else + { + fiboPrice1=afrh[mPitch[1]];fiboPrice2=afrl[mPitch[2]]; + } + ObjectCreate(nameObj,OBJ_FIBOFAN,0,afr[mPitch[1]],fiboPrice1,afr[mPitch[2]],fiboPrice2); + } + + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboFanS); + + FiboFanLevel(); + + } +//-------------------------------------------------------- +// Вывод фибо-вееров статических. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод фибо-вееров динамических. Начало. +//-------------------------------------------------------- +void screenFiboFanD() + { + double fiboPrice1, fiboPrice2; + + nameObj="fiboFanD" + ExtComplekt+"_"; + + ObjectDelete(nameObj); + + fiboPrice1=afrx[1];fiboPrice2=afrx[0]; + + ObjectCreate(nameObj,OBJ_FIBOFAN,0,afr[1],fiboPrice1,afr[0],fiboPrice2); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboFanD); + + FiboFanLevel(); + } +//-------------------------------------------------------- +// Вывод фибо-вееров динамических. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Уровни фибо-вееров. Конец. +//-------------------------------------------------------- +void FiboFanLevel() + { + if(ExtFiboFanExp) ObjectSet(nameObj,OBJPROP_FIBOLEVELS,6); else ObjectSet(nameObj,OBJPROP_FIBOLEVELS,4); + + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,STYLE_DASH); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+0,0.236); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+1,0.382); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+2,0.5); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+3,0.618); + + if (ExtFiboFanHidden) + { + ObjectSetFiboDescription(nameObj, 0, "23.6"); + ObjectSetFiboDescription(nameObj, 1, "38.2"); + ObjectSetFiboDescription(nameObj, 2, "50.0"); + ObjectSetFiboDescription(nameObj, 3, "61.8"); + } + if(ExtFiboFanExp) + { + if (ExtFiboType==0) + { + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+4,0.764); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+5,0.854); + + if (ExtFiboFanHidden) + { + ObjectSetFiboDescription(nameObj, 4, "76.4"); + ObjectSetFiboDescription(nameObj, 5, "85.4"); + } + } + else + { + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+4,0.786); + ObjectSet(nameObj,OBJPROP_FIRSTLEVEL+5,0.886); + + if (ExtFiboFanHidden) + { + ObjectSetFiboDescription(nameObj, 4, "78.6"); + ObjectSetFiboDescription(nameObj, 5, "88.6"); + } + } + } + } +//-------------------------------------------------------- +// Уровни фибо-вееров. Начало. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Вывод расширений Фибоначчи. Начало. +//-------------------------------------------------------- +void FiboExpansion() + { + if (ExtFiboExpansion>1) + { + int i; + double znach1,znach2,fi_1[]; + + nameObj="fiboExpansion" + ExtComplekt+"_"; + if (mExpansion[2]>0) + { + if (ExtSave) + { + nameObj=nameObj + save; + } + } + + ObjectDelete(nameObj); + if (afrl[mExpansion[0]]>0) + { + ObjectCreate(nameObj,OBJ_EXPANSION,0,afr[mExpansion[0]],afrl[mExpansion[0]],afr[mExpansion[1]],afrh[mExpansion[1]],afr[mExpansion[2]],afrl[mExpansion[2]]); + znach1=afrh[mExpansion[1]]-afrl[mExpansion[0]]; + znach2=afrl[mExpansion[2]]; + } + else + { + ObjectCreate(nameObj,OBJ_EXPANSION,0,afr[mExpansion[0]],afrh[mExpansion[0]],afr[mExpansion[1]],afrl[mExpansion[1]],afr[mExpansion[2]],afrh[mExpansion[2]]); + znach1=-(afrh[mExpansion[0]]-afrl[mExpansion[1]]); + znach2=afrh[mExpansion[2]]; + } + + ObjectSet(nameObj,OBJPROP_COLOR,ExtObjectColor); + ObjectSet(nameObj,OBJPROP_STYLE,ExtObjectStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,ExtObjectWidth); + ObjectSet(nameObj,OBJPROP_LEVELCOLOR,ExtFiboExpansionColor); + ObjectSet(nameObj,OBJPROP_LEVELSTYLE,ExtExpansionStyle); + ObjectSet(nameObj,OBJPROP_LEVELWIDTH,ExtExpansionWidth); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + if (ExtFiboType==0) + { + FiboExpansion_st(znach1, znach2); + } + else if (ExtFiboType==1) + { + FiboExpansion_Pesavento(znach1, znach2); + } + else if (ExtFiboType==2) + { + ObjectSet(nameObj,OBJPROP_FIBOLEVELS,Sizefi); + for (i=0;i=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,"_" + ExtComplekt + "pl")>-1) ObjectDelete (txt); + if (StringFind(txt,"_" + ExtComplekt + "ph")>-1) ObjectDelete (txt); + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление соединительных линий и чисел. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Удаление объектов. Начало. +// Удаление соединительных линий и чисел. +//-------------------------------------------------------- +void delete_objects2(string txt1) + { + int i; + string txt; + + for (i=ObjectsTotal(); i>=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,txt1)>-1)ObjectDelete (txt); + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление соединительных линий и чисел. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Удаление объектов. Начало. +// Удаление треугольников и рамки для точки D паттерна. +//-------------------------------------------------------- +void delete_objects3() + { + int i; + string txt; + + for (i=ObjectsTotal(); i>=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,"_"+ExtComplekt+"Triangle")>-1)ObjectDelete (txt); + + if (RangeForPointD>0) + { + txt=ObjectName(i); + if (StringFind(txt,"_"+ExtComplekt+"PointD")>-1)ObjectDelete (txt); + if (StringFind(txt,"_"+ExtComplekt+"PDL")>-1)ObjectDelete (txt); + } + + ArrayInitialize(PeakCenaX,0); + ArrayInitialize(PeakCenaA,0); + ArrayInitialize(PeakCenaB,0); + ArrayInitialize(PeakCenaC,0); + ArrayInitialize(PeakCenaD,0); + + ArrayInitialize(PeakTimeX,0); + ArrayInitialize(PeakTimeA,0); + ArrayInitialize(PeakTimeB,0); + ArrayInitialize(PeakTimeC,0); + ArrayInitialize(PeakTimeD,0); + } + + if (RangeForPointD>0) + { + FlagForD=true; + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление треугольников и рамки для точки D паттерна. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Удаление объектов. Начало. +// Удаление соединительных линий и чисел. +//-------------------------------------------------------- +void delete_objects4() + { + int i; + string txt; + + for (i=ObjectsTotal(); i>=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,"_" + ExtComplekt + "pg")>-1) ObjectDelete (txt); + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление соединительных линий и чисел. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Удаление объектов. Начало. +// Удаление Equilibrium. +//-------------------------------------------------------- +void delete_objects5() + { + int i; + string txt; + + for (i=ObjectsTotal(); i>=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,"_"+ExtComplekt+"Equilibrium")>-1)ObjectDelete (txt); + else if (StringFind(txt,"_"+ExtComplekt+"Reaction")>-1)ObjectDelete (txt); + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление Equilibrium. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Удаление объектов. Начало. +// Удаление спирали. +//-------------------------------------------------------- +void delete_objects_spiral() + { + int i; + + for(i=0;i=0; i--) + { + txt=ObjectName(i); + if (StringFind(txt,"NumberPeak" + "_" + ExtComplekt + "_")>-1) ObjectDelete (txt); + } + } +//-------------------------------------------------------- +// Удаление объектов. Конец. +// Удаление номеров переломов зигзага. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Удаление динамических объектов. Начало. +//-------------------------------------------------------- +void delete_objects_dinamic() + { + int i; + + ObjectDelete("fiboD" + ExtComplekt+"_"); + ObjectDelete("fiboFanD" + ExtComplekt+"_"); + ObjectDelete("RLineD" + ExtComplekt+"_"); + ObjectDelete("pitchforkD" + ExtComplekt+"_"); + ObjectDelete("ISL_D" + ExtComplekt+"_"); + ObjectDelete("RZD" + ExtComplekt+"_"); + ObjectDelete("pmedianaD" + ExtComplekt+"_"); + ObjectDelete("1-2pmedianaD" + ExtComplekt+"_"); + ObjectDelete("fiboExpansion" + ExtComplekt+"_"); + ObjectDelete("PivotZoneD" + ExtComplekt+"_"); + ObjectDelete("FanMedianaDinamic" + ExtComplekt+"_"); + ObjectDelete("FiboArcD" + ExtComplekt+"_"); + if (ExtPivotZZ1Num==1) ObjectDelete("LinePivotZZ" + "1" + ExtComplekt+"_"); + if (ExtPivotZZ2Num==1) ObjectDelete("LinePivotZZ" + "2" + ExtComplekt+"_"); + + for (i=0; i<7; i++) + { + nameObj="VLD"+i+" " + ExtComplekt+"_"; + ObjectDelete(nameObj); + } + } +//-------------------------------------------------------- +// Удаление динамических объектов. Конец. +//-------------------------------------------------------- + + + +//---------------------------------------------------- +// ZigZag (из МТ4 немного измененный). Начало. +//---------------------------------------------------- +void ZigZag_() + { +// ZigZag из МТ. Начало. + if (ExtMaxBar>0) _maxbarZZ=ExtMaxBar; else _maxbarZZ=Bars; + int shift, back,lasthighpos,lastlowpos; + double val,res; + double curlow,curhigh,lasthigh,lastlow; + int vDepth = 0; +// int Depth; + bool endCyklDirection=true; + + if (ExtIndicator==11) + { + bool endCykl=false; + Depth = minDepth; +// countGartley = 0; // Счетчик паттернов + countColor = 0; + if (flagExtGartleyTypeSearch2==false) {delete_objects3(); countGartley = 0; vPatOnOff = 0;} + + if (ExtGartleyTypeSearch>0 && ExtHiddenPP==2 && flagExtGartleyTypeSearch2==false) delete_objects4(); + } + else + { + Depth = minBars; + minDepth = minBars; + maxDepth = minBars; + } + + if (DirectionOfSearchMaxMin) vDepth = maxDepth; else vDepth = minDepth; + + while (endCyklDirection) + { + + if (ExtIndicator==11) + { + if (ExtLabel>0) {ArrayInitialize(la,0.0); ArrayInitialize(ha,0.0);} + ArrayInitialize(zz,0);ArrayInitialize(zzL,0);ArrayInitialize(zzH,0); + + if (DirectionOfSearchMaxMin) + { + if (vDepth < minDepth) + { + if (ExtGartleyTypeSearch>0 && ExtIndicator==11 && vPatOnOff==1) vDepth=minBarsToNumberPattern; + else vDepth=minBars; + endCykl=true; + } + } + else + { + if (vDepth > maxDepth) + { + if (ExtGartleyTypeSearch>0 && ExtIndicator==11 && vPatOnOff==1) vDepth=minBarsToNumberPattern; + else vDepth=minBars; + endCykl=true; + } + } + + Depth = vDepth; + + if (DirectionOfSearchMaxMin) + { + vDepth--; + } + else + { + vDepth++; + } + + if (flagExtGartleyTypeSearch2 && ExtGartleyTypeSearch==2 && vPatOnOff==1) {endCykl=true; Depth=minBarsToNumberPattern;} + } + else + { + endCyklDirection=false; + } + + minBarsX=Depth; + + // первый большой цикл + for(shift=_maxbarZZ-Depth; shift>=ExtMinBar; shift--) + { + val=Low[iLowest(NULL,0,MODE_LOW,Depth,shift)]; + if(val==lastlow) val=0.0; + else + { + lastlow=val; + if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0; + else + { + for(back=1; back<=ExtBackstep; back++) + { + res=zzL[shift+back]; + if((res!=0)&&(res>val)) zzL[shift+back]=0.0; + } + } + } + if (Low[shift]==val) + { + zzL[shift]=val; + if (ExtLabel>0) la[shift]=val; + } + + val=High[iHighest(NULL,0,MODE_HIGH,Depth,shift)]; + if(val==lasthigh) val=0.0; + else + { + lasthigh=val; + if((val-High[shift])>(ExtDeviation*Point)) val=0.0; + else + { + for(back=1; back<=ExtBackstep; back++) + { + res=zzH[shift+back]; + if((res!=0)&&(res0) ha[shift]=val; + } + } + + // второй большой цикл + lasthigh=-1; lasthighpos=-1; + lastlow=-1; lastlowpos=-1; + + for(shift=_maxbarZZ-Depth; shift>=ExtMinBar; shift--) + { + curlow=zzL[shift]; + curhigh=zzH[shift]; + if((curlow==0)&&(curhigh==0)) continue; + + if(curhigh!=0) + { + if(lasthigh>0) + { + if(lasthigh0) + { + if(lastlow>curlow) zzL[lastlowpos]=0; + else zzL[shift]=0; + } + + if((curlow=ExtMinBar; shift--) + { + zz[shift]=zzL[shift]; + if(shift>=_maxbarZZ-Depth) {zzH[shift]=0.0; zzL[shift]=0.0; zz[shift]=0.0;} + else + { + res=zzH[shift]; + if(res!=0.0) + { + zz[shift]=res; + } + } + } + + NoGorb(Depth); // удаляем горбы зигзага + + if (ExtIndicator!=11 && ExtLabel>0) // расставляем метки на барах, где появился новый луч и на переломах зигзага + { + Metka(); + } + + // поиск паттернов + if (ExtIndicator==11) + { + if (ExtLabel>0) // расставляем метки на барах, где появился новый луч и на переломах зигзага + { + Metka(); + } + + if (endCykl) + { + return(0); + } + + _Gartley("ExtIndicator=11_" + Depth+"/"+ExtDeviation+"/"+ExtBackstep, Depth); + + if (ExtGartleyTypeSearch==0 && vPatOnOff==1) + { + return(0); + } + } // поиск паттернов конец + } + } +//-------------------------------------------------------- +// ZigZag из МТ. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Исправление возникающих горбов зигзага. Начало. +//-------------------------------------------------------- +void NoGorb(int Depth) + { + double vel1, vel2, vel3, vel4; + int bar1, bar2, bar3, bar4; + int count; + for(int bar=Bars-Depth; bar>=0; bar--) + { + if (zz[bar]!=0) + { + count++; + vel4=vel3;bar4=bar3; + vel3=vel2;bar3=bar2; + vel2=vel1;bar2=bar1; + vel1=zz[bar];bar1=bar; + if (count<3) continue; + if ((vel3vel2)&&(vel2>vel1)) {zz[bar2]=0;zzL[bar2]=0;zzH[bar2]=0;bar=bar3+1;} + if ((vel2==vel1)&&(vel1!=0 )) {zz[bar1]=0;zzL[bar1]=0;zzH[bar1]=0;bar=bar3+1;} + } + } + } +//-------------------------------------------------------- +// Исправление возникающих горбов зигзага. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Расстановка меток. Начало. +//-------------------------------------------------------- +void Metka() + { + int shift, metka=0; // =0 - до первого перелома ZZ. =1 - ищем метки максимумов. =2 - ищем метки минимумов. + for(shift=Bars-1; shift>=0; shift--) + { + if (zz[shift]>0) + { + if (zzH[shift]>0) + { + metka=2; la[shift]=0; shift--; + } + else + { + metka=1; ha[shift]=0; shift--; + } + } + + if (metka==0) + { + ha[shift]=0; la[shift]=0; + } + else if (metka==1) + { + if (ha[shift]>0) metka=0; + la[shift]=0; + } + else if (metka==2) + { + if (la[shift]>0) metka=0; + ha[shift]=0; + } + } + } +//-------------------------------------------------------- +// Расстановка меток. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Поиск паттернов Gartley. Начало. +//-------------------------------------------------------- +void _Gartley(string _Depth, int Depth) + { + int i, j, k, m; + + double min_DeltaGartley = (1 - ExtDeltaGartley); + double max_DeltaGartley = (1 + ExtDeltaGartley); + double vl0382 = min_DeltaGartley * 0.382; + double vh05 = max_DeltaGartley * 0.5; + double vl0618 = min_DeltaGartley * 0.618; + double vh0618 = max_DeltaGartley * 0.618; + double vl0786 = min_DeltaGartley * 0.786; + double vh0786 = max_DeltaGartley * 0.786; + double vl0886 = min_DeltaGartley * 0.886; + double vh0886 = max_DeltaGartley * 0.886; + double vl1128 = min_DeltaGartley * 1.128; + double vl1272 = min_DeltaGartley * 1.272; + double vl1618 = min_DeltaGartley * phi; + double vh1618 = max_DeltaGartley * phi; + double vl2236 = min_DeltaGartley * 2.236; + double vh2236 = max_DeltaGartley * 2.236; + double vh2618 = max_DeltaGartley * 2.618; + double vh3618 = max_DeltaGartley * 3.618; + + double LivelDA1382,LivelDA1618,LivelDA2,LivelDA2618,LivelDA3618,LivelDA4618,LivelDC1382,LivelDC1618,LivelDC2,LivelDC2618,LivelDC3618,LivelDC4618; + double LevelForD; + datetime timeLineD; + + int aXABCD[6]; // номера баров с точками XABCD паттернов + double retXD; + double retXB; + double retBD; + double retAC; + double XA, BC; + + double vDelta0 = 0.000001; + int vNull = 0; + int X=1,A=2,B=3,C=4,D=5; + string nameObj1, nameObj2; + string vBull = "Bullish"; + string vBear = "Bearish"; + string vGartley = "Gartley"; + string vBat = "Bat"; + string vButterfly = "Butterfly"; + string vCrab = "Crab"; + int aNumBarPeak[]; + + color colorPattern; + + if (ExtIndicator!=11) delete_objects3(); + + if ((ExtGartleyTypeSearch==0 && ExtIndicator==11) || ExtIndicator!=11) vPatOnOff = 0; + vBullBear = ""; + vNamePattern = ""; + maxPeak = 0; + + for(shift=Bars-1; shift>=0; shift--) + { + if (zz[shift]>0) maxPeak++; + } + + ArrayResize(aNumBarPeak, maxPeak); + + shift = 0; + j = 0; + while ((shift < Bars) && (j < maxPeak)) + { + if (zz[shift] != 0) + { + aNumBarPeak[j] = shift; + j++; + } + shift++; + } + if (j -1) && (aXABCD[D] < maxBarToD+2)) + { + aXABCD[X] = aNumBarPeak[k + 4]; + aXABCD[A] = aNumBarPeak[k + 3]; + aXABCD[B] = aNumBarPeak[k + 2]; + aXABCD[C] = aNumBarPeak[k + 1]; + aXABCD[D] = aNumBarPeak[k]; + + if ((zz[aXABCD[A]] > zz[aXABCD[C]]) && (zz[aXABCD[C]] > zz[aXABCD[B]]) && (zz[aXABCD[B]] > zz[aXABCD[X]]) && (zz[aXABCD[X]] > zz[aXABCD[D]]) && ((zz[aXABCD[C]] - zzL[aXABCD[D]]) >= (zz[aXABCD[A]] - zz[aXABCD[B]]) * ExtCD)) + { + vBullBear = vBull; + } + else if ((zz[aXABCD[A]] > zz[aXABCD[C]]) && (zz[aXABCD[C]] > zz[aXABCD[B]]) && (zz[aXABCD[B]] > zz[aXABCD[D]]) && (zz[aXABCD[D]] > zz[aXABCD[X]]) && ((zz[aXABCD[C]] - zz[aXABCD[D]]) >= (zz[aXABCD[A]] - zz[aXABCD[B]]) * ExtCD)) + { + vBullBear = vBull; + } + else if ((zz[aXABCD[X]] > zz[aXABCD[D]]) && (zz[aXABCD[D]] > zz[aXABCD[B]]) && (zz[aXABCD[B]] > zz[aXABCD[C]]) && (zz[aXABCD[C]] > zz[aXABCD[A]]) && ((zz[aXABCD[D]] - zz[aXABCD[C]]) >= (zz[aXABCD[B]] - zz[aXABCD[A]]) * ExtCD)) + { + vBullBear = vBear; + } + else if ((zz[aXABCD[D]] > zz[aXABCD[X]]) && (zz[aXABCD[X]] > zz[aXABCD[B]]) && (zz[aXABCD[B]] > zz[aXABCD[C]]) && (zz[aXABCD[C]] > zz[aXABCD[A]]) && ((zz[aXABCD[D]] - zz[aXABCD[C]]) >= (zz[aXABCD[B]] - zz[aXABCD[A]]) * ExtCD)) + { + vBullBear = vBear; + } + + if (vBullBear!="") + { + if (vBullBear == vBull) + { + retXB = (zz[aXABCD[A]] - zz[aXABCD[B]]) / (zz[aXABCD[A]] - zz[aXABCD[X]] + vDelta0); + retXD = (zz[aXABCD[A]] - zz[aXABCD[D]]) / (zz[aXABCD[A]] - zz[aXABCD[X]] + vDelta0); + retBD = (zz[aXABCD[C]] - zz[aXABCD[D]]) / (zz[aXABCD[C]] - zz[aXABCD[B]] + vDelta0); + retAC = (zz[aXABCD[C]] - zz[aXABCD[B]]) / (zz[aXABCD[A]] - zz[aXABCD[B]] + vDelta0); + if (RangeForPointD>0 && FlagForD) + { + XA=zz[aXABCD[A]] - zz[aXABCD[X]]; + BC=zz[aXABCD[C]] - zz[aXABCD[B]]; + } + } + else if (vBullBear == vBear) + { + retXB = (zz[aXABCD[B]] - zz[aXABCD[A]]) / (zz[aXABCD[X]] - zz[aXABCD[A]] + vDelta0); + retXD = (zz[aXABCD[D]] - zz[aXABCD[A]]) / (zz[aXABCD[X]] - zz[aXABCD[A]] + vDelta0); + retBD = (zz[aXABCD[D]] - zz[aXABCD[C]]) / (zz[aXABCD[B]] - zz[aXABCD[C]] + vDelta0); + retAC = (zz[aXABCD[B]] - zz[aXABCD[C]]) / (zz[aXABCD[B]] - zz[aXABCD[A]] + vDelta0); + if (RangeForPointD>0 && FlagForD) + { + XA=zz[aXABCD[X]] - zz[aXABCD[A]]; + BC=zz[aXABCD[B]] - zz[aXABCD[C]]; + } + } + + if ((retAC >= vl0382) && (retAC <= vh0886) && (retXD >= vl0618) && (retXD <= vh0786) && (retBD >= vl1128) && (retBD <= vh2236) && (retXB >= vl0382) && (retXB <= vh0618)) + { + vNamePattern=vGartley; // Gartley + if (RangeForPointD>0 && FlagForD) + { + if (vBullBear == vBull) + { + LevelForDmin = MathMax(zz[aXABCD[A]]-XA*vh0786,zz[aXABCD[C]]-BC*vh2236); + LevelForDmax = MathMin(zz[aXABCD[A]]-XA*vl0618,zz[aXABCD[C]]-BC*vl1128); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*1.382; + LivelDA1618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*phi; + LivelDA2 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*2; + LivelDA2618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*1.382; + LivelDC1618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*phi; + LivelDC2 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*2; + LivelDC2618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(3+phi); + } + } + else if (vBullBear == vBear) + { + LevelForDmin = MathMax(zz[aXABCD[A]]+XA*vl0618,zz[aXABCD[C]]+BC*vl1128); + LevelForDmax = MathMin(zz[aXABCD[A]]+XA*vh0786,zz[aXABCD[C]]+BC*vh2236); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*1.382; + LivelDA1618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*phi; + LivelDA2 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*2; + LivelDA2618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*1.382; + LivelDC1618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*phi; + LivelDC2 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*2; + LivelDC2618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(3+phi); + } + } + } + } + else if ((retAC >= vl0382) && (retAC <= vh0886) && (retXD >= vl1272) && (retXD <= vh1618) && (retBD >= vl1272) && (retBD <= vh2618) && (retXB >= vl0618) && (retXB <= vh0886)) + { + vNamePattern=vButterfly; // Butterfly + if (RangeForPointD>0 && FlagForD) + { + if (vBullBear == vBull) + { + LevelForDmin = MathMax(zz[aXABCD[A]]-XA*vh1618,zz[aXABCD[C]]-BC*vh2618); + LevelForDmax = MathMin(zz[aXABCD[A]]-XA*vl1272,zz[aXABCD[C]]-BC*vl1272); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*1.382; + LivelDA1618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*phi; + LivelDA2 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*2; + LivelDA2618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*1.382; + LivelDC1618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*phi; + LivelDC2 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*2; + LivelDC2618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(3+phi); + } + } + else if (vBullBear == vBear) + { + LevelForDmin = MathMax(zz[aXABCD[A]]+XA*vl1272,zz[aXABCD[C]]+BC*vl1272); + LevelForDmax = MathMin(zz[aXABCD[A]]+XA*vh1618,zz[aXABCD[C]]+BC*vh2618); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*1.382; + LivelDA1618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*phi; + LivelDA2 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*2; + LivelDA2618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*1.382; + LivelDC1618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*phi; + LivelDC2 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*2; + LivelDC2618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(3+phi); + } + } + } + } + else if ((retAC >= vl0382) && (retAC <= vh0886) && (retXD >= vl1618) && (retXD <= vh1618) && (retBD >= vl2236) && (retBD <= vh3618) && (retXB >= vl0382) && (retXB <= vh0618)) + { + vNamePattern=vCrab; // Crab + if (RangeForPointD>0 && FlagForD) + { + if (vBullBear == vBull) + { + LevelForDmin = MathMax(zz[aXABCD[A]]-XA*vh1618,zz[aXABCD[C]]-BC*vh3618); + LevelForDmax = MathMin(zz[aXABCD[A]]-XA*vl1618,zz[aXABCD[C]]-BC*vl2236); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*1.382; + LivelDA1618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*phi; + LivelDA2 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*2; + LivelDA2618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*1.382; + LivelDC1618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*phi; + LivelDC2 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*2; + LivelDC2618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(3+phi); + } + } + else if (vBullBear == vBear) + { + LevelForDmin = MathMax(zz[aXABCD[A]]+XA*vl1618,zz[aXABCD[C]]+BC*vl2236); + LevelForDmax = MathMin(zz[aXABCD[A]]+XA*vh1618,zz[aXABCD[C]]+BC*vh3618); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*1.382; + LivelDA1618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*phi; + LivelDA2 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*2; + LivelDA2618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*1.382; + LivelDC1618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*phi; + LivelDC2 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*2; + LivelDC2618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(3+phi); + } + } + } + } + else if ((retAC >= vl0382) && (retAC <= vh0886) && (retXD >= vl0886) && (retXD <= vh0886) && (retBD >= vl1272) && (retBD <= vh2618) && (retXB >= vl0382) && (retXB <= vh0618)) + { + vNamePattern=vBat; // Bat + if (RangeForPointD>0 && FlagForD) + { + if (vBullBear == vBull) + { + LevelForDmin = MathMax(zz[aXABCD[A]]-XA*vh0886,zz[aXABCD[C]]-BC*vh2618); + LevelForDmax = MathMin(zz[aXABCD[A]]-XA*vl0886,zz[aXABCD[C]]-BC*vl1272); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*1.382; + LivelDA1618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*phi; + LivelDA2 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*2; + LivelDA2618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]-(zz[aXABCD[A]]-zz[aXABCD[B]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*1.382; + LivelDC1618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*phi; + LivelDC2 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*2; + LivelDC2618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]-(zz[aXABCD[C]]-zz[aXABCD[B]])*(3+phi); + } + } + else if (vBullBear == vBear) + { + LevelForDmin = MathMax(zz[aXABCD[A]]+XA*vl0886,zz[aXABCD[C]]+BC*vl1272); + LevelForDmax = MathMin(zz[aXABCD[A]]+XA*vh0886,zz[aXABCD[C]]+BC*vh2618); + if (RangeForPointD==2) + { + LivelDA1382 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*1.382; + LivelDA1618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*phi; + LivelDA2 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*2; + LivelDA2618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(1+phi); + LivelDA3618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(2+phi); + LivelDA4618 = zz[aXABCD[A]]+(zz[aXABCD[B]]-zz[aXABCD[A]])*(3+phi); + LivelDC1382 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*1.382; + LivelDC1618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*phi; + LivelDC2 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*2; + LivelDC2618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(1+phi); + LivelDC3618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(2+phi); + LivelDC4618 = zz[aXABCD[C]]+(zz[aXABCD[B]]-zz[aXABCD[C]])*(3+phi); + } + } + } + } + } + + if ((vNamePattern != "") && (aXABCD[D] < maxBarToD+2)) + { + if (ExtGartleyTypeSearch>0 && ExtIndicator==11) + { + for (m=0;m<=countGartley;m++) + { + if (PeakCenaX[m]==zz[aXABCD[X]] && PeakCenaA[m]==zz[aXABCD[A]] && PeakCenaB[m]==zz[aXABCD[B]] && PeakCenaC[m]==zz[aXABCD[C]] && PeakCenaD[m]==zz[aXABCD[D]]) + { + if (PeakTimeX[m]==Time[aXABCD[X]] && PeakTimeA[m]==Time[aXABCD[A]] && PeakTimeB[m]==Time[aXABCD[B]] && PeakTimeC[m]==Time[aXABCD[C]] && PeakTimeD[m]==Time[aXABCD[D]]) {k++; break;} + } + } + + if (m<=countGartley) + { + vBullBear = ""; + vNamePattern = ""; + continue; + } + + if (ArraySize(PeakCenaX)zz[aXABCD[A]]) + { + for (i=aXABCD[X]-1;i>=aXABCD[A];i--) + { + delta=Low[i]-(zz[aXABCD[X]]+(aXABCD[X]-i)*tangens); + if (delta=aXABCD[C];i--) + { + delta=Low[i]-(zz[aXABCD[B]]+(aXABCD[B]-i)*tangens); + if (delta=aXABCD[A];i--) + { + delta=High[i]-(zz[aXABCD[X]]+(aXABCD[X]-i)*tangens); + if (delta>h_ea) h_ea=delta; + } + + for (i=aXABCD[B]-1;i>=aXABCD[C];i--) + { + delta=High[i]-(zz[aXABCD[B]]+(aXABCD[B]-i)*tangens); + if (delta>h_ec) h_ec=delta; + } + } + } + + nameObj="_"+ExtComplekt+"Equilibrium_" + countGartley; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[X]],zz[aXABCD[X]],Time[aXABCD[B]],zz[aXABCD[B]]); + ObjectSet(nameObj,OBJPROP_COLOR,ColorEquilibrium); + ObjectSet(nameObj,OBJPROP_STYLE,EquilibriumStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,EquilibriumWidth); + nameObj="_"+ExtComplekt+"Reaction1_" + countGartley; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],zz[aXABCD[B]]+tangens*(aXABCD[B]-aXABCD[C])-h_ec,Time[0],zz[aXABCD[B]]+tangens*aXABCD[B]-h_ec); + ObjectSet(nameObj,OBJPROP_COLOR,ColorReaction); + ObjectSet(nameObj,OBJPROP_STYLE,EquilibriumStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,EquilibriumWidth); + nameObj="_"+ExtComplekt+"Reaction2_" + countGartley; + ObjectDelete(nameObj); + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],zz[aXABCD[B]]+tangens*(aXABCD[B]-aXABCD[C])-h_ea,Time[0],zz[aXABCD[B]]+tangens*aXABCD[B]-h_ea); + ObjectSet(nameObj,OBJPROP_COLOR,ColorReaction); + ObjectSet(nameObj,OBJPROP_STYLE,EquilibriumStyle); + ObjectSet(nameObj,OBJPROP_WIDTH,EquilibriumWidth); + +// Equilibrium=false; + } + + nameObj1="_"+ExtComplekt+"Triangle1_" + countGartley + "_" + _Depth + "_" + aXABCD[D] + "_" +vBullBear + " " + vNamePattern; + nameObj2="_"+ExtComplekt+"Triangle2_" + countGartley + "_" + _Depth + "_" + aXABCD[D] + "_" +vBullBear + " " + vNamePattern; + + vPatOnOff = 1; + + //--------------------------------------------- + if(f==1 && ExtIndicator!=11) + { + f=0; + if(ExtPlayAlert) + { + Alert (Symbol()," ",Period()," появился новый Паттерн"); + PlaySound("alert.wav"); + } + if (ExtSendMail) _SendMail("There was a pattern","on " + Symbol() + " " + Period() + " pattern " + vBullBear + " " + vNamePattern); + } + //--------------------------------------------- + + if (vBullBear == vBull) + { + ObjectCreate(nameObj1,OBJ_TRIANGLE,0,Time[aXABCD[X]],zz[aXABCD[X]],Time[aXABCD[B]],zz[aXABCD[B]],Time[aXABCD[A]],zz[aXABCD[A]]); + ObjectSet(nameObj1,OBJPROP_COLOR,colorPattern); + ObjectCreate(nameObj2,OBJ_TRIANGLE,0,Time[aXABCD[B]],zz[aXABCD[B]],Time[aXABCD[D]],zz[aXABCD[D]],Time[aXABCD[C]],zz[aXABCD[C]]); + ObjectSet(nameObj2,OBJPROP_COLOR,colorPattern); + } + else + { + ObjectCreate(nameObj1,OBJ_TRIANGLE,0,Time[aXABCD[X]],zz[aXABCD[X]],Time[aXABCD[B]],zz[aXABCD[B]],Time[aXABCD[A]],zz[aXABCD[A]]); + ObjectSet(nameObj1,OBJPROP_COLOR,colorPattern); + ObjectCreate(nameObj2,OBJ_TRIANGLE,0,Time[aXABCD[B]],zz[aXABCD[B]],Time[aXABCD[D]],zz[aXABCD[D]],Time[aXABCD[C]],zz[aXABCD[C]]); + ObjectSet(nameObj2,OBJPROP_COLOR,colorPattern); + } + + if (RangeForPointD>0) // Вывод прямоугольника для зоны точки D + { + if (FlagForD) + { +// FlagForD=false; + for (j=aXABCD[D];j<=aXABCD[C]-1;j++) + { + if (vBullBear == vBull) + { + if (LevelForDmax>=Low[j]) TimeForDmax = Time[j]; + } + else if (vBullBear == vBear) + { + if (LevelForDmin<=High[j]) TimeForDmin = Time[j]; + } + } + + if (vBullBear == vBull) + { + TimeForDmin = TimeForDmax+((LevelForDmax-LevelForDmin)/((zz[aXABCD[C]]-zz[aXABCD[D]])/(aXABCD[C]-aXABCD[D]+1)))*Period()*60; + } + else if (vBullBear == vBear) + { + TimeForDmax = TimeForDmin+((LevelForDmax-LevelForDmin)/((zz[aXABCD[D]]-zz[aXABCD[C]])/(aXABCD[C]-aXABCD[D]+1)))*Period()*60; + } +/* +//?? if ((NumberPattern-1==countGartley-1 && ExtGartleyTypeSearch>0) || ExtGartleyTypeSearch==0) + { + TimeForDmaxToNumberPattern = TimeForDmax; + TimeForDminToNumberPattern = TimeForDmin; + } +*/ + + if (TimeForDmin>TimeForDmax) + { + timeLineD=TimeForDmin; + TimeForDmin=TimeForDmax; + TimeForDmax=timeLineD; + } + else + { + timeLineD=TimeForDmax; + } + + if (LevelForDmin>LevelForDmax) + { + LevelForD=LevelForDmin; + LevelForDmin=LevelForDmax; + LevelForDmax=LevelForD; + } + + nameObj="_"+ExtComplekt+"PointD_" + countGartley + ""; + + ObjectCreate(nameObj,OBJ_RECTANGLE,0,TimeForDmin,LevelForDmin,TimeForDmax,LevelForDmax); + ObjectSet(nameObj, OBJPROP_BACK, false); + ObjectSet(nameObj, OBJPROP_COLOR, ExtColorRangeForPointD); + + if (RangeForPointD==2) + { + if (LevelForDmax>=LivelDA1382 && LivelDA1382>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA1382_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA1382,timeLineD,LivelDA1382); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDA1618 && LivelDA1618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA1618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA1618,timeLineD,LivelDA1618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDA2 && LivelDA2>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA2_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA2,timeLineD,LivelDA2); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDA2618 && LivelDA2618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA2618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA2618,timeLineD,LivelDA2618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDA3618 && LivelDA3618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA3618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA3618,timeLineD,LivelDA3618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDA4618 && LivelDA4618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLA4618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDA4618,timeLineD,LivelDA4618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_AB); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC1382 && LivelDC1382>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC1382_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC1382,timeLineD,LivelDC1382); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC1618 && LivelDC1618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC1618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC1618,timeLineD,LivelDC1618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC2 && LivelDC2>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC2_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC2,timeLineD,LivelDC2); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC2618 && LivelDC2618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC2618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC2618,timeLineD,LivelDC2618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC3618 && LivelDC3618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC3618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC3618,timeLineD,LivelDC3618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + + if (LevelForDmax>=LivelDC4618 && LivelDC4618>=LevelForDmin) + { + nameObj="_"+ExtComplekt+"PDLC4618_" + countGartley + ""; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[C]],LivelDC4618,timeLineD,LivelDC4618); + ObjectSet(nameObj, OBJPROP_COLOR, ExtLineForPointD_BC); + ObjectSet(nameObj, OBJPROP_RAY, false); + } + } + + if (ExtGartleyTypeSearch>0 && ExtIndicator==11 && ExtHiddenPP==2) + { + k1=MathCeil((aXABCD[X]+aXABCD[B])/2); + nameObj="_" + ExtComplekt + "pgtxt" + Time[aXABCD[B]] + "_" + Time[aXABCD[X]]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(zz[aXABCD[B]]+zz[aXABCD[X]])/2); + ObjectSetText(nameObj,DoubleToStr(retXB,3),ExtSizeTxt,"Arial", ExtNotFibo); + nameObj="_" + ExtComplekt + "pg" + Time[aXABCD[B]] + "_" + Time[aXABCD[X]]; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[X]],zz[aXABCD[X]],Time[aXABCD[B]],zz[aXABCD[B]]); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + k1=MathCeil((aXABCD[X]+aXABCD[D])/2); + nameObj="_" + ExtComplekt + "pgtxt" + Time[aXABCD[D]] + "_" + Time[aXABCD[X]]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(zz[aXABCD[D]]+zz[aXABCD[X]])/2); + ObjectSetText(nameObj,DoubleToStr(retXD,3),ExtSizeTxt,"Arial", ExtNotFibo); + nameObj="_" + ExtComplekt + "pg" + Time[aXABCD[D]] + "_" + Time[aXABCD[X]]; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[X]],zz[aXABCD[X]],Time[aXABCD[D]],zz[aXABCD[D]]); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + k1=MathCeil((aXABCD[B]+aXABCD[D])/2); + nameObj="_" + ExtComplekt + "pgtxt" + Time[aXABCD[D]] + "_" + Time[aXABCD[B]]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(zz[aXABCD[D]]+zz[aXABCD[B]])/2); + ObjectSetText(nameObj,DoubleToStr(retBD,3),ExtSizeTxt,"Arial", ExtNotFibo); + nameObj="_" + ExtComplekt + "pg" + Time[aXABCD[D]] + "_" + Time[aXABCD[B]]; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[B]],zz[aXABCD[B]],Time[aXABCD[D]],zz[aXABCD[D]]); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + k1=MathCeil((aXABCD[A]+aXABCD[C])/2); + nameObj="_" + ExtComplekt + "pgtxt" + Time[aXABCD[C]] + "_" + Time[aXABCD[A]]; + ObjectCreate(nameObj,OBJ_TEXT,0,Time[k1],(zz[aXABCD[C]]+zz[aXABCD[A]])/2); + ObjectSetText(nameObj,DoubleToStr(retAC,3),ExtSizeTxt,"Arial", ExtNotFibo); + nameObj="_" + ExtComplekt + "pg" + Time[aXABCD[C]] + "_" + Time[aXABCD[A]]; + ObjectCreate(nameObj,OBJ_TREND,0,Time[aXABCD[A]],zz[aXABCD[A]],Time[aXABCD[C]],zz[aXABCD[C]]); + ObjectSet(nameObj,OBJPROP_RAY,false); + ObjectSet(nameObj,OBJPROP_STYLE,STYLE_DOT); + ObjectSet(nameObj,OBJPROP_COLOR,ExtLine); + ObjectSet(nameObj,OBJPROP_BACK,ExtBack); + + } + } + + } + +// vBullBear = ""; +// vNamePattern = ""; + + return(0); + } + else + { + vBullBear = ""; + vNamePattern = ""; + vBullBearToNumberPattern = ""; + vNamePatternToNumberPattern = ""; + } + k++; + } + } +//-------------------------------------------------------- +// Поиск паттернов Gartley. Конец. +//-------------------------------------------------------- + + +//---------------------------------------------------- +// ZigZag Алекса немного измененный. Начало. +//---------------------------------------------------- +void ang_AZZ_() + { + int i,n; +// cbi=Bars-IndicatorCounted()-1; + if (ExtMaxBar>0) cbi=ExtMaxBar; else cbi=Bars-1; +//--------------------------------- + for (i=cbi; i>=ExtMinBar; i--) + { +//------------------------------------------------- + // запоминаем значение направления тренда fs и средней цены si на предыдущем баре + if (tisi+di && Low[i]si-Low[i]) si=High[i]-di; // Отклонение хая от средней цены больше отклонения лова +// else if (High[i]-si=si+di) si=High[i]-di; // + else if (Low[i]si+di) si=High[i]-di; // + } + } + + // Вычисление начального значения средней цены + if (i>cbi-1) {si=(High[i]+Low[i])/2;} + + // Определяем направление тренда для расчетного бара + if (si>sip) fs=1; // Тренд восходящий + if (si0) + { + ha[i]=High[i]; la[bi]=Low[bi]; la[i]=0; + tmh=Time[i]; ha[i]=High[i]; la[i]=0; // простановка метки на восходящем луче + } + } + + if (fs==2 && fsp==1) // Тредн сменился с восходящего на нисходящий + { + lm=Low[i]; + + ai=iBarShift(Symbol(),Period(),tai); + zz[ai]=High[ai]; + zzH[ai]=High[ai]; + tbi=Time[i]; + si=Low[i]+di; + fsp=fs; + sip=si; + if (ExtLabel>0) + { + ha[ai]=High[ai]; ha[i]=0; la[i]=Low[i]; + tml=Time[i]; ha[i]=0; la[i]=Low[i]; // простановка метки на нисходящем луче + } + } + + // Продолжение tренда. Отслеживание тренда. + if (fs==1 && High[i]>hm) + {hm=High[i]; tai=Time[i]; si=High[i]-di;} + if (fs==2 && Low[i]=0; n--) {zzH[n]=0; zz[n]=0; if (ExtLabel>0) ha[n]=0;} + zz[ai0]=High[ai0]; zzH[ai0]=High[ai0]; zzL[ai0]=0; if (ExtLabel>0) ha[ai0]=High[ai0]; + } + if (fs==2) + { + for (n=ai0-1; n>=0; n--) {zzL[n]=0; zz[n]=0; if (ExtLabel>0) la[n]=0;} + zz[bi0]=Low[bi0]; zzL[bi0]=Low[bi0]; zzH[bi0]=0; if (ExtLabel>0) la[bi0]=Low[bi0]; + } + + if (ExtLabel>0) + { + if (fs==1) {aim=iBarShift(Symbol(),0,tmh); if (aim0) cbi=ExtMaxBar; else cbi=Bars-1; +//--------------------------------- + for (i=cbi; i>=ExtMinBar; i--) + { +//------------------------------------------------- + // Устанавливаем начальные значения минимума и максимума бара + if (lLast==0) {lLast=Low[i];hLast=High[i]; if (ExtIndicator==3) di=hLast-lLast;} + + // Определяем направление тренда до первой точки смены тренда. + // Или до точки начала первого луча за левым краем. + if (fs==0) + { + if (lLastLow[i] && hLast>High[i]) {fs=2; lLast=Low[i]; si=Low[i]; bi=i; tbi=Time[i]; if (ExtIndicator==3) di=High[i]-Low[i];} // тренд нисходящий + } + + if (ti0) {countBar--; if (i==0 && countBar==0) fcount0=true;} + // Остановка. Определение дальнейшего направления тренда. + if (fs==1) + { + if (hLast>High[i] && !fh) fh=true; + + if (i==0) + { + + if (Close[i+1]Low[i+1] && High[i+1]i+1 && fh && !fcount0) {fs=2; countBar=minBars; fh=false;} + + if (fs==2) // Тредн сменился с восходящего на нисходящий на предыдущем баре + { + zz[ai0]=High[ai0]; + zzH[ai0]=High[ai0]; + lLast=Low[i+1]; + if (ExtIndicator==3) di=High[i+1]-Low[i+1]; + si=Low[i+1]; + bi=i+1; + tbi=Time[i+1]; + if (ExtLabel>0) + { + ha[ai0]=High[ai0]; + tml=Time[i+1]; ha[i+1]=0; la[i+1]=Low[i+1]; // простановка метки на нисходящем луче + } + else if (chHL && chHL_PeakDet_or_vts) {ha[i+1]=si+di; la[i+1]=si;} + } + + } + else + { + if (Close[i]Low[i] && High[i]0) + { + ha[ai]=High[ai]; + tml=Time[i]; ha[i]=0; la[i]=Low[i]; // простановка метки на нисходящем луче + } + else if (chHL && chHL_PeakDet_or_vts) {ha[i]=si+di; la[i]=si;} + } + } + + } + else // fs==2 + { + if (lLasthLast && fl) {fs=1; countBar=minBars; fl=false;} + if (countBar==0 && si+dilLast && bi0>i+1 && fl && !fcount0) {fs=1; countBar=minBars; fl=false;} + + if (fs==1) // Тредн сменился с нисходящего на восходящий на предыдущем баре + { + zz[bi0]=Low[bi0]; + zzL[bi0]=Low[bi0]; + hLast=High[i+1]; + if (ExtIndicator==3) di=High[i+1]-Low[i+1]; + si=High[i+1]; + ai=i+1; + tai=Time[i+1]; + if (ExtLabel>0) + { + la[bi0]=Low[bi0]; + tmh=Time[i+1]; ha[i+1]=High[i+1]; la[i+1]=0; // простановка метки на восходящем луче + } + else if (chHL && chHL_PeakDet_or_vts) {ha[i+1]=si; la[i+1]=si-di;} + } + + } + else + { + if (Close[i]>hLast && fl) {fs=1; countBar=minBars; fl=false;} + if (countBar==0 && si+dilLast && fl) {fs=1; countBar=minBars; fl=false;} + + if (fs==1) // Тредн сменился с нисходящего на восходящий + { + zz[bi]=Low[bi]; + zzL[bi]=Low[bi]; + hLast=High[i]; + if (ExtIndicator==3) di=High[i]-Low[i]; + si=High[i]; + ai=i; + tai=Time[i]; + if (ExtLabel>0) + { + la[bi]=Low[bi]; + tmh=Time[i]; ha[i]=High[i]; la[i]=0; // простановка метки на восходящем луче + } + else if (chHL && chHL_PeakDet_or_vts==1) {ha[i]=si; la[i]=si-di;} + } + } + } + } + + // Продолжение тренда + if (fs==1 && High[i]>si) {ai=i; tai=Time[i]; hLast=High[i]; si=High[i]; countBar=minBars; fh=false; if (ExtIndicator==3) di=High[i]-Low[i];} + + if (fs==2 && Low[i]=0; n--) {zzH[n]=0; zz[n]=0; if (ExtLabel>0) ha[n]=0;} + zz[ai0]=High[ai0]; zzH[ai0]=High[ai0]; zzL[ai0]=0; if (ExtLabel>0) ha[ai0]=High[ai0]; + } + if (fs==2) + { + for (n=ai0-1; n>=0; n--) {zzL[n]=0; zz[n]=0; if (ExtLabel>0) la[n]=0;} + zz[bi0]=Low[bi0]; zzL[bi0]=Low[bi0]; zzH[bi0]=0; if (ExtLabel>0) la[bi0]=Low[bi0]; + } + + if (ExtLabel>0) + { + if (fs==1) {aim=iBarShift(Symbol(),0,tmh); if (aim0) + { + ArrayInitialize(la,0.0); + ArrayInitialize(ha,0.0); + } + + GetHigh(0,Bars,0.0,0); + + // final cutting + lasthigh=-1; lasthighpos=-1; + lastlow=-1; lastlowpos=-1; + + for(shift=Bars; shift>=0; shift--) + { + curlow=zzL[shift]; + curhigh=zzH[shift]; + if((curlow==0)&&(curhigh==0)) continue; + //--- + if(curhigh!=0) + { + if(lasthigh>0) + { + if(lasthigh0) + { + if(lastlow>curlow) zzL[lastlowpos]=0; + else zzL[shift]=0; + } + //--- + if((curlow=0; shift--) + { + zz[shift]=zzL[shift]; + res=zzH[shift]; + if(res!=0.0) zz[shift]=res; + } + + if (ExtLabel>0) // расставляем метки + { + for(shift=Bars-1; shift>=0; shift--) + { + + if (zz[shift]>0) + { + if (zzH[shift]>0) + { + peak=High[shift]; wrpeak=Low[shift]; + ha[shift]=High[shift]; la[shift]=0; + metka=2; shift--; + } + else + { + peak=Low[shift]; wrpeak=High[shift]; + la[shift]=Low[shift]; ha[shift]=0; + metka=1; shift--; + } + } + + if (metka==1) + { + if (wrpeakminSize*Point) {metka=0; ha[shift]=High[shift];} + } + else + { + wrpeak=High[shift]; + } + } + else if (metka==2) + { + if (wrpeak>Low[shift]) + { + if (peak-Low[shift]>minSize*Point) {metka=0; la[shift]=Low[shift];} + } + else + { + wrpeak=Low[shift]; + } + } + + } + } + + } + +void GetHigh(int start, int end, double price, int step) + { + int count=end-start; + if (count<=0) return; + int i=iHighest(NULL,0,MODE_HIGH,count+1,start); + double val=High[i]; + if ((val-price)>(minSize*Point)) + { + zzH[i]=val; + if (i==start) {GetLow(start+step,end-step,val,1-step); if (zzL[start-1]>0) zzL[start]=0; return;} + if (i==end) {GetLow(start+step,end-step,val,1-step); if (zzL[end+1]>0) zzL[end]=0; return;} + GetLow(start,i-1,val,0); + GetLow(i+1,end,val,0); + } + } + +void GetLow(int start, int end, double price, int step) + { + int count=end-start; + if (count<=0) return; + int i=iLowest(NULL,0,MODE_LOW,count+1,start); + double val=Low[i]; + if ((price-val)>(minSize*Point)) + { + zzL[i]=val; + if (i==start) {GetHigh(start+step,end-step,val,1-step); if (zzH[start-1]>0) zzH[start]=0; return;} + if (i==end) {GetHigh(start+step,end-step,val,1-step); if (zzH[end+1]>0) zzH[end]=0; return;} + GetHigh(start,i-1,val,0); + GetHigh(i+1,end,val,0); + } + } +//-------------------------------------------------------- +// ZigZag tauber. Конец. +//-------------------------------------------------------- + +//---------------------------------------------------- +// Свинги Ганна. Начало. +//---------------------------------------------------- +void GannSwing() + { + int i,n; + + // Переменные для Свингов Ганна + double lLast_m=0, hLast_m=0; + int countBarExt=0; // счетчик внешних баров + int countBarl=0,countBarh=0; + fs=0; ti=0; + +// lLast, hLast - минимум и максимум активного бара +// lLast_m, hLast_m - минимум и максимум "промежуточных" баров + + + ArrayInitialize(zz,0.0); + ArrayInitialize(zzL,0.0); + ArrayInitialize(zzH,0.0); + if (ExtLabel>0) + { + ArrayInitialize(la,0.0); + ArrayInitialize(ha,0.0); + } + + + +// cbi=Bars-IndicatorCounted()-1; +//--------------------------------- +// cbi=Bars-1; + if (ExtMaxBar>0) cbi=ExtMaxBar; else cbi=Bars-1; + for (i=cbi; i>=ExtMinBar; i--) + { +//------------------------------------------------- + // Устанавливаем начальные значения минимума и максимума бара + if (lLast==0) {lLast=Low[i]; hLast=High[i]; ai=i; bi=i;} + if (ti!=Time[i]) + { + ti=Time[i]; + if (lLast_m==0 && hLast_m==0) + { + if (lLast>Low[i] && hLastLow[i] && hLast>=High[i]) // Тенденция на текущем баре нисходящая + { + lLast_m=Low[i];hLast_m=0;countBarh=0;countBarExt=0; + if (fs!=2) countBarl++; + else {lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; bi=i; tbi=Time[i];} + } + } + else if (lLast_m>0 && hLast_m>0) // Внешний бар (предыдущий) + { + if (lLast_m>Low[i] && hLast_mLow[i] && hLast_m>=High[i]) // Тенденция на текущем баре нисходящая + { + lLast_m=Low[i];hLast_m=0;countBarh=0;countBarExt=0; + if (fs!=2) countBarl++; + else {lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; bi=i; tbi=Time[i];} + } + } + else if (lLast_m>0) + { + if (lLast_m>Low[i] && hLastLow[i] && hLast>=High[i]) // Тенденция на текущем баре нисходящая + { + lLast_m=Low[i];hLast_m=0;countBarh=0;countBarExt=0; + if (fs!=2) countBarl++; + else {lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; bi=i; tbi=Time[i];} + } + } + else if (hLast_m>0) + { + if (lLast>Low[i] && hLast_mLow[i] && hLast_m>=High[i]) // Тенденция на текущем баре нисходящая + { + lLast_m=Low[i];hLast_m=0;countBarh=0;countBarExt=0; + if (fs!=2) countBarl++; + else {lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; bi=i; tbi=Time[i];} + } + } + + // Определяем направление тренда. + if (fs==0) + { + if (lLasthLast_m) // внутренний бар + { + lLast=Low[i]; hLast=High[i]; ai=i; bi=i; countBarl=0;countBarh=0;countBarExt=0; + } + + if (countBarh>countBarl && countBarh>countBarExt && countBarh>minBars) + { + lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; + fs=1;countBarh=0;countBarl=0;countBarExt=0; + zz[bi]=Low[bi]; + zzL[bi]=Low[bi]; + zzH[bi]=0; + ai=i; + tai=Time[i]; + } + else if (countBarl>countBarh && countBarl>countBarExt && countBarl>minBars) + { + lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; + fs=2;countBarl=0;countBarh=0;countBarExt=0; + zz[ai]=High[ai]; + zzH[ai]=High[ai]; + zzL[ai]=0; + bi=i; + tbi=Time[i]; + } + } + else + { + if (lLast_m==0 && hLast_m==0) + { + countBarl=0;countBarh=0;countBarExt=0; + } + + // Тенденция восходящая + if (fs==1) + { + if (countBarl>countBarh && countBarl>countBarExt && countBarl>minBars) // Определяем точку смены тенденции. + { + // запоминаем значение направления тренда fs на предыдущем баре + ai=iBarShift(Symbol(),Period(),tai); + fs=2; + countBarl=0; + + zz[ai]=High[ai]; + zzH[ai]=High[ai]; + zzL[ai]=0; + bi=i; + if (ExtLabel>0) + { + ha[ai]=High[ai]; la[ai]=0; // простановка меток на максимумах + tml=Time[i]; ha[i]=0; la[i]=Low[i]; // простановка метки на нисходящем луче + } + tbi=Time[i]; + + lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; + + for (n=0;countBarExtHigh[i+n+1]) {countBarExt++; countBarh++; lLast=Low[i+n+1]; hLast=High[i+n+1]; hLast_m=High[i];} + else break; + } + + lLast=Low[i]; hLast=High[i]; + + } + } + + // Тенденция нисходящая + if (fs==2) + { + if (countBarh>countBarl && countBarh>countBarExt && countBarh>minBars) // Определяем точку смены тенденции. + { + // запоминаем значение направления тренда fs на предыдущем баре + bi=iBarShift(Symbol(),Period(),tbi); + fs=1; + countBarh=0; + + zz[bi]=Low[bi]; + zzL[bi]=Low[bi]; + zzH[bi]=0; + ai=i; + if (ExtLabel>0) + { + ha[bi]=0; la[bi]=Low[bi]; // простановка меток на минимумах + tmh=Time[i]; ha[i]=High[i]; la[i]=0; // простановка метки на восходящем луче + } + tai=Time[i]; + + lLast=Low[i]; hLast=High[i]; lLast_m=0; hLast_m=0; + + for (n=0;countBarExtHigh[i+n+1]) {countBarExt++; countBarl++; lLast=Low[i+n+1]; hLast=High[i+n+1]; lLast_m=Low[i];} + else break; + } + + lLast=Low[i]; hLast=High[i]; + + } + } + } + } + if (i==0) + { + if (hLast0) {ha[ai]=High[ai]; la[ai]=0;} // гуляющая метка + } + else if (lLast>Low[i] && fs==2) // Тенденция на текущем баре нисходящая + { + bi=i; tbi=Time[i]; zz[bi]=Low[bi]; zzL[bi]=Low[bi]; zzH[bi]=0; + if (ExtLabel>0) {la[bi]=Low[bi]; ha[bi]=0;} // гуляющая метка + } +//=================================================================================================== + + // Нулевой бар. Расчет первого луча ZigZag-a + ai0=iBarShift(Symbol(),Period(),tai); + bi0=iBarShift(Symbol(),Period(),tbi); + + if (bi0>1) if (fs==1) + { + for (n=bi0-1; n>=0; n--) {zzH[n]=0.0; zz[n]=0.0; if (ExtLabel>0) ha[n]=0;} + zz[ai0]=High[ai0]; zzH[ai0]=High[ai0]; zzL[ai0]=0.0; if (ExtLabel>0) ha[ai0]=High[ai0]; + } + if (ai0>1) if (fs==2) + { + for (n=ai0-1; n>=0; n--) {zzL[n]=0.0; zz[n]=0.0; if (ExtLabel>0) la[n]=0;} + zz[bi0]=Low[bi0]; zzL[bi0]=Low[bi0]; zzH[bi0]=0.0; if (ExtLabel>0) la[bi0]=Low[bi0]; + } + + if (ExtLabel>0) + { + if (fs==1) {aim=iBarShift(Symbol(),0,tmh); if (aim0) + { +// datetime nen_time=iTime(NULL,GrossPeriod,ExtMinBar); + datetime nen_time=iTime(NULL,GrossPeriod,0); + int i=0, j=0; // j - номер бара с максимальным максимумом (минимальным минимумом) в полоске nen-ZigZag + double nen_dt=0, last_j=0, last_nen=0; //last_j - значение максимального максимума (минимального минимума) в полоске nen_ZigZag + int limit, big_limit, bigshift=0; + + int i_metka=-1, i_metka_m=-1, k, m, jm; + bool fl_metka=false; + double last_jm=0, last_nen_m=0; + +// if (ExtLabel>0) metka=1; else metka=0; + if (ExtMaxBar>0) _maxbarZZ=ExtMaxBar; else _maxbarZZ=Bars; + + if (init_zz) + { + limit=_maxbarZZ-1; + big_limit=iBars(NULL,GrossPeriod)-1; + } + else + { + limit=iBarShift(NULL,0,afr[2]); + big_limit=iBarShift(NULL,GrossPeriod,afr[2]); + } + + while (bigshift=nen_time) + { + if (ExtIndicator==6) + { + if (ExtLabel>0) + { + ha[i]=iCustom(NULL,GrossPeriod,"ZigZag_new_nen4",minBars,ExtDeviation,ExtBackstep,1,1,bigshift); + la[i]=iCustom(NULL,GrossPeriod,"ZigZag_new_nen4",minBars,ExtDeviation,ExtBackstep,1,2,bigshift); + } + nen_ZigZag[i]=iCustom(NULL,GrossPeriod,"ZigZag_new_nen4",minBars,ExtDeviation,ExtBackstep,0,0,bigshift); + } + else if (ExtIndicator==7) + { + if (ExtLabel>0) + { + ha[i]=iCustom(NULL,GrossPeriod,"DT_ZZ_nen",minBars,1,1,bigshift); + la[i]=iCustom(NULL,GrossPeriod,"DT_ZZ_nen",minBars,1,2,bigshift); + } + nen_ZigZag[i]=iCustom(NULL,GrossPeriod,"DT_ZZ_nen",minBars,0,0,bigshift); + } + else if (ExtIndicator==8) nen_ZigZag[i]=iCustom(NULL,GrossPeriod,"CZigZag",minBars,ExtDeviation,0,bigshift); + else if (ExtIndicator==10) + { + if (ExtLabel>0) + { + ha[i]=iCustom(NULL,GrossPeriod,"Swing_ZZ_1",minBars,1,1,bigshift); + la[i]=iCustom(NULL,GrossPeriod,"Swing_ZZ_1",minBars,1,2,bigshift); + } + nen_ZigZag[i]=iCustom(NULL,GrossPeriod,"Swing_ZZ_1",minBars,1,0,bigshift); + } + i++; + } + else {bigshift++;nen_time=iTime(NULL,GrossPeriod,bigshift);} + } + + if (init_zz) // обработка истории + { + double i1=0, i2=0; + init_zz=false; + + for (i=limit;i>ExtMinBar;i--) // определение направления первого луча + { + if (nen_ZigZag[i]>0) + { + if (i1==0) i1=nen_ZigZag[i]; + else if (i1>0 && i1!=nen_ZigZag[i]) i2=nen_ZigZag[i]; + if (i2>0) + { + if (i1>i2) hi_nen=true; + else hi_nen=false; + break; + } + } + } + } + else // режим реального времени + { + if (afrl[2]>0) hi_nen=false; else hi_nen=true; + } + + for (i=limit;i>=0;i--) + { +// if (i0) + { + if (ExtLabel==2) + { + if (i_metka_m>=0 && !fl_metka) + { + m=i_metka_m-GrossPeriod/Period(); + + for (k=i_metka_m; k>m; k--) + { + ha[k]=0; la[k]=0; + } + + if (hi_nen) ha[jm]=last_nen_m; + else la[jm]=last_nen_m; + jm=0; last_nen_m=0; last_jm=0; i_metka_m=-1; + } + + if (i_metka<0) i_metka=i; + } + + fl_metka=true; + + if (nen_dt>0 && nen_dt!=nen_ZigZag[i]) + { + if (i_metka>=0 && fl_metka) + { + m=i_metka-GrossPeriod/Period(); + for (k=i_metka; k>m; k--) + { + ha[k]=0; la[k]=0; + } + if (hi_nen) ha[j]=last_nen; + else la[j]=last_nen; + i_metka=i; + } + + if (hi_nen) {hi_nen=false;zzH[j]=last_nen;} + else {hi_nen=true;zzL[j]=last_nen;} + last_j=0;nen_dt=0;zz[j]=last_nen; + } + + if (hi_nen) + { + nen_dt=nen_ZigZag[i]; + if (last_jLow[i]) {j=i;last_j=Low[i];last_nen=nen_ZigZag[i];} + } + + if (nen_dt>0 && i==0) // определение перелома на нулевом баре GrossPeriod + { + if (i_metka>=0 && fl_metka) + { + m=i_metka-GrossPeriod/Period(); + for (k=i_metka; k>m; k--) + { + ha[k]=0; la[k]=0; + } + if (hi_nen) ha[j]=last_nen; + else la[j]=last_nen; + fl_metka=false; + } + + zz[j]=last_nen; + if (hi_nen) zzH[j]=last_nen; else zzL[j]=last_nen; + } + } + else + { + if (last_j>0 && fl_metka) + { + if (i_metka>=0 && fl_metka) + { + m=i_metka-GrossPeriod/Period(); + + for (k=i_metka; k>m; k--) + { + ha[k]=0; la[k]=0; + } + if (hi_nen) ha[j]=last_nen; + else la[j]=last_nen; + } + + fl_metka=false; + + if (hi_nen) {hi_nen=false;zzH[j]=last_nen;} + else {hi_nen=true;zzL[j]=last_nen;} + last_j=0;nen_dt=0;zz[j]=last_nen; + i_metka=-1; + } + + if (ExtLabel==2) + { + if ((ha[i]>0 || la[i]>0) && !fl_metka) + { + + if (i_metka_m<0) + { + i_metka_m=i; jm=i; + if (hi_nen) + { + last_jm=High[i];last_nen_m=ha[i]; + } + else + { + last_jm=Low[i];last_nen_m=la[i]; + } + } + + if (hi_nen) + { + if (last_nen_m>last_jm) {jm=i;last_jm=High[i];} + } + else + { + if (last_nen_mzzbarhigh) {curbar=zzbarhigh; curpr=High[zzbarhigh];} + if(zzbarlow==zzbarhigh){curbar=zzbarlow;curpr=funk1(zzbarlow, n);} + + ArrayResize(Mbar,ExtPoint); + ArrayResize(Mprice,ExtPoint); + j=0; + endpr=curpr; + endbar=curbar; + Mbar[j]=curbar; + Mprice[j]=curpr; + + EP--; + if(curpr==Low[curbar]) flag=true; + else flag=false; + fl=flag; + + i=curbar+1; + while(EP>0) + { + if(flag) + { + while(i<=Bars-1) + { + curbar1=iHighest(NULL,0,MODE_HIGH,n,i); + curbar2=iHighest(NULL,0,MODE_HIGH,n,curbar1); + if(curbar1==curbar2){curbar=curbar1;curpr=High[curbar];flag=false;i=curbar+1;j++;break;} + else i=curbar2; + } + + Mbar[j]=curbar; + Mprice[j]=curpr; + EP--; + + } + + if(EP==0) break; + + if(!flag) + { + while(i<=Bars-1) + { + curbar1=iLowest(NULL,0,MODE_LOW,n,i); + curbar2=iLowest(NULL,0,MODE_LOW,n,curbar1); + if(curbar1==curbar2){curbar=curbar1;curpr=Low[curbar];flag=true;i=curbar+1;j++;break;} + else i=curbar2; + } + + Mbar[j]=curbar; + Mprice[j]=curpr; + EP--; + } + } + /* исправление вершин */ + if(Mprice[0]==Low[Mbar[0]])fd=true; else fd=false; + for(k=0;k<=ExtPoint-1;k++) + { + if(k==0) + { + if(fd==true) + { + Mbar[k]=iLowest(NULL,0,MODE_LOW,Mbar[k+1]-Mbar[k],Mbar[k]);Mprice[k]=Low[Mbar[k]];endbar=minBars; + } + if(fd==false) + { + Mbar[k]=iHighest(NULL,0,MODE_HIGH,Mbar[k+1]-Mbar[k],Mbar[k]);Mprice[k]=High[Mbar[k]];endbar=minBars; + } + } + if(k=0 && a=a; i--) {zzH[i]=zzH[i-a]; zzL[i]=zzL[i-a];} + for(;i>=0;i--) {zzH[i]=0; zzL[i]=0;} + } + } + else + { + ii=barz; + H1=ii+1; L1=ii; + H2=ii+3; L2=ii+2; + L2p=Low[L2];H2p=High[H2]; + L1p=Low[L1];H1p=High[H1]; + H3=H2; H3p=H2p; + L3=L2; L3p=L2p; + } + act_time=Time[1]; + + for(c=0; ii>=0; c++, ii--) + { +// if(c>tb) if(zzFill) zz[ii+mnm]=MathMax(zzL[ii+mnm],zzH[ii+mnm]); +// if(c>tb) if(zzFill) zz[ii]=MathMax(zzL[ii],zzH[ii]); + H=ii; L=ii; Hp= High[H]; Lp= Low[L]; + //------------------------------------------------------------------------------------- + if(H2=H1p ) + { + H1=H; H1p=Hp; + if( H1p>H2p ) + { + zzH[H2]=0; + H1=H; H1p=Hp; + H2=H1; H2p=H1p; + L1=H1; L1p=H1p; + zzH[H2]=H2p; + } + } + else if( Lp<=L1p ) + { + L1=L; L1p=Lp; + x=ray_value(L2,L2p,H2+(L2-H3)*0.5,H2p+(L2p-H3p)*0.5,L1); + if( L1p<=L2p//также работает L1p<=L2p*0.75+H2p*0.25 или любые другие условия + || tb*tb*Point<(H2p-L1p)*(H2-L1)) + { //сдвигаем все Low + L4=L3; L4p=L3p; + L3=L2; L3p=L2p; + L2=L1; L2p=L1p; + H1=L1; H1p=L1p; + zzL[L2]=L2p; + } + } + } + //-------------------------------------------------------------- + if(L2=H1p ) + { + H1=H; H1p=Hp; + x=ray_value(H2,H2p,L2+0.5*(H2-L3),L2p+0.5*(H2p-L3p),H1); + if( H1p>=H2p//можно и так: H1p>=H2p*0.75+L2p*0.25 + || tb*tb*Point<(H1p-L2p)*(L2-H1)) + { //сдвигаем все High + H4=H3; H4p=H3p; + H3=H2; H3p=H2p; + H2=H1; H2p=H1p; + L1=H1; L1p=H1p; + zzH[H2]=H2p; + } + } + + }//-------------------------------------------------------------------------------- + }//for + for(ii=bb-1; ii>=0; ii--) zz[ii]=MathMax(zzL[ii],zzH[ii]); +}//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° +// SQZZ by tovaroved.lv. Конец. +//--------------------------------------------------------======================================================================= + +//-------------------------------------------------------- +// ZZ_2L_nen . Начало. +//#property copyright "Copyright © 2007, wellx. ver 0.07 alpha" +//#property link "aveliks@gmail.com" +//-------------------------------------------------------- +void ZZ_2L_nen() + { + int count = IndicatorCounted(); + int k, i,shift,cnt, pos,curhighpos,curlowpos; + + if (Bars-count-1>2) + { + count=0; NewBarTime=0; countbars=0; realcnt=0; + ArrayInitialize(zz,0); ArrayInitialize(zzL,0); ArrayInitialize(zzH,0); + } + + for (k=(Bars-count-1);k>=0;k--) + { + +// Print("Prev-Bars :",Bars); + if(( NewBarTime==Time[0]) || (realcnt==Bars)) + first=false; + else first=true; + + + //-------------------------------------------------------------------- + //Находим первую точку индикатора + //-------------------------------------------------------------------- + if (first) + { + lastlowpos=Bars-1; + lasthighpos=Bars-1; + zzL[Bars-1]=0.0; + zzH[Bars-1]=0.0; + zz[Bars-1]=0.0; + realcnt=2; + + for(shift=(Bars-2); shift>=0; shift--) + { + if ((High[shift]>High[shift+1]) && (Low[shift]>=Low[shift+1])) + { + zzL[shift]=0.0; + zzH[shift]=High[shift]; + zz[shift]=High[shift]; + lasthighpos=shift; + lasthigh=High[shift]; + lastlow=Low[Bars-1]; + pos=shift; + first=false; + //Print("First ", Bars ," ",shift," ",zz[shift]," ",zzH[shift]," ",zzL[shift]); + break; + } + if ((High[shift]<=High[shift+1]) && (Low[shift]High[shift+1]) && (Low[shift](Low[shift+1]-Low[shift])) + { + zzL[shift]=0.0; + zzH[shift]=High[shift]; + zz[shift]=High[shift]; + zzL[shift]=0.0; + lasthighpos=shift; + lasthigh=High[shift]; + lastlow=Low[Bars-1]; + pos=shift; + first=false; + //Print("First ", Bars ," ",shift," ",zz[shift]," ",zzH[shift]," ",zzL[shift]); + break; + } + if ((High[shift]-High[shift+1])<(Low[shift+1]-Low[shift])) + { + zzL[shift]=Low[shift]; + zzH[shift]=0.0; + zz[shift]=Low[shift]; + lasthighpos=shift; + lasthigh=High[shift]; + lastlow=Low[Bars-1]; + pos=shift; + first=false; + //Print("First ", Bars ," ",shift," ",zz[shift]," ",zzH[shift]," ",zzL[shift]); + break; + } + if ((High[shift]-High[shift+1])==(Low[shift+1]-Low[shift])) + { + zzL[shift]=0.0; + zzH[shift]=0.0; + zz[shift]=0.0; + } + } + if ((High[shift]Low[shift+1])) + { + zzL[shift]=0.0; + zzH[shift]=0.0; + zz[shift]=0.0; + } + pos=shift; + realcnt=realcnt+1; + } +// Print("Start-Bars :",Bars," Realcnt ", realcnt, " Point " , Point); + + + //------------------------------------------------------------------------- + // здесь начинается отработка основного цикла ЗЗ + //------------------------------------------------------------------------- + + for(shift=pos-1; shift>=0; shift--) + { + if ((High[shift]>High[shift+1]) && (Low[shift]>=Low[shift+1])) + { + if (lasthighposHigh[lasthighpos]) + { + zzL[shift]=0.0; + zzH[shift]=High[shift]; + zz[shift]=High[shift]; + zz[lasthighpos]=0.0; + if (shift!=0) + lasthighpos=shift; + lasthigh=High[shift]; + if (lastlowpos!=Bars) + { + // Надо рассчитать позднее длины лучей + } + } + } + if (lasthighpos>lastlowpos) + { + if ((((High[shift]-Low[lastlowpos])>(StLevel*Point)) && ((lastlowpos-shift)>=minBars)) || + ((High[shift]-Low[lastlowpos])>=(BigLevel*Point))) + { + zzL[shift]=0.0; + zzH[shift]=High[shift]; + zz[shift]=High[shift]; + //zz[lasthighpos]=0.0; + if (shift!=0) + lasthighpos=shift; + lasthigh=High[shift]; + } + } + } + if ((High[shift]<=High[shift+1]) && (Low[shift]lasthighpos) + { + if ((((High[lasthighpos]-Low[shift])>(StLevel*Point)) && ((lasthighpos-shift)>=minBars)) || + ((High[lasthighpos]-Low[shift])>=(BigLevel*Point))) + { + zzL[shift]=Low[shift]; + zzH[shift]=0.0; + zz[shift]=Low[shift]; + //zz[lastlowpos]=0.0; + if (shift!=0) + lastlowpos=shift; + lastlow=Low[shift]; + } + } + } + if ((High[shift]>High[shift+1]) && (Low[shift]High[lasthighpos]) + { + zzL[shift]=0.0; + zzH[shift]=High[shift]; + zz[shift]=High[shift]; + zz[lasthighpos]=0.0; + if (shift!=0) + lasthighpos=shift; + lasthigh=High[shift]; + } + } + } + realcnt=realcnt+1; + // if (shift<=0) + //Print("Main ",shift," LastHighPos ",lasthighpos," LastHigh ",lasthigh," LastLowPos ", lastlowpos," LastLow ", lastlow , " ",zz[shift]," ",zzH[shift]," ",zzL[shift]); + } + + first=false; + countbars=Bars; + NewBarTime=Time[0]; + } + + //**************************************************************************************************** + // + // Обработка нулевого бара + // + //**************************************************************************************************** + else + //if (!first) + + { + if (realcnt!=Bars) + { + first=True; + return(0); + } + + if (Close[0]>=lasthigh) + { + if (lastlowposlastlow) + { + if ((((High[0]-Low[lastlowpos])>(StLevel*Point)) && ((lastlowpos)>=minBars)) || + ((High[0]-Low[lastlowpos])>(BigLevel*Point))) + { + zzL[0]=0.0; + zzH[0]=High[0]; + zz[0]=High[0]; + lasthigh=High[0]; + // lasthighpos=0; + //Print("H2 "); + } + } + } + if (lastlowpos>lasthighpos) + { + if (High[0]>=lasthigh) + { + zz[lasthighpos]=0.0; + zz[0]=High[0]; + zzL[0]=0.0; + zzH[0]=High[0]; + lasthighpos=0; + lasthigh=High[0]; + //Print("H3 "); + } + } + //lasthigh=High[0]; + } + if (Close[0]<=lastlow) + { + if (lastlowposlasthighpos) + { + if (High[0](StLevel*Point)) && ((lasthighpos-shift)>=minBars)) || + ((High[lasthighpos]-Low[shift])>(BigLevel*Point))) + { + zz[0]=Low[0]; + zzL[0]=Low[0]; + zzH[0]=0.0; + lastlow=Low[0]; + // lastlowpos=0; + //Print("L3 "); + } + } + } + //lastlow=Low[0]; + } + //Print( Bars," ", Open[0], " ", Low[0]," ",High[0]," ",Close[0]); + //Print("Zero ",0," LastHighPos ",lasthighpos," LastHigh ",lasthigh," LastLowPos ", lastlowpos," LastLow ", lastlow , " ",zz[0]," ",zzH[0]," ",zzL[0]); + //Print("Bars :",Bars); +// Print("Zero - Bars :",Bars," Realcnt ", realcnt); + } + + return(0); + } + + + } +//-------------------------------------------------------- +// ZZ_2L_nen . Конец. +//#property copyright "Copyright © 2007, wellx. ver 0.07 alpha" +//#property link "aveliks@gmail.com" +//-------------------------------------------------------- + + + +//-------------------------------------------------------- +// Индикатор i-vts . Начало. +//-------------------------------------------------------- +//+------------------------------------------------------------------+ +//| i-VTS.mq4 | +//| Тахир & KimIV | +//| http://www.kimiv.ru | +//| | +//| 06.12.2005 Индикатор VTS | +//+------------------------------------------------------------------+ +// +// Этот индикатор Игорь Ким перевел с MQL на MQ4 +// +void i_vts() // + { + int LoopBegin, sh; + + if (NumberOfBars==0) LoopBegin=Bars-1; + else LoopBegin=NumberOfBars-1; + LoopBegin=MathMin(Bars-25, LoopBegin); + + for (sh=LoopBegin; sh>=0; sh--) + { + GetValueVTS("", 0, NumberOfVTS, sh); + ha[sh]=ms[0]; + la[sh]=ms[1]; + } + } + +void i_vts1() // + { + int LoopBegin, sh; + + if (NumberOfBars==0) LoopBegin=Bars-1; + else LoopBegin=NumberOfBars-1; + LoopBegin=MathMin(Bars-25, LoopBegin); + + for (sh=LoopBegin; sh>=0; sh--) + { + GetValueVTS("", 0, NumberOfVTS1, sh); + ham[sh]=ms[0]; + lam[sh]=ms[1]; + } + } +//+------------------------------------------------------------------+ +//------- Поключение внешних модулей --------------------------------- +//+------------------------------------------------------------------+ +//| Параметры: | +//| sym - наименование инструмента | +//| tf - таймфрейм (количество минут) | +//| ng - номер группы | +//| nb - номер бара | +//| ms - массив сигналов | +//+------------------------------------------------------------------+ +void GetValueVTS(string sym, int tf, int ng, int nb) + { + if (sym=="") sym=Symbol(); + double f1, f2, s1, s2; + + f1=iClose(sym, tf, nb)-3*iATR(sym, tf, 10, nb); + f2=iClose(sym, tf, nb)+3*iATR(sym, tf, 10, nb); + for (int i=1; i<=ng; i++) + { + s1=iClose(sym, tf, nb+i)-3*iATR(sym, tf, 10, nb+i); + s2=iClose(sym, tf, nb+i)+3*iATR(sym, tf, 10, nb+i); + if (f1s2) f2=s2; + } + ms[0]=f2; // верхняя линия + ms[1]=f1; // нижняя линия + } +//+------------------------------------------------------------------+ +//-------------------------------------------------------- +// Индикатор i-vts . Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Параметры разных таймфреймов. Начало. +//-------------------------------------------------------- +void info_TF() + { + string info, info1, info2, info3, txt, regim, perc; + int i; + double pips; + + openTF[0]=iOpen(NULL,PERIOD_MN1,0); + closeTF[0]=iClose(NULL,PERIOD_MN1,0); + lowTF[0]=iLow(NULL,PERIOD_MN1,0); + highTF[0]=iHigh(NULL,PERIOD_MN1,0); + + openTF[1]=iOpen(NULL,PERIOD_W1,0); + closeTF[1]=iClose(NULL,PERIOD_W1,0); + lowTF[1]=iLow(NULL,PERIOD_W1,0); + highTF[1]=iHigh(NULL,PERIOD_W1,0); + + openTF[2]=iOpen(NULL,PERIOD_D1,0); + closeTF[2]=iClose(NULL,PERIOD_D1,0); + lowTF[2]=iLow(NULL,PERIOD_D1,0); + highTF[2]=iHigh(NULL,PERIOD_D1,0); + + openTF[3]=iOpen(NULL,PERIOD_H4,0); + closeTF[3]=iClose(NULL,PERIOD_H4,0); + lowTF[3]=iLow(NULL,PERIOD_H4,0); + highTF[3]=iHigh(NULL,PERIOD_H4,0); + + openTF[4]=iOpen(NULL,PERIOD_H1,0); + closeTF[4]=iClose(NULL,PERIOD_H1,0); + lowTF[4]=iLow(NULL,PERIOD_H1,0); + highTF[4]=iHigh(NULL,PERIOD_H1,0); + + if (StringSubstr(info_comment,2,1)=="1") + { + if (minPercent>0) perc=DoubleToStr(MathAbs(minPercent),1); else perc="0.0"; + switch (ExtIndicator) + { + case 0 : {regim=" | "+ ExtIndicator + " / " + minBars + " / " + ExtDeviation + " / " + ExtBackstep; break;} + case 1 : {regim=" | "+ ExtIndicator + " / " + minSize + " / " + perc+" %"; break;} + case 2 : {regim=" | "+ ExtIndicator + " / " + minBars + "/" + minSize; break;} + case 3 : {regim=" | "+ ExtIndicator + " / " + minBars; break;} + case 4 : {regim=" | "+ ExtIndicator + " / " + minSize; break;} + case 5 : {regim=" | "+ ExtIndicator + " / " + minBars; break;} + case 6 : {regim=" | "+ ExtIndicator + " / " + GrossPeriod + " / " + minBars + " / " + ExtDeviation + " / " + ExtBackstep; break;} + case 7 : {regim=" | "+ ExtIndicator + " / " + GrossPeriod + " / " + minBars; break;} + case 8 : {regim=" | "+ ExtIndicator + " / " + GrossPeriod + " / " + minBars + " / " + ExtDeviation; break;} + case 10 : {regim=" | "+ ExtIndicator + " / " + GrossPeriod + " / " + minBars; break;} + case 11 : {regim=" | "+ ExtIndicator + " / " + Depth + " / " + ExtDeviation + " / " + ExtBackstep; break;} + case 12 : {regim=" | "+ ExtIndicator + " / " + minSize; break;} + case 13 : {regim=" | "+ ExtIndicator + " / " + minBars + " / " + minSize; break;} + case 14 : {regim=" | "+ ExtIndicator + " / " + StLevel + " / " + BigLevel + " / " + minBars; break;} + } + } + info=""; + + if (StringSubstr(info_comment,0,1)=="1") + { + for (i=0;i<5;i++) + { + pips=(highTF[i]-lowTF[i])/Point; + if (pips>0) + { + if (openTF[i]==closeTF[i]) {txt=" = ";} + else if (openTF[i]!=closeTF[i] && MathAbs((highTF[i]-lowTF[i])/(openTF[i]-closeTF[i]))>=6.6) {txt=" -|- ";} + else if (openTF[i]>closeTF[i]) {txt=" \/ ";} + else if (openTF[i]0) + { + if (afrh[1]!=0) info1=info1+" "+DoubleToStr(100*MathAbs(afrh[1]-afrl[0])/afrh[1],2)+" %"; + } + else + { + if (afrl[1]!=0) info1=info1+" "+DoubleToStr(100*MathAbs(afrh[0]-afrl[1])/afrl[1],2)+" %"; + } + } + info1=info1+regim; + + if (StringSubstr(info_comment,3,1)=="1") + { + if (ExtGartleyTypeSearch==0) countGartley++; + if (RangeForPointD>0 && vNamePatternToNumberPattern != "") + { + info2=" It is found " + countGartley + " patterns - for pattern N " + NumberPattern + " - " + vBullBearToNumberPattern + " " + vNamePatternToNumberPattern + " - " + DoubleToStr(LevelForDminToNumberPattern,Digits) + " < Range of the prices D < " + DoubleToStr(LevelForDmaxToNumberPattern,Digits) + ""; + } + else info2=""; + } + + if (StringSubstr(info_comment,4,1)=="1") + { + if (info_RZS_RL=="") + { + info=""; + } + else + { + info="RL_Static="+info_RZS_RL + " "; + } + + info3=info; + + if (info_RZD_RL=="") + { + info3=info; + } + else + { + info3=info+"RL_Dinamic="+info_RZD_RL; + } + } + + Comment(info1,"\n",info2,"\n",""+info3); + close_TF=Close[0]; + } +//-------------------------------------------------------- +// Параметры разных таймфреймов. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Изменение размера массивов. Начало. +//-------------------------------------------------------- +void arrResize(int size) + { + ArrayResize(fi,size); + ArrayResize(fitxt,size); + ArrayResize(fitxt100,size); + } +//-------------------------------------------------------- +// Изменение размера массивов. Начало. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Создаем массивы с числами. Начало. +//-------------------------------------------------------- +void array_() + { + for (int i=0; i<65; i++) + { + numberFibo [i]=0; + numberPesavento [i]=0; + numberGartley [i]=0; + numberGilmorQuality [i]=0; + numberGilmorGeometric [i]=0; + numberGilmorHarmonic [i]=0; + numberGilmorArithmetic[i]=0; + numberGilmorGoldenMean[i]=0; + numberSquare [i]=0; + numberCube [i]=0; + numberRectangle [i]=0; + numberExt [i]=0; + } + + number [0]=0.111; + numbertxt [0]=".111"; + numberCube [0]=1; + + number [1]=0.125; + numbertxt [1]=".125"; + numberMix [1]=1; + numberGilmorHarmonic [1]=1; + + number [2]=0.146; + numbertxt [2]=".146"; + numberFibo [2]=1; + numberGilmorGeometric [2]=1; + + number [3]=0.167; + numbertxt [3]=".167"; + numberGilmorArithmetic[3]=1; + + number [4]=0.177; + numbertxt [4]=".177"; + numberGilmorHarmonic [4]=1; + numberSquare [4]=1; + + number [5]=0.186; + numbertxt [5]=".186"; + numberGilmorGeometric [5]=1; + + number [6]=0.192; + numbertxt [6]=".192"; + numberCube [6]=1; + + number [7]=0.2; + numbertxt [7]=".2"; + numberRectangle [7]=1; + + number [8]=0.236; + numbertxt [8]=".236"; + numberFibo [8]=1; + numberMix [8]=1; + numberGilmorGeometric [8]=1; + numberGilmorGoldenMean[8]=1; + + number [9]=0.25; + numbertxt [9]=".25"; + numberPesavento [9]=1; + numberGilmorQuality [9]=1; + numberGilmorHarmonic [9]=1; + numberSquare [9]=1; + + number [10]=0.3; + numbertxt [10]=".3"; + numberGilmorGeometric [10]=1; + numberGilmorGoldenMean[10]=1; + + number [11]=0.333; + numbertxt [11]=".333"; + numberGilmorArithmetic[11]=1; + numberCube [11]=1; + + number [12]=0.354; + numbertxt [12]=".354"; + numberGilmorHarmonic [12]=1; + numberSquare [12]=1; + + number [13]=0.382; + numbertxt [13]=".382"; + numberFibo [13]=1; + numberPesavento [13]=1; + numberGartley [13]=1; + numberGilmorQuality [13]=1; + numberGilmorGeometric [13]=1; + + number [14]=0.447; + numbertxt [14]=".447"; + numberGartley [14]=1; + numberRectangle [14]=1; + + number [15]=0.486; + numbertxt [15]=".486"; + numberGilmorGeometric [15]=1; + numberGilmorGoldenMean[15]=1; + + number [16]=0.5; + numbertxt [16]=".5"; + numberFibo [16]=1; + numberPesavento [16]=1; + numberGartley [16]=1; + numberGilmorQuality [16]=1; + numberGilmorHarmonic [16]=1; + numberSquare [16]=1; + + number [17]=0.526; + numbertxt [17]=".526"; + numberGilmorGeometric [17]=1; + + number [18]=0.577; + numbertxt [18]=".577"; + numberGilmorArithmetic[18]=1; + numberCube [18]=1; + + number [19]=0.618; + numbertxt [19]=".618"; + numberFibo [19]=1; + numberPesavento [19]=1; + numberGartley [19]=1; + numberGilmorQuality [19]=1; + numberGilmorGeometric [19]=1; + numberGilmorGoldenMean[19]=1; + + number [20]=0.667; + numbertxt [20]=".667"; + numberGilmorQuality [20]=1; + numberGilmorArithmetic[20]=1; + + number [21]=0.707; + numbertxt [21]=".707"; + numberPesavento [21]=1; + numberGartley [21]=1; + numberGilmorHarmonic [21]=1; + numberSquare [21]=1; + + number [22]=0.764; + numbertxt [22]=".764"; + numberFibo [22]=1; + + number [23]=0.786; + numbertxt [23]=".786"; + numberPesavento [23]=1; + numberGartley [23]=1; + numberGilmorQuality [23]=1; + numberGilmorGeometric [23]=1; + numberGilmorGoldenMean[23]=1; + + number [24]=0.809; + numbertxt [24]=".809"; + numberExt [24]=1; + + number [25]=0.841; + numbertxt [25]=".841"; + numberPesavento [25]=1; + + number [26]=0.854; + numbertxt [26]=".854"; + numberFibo [26]=1; + numberMix [26]=1; + + number [27]=0.874; + numbertxt [27]=".874"; + numberExt [27]=1; + + number [28]=0.886; + numbertxt [28]=".886"; + numberGartley [28]=1; + + number [29]=1.0; + numbertxt [29]="1."; + numberFibo [29]=1; + numberPesavento [29]=1; + numberGartley [29]=1; + numberGilmorQuality [29]=1; + numberGilmorGeometric [29]=1; + + number [30]=1.128; + numbertxt [30]="1.128"; + numberPesavento [30]=1; + numberGartley [30]=1; + + number [31]=1.236; + numbertxt [31]="1.236"; + numberFibo [31]=1; + + number [32]=1.272; + numbertxt [32]="1.272"; + numberPesavento [32]=1; + numberGartley [32]=1; + numberGilmorQuality [32]=1; + numberGilmorGeometric [32]=1; + numberGilmorGoldenMean[32]=1; + + number [33]=1.309; + numbertxt [33]="1.309"; + numberExt [33]=1; + + number [34]=1.414; + numbertxt [34]="1.414"; + numberPesavento [34]=1; + numberGartley [34]=1; + numberGilmorHarmonic [34]=1; + numberSquare [34]=1; + + number [35]=1.5; + numbertxt [35]="1.5"; +// numberPesavento [35]=1; + numberGilmorArithmetic[35]=1; + + number [36]=phi; + numbertxt [36]="1.618"; + numberFibo [36]=1; + numberPesavento [36]=1; + numberGartley [36]=1; + numberGilmorQuality [36]=1; + numberGilmorGeometric [36]=1; + numberGilmorGoldenMean[36]=1; + + number [37]=1.732; + numbertxt [37]="1.732"; + numberMix [37]=1; + numberGilmorQuality [37]=1; + numberGilmorArithmetic[37]=1; + numberCube [37]=1; + + number [38]=1.75; + numbertxt [38]="1.75"; + numberGilmorQuality [38]=1; + + number [39]=1.902; + numbertxt [39]="1.902"; + numberMix [39]=1; + numberGilmorGeometric [39]=1; + + number [40]=2.0; + numbertxt [40]="2."; + numberPesavento [40]=1; + numberGartley [40]=1; + numberGilmorQuality [40]=1; + numberGilmorHarmonic [40]=1; + numberSquare [40]=1; + + number [41]=2.058; + numbertxt [41]="2.058"; + numberGilmorGeometric [41]=1; + numberGilmorGoldenMean[41]=1; + + number [42]=2.236; + numbertxt [42]="2.236"; + numberGartley [42]=1; + numberGilmorQuality [42]=1; + numberRectangle [42]=1; + + number [43]=2.288; + numbertxt [43]="2.288"; + numberExt [43]=1; + + number [44]=2.5; + numbertxt [44]="2.5"; + numberGilmorQuality [44]=1; + + number [45]=2.618; + numbertxt [45]="2.618"; + numberPesavento [45]=1; + numberGartley [45]=1; + numberGilmorQuality [45]=1; + numberGilmorGeometric [45]=1; + numberGilmorGoldenMean[45]=1; + + number [46]=2.828; + numbertxt [46]="2.828"; + numberGilmorHarmonic [46]=1; + numberSquare [46]=1; + + number [47]=3.0; + numbertxt [47]="3.0"; + numberGilmorQuality [47]=1; + numberGilmorArithmetic[47]=1; + numberCube [47]=1; + + number [48]=3.142; + numbertxt [48]="3.142"; + numberGartley [48]=1; + + number [49]=3.236; + numbertxt [49]="3.236"; + numberExt [49]=1; + + number [50]=3.33; + numbertxt [50]="3.33"; + numberGilmorQuality [50]=1; + numberGilmorGeometric [50]=1; + numberGilmorGoldenMean[50]=1; + numberExt [50]=1; + + number [51]=3.464; + numbertxt [51]="3.464"; + numberExt [51]=1; + + number [52]=3.618; + numbertxt [52]="3.618"; + numberGartley [52]=1; + + number [53]=4.0; + numbertxt [53]="4."; + numberPesavento [53]=1; + numberGilmorHarmonic [53]=1; + numberSquare [53]=1; + + number [54]=4.236; + numbertxt [54]="4.236"; + numberFibo [54]=1; + numberGilmorQuality [54]=1; + numberGilmorGeometric [54]=1; + numberExt [54]=1; + + number [55]=4.472; + numbertxt [55]="4.472"; + numberExt [55]=1; + + number [56]=5.0; + numbertxt [56]="5."; + numberRectangle [56]=1; + + number [57]=5.2; + numbertxt [57]="5.2"; + numberCube [57]=1; + + number [58]=5.388; + numbertxt [58]="5.388"; + numberGilmorGeometric [58]=1; + + number [59]=5.657; + numbertxt [59]="5.657"; + numberGilmorHarmonic [59]=1; + numberSquare [59]=1; + + number [60]=6.0; + numbertxt [60]="6."; + numberGilmorArithmetic[60]=1; + + number [61]=6.854; + numbertxt [61]="6.854"; + numberGilmorQuality [61]=1; + numberGilmorGeometric [61]=1; + + number [62]=8.0; + numbertxt [62]="8."; + numberGilmorHarmonic [62]=1; + + number [63]=9.0; + numbertxt [63]="9."; + numberCube [63]=1; +/* + number []=; + numbertxt []=; + +// ExtFiboType=0 + numberFibo []=; +// 0 + numberPesavento []=; +// 1 + numberGartley []=; +// 2 + numberMix []=; +// 3 + numberGilmorQuality []=; +// 4 + numberGilmorGeometric []=; +// 5 + numberGilmorHarmonic []=; +// 6 + numberGilmorArithmetic[]=; +// 7 + numberGilmorGoldenMean[]=; +// 8 + numberSquare []=; +// 9 + numberCube []=; +// 10 + numberRectangle []=; +// 11 + numberExt []=; +*/ + } +//-------------------------------------------------------- +// Создаем массивы с числами. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Определение значений и цвета чисел для паттернов Песавенто. Начало. +//-------------------------------------------------------- +void Pesavento_patterns() + { + if (ExtFiboType==1) + { + switch (ExtFiboChoice) + { + case 0 : {search_number(numberPesavento, ExtPesavento) ;break;} + case 1 : {search_number(numberGartley, ExtGartley886) ;break;} + case 2 : {search_number(numberGartley, ExtGartley886) ;break;} + case 3 : {search_number(numberGilmorQuality, ExtPesavento) ;break;} + case 4 : {search_number(numberGilmorGeometric, ExtPesavento) ;break;} + case 5 : {search_number(numberGilmorHarmonic, ExtPesavento) ;break;} + case 6 : {search_number(numberGilmorArithmetic, ExtPesavento) ;break;} + case 7 : {search_number(numberGilmorGoldenMean, ExtPesavento) ;break;} + case 8 : {search_number(numberSquare, ExtPesavento) ;break;} + case 9 : {search_number(numberCube, ExtPesavento) ;break;} + case 10 : {search_number(numberRectangle, ExtPesavento) ;break;} + case 11 : {search_number(numberExt, ExtPesavento) ;break;} + } + } + else + { + search_number(numberFibo, ExtPesavento); + } + + } +//-------------------------------------------------------- +// Определение значений и цвета чисел для паттернов Песавенто. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Поиск числа для паттернов Песавенто. Начало. +//-------------------------------------------------------- +void search_number(int arr[], color cPattern) + { + int ki; + colorPPattern=ExtNotFibo; + if (ExtFiboChoice!=2) + { + if (ExtDeltaType==2) for (ki=kiPRZ;ki<=63;ki++) + { + if (arr[ki]>0) + { + if (MathAbs((number[ki]-kj)/number[ki])<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=cPattern; break;} + } + } + + if (ExtDeltaType==1) for (ki=kiPRZ;ki<=63;ki++) + { + if (arr[ki]>0) + { + if (MathAbs(number[ki]-kj)<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=cPattern; break;} + } + } + } + else + { + if (ExtDeltaType==2) for (ki=kiPRZ;ki<=63;ki++) + { + if (arr[ki]>0) + { + if (MathAbs((number[ki]-kj)/number[ki])<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=cPattern; break;} + } + else if (numberMix[ki]>0) + if (MathAbs((number[ki]-kj)/number[ki])<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=ExtPesavento; break;} + } + + if (ExtDeltaType==1) for (ki=kiPRZ;ki<=63;ki++) + { + if (arr[ki]>0) + { + if (MathAbs(number[ki]-kj)<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=cPattern; break;} + } + else if (numberMix[ki]>0) + if (MathAbs(number[ki]-kj)<=ExtDelta) + {kk=number[ki]; txtkk=numbertxt[ki]; k2=-1; colorPPattern=ExtPesavento; break;} + } + } + } +//-------------------------------------------------------- +// Поиск числа для паттернов Песавенто. Конец. +//-------------------------------------------------------- + +//-------------------------------------------------------- +// Отправка сообщения на электронную почту. Начало. +//-------------------------------------------------------- +void _SendMail(string subject, string some_text) + { + SendMail(subject, some_text); + } +//-------------------------------------------------------- +// Отправка сообщения на электронную почту. Конец. +//-------------------------------------------------------- + + +//-------------------------------------------------------- +// Преобразование строки в цвет. Начало. +// Функцию написал Integer. http://forum.mql4.com/ru/7134 +//-------------------------------------------------------- +color fStrToColor(string aName){ + + color tColor[]={ Black, DarkGreen, DarkSlateGray, Olive, Green, Teal, Navy, Purple, + Maroon, Indigo, MidnightBlue, DarkBlue, DarkOliveGreen, SaddleBrown, + ForestGreen, OliveDrab, SeaGreen, DarkGoldenrod, DarkSlateBlue, + Sienna, MediumBlue, Brown, DarkTurquoise, DimGray, LightSeaGreen, + DarkViolet, FireBrick, MediumVioletRed, MediumSeaGreen, Chocolate, + Crimson, SteelBlue, Goldenrod, MediumSpringGreen, LawnGreen, + CadetBlue, DarkOrchid, YellowGreen, LimeGreen, OrangeRed, DarkOrange, + Orange, Gold, Yellow, Chartreuse, Lime, SpringGreen, Aqua, DeepSkyBlue, + Blue, Magenta, Red, Gray, SlateGray, Peru, BlueViolet, LightSlateGray, + DeepPink, MediumTurquoise, DodgerBlue, Turquoise, RoyalBlue, SlateBlue, + DarkKhaki, IndianRed, MediumOrchid, GreenYellow, MediumAquamarine, + DarkSeaGreen, Tomato, RosyBrown, Orchid, MediumPurple, PaleVioletRed, + Coral, CornflowerBlue, DarkGray, SandyBrown, MediumSlateBlue, Tan, + DarkSalmon, BurlyWood, HotPink, Salmon, Violet, LightCoral, SkyBlue, + LightSalmon, Plum, Khaki, LightGreen, Aquamarine, Silver, LightSkyBlue, + LightSteelBlue, LightBlue, PaleGreen, Thistle, PowderBlue, PaleGoldenrod, + PaleTurquoise, LightGray, Wheat, NavajoWhite, Moccasin, LightPink, + Gainsboro, PeachPuff, Pink, Bisque, LightGoldenrod, BlanchedAlmond, + LemonChiffon, Beige, AntiqueWhite, PapayaWhip, Cornsilk, LightYellow, + LightCyan, Linen, Lavender, MistyRose, OldLace, WhiteSmoke, Seashell, + Ivory, Honeydew, AliceBlue, LavenderBlush, MintCream, Snow, White + }; + string tName[]={ "Black", "DarkGreen", "DarkSlateGray", "Olive", "Green", "Teal", "Navy", "Purple", + "Maroon", "Indigo", "MidnightBlue", "DarkBlue", "DarkOliveGreen", "SaddleBrown", + "ForestGreen", "OliveDrab", "SeaGreen", "DarkGoldenrod", "DarkSlateBlue", + "Sienna", "MediumBlue", "Brown", "DarkTurquoise", "DimGray", "LightSeaGreen", + "DarkViolet", "FireBrick", "MediumVioletRed", "MediumSeaGreen", "Chocolate", + "Crimson", "SteelBlue", "Goldenrod", "MediumSpringGreen", "LawnGreen", + "CadetBlue", "DarkOrchid", "YellowGreen", "LimeGreen", "OrangeRed", "DarkOrange", + "Orange", "Gold", "Yellow", "Chartreuse", "Lime", "SpringGreen", "Aqua", "DeepSkyBlue", + "Blue", "Magenta", "Red", "Gray", "SlateGray", "Peru", "BlueViolet", "LightSlateGray", + "DeepPink", "MediumTurquoise", "DodgerBlue", "Turquoise", "RoyalBlue", "SlateBlue", + "DarkKhaki", "IndianRed", "MediumOrchid", "GreenYellow", "MediumAquamarine", + "DarkSeaGreen", "Tomato", "RosyBrown", "Orchid", "MediumPurple", "PaleVioletRed", + "Coral", "CornflowerBlue", "DarkGray", "SandyBrown", "MediumSlateBlue", "Tan", + "DarkSalmon", "BurlyWood", "HotPink", "Salmon", "Violet", "LightCoral", "SkyBlue", + "LightSalmon", "Plum", "Khaki", "LightGreen", "Aquamarine", "Silver", "LightSkyBlue", + "LightSteelBlue", "LightBlue", "PaleGreen", "Thistle", "PowderBlue", "PaleGoldenrod", + "PaleTurquoise", "LightGray", "Wheat", "NavajoWhite", "Moccasin", "LightPink", + "Gainsboro", "PeachPuff", "Pink", "Bisque", "LightGoldenrod", "BlanchedAlmond", + "LemonChiffon", "Beige", "AntiqueWhite", "PapayaWhip", "Cornsilk", "LightYellow", + "LightCyan", "Linen", "Lavender", "MistyRose", "OldLace", "WhiteSmoke", "Seashell", + "Ivory", "Honeydew", "AliceBlue", "LavenderBlush", "MintCream", "Snow", "White" + }; + aName=StringTrimLeft(StringTrimRight(aName)); + for(int i=0;i0) counted_bars--; + limit=Bars-counted_bars; + for(i=1; i<=limit; i++) + { + counter=i; + Range=0; + AvgRange=0; + for(counter=i ;counter<=i+9;counter++) + { + // AvgRange=AvgRange+MathAbs(iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i)-iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i+1)); + AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); + } + Range=AvgRange/10; + fastMAnow=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i); + fastMAprevious=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i+1); + slowMAnow=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_SIGNAL, i); + slowMAprevious=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_SIGNAL, i+1); + CrossUp[i]=EMPTY_VALUE; + CrossDown[i]=EMPTY_VALUE; + if + (((show_KD_cross)&&(fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious))|| + ((show_K_OBOScross)&&(fastMAnow > OverSoldLevel) && (fastMAprevious < OverSoldLevel))|| + ((show_D_OBOScross)&&(slowMAnow > OverSoldLevel) && (slowMAprevious < OverSoldLevel)) ) + { + if (i==1 && flagval1==0) + { + flagval1=1; + flagval2=0; + if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); + if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); + } + CrossUp[i]=Low[i] - Range*0.5; + // CrossUp[i] = AvgRange; + CrossDown[i]=EMPTY_VALUE; + } + else if + (((show_KD_cross)&&(fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious))|| + ((show_K_OBOScross)&&(fastMAnow < OverBoughtLevel) && (fastMAprevious > OverBoughtLevel))|| + ((show_D_OBOScross)&&(slowMAnow < OverBoughtLevel) && (slowMAprevious > OverBoughtLevel)) ) + { + if (i==1 && flagval2==0) + { + flagval2=1; + flagval1=0; + if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); + if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); + } + CrossDown[i]=High[i] + Range*0.5; + // CrossDown[i] = AvgRange; + CrossUp[i]=EMPTY_VALUE; + } + } +//---- + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/adaptive adx.mq4 b/adaptive adx.mq4 new file mode 100644 index 0000000..ef01cf2 --- /dev/null +++ b/adaptive adx.mq4 @@ -0,0 +1,634 @@ +//+------------------------------------------------------------------+ +//| cfb adaptive wilders ADX | +//| mladen | +//+------------------------------------------------------------------+ +#property copyright "mladen" +#property link "mladenfx@gmail.com" + +#property indicator_separate_window +#property indicator_buffers 3 +#property indicator_color1 DeepSkyBlue +#property indicator_color2 LimeGreen +#property indicator_style2 STYLE_DOT +#property indicator_color3 Red +#property indicator_style3 STYLE_DOT +#property indicator_minimum 0 +#property indicator_level1 20 +#property indicator_levelcolor Gold + +// +// +// +// +// + +extern string TimeFrame = "Current time frame"; +extern int ShortLimit = 10; +extern int LongLimit = 20; +extern int CfbNormLength = 50; +extern int CfbDepth = 6; +extern int CfbPrice = PRICE_WEIGHTED; +extern int CfbSmooth = 8; +extern double CfbResultSmooth = 1.5; +extern double CfbResultSmoothPhase = 0.0; +extern bool CfbResultSmoothDouble = true; +extern double AdxPhase = 0; +extern bool AdxSmoothDouble = true; +extern double SmoothLength = 5.0; +extern double SmoothPhase = 0; +extern bool SmoothDouble = true; +extern int AdxPrice = PRICE_CLOSE; +extern int triggerlevel = 20; +extern bool Interpolate = true; + +extern bool alertsOn = true; +extern bool alertsOnCurrent = false; +extern bool alertsMessage = true; +extern bool alertsSound = false; +extern bool alertsEmail = false; + +// +// +// +// +// + +double adx[]; +double DIp[]; +double DIm[]; +double averageDIp[]; +double averageDIm[]; +double averageTR[]; +double cfb[]; +double trend[]; + +// +// +// +// + +string indicatorFileName; +bool calculateValue; +bool returnBars; +int timeFrame; + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +// +// +// +// +// + +int init() +{ + IndicatorBuffers(8); + SetIndexBuffer(0,adx); SetIndexLabel(0,"ADX"); + SetIndexBuffer(1,DIp); + SetIndexBuffer(2,DIm); + SetIndexBuffer(3,averageDIp); + SetIndexBuffer(4,averageDIm); + SetIndexBuffer(5,averageTR); + SetIndexBuffer(6,cfb); + SetIndexBuffer(7,trend); + for (int i=0;i<8;i++) SetIndexEmptyValue(i,0.00); + + // + // + // + // + // + + string PriceType; + switch(AdxPrice) + { + case PRICE_CLOSE: PriceType = "Close"; break; // 0 + case PRICE_OPEN: PriceType = "Open"; break; // 1 + case PRICE_HIGH: PriceType = "High"; break; // 2 + case PRICE_LOW: PriceType = "Low"; break; // 3 + case PRICE_MEDIAN: PriceType = "Median"; break; // 4 + case PRICE_TYPICAL: PriceType = "Typical"; break; // 5 + case PRICE_WEIGHTED: PriceType = "Weighted"; break; // 6 + } + + // + // + // + // + // + + indicatorFileName = WindowExpertName(); + calculateValue = (TimeFrame=="calculateValue"); if (calculateValue) return(0); + returnBars = (TimeFrame=="returnBars"); if (returnBars) return(0); + timeFrame = stringToTimeFrame(TimeFrame); + + // + // + // + // + // + + IndicatorShortName(timeFrameToString(timeFrame)+ " Cfb adaptive Adx ("+ShortLimit+","+LongLimit+")"); + return(0); +} + +// +// +// +// +// + +int deinit() { return(0); } + +//+------------------------------------------------------------------+ +//| | +//+------------------------------------------------------------------+ +// +// +// +// +// + +int start() +{ + int counted_bars=IndicatorCounted(); + int i,r,n,j,limit; + + if(counted_bars<0) return(-1); + if(counted_bars>0) counted_bars--; + limit = MathMin(Bars-counted_bars,Bars-1); + if (returnBars) { adx[0] = limit+1; return(0); } + + // + // + // + // + // + + if (calculateValue || timeFrame == Period()) + { + + // + // + // + // + // + // + + for(i=limit, r=Bars-i-1; i>=0; i--, r++) + { + + cfb[i] = iDSmooth(iCfb(Bars,iMA(NULL,0,1,0,MODE_SMA,CfbPrice,i),CfbDepth,CfbSmooth,r),CfbResultSmooth,CfbResultSmoothPhase,CfbResultSmoothDouble,i); + + // + // + // + // + // + + double cfbMax = cfb[i]; + double cfbMin = cfb[i]; + for (int k=1; k 0) + double ratio = (cfb[i]-cfbMin)/denominator; + else ratio = 0.5; + + // + // + // + // + // + + double AdxLength = MathCeil(ShortLimit+ratio*(LongLimit-ShortLimit)); + double sf = 1.0/AdxLength; + double currTR = MathMax(High[i],Close[i+1])-MathMin(Low[i],Close[i+1]); + double DeltaHi = High[i] - High[i+1]; + double DeltaLo = Low[i+1] - Low[i]; + double plusDM = 0.00; + double minusDM = 0.00; + + if ((DeltaHi > DeltaLo) && (DeltaHi > 0)) plusDM = DeltaHi; + if ((DeltaLo > DeltaHi) && (DeltaLo > 0)) minusDM = DeltaLo; + + // + // + // + // + // + + averageDIp[i] = averageDIp[i+1] + sf*(plusDM - averageDIp[i+1]); + averageDIm[i] = averageDIm[i+1] + sf*(minusDM - averageDIm[i+1]); + averageTR[i] = averageTR[i+1] + sf*(currTR - averageTR[i+1]); + + // + // + // + // + // + + DIp[i] = 0.00; + DIm[i] = 0.00; + if (averageTR[i] > 0) + { + DIp[i] = 100.0*iDSmooth(averageDIp[i],AdxLength,AdxPhase,AdxSmoothDouble,i,20)/averageTR[i]; + DIm[i] = 100.0*iDSmooth(averageDIm[i],AdxLength,AdxPhase,AdxSmoothDouble,i,40)/averageTR[i]; + } + + double DX; + if((DIp[i] + DIm[i])> 0) + DX = 100.00*iDSmooth(MathAbs(DIp[i] - DIm[i])/(DIp[i] + DIm[i]),SmoothLength,SmoothPhase,SmoothDouble,i,60); + else DX = 100.00*iDSmooth(0, SmoothLength,SmoothPhase,SmoothDouble,i,60); + + adx[i] = (adx[i+1])+ sf *(DX - adx[i+1]); + trend[i] = trend[i+1]; + + if (adx[i]>adx[i+1] && adx[i] > triggerlevel && DIp[i] > DIm[i]) trend[i]= 1; + if (adx[i]>adx[i+1] && adx[i] > triggerlevel && DIp[i] < DIm[i]) trend[i]=-1; + + } + + // + // + // + // + // + + manageAlerts(); + return(0); + } + + limit = MathMax(limit,MathMin(Bars,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period())); + for (i=limit;i>=0; i--) + { + int y = iBarShift(NULL,timeFrame,Time[i]); + adx[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",ShortLimit,LongLimit,CfbNormLength,CfbDepth,CfbPrice,CfbSmooth,CfbResultSmooth,CfbResultSmoothPhase,CfbResultSmoothDouble,AdxPhase,AdxSmoothDouble,SmoothLength,SmoothPhase,SmoothDouble,AdxPrice,triggerlevel,0,y); + DIp[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",ShortLimit,LongLimit,CfbNormLength,CfbDepth,CfbPrice,CfbSmooth,CfbResultSmooth,CfbResultSmoothPhase,CfbResultSmoothDouble,AdxPhase,AdxSmoothDouble,SmoothLength,SmoothPhase,SmoothDouble,AdxPrice,triggerlevel,1,y); + DIm[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",ShortLimit,LongLimit,CfbNormLength,CfbDepth,CfbPrice,CfbSmooth,CfbResultSmooth,CfbResultSmoothPhase,CfbResultSmoothDouble,AdxPhase,AdxSmoothDouble,SmoothLength,SmoothPhase,SmoothDouble,AdxPrice,triggerlevel,2,y); + trend[i] = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",ShortLimit,LongLimit,CfbNormLength,CfbDepth,CfbPrice,CfbSmooth,CfbResultSmooth,CfbResultSmoothPhase,CfbResultSmoothDouble,AdxPhase,AdxSmoothDouble,SmoothLength,SmoothPhase,SmoothDouble,AdxPrice,triggerlevel,7,y); + + // + // + // + // + // + + if (timeFrame <= Period() || y==iBarShift(NULL,timeFrame,Time[i-1])) continue; + if (!Interpolate) continue; + + // + // + // + // + // + + datetime time = iTime(NULL,timeFrame,y); + for(n = 1; i+n < Bars && Time[i+n] >= time; n++) continue; + double factor = 1.0 / n; + for(j = 1; j < n; j++) + { + adx[i+j]= j*factor*adx[i+n] + (1.0-j*factor)*adx[i]; + DIp[i+j]= j*factor*DIp[i+n] + (1.0-j*factor)*DIp[i]; + DIm[i+j]= j*factor*DIm[i+n] + (1.0-j*factor)*DIm[i]; + + } + } + + manageAlerts(); + + return(0); +} +//+------------------------------------------------------------------ +//| +//+------------------------------------------------------------------ +// +// + +int Depths[] = {2,3,4,6,8,12,16,24,32,48,64,96,128,192}; +double workCfb[][28]; + +// +// +// +// +// + +double iCfb(int totalBars, double price, int depth, int smooth, int i) +{ + if (ArrayRange(workCfb,0) != totalBars) ArrayResize(workCfb,totalBars); + + // + // + // + // + // + + double suma = 0; + double sumb = 0; + double cfb = 0; + double evenCoef = 1; + double oddCoef = 1; + double avg = 0; + + if (i>=smooth) + for (int k=depth-1; k>=0; k--) + { + workCfb[i][k] = iCfbFunc(totalBars,price,i,Depths[k],k); + workCfb[i][k+14] = workCfb[i-1][k+14] + (workCfb[i][k]-workCfb[i-smooth][k])/smooth; + + if ((k%2)==0) + { avg = oddCoef * workCfb[i][k+14]; oddCoef = oddCoef * (1 - avg); } + else { avg = evenCoef * workCfb[i][k+14]; evenCoef = evenCoef * (1 - avg); } + + suma += avg*avg*Depths[k]; + sumb += avg; + } + else for (k=depth-1; k>=0; k--) { workCfb[i][k] = 0; workCfb[i][k+14] = 0; } + + // + // + // + // + // + + if (sumb != 0) cfb = suma/sumb; + return(cfb); +} + +//+------------------------------------------------------------------ +//| +//+------------------------------------------------------------------ +// +// +// +// +// + +double workCfbFunc[][70]; +#define _prices 0 +#define _roc 1 +#define _value1 2 +#define _value2 3 +#define _value3 4 + +// +// +// +// + +double iCfbFunc(int totalBars, double price, int r, int depth, int k) +{ + k *= 5; + if (ArrayRange(workCfbFunc,0) != totalBars) ArrayResize(workCfbFunc,totalBars); + if (r<=(depth+1)) + { + workCfbFunc[r][k+_prices] = 0; + workCfbFunc[r][k+_roc] = 0; + workCfbFunc[r][k+_value1] = 0; + workCfbFunc[r][k+_value2] = 0; + workCfbFunc[r][k+_value3] = 0; + return(0); + } + workCfbFunc[r][k+_prices] = price; + + // + // + // + // + // + + workCfbFunc[r][k+_roc] = MathAbs(workCfbFunc[r][k+_prices] - workCfbFunc[r-1][k+_prices]); + workCfbFunc[r][k+_value1] = workCfbFunc[r-1][k+_value1] - workCfbFunc[r-depth][k+_roc] + workCfbFunc[r][k+_roc]; + workCfbFunc[r][k+_value2] = workCfbFunc[r-1][k+_value2] - workCfbFunc[r-1][k+_value1] + workCfbFunc[r][k+_roc]*depth; + workCfbFunc[r][k+_value3] = workCfbFunc[r-1][k+_value3] - workCfbFunc[r-1-depth][k+_prices] + workCfbFunc[r-1][k+_prices]; + + double dividend = MathAbs(depth*workCfbFunc[r][k+_prices]-workCfbFunc[r][k+_value3]); + + // + // + // + // + // + + if (workCfbFunc[r][k+_value2] != 0) + return( dividend / workCfbFunc[r][k+_value2]); + else return(0.00); +} + +//+------------------------------------------------------------------ +//| +//+------------------------------------------------------------------ +// +// +// +// +// + +double wrk[][80]; + +#define bsmax 5 +#define bsmin 6 +#define volty 7 +#define vsum 8 +#define avolty 9 + +// +// +// +// +// + +double iDSmooth(double price, double length, double phase, bool isDouble, int i, int s=0) +{ + if (isDouble) + return (iSmooth(iSmooth(price,MathSqrt(length),phase,i,s),MathSqrt(length),phase,i,s+10)); + else return (iSmooth(price,length,phase,i,s)); +} + +// +// +// +// +// + +double iSmooth(double price, double length, double phase, int i, int s=0) +{ + if (length <=1) return(price); + if (ArrayRange(wrk,0) != Bars) ArrayResize(wrk,Bars); + + int r = Bars-i-1; + if (r==0) { for(int k=0; k<7; k++) wrk[r][k+s]=price; for(; k<10; k++) wrk[r][k+s]=0; return(price); } + + // + // + // + // + // + + double len1 = MathMax(MathLog(MathSqrt(0.5*(length-1)))/MathLog(2.0)+2.0,0); + double pow1 = MathMax(len1-2.0,0.5); + double del1 = price - wrk[r-1][bsmax+s]; + double del2 = price - wrk[r-1][bsmin+s]; + double div = 1.0/(10.0+10.0*(MathMin(MathMax(length-10,0),100))/100); + int forBar = MathMin(r,10); + + wrk[r][volty+s] = 0; + if(MathAbs(del1) > MathAbs(del2)) wrk[r][volty+s] = MathAbs(del1); + if(MathAbs(del1) < MathAbs(del2)) wrk[r][volty+s] = MathAbs(del2); + wrk[r][vsum+s] = wrk[r-1][vsum+s] + (wrk[r][volty+s]-wrk[r-forBar][volty+s])*div; + + // + // + // + // + // + + wrk[r][avolty+s] = wrk[r-1][avolty+s]+(2.0/(MathMax(4.0*length,30)+1.0))*(wrk[r][vsum+s]-wrk[r-1][avolty+s]); + if (wrk[r][avolty+s] > 0) + double dVolty = wrk[r][volty+s]/wrk[r][avolty+s]; else dVolty = 0; + if (dVolty > MathPow(len1,1.0/pow1)) dVolty = MathPow(len1,1.0/pow1); + if (dVolty < 1) dVolty = 1.0; + + // + // + // + // + // + + double pow2 = MathPow(dVolty, pow1); + double len2 = MathSqrt(0.5*(length-1))*len1; + double Kv = MathPow(len2/(len2+1), MathSqrt(pow2)); + + if (del1 > 0) wrk[r][bsmax+s] = price; else wrk[r][bsmax+s] = price - Kv*del1; + if (del2 < 0) wrk[r][bsmin+s] = price; else wrk[r][bsmin+s] = price - Kv*del2; + + // + // + // + // + // + + double R = MathMax(MathMin(phase,100),-100)/100.0 + 1.5; + double beta = 0.45*(length-1)/(0.45*(length-1)+2); + double alpha = MathPow(beta,pow2); + + wrk[r][0+s] = price + alpha*(wrk[r-1][0+s]-price); + wrk[r][1+s] = (price - wrk[r][0+s])*(1-beta) + beta*wrk[r-1][1+s]; + wrk[r][2+s] = (wrk[r][0+s] + R*wrk[r][1+s]); + wrk[r][3+s] = (wrk[r][2+s] - wrk[r-1][4+s])*MathPow((1-alpha),2) + MathPow(alpha,2)*wrk[r-1][3+s]; + wrk[r][4+s] = (wrk[r-1][4+s] + wrk[r][3+s]); + + // + // + // + // + // + + return(wrk[r][4+s]); +} + +// +// +// +// +// + +string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"}; +int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200}; + +// +// +// +// +// + +int stringToTimeFrame(string tfs) +{ + tfs = stringUpperCase(tfs); + for (int i=ArraySize(iTfTable)-1; i>=0; i--) + if (tfs==sTfTable[i] || tfs==""+iTfTable[i]) return(MathMax(iTfTable[i],Period())); + return(Period()); +} +string timeFrameToString(int tf) +{ + for (int i=ArraySize(iTfTable)-1; i>=0; i--) + if (tf==iTfTable[i]) return(sTfTable[i]); + return(""); +} + +// +// +// +// +// + +string stringUpperCase(string str) +{ + string s = str; + + for (int length=StringLen(str)-1; length>=0; length--) + { + int char = StringGetChar(s, length); + if((char > 96 && char < 123) || (char > 223 && char < 256)) + s = StringSetChar(s, length, char - 32); + else if(char > -33 && char < 0) + s = StringSetChar(s, length, char + 224); + } + return(s); +} + +// +// +// +// +// + +void manageAlerts() +{ + if (!calculateValue && alertsOn) + { + if (alertsOnCurrent) + int whichBar = 0; + else whichBar = 1; whichBar = iBarShift(NULL,0,iTime(NULL,timeFrame,whichBar)); + if (trend[whichBar] != trend[whichBar+1]) + { + if (trend[whichBar] == 1) doAlert(whichBar,"up"); + if (trend[whichBar] == -1) doAlert(whichBar,"down"); + } + } +} + +// +// +// +// +// + +void doAlert(int forBar, string doWhat) +{ + static string previousAlert="nothing"; + static datetime previousTime; + string message; + + if (previousAlert != doWhat || previousTime != Time[forBar]) { + previousAlert = doWhat; + previousTime = Time[forBar]; + + // + // + // + // + // + + message = StringConcatenate(Symbol()," ",timeFrameToString(timeFrame)," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," cfb adx changed direction to ",doWhat); + if (alertsMessage) Alert(message); + if (alertsEmail) SendMail(StringConcatenate(Symbol()," cfb adx "),message); + if (alertsSound) PlaySound("alert2.wav"); + } +} + diff --git a/ccDynamic_Trend_Multi_Currency_v4.mq4 b/ccDynamic_Trend_Multi_Currency_v4.mq4 new file mode 100644 index 0000000..511b65f --- /dev/null +++ b/ccDynamic_Trend_Multi_Currency_v4.mq4 @@ -0,0 +1,3409 @@ +/* + Generated by EX4-TO-MQ4 decompiler ONE FILE V4.0.218.3 + EX4 ID : 04E20A41724C2645BAEB3FDF008C44EC + Website: http://purebeam.biz + E-mail : purebeam@gmail.com +*/ +#property copyright "Copyright © 2007, cja Trading" +#property link "ccjjaa@gmail.com" + +#property indicator_chart_window + +extern int Dynamic_Number = 789789; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern string Please_NOTE__Currency_Symbol = " must be EURUSD not eurusd"; +extern string Currency_Symbol = ""; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern int BarsShift_Side = 0; +extern int BarsShift_UP_DN = 20; +extern int WindowToUse = 0; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$ = "Title & Border Color Settings"; +extern color Border_color = SlateGray; +extern color BackGround_color = Black; +extern color Currency_color = DarkOrange; +extern color PeriodTitles_color = Silver; +extern color DynamicTitle_color = Gray; +extern color DottedSeparator_color = SlateGray; +extern string $$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern string $$$$$$$$$$$$$$$$$$$$$$ = "AutoUP Bar Color Settings"; +extern string NOTE_Auto_UPColors_avaliable = "* Lime * Olive * SeaGreen * Gray"; +extern string _ = "* RoyalBlue * Blue * Gold"; +extern color AutoUP_color = Lime; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern string $$$$$$$$$$$$$$$$$$$$$ = "AutoDN Bar Color Settings"; +extern string NOTE_Auto_DNColors_avaliable = "* Red * Magenta * RoyalBlue * Gray"; +extern string _. = "* MediumVioletRed * Blue * Orange"; +extern color AutoDN_color = Red; +extern string $$$$$$$$$$$$$$$$$$$$$$$$$$$$ = "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"; +extern string $$$$$$$$$$$$$$$$$$$$$$$ = "Manual Bar Color Settings"; +extern color UPcolor_1 = Lime; +extern color UPcolor_2 = Lime; +extern color UPcolor_3 = Lime; +extern color UPcolor_4 = C'0x00,0xDC,0x00'; +extern color UPcolor_5 = C'0x00,0xC8,0x00'; +extern color UPcolor_6 = C'0x00,0xA0,0x00'; +extern color UPcolor_7 = C'0x00,0x82,0x00'; +extern color UPcolor_8 = DarkGreen; +extern color UPcolor_9 = C'0x00,0x50,0x00'; +extern color DNcolor_1 = Red; +extern color DNcolor_2 = Red; +extern color DNcolor_3 = Red; +extern color DNcolor_4 = Red; +extern color DNcolor_5 = C'0xDC,0x00,0x00'; +extern color DNcolor_6 = C'0xB4,0x00,0x00'; +extern color DNcolor_7 = C'0x96,0x00,0x00'; +extern color DNcolor_8 = C'0x78,0x00,0x00'; +extern color DNcolor_9 = C'0x64,0x00,0x00'; +extern color EQUALcolor = Silver; +int gi_328; +string gs_dummy_332; +double g_color_340; + +int CreateDynamic(string a_name_0, int a_y_8, int a_x_12) { + ObjectCreate(a_name_0, OBJ_LABEL, WindowToUse, 0, 0); + ObjectSet(a_name_0, OBJPROP_CORNER, 0); + ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_12); + ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_8); + ObjectSet(a_name_0, OBJPROP_BACK, FALSE); + return (0); +} + +int CreateDyAlert(string a_name_0, int a_x_8, int a_y_12) { + ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0); + ObjectSet(a_name_0, OBJPROP_CORNER, 0); + ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8); + ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12); + ObjectSet(a_name_0, OBJPROP_BACK, FALSE); + return (0); +} + +int init() { + if (AutoUP_color == Blue) { + UPcolor_1 = C'0x6E,0x6E,0xFF'; + UPcolor_2 = C'0x5E,0x5E,0xFF'; + UPcolor_3 = C'0x4A,0x4A,0xFF'; + UPcolor_4 = C'0x36,0x36,0xFF'; + UPcolor_5 = Blue; + UPcolor_6 = C'0x00,0x00,0xDC'; + UPcolor_7 = C'0x00,0x00,0xBE'; + UPcolor_8 = C'0x00,0x00,0xA0'; + UPcolor_9 = C'0x00,0x00,0x8C'; + } + if (AutoDN_color == Blue) { + DNcolor_1 = C'0x6E,0x6E,0xFF'; + DNcolor_2 = C'0x5E,0x5E,0xFF'; + DNcolor_3 = C'0x4A,0x4A,0xFF'; + DNcolor_4 = C'0x36,0x36,0xFF'; + DNcolor_5 = Blue; + DNcolor_6 = C'0x00,0x00,0xDC'; + DNcolor_7 = C'0x00,0x00,0xBE'; + DNcolor_8 = C'0x00,0x00,0xA0'; + DNcolor_9 = C'0x00,0x00,0x8C'; + } + if (AutoUP_color == SeaGreen) { + UPcolor_1 = C'0x66,0xCC,0x94'; + UPcolor_2 = C'0x54,0xC7,0x88'; + UPcolor_3 = C'0x46,0xC1,0x7D'; + UPcolor_4 = C'0x3C,0xB5,0x72'; + UPcolor_5 = C'0x37,0xA8,0x6A'; + UPcolor_6 = C'0x31,0x93,0x5C'; + UPcolor_7 = C'0x2C,0x7E,0x53'; + UPcolor_8 = C'0x26,0x6E,0x49'; + UPcolor_9 = C'0x22,0x5F,0x3F'; + } + if (AutoUP_color == Gold) { + UPcolor_1 = Gold; + UPcolor_2 = Gold; + UPcolor_3 = Gold; + UPcolor_4 = C'0xDC,0xBE,0x00'; + UPcolor_5 = C'0xD2,0xB4,0x00'; + UPcolor_6 = C'0xB4,0xA0,0x00'; + UPcolor_7 = C'0xA0,0x82,0x00'; + UPcolor_8 = C'0x82,0x6E,0x00'; + UPcolor_9 = C'0x6E,0x5A,0x00'; + } + if (AutoDN_color == Orange) { + DNcolor_1 = C'0xFF,0xBE,0x3C'; + DNcolor_2 = C'0xFF,0xB4,0x1E'; + DNcolor_3 = C'0xFF,0xAA,0x0D'; + DNcolor_4 = C'0xFF,0x96,0x0B'; + DNcolor_5 = C'0xFF,0x82,0x09'; + DNcolor_6 = C'0xF0,0x78,0x00'; + DNcolor_7 = C'0xDC,0x6E,0x00'; + DNcolor_8 = C'0xBE,0x5A,0x00'; + DNcolor_9 = C'0x96,0x46,0x00'; + } + if (AutoUP_color == Gray) { + UPcolor_1 = C'0xB4,0xB4,0xB4'; + UPcolor_2 = C'0xA5,0xA5,0xA5'; + UPcolor_3 = C'0x96,0x96,0x96'; + UPcolor_4 = C'0x87,0x87,0x87'; + UPcolor_5 = C'0x78,0x78,0x78'; + UPcolor_6 = DimGray; + UPcolor_7 = C'0x5A,0x5A,0x5A'; + UPcolor_8 = C'0x4B,0x4B,0x4B'; + UPcolor_9 = C'0x3C,0x3C,0x3C'; + } + if (AutoDN_color == Gray) { + DNcolor_1 = C'0xB4,0xB4,0xB4'; + DNcolor_2 = C'0xA5,0xA5,0xA5'; + DNcolor_3 = C'0x96,0x96,0x96'; + DNcolor_4 = C'0x87,0x87,0x87'; + DNcolor_5 = C'0x78,0x78,0x78'; + DNcolor_6 = DimGray; + DNcolor_7 = C'0x5A,0x5A,0x5A'; + DNcolor_8 = C'0x4B,0x4B,0x4B'; + DNcolor_9 = C'0x3C,0x3C,0x3C'; + } + if (AutoUP_color == RoyalBlue) { + UPcolor_1 = C'0x98,0xAE,0xEF'; + UPcolor_2 = C'0x8B,0xA4,0xED'; + UPcolor_3 = C'0x7E,0x9A,0xEB'; + UPcolor_4 = C'0x66,0x87,0xE8'; + UPcolor_5 = C'0x52,0x77,0xE4'; + UPcolor_6 = C'0x42,0x6A,0xE1'; + UPcolor_7 = C'0x2E,0x5A,0xDE'; + UPcolor_8 = C'0x20,0x4B,0xCC'; + UPcolor_9 = C'0x1B,0x3E,0xA7'; + } + if (AutoDN_color == RoyalBlue) { + DNcolor_1 = C'0x98,0xAE,0xEF'; + DNcolor_2 = C'0x8B,0xA4,0xED'; + DNcolor_3 = C'0x7E,0x9A,0xEB'; + DNcolor_4 = C'0x66,0x87,0xE8'; + DNcolor_5 = C'0x52,0x77,0xE4'; + DNcolor_6 = C'0x42,0x6A,0xE1'; + DNcolor_7 = C'0x2E,0x5A,0xDE'; + DNcolor_8 = C'0x20,0x4B,0xCC'; + DNcolor_9 = C'0x1B,0x3E,0xA7'; + } + if (AutoDN_color == MediumVioletRed) { + DNcolor_1 = C'0xEE,0x60,0xB9'; + DNcolor_2 = C'0xEA,0x37,0xA7'; + DNcolor_3 = C'0xDB,0x17,0x92'; + DNcolor_4 = C'0xC4,0x15,0x83'; + DNcolor_5 = C'0xB3,0x13,0x77'; + DNcolor_6 = C'0x9F,0x11,0x6A'; + DNcolor_7 = C'0x8C,0x0F,0x5E'; + DNcolor_8 = C'0x7C,0x0D,0x52'; + DNcolor_9 = C'0x68,0x0C,0x47'; + } + if (AutoUP_color == Olive) { + UPcolor_1 = C'0xDF,0xDF,0x00'; + UPcolor_2 = C'0xCB,0xCB,0x00'; + UPcolor_3 = C'0xB7,0xB7,0x00'; + UPcolor_4 = C'0xA3,0xA3,0x00'; + UPcolor_5 = C'0x8F,0x8F,0x00'; + UPcolor_6 = C'0x7B,0x7B,0x00'; + UPcolor_7 = C'0x67,0x67,0x00'; + UPcolor_8 = C'0x53,0x53,0x00'; + UPcolor_9 = C'0x3F,0x3F,0x00'; + } + if (AutoDN_color == Fuchsia) { + DNcolor_1 = C'0xFF,0xA0,0xFF'; + DNcolor_2 = C'0xFF,0x82,0xFF'; + DNcolor_3 = C'0xFF,0x64,0xFF'; + DNcolor_4 = C'0xFF,0x50,0xFF'; + DNcolor_5 = C'0xFA,0x00,0xFA'; + DNcolor_6 = C'0xDC,0x00,0xDC'; + DNcolor_7 = C'0xBE,0x00,0xBE'; + DNcolor_8 = C'0xA0,0x00,0xA0'; + DNcolor_9 = C'0x82,0x00,0x82'; + } + return (0); +} + +int deinit() { + ObjectDelete("ALLTrend_UP"); + ObjectDelete("ALLTrend_DOWN"); + ObjectDelete("SIG_LEVEL" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_1" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_2" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_3" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_4" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_5" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_6" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_7" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_8" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_9" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_10" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_11" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_12" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_13" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_14" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_15" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_16" + Dynamic_Number); + ObjectDelete("SIG_LEVEL_17" + Dynamic_Number); + ObjectDelete("H4_LEVEL" + Dynamic_Number); + ObjectDelete("H4_LEVEL_1" + Dynamic_Number); + ObjectDelete("H4_LEVEL_2" + Dynamic_Number); + ObjectDelete("H4_LEVEL_3" + Dynamic_Number); + ObjectDelete("H4_LEVEL_4" + Dynamic_Number); + ObjectDelete("H4_LEVEL_5" + Dynamic_Number); + ObjectDelete("H4_LEVEL_6" + Dynamic_Number); + ObjectDelete("H4_LEVEL_7" + Dynamic_Number); + ObjectDelete("H4_LEVEL_8" + Dynamic_Number); + ObjectDelete("H4_LEVEL_9" + Dynamic_Number); + ObjectDelete("H4_LEVEL_10" + Dynamic_Number); + ObjectDelete("H4_LEVEL_11" + Dynamic_Number); + ObjectDelete("H4_LEVEL_12" + Dynamic_Number); + ObjectDelete("H4_LEVEL_13" + Dynamic_Number); + ObjectDelete("H4_LEVEL_14" + Dynamic_Number); + ObjectDelete("H4_LEVEL_15" + Dynamic_Number); + ObjectDelete("H4_LEVEL_16" + Dynamic_Number); + ObjectDelete("H4_LEVEL_17" + Dynamic_Number); + ObjectDelete("M30_LEVEL" + Dynamic_Number); + ObjectDelete("M30_LEVEL_1" + Dynamic_Number); + ObjectDelete("M30_LEVEL_2" + Dynamic_Number); + ObjectDelete("M30_LEVEL_3" + Dynamic_Number); + ObjectDelete("M30_LEVEL_4" + Dynamic_Number); + ObjectDelete("M30_LEVEL_5" + Dynamic_Number); + ObjectDelete("M30_LEVEL_6" + Dynamic_Number); + ObjectDelete("M30_LEVEL_7" + Dynamic_Number); + ObjectDelete("M30_LEVEL_8" + Dynamic_Number); + ObjectDelete("M30_LEVEL_9" + Dynamic_Number); + ObjectDelete("M30_LEVEL_10" + Dynamic_Number); + ObjectDelete("M30_LEVEL_11" + Dynamic_Number); + ObjectDelete("M30_LEVEL_12" + Dynamic_Number); + ObjectDelete("M30_LEVEL_13" + Dynamic_Number); + ObjectDelete("M30_LEVEL_14" + Dynamic_Number); + ObjectDelete("M30_LEVEL_15" + Dynamic_Number); + ObjectDelete("M30_LEVEL_16" + Dynamic_Number); + ObjectDelete("M30_LEVEL_17" + Dynamic_Number); + ObjectDelete("M5_LEVEL" + Dynamic_Number); + ObjectDelete("M5_LEVEL_1" + Dynamic_Number); + ObjectDelete("M5_LEVEL_2" + Dynamic_Number); + ObjectDelete("M5_LEVEL_3" + Dynamic_Number); + ObjectDelete("M5_LEVEL_4" + Dynamic_Number); + ObjectDelete("M5_LEVEL_5" + Dynamic_Number); + ObjectDelete("M5_LEVEL_6" + Dynamic_Number); + ObjectDelete("M5_LEVEL_7" + Dynamic_Number); + ObjectDelete("M5_LEVEL_8" + Dynamic_Number); + ObjectDelete("M5_LEVEL_9" + Dynamic_Number); + ObjectDelete("M5_LEVEL_10" + Dynamic_Number); + ObjectDelete("M5_LEVEL_11" + Dynamic_Number); + ObjectDelete("M5_LEVEL_12" + Dynamic_Number); + ObjectDelete("M5_LEVEL_13" + Dynamic_Number); + ObjectDelete("M5_LEVEL_14" + Dynamic_Number); + ObjectDelete("M5_LEVEL_15" + Dynamic_Number); + ObjectDelete("M5_LEVEL_16" + Dynamic_Number); + ObjectDelete("M5_LEVEL_17" + Dynamic_Number); + ObjectDelete("TREND_Display" + Dynamic_Number); + ObjectDelete("TREND_Display1" + Dynamic_Number); + ObjectDelete("TREND_Display2" + Dynamic_Number); + ObjectDelete("TREND_Display3" + Dynamic_Number); + ObjectDelete("TREND_Display4" + Dynamic_Number); + ObjectDelete("TREND_Display5" + Dynamic_Number); + ObjectDelete("TREND_Display6" + Dynamic_Number); + ObjectDelete("TREND_Display7" + Dynamic_Number); + ObjectDelete("TREND_Display8" + Dynamic_Number); + ObjectDelete("SIG_RESULTS" + Dynamic_Number); + ObjectDelete("EXPIRED" + Dynamic_Number); + ObjectDelete("EXPIRED1" + Dynamic_Number); + ObjectDelete("EXPIRED2" + Dynamic_Number); + ObjectDelete("EXPIRED3" + Dynamic_Number); + ObjectDelete("EXPIRED4" + Dynamic_Number); + ObjectDelete("EXPIRED5" + Dynamic_Number); + ObjectDelete("EXPIRED6" + Dynamic_Number); + ObjectDelete("EXPIRED7" + Dynamic_Number); + ObjectDelete("EXPIRED8" + Dynamic_Number); + ObjectDelete("BCKGRND01" + Dynamic_Number); + ObjectDelete("BCKGRND02" + Dynamic_Number); + ObjectDelete("BCKGRND03" + Dynamic_Number); + ObjectDelete("BCKGRND04" + Dynamic_Number); + return (0); +} + +int start() { + color l_color_28; + double ld_432; + double ld_440; + double ld_448; + double ld_456; + double ld_472; + double ld_480; + double ld_488; + double ld_496; + double ld_504; + double ld_512; + double ld_520; + double ld_528; + double ld_536; + double ld_544; + double ld_552; + double ld_560; + double ld_568; + double ld_576; + double ld_584; + double ld_592; + double ld_600; + double ld_608; + double ld_616; + double ld_624; + double ld_632; + double ld_640; + double ld_648; + double ld_656; + double ld_664; + double ld_672; + double ld_680; + double ld_688; + double ld_696; + double ld_704; + double ld_712; + double ld_720; + double ld_728; + double ld_736; + double ld_744; + double ld_unused_752; + double ld_760; + double ld_768; + double ld_776; + double ld_784; + double ld_792; + double ld_800; + double ld_808; + double ld_816; + double ld_824; + double ld_832; + double ld_840; + double ld_848; + double ld_856; + double ld_864; + double ld_872; + double ld_880; + double ld_888; + double ld_896; + double ld_904; + double ld_912; + double ld_920; + double ld_928; + double ld_936; + double ld_944; + double ld_952; + double ld_960; + double ld_968; + double ld_976; + double ld_984; + double ld_992; + double ld_1000; + double ld_1424; + double ld_1432; + double ld_1440; + double ld_1448; + double ld_1456; + double ld_1464; + double ld_1472; + double ld_1480; + double ld_1488; + double ld_1496; + double ld_1504; + double ld_1512; + double ld_1520; + double ld_1528; + double ld_1536; + double ld_1544; + double ld_1552; + double ld_1560; + double ld_1568; + double ld_1576; + double ld_1584; + double ld_1592; + double ld_1600; + double ld_1608; + double ld_1616; + double ld_1624; + double ld_1632; + double ld_1640; + double ld_1648; + double ld_1656; + double ld_1664; + double ld_1672; + double ld_1680; + double ld_1688; + double ld_1696; + double ld_1704; + double ld_1712; + double ld_1720; + double ld_1728; + double ld_1736; + double ld_1744; + double ld_1752; + double ld_1760; + double ld_1768; + double ld_1776; + double ld_1784; + double ld_1792; + double ld_1800; + double ld_1808; + double ld_1816; + double ld_1824; + double ld_1832; + double ld_1840; + double ld_1848; + double ld_1856; + double ld_1864; + double ld_1872; + double ld_1880; + double ld_1888; + double ld_1896; + double ld_1904; + double ld_1912; + double ld_1920; + double ld_1928; + double ld_1936; + double ld_1944; + double ld_1952; + double ld_1960; + double ld_1968; + double ld_1976; + double ld_1984; + double ld_1992; + double ld_2416; + double ld_2424; + double ld_2432; + double ld_2440; + double ld_2448; + double ld_2456; + double ld_2464; + double ld_2472; + double ld_2480; + double ld_2488; + double ld_2496; + double ld_2504; + double ld_2512; + double ld_2520; + double ld_2528; + double ld_2536; + double ld_2544; + double ld_2552; + double ld_2560; + double ld_2568; + double ld_2576; + double ld_2584; + double ld_2592; + double ld_2600; + double ld_2608; + double ld_2616; + double ld_2624; + double ld_2632; + double ld_2640; + double ld_2648; + double ld_2656; + double ld_2664; + double ld_2672; + double ld_2680; + double ld_2688; + double ld_2696; + double ld_2704; + double ld_2712; + double ld_2720; + double ld_2728; + double ld_2736; + double ld_2744; + double ld_2752; + double ld_2760; + double ld_2768; + double ld_2776; + double ld_2784; + double ld_2792; + double ld_2800; + double ld_2808; + double ld_2816; + double ld_2824; + double ld_2832; + double ld_2840; + double ld_2848; + double ld_2856; + double ld_2864; + double ld_2872; + double ld_2880; + double ld_2888; + double ld_2896; + double ld_2904; + double ld_2912; + double ld_2920; + double ld_2928; + double ld_2936; + double ld_2944; + double ld_2952; + double ld_2960; + double ld_2968; + double ld_2976; + double ld_2984; + double ld_3408; + double ld_3416; + double ld_3424; + double ld_3432; + double ld_3440; + double ld_3448; + double ld_3456; + double ld_3464; + double ld_3472; + double ld_3480; + double ld_3488; + double ld_3496; + double ld_3504; + double ld_3512; + double ld_3520; + double ld_3528; + double ld_3536; + double ld_3544; + double ld_3552; + double ld_3560; + double ld_3568; + double ld_3576; + double ld_3584; + double ld_3592; + double ld_3600; + double ld_3608; + double ld_3616; + double ld_3624; + double ld_3632; + double ld_3640; + double ld_3648; + double ld_3656; + double ld_3664; + double ld_3672; + double ld_3680; + double ld_3688; + double ld_3696; + double ld_3704; + double ld_3712; + double ld_3720; + double ld_3728; + double ld_3736; + double ld_3744; + double ld_3752; + double ld_3760; + double ld_3768; + double ld_3776; + double ld_3784; + double ld_3792; + double ld_3800; + double ld_3808; + double ld_3816; + double ld_3824; + double ld_3832; + double ld_3840; + double ld_3848; + double ld_3856; + double ld_3864; + double ld_3872; + double ld_3880; + double ld_3888; + double ld_3896; + double ld_3904; + double ld_3912; + double ld_3920; + double ld_3928; + double ld_3936; + double ld_3944; + double ld_3952; + double ld_3960; + double ld_3968; + double ld_3976; + double ld_4400; + double ld_4408; + double ld_4416; + double ld_4424; + double ld_4432; + double ld_4440; + double ld_4448; + double ld_4456; + double ld_4464; + double ld_4472; + double ld_4480; + double ld_4488; + double ld_4496; + double ld_4504; + double ld_4512; + double ld_4520; + double ld_4528; + double ld_4536; + double ld_4544; + double ld_4552; + double ld_4560; + double ld_4568; + double ld_4576; + double ld_4584; + double ld_4592; + double ld_4600; + double ld_4608; + double ld_4616; + double ld_4624; + double ld_4632; + double ld_4640; + double ld_4648; + double ld_4656; + double ld_4664; + double ld_4672; + double ld_4680; + double ld_4688; + double ld_4696; + double ld_4704; + double ld_4712; + double ld_4720; + double ld_4728; + double ld_4736; + double ld_4744; + double ld_4752; + double ld_4760; + double ld_4768; + double ld_4776; + double ld_4784; + double ld_4792; + double ld_4800; + double ld_4808; + double ld_4816; + double ld_4824; + double ld_4832; + double ld_4840; + double ld_4848; + double ld_4856; + double ld_4864; + double ld_4872; + double ld_4880; + double ld_4888; + double ld_4896; + double ld_4904; + double ld_4912; + double ld_4920; + double ld_4928; + double ld_4936; + double ld_4944; + double ld_4952; + double ld_4960; + double ld_4968; + double ld_5392; + double ld_5400; + double ld_5408; + double ld_5416; + double ld_5424; + double ld_5432; + double ld_5440; + double ld_5448; + double ld_5456; + double ld_5464; + double ld_5472; + double ld_5480; + double ld_5488; + double ld_5496; + double ld_5504; + double ld_5512; + double ld_5520; + double ld_5528; + double ld_5536; + double ld_5544; + double ld_5552; + double ld_5560; + double ld_5568; + double ld_5576; + double ld_5584; + double ld_5592; + double ld_5600; + double ld_5608; + double ld_5616; + double ld_5624; + double ld_5632; + double ld_5640; + double ld_5648; + double ld_5656; + double ld_5664; + double ld_5672; + double ld_5680; + double ld_5688; + double ld_5696; + double ld_5704; + double ld_5712; + double ld_5720; + double ld_5728; + double ld_5736; + double ld_5744; + double ld_5752; + double ld_5760; + double ld_5768; + double ld_5776; + double ld_5784; + double ld_5792; + double ld_5800; + double ld_5808; + double ld_5816; + double ld_5824; + double ld_5832; + double ld_5840; + double ld_5848; + double ld_5856; + double ld_5864; + double ld_5872; + double ld_5880; + double ld_5888; + double ld_5896; + double ld_5904; + double ld_5912; + double ld_5920; + double ld_5928; + double ld_5936; + double ld_5944; + double ld_5952; + double ld_5960; + color l_color_6176; + color l_color_6180; + color l_color_6184; + color l_color_6188; + color l_color_6192; + color l_color_6196; + color l_color_6200; + color l_color_6204; + color l_color_6208; + color l_color_6212; + color l_color_6216; + color l_color_6220; + color l_color_6224; + color l_color_6228; + color l_color_6232; + color l_color_6236; + color l_color_6240; + color l_color_6244; + color l_color_6256; + color l_color_6404; + color l_color_6408; + color l_color_6412; + color l_color_6416; + color l_color_6420; + color l_color_6424; + color l_color_6428; + color l_color_6432; + color l_color_6436; + color l_color_6440; + color l_color_6444; + color l_color_6448; + color l_color_6452; + color l_color_6456; + color l_color_6460; + color l_color_6464; + color l_color_6468; + color l_color_6472; + color l_color_6620; + color l_color_6624; + color l_color_6628; + color l_color_6632; + color l_color_6636; + color l_color_6640; + color l_color_6644; + color l_color_6648; + color l_color_6652; + color l_color_6656; + color l_color_6660; + color l_color_6664; + color l_color_6668; + color l_color_6672; + color l_color_6676; + color l_color_6680; + color l_color_6684; + color l_color_6688; + color l_color_6836; + color l_color_6840; + color l_color_6844; + color l_color_6848; + color l_color_6852; + color l_color_6856; + color l_color_6860; + color l_color_6864; + color l_color_6868; + color l_color_6872; + color l_color_6876; + color l_color_6880; + color l_color_6884; + color l_color_6888; + color l_color_6892; + color l_color_6896; + color l_color_6900; + color l_color_6904; + double ld_4 = NormalizeDouble(MarketInfo(Symbol(), MODE_BID), Digits); + double l_ima_12 = iMA(Symbol(), PERIOD_M1, 1, 0, MODE_EMA, PRICE_CLOSE, 1); + string ls_unused_20 = ""; + if (l_ima_12 > ld_4) { + ls_unused_20 = ""; + l_color_28 = DarkBlue; + g_color_340 = DarkOrange; + } + if (l_ima_12 < ld_4) { + ls_unused_20 = ""; + l_color_28 = Silver; + g_color_340 = Red; + } + if (l_ima_12 == ld_4) { + ls_unused_20 = ""; + l_color_28 = DarkOrange; + g_color_340 = Blue; + } + if (BarsShift_UP_DN < 0) return (0); + if (Currency_Symbol == "") Currency_Symbol = Symbol(); + if (StringFind(Currency_Symbol, "JPY", 0) != -1) gi_328 = 2; + else gi_328 = 4; + double ld_40 = NormalizeDouble(MarketInfo(Currency_Symbol, MODE_BID), gi_328); + double ld_48 = (iHigh(Currency_Symbol, PERIOD_M1, 0) + iLow(Currency_Symbol, PERIOD_M1, 0) + iClose(Currency_Symbol, PERIOD_M1, 0)) / 3.0; + double ld_56 = (iHigh(Currency_Symbol, PERIOD_M1, 1) + iLow(Currency_Symbol, PERIOD_M1, 1) + iClose(Currency_Symbol, PERIOD_M1, 1)) / 3.0; + double ld_64 = (iHigh(Currency_Symbol, PERIOD_M1, 2) + iLow(Currency_Symbol, PERIOD_M1, 2) + iClose(Currency_Symbol, PERIOD_M1, 2)) / 3.0; + double ld_72 = (iHigh(Currency_Symbol, PERIOD_M1, 3) + iLow(Currency_Symbol, PERIOD_M1, 3) + iClose(Currency_Symbol, PERIOD_M1, 3)) / 3.0; + double ld_80 = (iHigh(Currency_Symbol, PERIOD_M1, 4) + iLow(Currency_Symbol, PERIOD_M1, 4) + iClose(Currency_Symbol, PERIOD_M1, 4)) / 3.0; + double ld_88 = (iHigh(Currency_Symbol, PERIOD_M1, 5) + iLow(Currency_Symbol, PERIOD_M1, 5) + iClose(Currency_Symbol, PERIOD_M1, 5)) / 3.0; + double ld_96 = 2.0 * ld_48 + (iHigh(Currency_Symbol, PERIOD_M1, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 0)); + double ld_104 = 2.0 * ld_56 + (iHigh(Currency_Symbol, PERIOD_M1, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 1)); + double ld_112 = 2.0 * ld_64 + (iHigh(Currency_Symbol, PERIOD_M1, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 2)); + double ld_120 = 2.0 * ld_72 + (iHigh(Currency_Symbol, PERIOD_M1, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 3)); + double ld_128 = 2.0 * ld_80 + (iHigh(Currency_Symbol, PERIOD_M1, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 4)); + double ld_136 = 2.0 * ld_88 + (iHigh(Currency_Symbol, PERIOD_M1, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_M1, 5)); + double ld_144 = ld_48 + (iHigh(Currency_Symbol, PERIOD_M1, 0) - iLow(Currency_Symbol, PERIOD_M1, 0)); + double ld_152 = ld_56 + (iHigh(Currency_Symbol, PERIOD_M1, 1) - iLow(Currency_Symbol, PERIOD_M1, 1)); + double ld_160 = ld_64 + (iHigh(Currency_Symbol, PERIOD_M1, 2) - iLow(Currency_Symbol, PERIOD_M1, 2)); + double ld_168 = ld_72 + (iHigh(Currency_Symbol, PERIOD_M1, 3) - iLow(Currency_Symbol, PERIOD_M1, 3)); + double ld_176 = ld_80 + (iHigh(Currency_Symbol, PERIOD_M1, 4) - iLow(Currency_Symbol, PERIOD_M1, 4)); + double ld_184 = ld_88 + (iHigh(Currency_Symbol, PERIOD_M1, 5) - iLow(Currency_Symbol, PERIOD_M1, 5)); + double ld_192 = 2.0 * ld_48 - iLow(Currency_Symbol, PERIOD_M1, 0); + double ld_200 = 2.0 * ld_56 - iLow(Currency_Symbol, PERIOD_M1, 1); + double ld_208 = 2.0 * ld_64 - iLow(Currency_Symbol, PERIOD_M1, 2); + double ld_216 = 2.0 * ld_72 - iLow(Currency_Symbol, PERIOD_M1, 3); + double ld_224 = 2.0 * ld_80 - iLow(Currency_Symbol, PERIOD_M1, 4); + double ld_232 = 2.0 * ld_88 - iLow(Currency_Symbol, PERIOD_M1, 5); + double ld_240 = (iHigh(Currency_Symbol, PERIOD_M1, 0) + iLow(Currency_Symbol, PERIOD_M1, 0) + iClose(Currency_Symbol, PERIOD_M1, 0)) / 3.0; + double ld_248 = (iHigh(Currency_Symbol, PERIOD_M1, 1) + iLow(Currency_Symbol, PERIOD_M1, 1) + iClose(Currency_Symbol, PERIOD_M1, 1)) / 3.0; + double ld_256 = (iHigh(Currency_Symbol, PERIOD_M1, 2) + iLow(Currency_Symbol, PERIOD_M1, 2) + iClose(Currency_Symbol, PERIOD_M1, 2)) / 3.0; + double ld_264 = (iHigh(Currency_Symbol, PERIOD_M1, 3) + iLow(Currency_Symbol, PERIOD_M1, 3) + iClose(Currency_Symbol, PERIOD_M1, 3)) / 3.0; + double ld_272 = (iHigh(Currency_Symbol, PERIOD_M1, 4) + iLow(Currency_Symbol, PERIOD_M1, 4) + iClose(Currency_Symbol, PERIOD_M1, 4)) / 3.0; + double ld_280 = (iHigh(Currency_Symbol, PERIOD_M1, 5) + iLow(Currency_Symbol, PERIOD_M1, 5) + iClose(Currency_Symbol, PERIOD_M1, 5)) / 3.0; + double ld_288 = 2.0 * ld_48 - iHigh(Currency_Symbol, PERIOD_M1, 0); + double ld_296 = 2.0 * ld_56 - iHigh(Currency_Symbol, PERIOD_M1, 1); + double ld_304 = 2.0 * ld_64 - iHigh(Currency_Symbol, PERIOD_M1, 2); + double ld_312 = 2.0 * ld_72 - iHigh(Currency_Symbol, PERIOD_M1, 3); + double ld_320 = 2.0 * ld_80 - iHigh(Currency_Symbol, PERIOD_M1, 4); + double ld_328 = 2.0 * ld_88 - iHigh(Currency_Symbol, PERIOD_M1, 5); + double ld_336 = ld_48 - (iHigh(Currency_Symbol, PERIOD_M1, 0) - iLow(Currency_Symbol, PERIOD_M1, 0)); + double ld_344 = ld_56 - (iHigh(Currency_Symbol, PERIOD_M1, 1) - iLow(Currency_Symbol, PERIOD_M1, 1)); + double ld_352 = ld_64 - (iHigh(Currency_Symbol, PERIOD_M1, 2) - iLow(Currency_Symbol, PERIOD_M1, 2)); + double ld_360 = ld_72 - (iHigh(Currency_Symbol, PERIOD_M1, 3) - iLow(Currency_Symbol, PERIOD_M1, 3)); + double ld_368 = ld_80 - (iHigh(Currency_Symbol, PERIOD_M1, 4) - iLow(Currency_Symbol, PERIOD_M1, 4)); + double ld_376 = ld_88 - (iHigh(Currency_Symbol, PERIOD_M1, 5) - iLow(Currency_Symbol, PERIOD_M1, 5)); + double ld_384 = 2.0 * ld_48 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 0) - iLow(Currency_Symbol, PERIOD_M1, 0)); + double ld_392 = 2.0 * ld_56 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 1) - iLow(Currency_Symbol, PERIOD_M1, 1)); + double ld_400 = 2.0 * ld_64 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 2) - iLow(Currency_Symbol, PERIOD_M1, 2)); + double ld_408 = 2.0 * ld_72 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 3) - iLow(Currency_Symbol, PERIOD_M1, 3)); + double ld_416 = 2.0 * ld_80 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 4) - iLow(Currency_Symbol, PERIOD_M1, 4)); + double ld_424 = 2.0 * ld_88 - (2.0 * iHigh(Currency_Symbol, PERIOD_M1, 5) - iLow(Currency_Symbol, PERIOD_M1, 5)); + if (ld_48 > ld_40) { + ld_432 = 0; + ld_720 = 1; + } + if (ld_48 < ld_40) { + ld_432 = 1; + ld_720 = 0; + } + if (ld_56 > ld_40) { + ld_440 = 0; + ld_728 = 1; + } + if (ld_56 < ld_40) { + ld_440 = 1; + ld_728 = 0; + } + if (ld_64 > ld_40) { + ld_448 = 0; + ld_736 = 1; + } + if (ld_64 < ld_40) { + ld_448 = 1; + ld_736 = 0; + } + if (ld_72 > ld_40) { + ld_456 = 0; + ld_744 = 1; + } + if (ld_72 < ld_40) { + ld_456 = 1; + ld_744 = 0; + } + if (ld_80 > ld_40) { + ld_432 = 0; + ld_unused_752 = 1; + } + if (ld_80 < ld_40) { + ld_432 = 1; + ld_unused_752 = 0; + } + if (ld_192 > ld_40) { + ld_472 = 0; + ld_760 = 1; + } + if (ld_192 < ld_40) { + ld_472 = 1; + ld_760 = 0; + } + if (ld_200 > ld_40) { + ld_480 = 0; + ld_768 = 1; + } + if (ld_200 < ld_40) { + ld_480 = 1; + ld_768 = 0; + } + if (ld_208 > ld_40) { + ld_488 = 0; + ld_776 = 1; + } + if (ld_208 < ld_40) { + ld_488 = 1; + ld_776 = 0; + } + if (ld_216 > ld_40) { + ld_496 = 0; + ld_784 = 1; + } + if (ld_216 < ld_40) { + ld_496 = 1; + ld_784 = 0; + } + if (ld_224 > ld_40) { + ld_504 = 0; + ld_792 = 1; + } + if (ld_224 < ld_40) { + ld_504 = 1; + ld_792 = 0; + } + if (ld_232 > ld_40) { + ld_512 = 0; + ld_800 = 1; + } + if (ld_232 < ld_40) { + ld_512 = 1; + ld_800 = 0; + } + if (ld_288 > ld_40) { + ld_520 = 0; + ld_808 = 1; + } + if (ld_288 < ld_40) { + ld_520 = 1; + ld_808 = 0; + } + if (ld_296 > ld_40) { + ld_528 = 0; + ld_816 = 1; + } + if (ld_296 < ld_40) { + ld_528 = 1; + ld_816 = 0; + } + if (ld_304 > ld_40) { + ld_536 = 0; + ld_824 = 1; + } + if (ld_304 < ld_40) { + ld_536 = 1; + ld_824 = 0; + } + if (ld_312 > ld_40) { + ld_544 = 0; + ld_832 = 1; + } + if (ld_312 < ld_40) { + ld_544 = 1; + ld_832 = 0; + } + if (ld_320 > ld_40) { + ld_552 = 0; + ld_840 = 1; + } + if (ld_320 < ld_40) { + ld_552 = 1; + ld_840 = 0; + } + if (ld_328 > ld_40) { + ld_560 = 0; + ld_848 = 1; + } + if (ld_328 < ld_40) { + ld_560 = 1; + ld_848 = 0; + } + if (ld_144 > ld_40) { + ld_568 = 0; + ld_856 = 1; + } + if (ld_144 < ld_40) { + ld_568 = 1; + ld_856 = 0; + } + if (ld_152 > ld_40) { + ld_576 = 0; + ld_864 = 1; + } + if (ld_152 < ld_40) { + ld_576 = 1; + ld_864 = 0; + } + if (ld_160 > ld_40) { + ld_584 = 0; + ld_872 = 1; + } + if (ld_160 < ld_40) { + ld_584 = 1; + ld_872 = 0; + } + if (ld_168 > ld_40) { + ld_592 = 0; + ld_880 = 1; + } + if (ld_168 < ld_40) { + ld_592 = 1; + ld_880 = 0; + } + if (ld_176 > ld_40) { + ld_600 = 0; + ld_888 = 1; + } + if (ld_176 < ld_40) { + ld_600 = 1; + ld_888 = 0; + } + if (ld_184 > ld_40) { + ld_608 = 0; + ld_896 = 1; + } + if (ld_184 < ld_40) { + ld_608 = 1; + ld_896 = 0; + } + if (ld_336 > ld_40) { + ld_616 = 0; + ld_904 = 1; + } + if (ld_336 < ld_40) { + ld_616 = 1; + ld_904 = 0; + } + if (ld_344 > ld_40) { + ld_624 = 0; + ld_912 = 1; + } + if (ld_344 < ld_40) { + ld_624 = 1; + ld_912 = 0; + } + if (ld_352 > ld_40) { + ld_632 = 0; + ld_920 = 1; + } + if (ld_352 < ld_40) { + ld_632 = 1; + ld_920 = 0; + } + if (ld_360 > ld_40) { + ld_640 = 0; + ld_928 = 1; + } + if (ld_360 < ld_40) { + ld_640 = 1; + ld_928 = 0; + } + if (ld_368 > ld_40) { + ld_648 = 0; + ld_936 = 1; + } + if (ld_368 < ld_40) { + ld_648 = 1; + ld_936 = 0; + } + if (ld_376 > ld_40) { + ld_656 = 0; + ld_944 = 1; + } + if (ld_376 < ld_40) { + ld_656 = 1; + ld_944 = 0; + } + if (ld_96 > ld_40) { + ld_664 = 0; + ld_952 = 1; + } + if (ld_96 < ld_40) { + ld_664 = 1; + ld_952 = 0; + } + if (ld_104 > ld_40) { + ld_672 = 0; + ld_960 = 1; + } + if (ld_104 < ld_40) { + ld_672 = 1; + ld_960 = 0; + } + if (ld_112 > ld_40) { + ld_680 = 0; + ld_968 = 1; + } + if (ld_112 < ld_40) { + ld_680 = 1; + ld_968 = 0; + } + if (ld_120 > ld_40) { + ld_688 = 0; + ld_984 = 1; + } + if (ld_120 < ld_40) { + ld_688 = 1; + ld_984 = 0; + } + if (ld_128 > ld_40) { + ld_704 = 0; + ld_992 = 1; + } + if (ld_128 < ld_40) { + ld_704 = 1; + ld_992 = 0; + } + if (ld_136 > ld_40) { + ld_712 = 0; + ld_1000 = 1; + } + if (ld_136 < ld_40) { + ld_712 = 1; + ld_1000 = 0; + } + double ld_1008 = ld_432 + ld_440 + ld_448 + ld_456 + ld_432 + ld_472 + ld_480 + ld_488 + ld_496 + ld_504 + ld_512 + ld_520 + ld_528 + ld_536 + ld_544 + ld_552 + ld_560 + ld_568 + ld_576 + ld_584 + ld_592 + ld_600 + ld_608 + ld_616 + ld_624 + ld_632 + ld_640 + ld_648 + ld_656 + ld_664 + ld_672 + ld_680 + ld_688 + ld_696 + ld_704 + ld_712; + double ld_1016 = ld_720 + ld_728 + ld_736 + ld_744 + ld_720 + ld_760 + ld_768 + ld_776 + ld_784 + ld_792 + ld_800 + ld_808 + ld_816 + ld_824 + ld_832 + ld_840 + ld_848 + ld_856 + ld_864 + ld_872 + ld_880 + ld_888 + ld_896 + ld_904 + ld_912 + ld_920 + ld_928 + ld_936 + ld_944 + ld_952 + ld_960 + ld_968 + ld_976 + ld_984 + ld_992 + ld_1000; + string l_dbl2str_1024 = DoubleToStr(100.0 * (ld_1008 / 36.0), 0); + string ls_unused_1032 = DoubleToStr(100 - StrToDouble(l_dbl2str_1024), 0); + double ld_1040 = (iHigh(Currency_Symbol, PERIOD_M5, 0) + iLow(Currency_Symbol, PERIOD_M5, 0) + iClose(Currency_Symbol, PERIOD_M5, 0)) / 3.0; + double ld_1048 = (iHigh(Currency_Symbol, PERIOD_M5, 1) + iLow(Currency_Symbol, PERIOD_M5, 1) + iClose(Currency_Symbol, PERIOD_M5, 1)) / 3.0; + double ld_1056 = (iHigh(Currency_Symbol, PERIOD_M5, 2) + iLow(Currency_Symbol, PERIOD_M5, 2) + iClose(Currency_Symbol, PERIOD_M5, 2)) / 3.0; + double ld_1064 = (iHigh(Currency_Symbol, PERIOD_M5, 3) + iLow(Currency_Symbol, PERIOD_M5, 3) + iClose(Currency_Symbol, PERIOD_M5, 3)) / 3.0; + double ld_1072 = (iHigh(Currency_Symbol, PERIOD_M5, 4) + iLow(Currency_Symbol, PERIOD_M5, 4) + iClose(Currency_Symbol, PERIOD_M5, 4)) / 3.0; + double ld_1080 = (iHigh(Currency_Symbol, PERIOD_M5, 5) + iLow(Currency_Symbol, PERIOD_M5, 5) + iClose(Currency_Symbol, PERIOD_M5, 5)) / 3.0; + double ld_1088 = 2.0 * ld_1040 + (iHigh(Currency_Symbol, PERIOD_M5, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 0)); + double ld_1096 = 2.0 * ld_1048 + (iHigh(Currency_Symbol, PERIOD_M5, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 1)); + double ld_1104 = 2.0 * ld_1056 + (iHigh(Currency_Symbol, PERIOD_M5, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 2)); + double ld_1112 = 2.0 * ld_1064 + (iHigh(Currency_Symbol, PERIOD_M5, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 3)); + double ld_1120 = 2.0 * ld_1072 + (iHigh(Currency_Symbol, PERIOD_M5, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 4)); + double ld_1128 = 2.0 * ld_1080 + (iHigh(Currency_Symbol, PERIOD_M5, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_M5, 5)); + double ld_1136 = ld_1040 + (iHigh(Currency_Symbol, PERIOD_M5, 0) - iLow(Currency_Symbol, PERIOD_M5, 0)); + double ld_1144 = ld_1048 + (iHigh(Currency_Symbol, PERIOD_M5, 1) - iLow(Currency_Symbol, PERIOD_M5, 1)); + double ld_1152 = ld_1056 + (iHigh(Currency_Symbol, PERIOD_M5, 2) - iLow(Currency_Symbol, PERIOD_M5, 2)); + double ld_1160 = ld_1064 + (iHigh(Currency_Symbol, PERIOD_M5, 3) - iLow(Currency_Symbol, PERIOD_M5, 3)); + double ld_1168 = ld_1072 + (iHigh(Currency_Symbol, PERIOD_M5, 4) - iLow(Currency_Symbol, PERIOD_M5, 4)); + double ld_1176 = ld_1080 + (iHigh(Currency_Symbol, PERIOD_M5, 5) - iLow(Currency_Symbol, PERIOD_M5, 5)); + double ld_1184 = 2.0 * ld_1040 - iLow(Currency_Symbol, PERIOD_M5, 0); + double ld_1192 = 2.0 * ld_1048 - iLow(Currency_Symbol, PERIOD_M5, 1); + double ld_1200 = 2.0 * ld_1056 - iLow(Currency_Symbol, PERIOD_M5, 2); + double ld_1208 = 2.0 * ld_1064 - iLow(Currency_Symbol, PERIOD_M5, 3); + double ld_1216 = 2.0 * ld_1072 - iLow(Currency_Symbol, PERIOD_M5, 4); + double ld_1224 = 2.0 * ld_1080 - iLow(Currency_Symbol, PERIOD_M5, 5); + double ld_1232 = (iHigh(Currency_Symbol, PERIOD_M5, 0) + iLow(Currency_Symbol, PERIOD_M5, 0) + iClose(Currency_Symbol, PERIOD_M5, 0)) / 3.0; + double ld_1240 = (iHigh(Currency_Symbol, PERIOD_M5, 1) + iLow(Currency_Symbol, PERIOD_M5, 1) + iClose(Currency_Symbol, PERIOD_M5, 1)) / 3.0; + double ld_1248 = (iHigh(Currency_Symbol, PERIOD_M5, 2) + iLow(Currency_Symbol, PERIOD_M5, 2) + iClose(Currency_Symbol, PERIOD_M5, 2)) / 3.0; + double ld_1256 = (iHigh(Currency_Symbol, PERIOD_M5, 3) + iLow(Currency_Symbol, PERIOD_M5, 3) + iClose(Currency_Symbol, PERIOD_M5, 3)) / 3.0; + double ld_1264 = (iHigh(Currency_Symbol, PERIOD_M5, 4) + iLow(Currency_Symbol, PERIOD_M5, 4) + iClose(Currency_Symbol, PERIOD_M5, 4)) / 3.0; + double ld_1272 = (iHigh(Currency_Symbol, PERIOD_M5, 5) + iLow(Currency_Symbol, PERIOD_M5, 5) + iClose(Currency_Symbol, PERIOD_M5, 5)) / 3.0; + double ld_1280 = 2.0 * ld_1040 - iHigh(Currency_Symbol, PERIOD_M5, 0); + double ld_1288 = 2.0 * ld_1048 - iHigh(Currency_Symbol, PERIOD_M5, 1); + double ld_1296 = 2.0 * ld_1056 - iHigh(Currency_Symbol, PERIOD_M5, 2); + double ld_1304 = 2.0 * ld_1064 - iHigh(Currency_Symbol, PERIOD_M5, 3); + double ld_1312 = 2.0 * ld_1072 - iHigh(Currency_Symbol, PERIOD_M5, 4); + double ld_1320 = 2.0 * ld_1080 - iHigh(Currency_Symbol, PERIOD_M5, 5); + double ld_1328 = ld_1040 - (iHigh(Currency_Symbol, PERIOD_M5, 0) - iLow(Currency_Symbol, PERIOD_M5, 0)); + double ld_1336 = ld_1048 - (iHigh(Currency_Symbol, PERIOD_M5, 1) - iLow(Currency_Symbol, PERIOD_M5, 1)); + double ld_1344 = ld_1056 - (iHigh(Currency_Symbol, PERIOD_M5, 2) - iLow(Currency_Symbol, PERIOD_M5, 2)); + double ld_1352 = ld_1064 - (iHigh(Currency_Symbol, PERIOD_M5, 3) - iLow(Currency_Symbol, PERIOD_M5, 3)); + double ld_1360 = ld_1072 - (iHigh(Currency_Symbol, PERIOD_M5, 4) - iLow(Currency_Symbol, PERIOD_M5, 4)); + double ld_1368 = ld_1080 - (iHigh(Currency_Symbol, PERIOD_M5, 5) - iLow(Currency_Symbol, PERIOD_M5, 5)); + double ld_1376 = 2.0 * ld_1040 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 0) - iLow(Currency_Symbol, PERIOD_M5, 0)); + double ld_1384 = 2.0 * ld_1048 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 1) - iLow(Currency_Symbol, PERIOD_M5, 1)); + double ld_1392 = 2.0 * ld_1056 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 2) - iLow(Currency_Symbol, PERIOD_M5, 2)); + double ld_1400 = 2.0 * ld_1064 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 3) - iLow(Currency_Symbol, PERIOD_M5, 3)); + double ld_1408 = 2.0 * ld_1072 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 4) - iLow(Currency_Symbol, PERIOD_M5, 4)); + double ld_1416 = 2.0 * ld_1080 - (2.0 * iHigh(Currency_Symbol, PERIOD_M5, 5) - iLow(Currency_Symbol, PERIOD_M5, 5)); + if (ld_1040 > ld_40) { + ld_1424 = 0; + ld_1712 = 1; + } + if (ld_1040 < ld_40) { + ld_1424 = 1; + ld_1712 = 0; + } + if (ld_1048 > ld_40) { + ld_1432 = 0; + ld_1720 = 1; + } + if (ld_1048 < ld_40) { + ld_1432 = 1; + ld_1720 = 0; + } + if (ld_1056 > ld_40) { + ld_1440 = 0; + ld_1728 = 1; + } + if (ld_1056 < ld_40) { + ld_1440 = 1; + ld_1728 = 0; + } + if (ld_1064 > ld_40) { + ld_1448 = 0; + ld_1736 = 1; + } + if (ld_1064 < ld_40) { + ld_1448 = 1; + ld_1736 = 0; + } + if (ld_1072 > ld_40) { + ld_1456 = 0; + ld_1744 = 1; + } + if (ld_1072 < ld_40) { + ld_1456 = 1; + ld_1744 = 0; + } + if (ld_1184 > ld_40) { + ld_1464 = 0; + ld_1752 = 1; + } + if (ld_1184 < ld_40) { + ld_1464 = 1; + ld_1752 = 0; + } + if (ld_1192 > ld_40) { + ld_1472 = 0; + ld_1760 = 1; + } + if (ld_1192 < ld_40) { + ld_1472 = 1; + ld_1760 = 0; + } + if (ld_1200 > ld_40) { + ld_1480 = 0; + ld_1768 = 1; + } + if (ld_1200 < ld_40) { + ld_1480 = 1; + ld_1768 = 0; + } + if (ld_1208 > ld_40) { + ld_1488 = 0; + ld_1776 = 1; + } + if (ld_1208 < ld_40) { + ld_1488 = 1; + ld_1776 = 0; + } + if (ld_1216 > ld_40) { + ld_1496 = 0; + ld_1784 = 1; + } + if (ld_1216 < ld_40) { + ld_1496 = 1; + ld_1784 = 0; + } + if (ld_1224 > ld_40) { + ld_1504 = 0; + ld_1792 = 1; + } + if (ld_1224 < ld_40) { + ld_1504 = 1; + ld_1792 = 0; + } + if (ld_1280 > ld_40) { + ld_1512 = 0; + ld_1800 = 1; + } + if (ld_1280 < ld_40) { + ld_1512 = 1; + ld_1800 = 0; + } + if (ld_1288 > ld_40) { + ld_1520 = 0; + ld_1808 = 1; + } + if (ld_1288 < ld_40) { + ld_1520 = 1; + ld_1808 = 0; + } + if (ld_1296 > ld_40) { + ld_1528 = 0; + ld_1816 = 1; + } + if (ld_1296 < ld_40) { + ld_1528 = 1; + ld_1816 = 0; + } + if (ld_1304 > ld_40) { + ld_1536 = 0; + ld_1824 = 1; + } + if (ld_1304 < ld_40) { + ld_1536 = 1; + ld_1824 = 0; + } + if (ld_1312 > ld_40) { + ld_1544 = 0; + ld_1832 = 1; + } + if (ld_1312 < ld_40) { + ld_1544 = 1; + ld_1832 = 0; + } + if (ld_1320 > ld_40) { + ld_1552 = 0; + ld_1840 = 1; + } + if (ld_1320 < ld_40) { + ld_1552 = 1; + ld_1840 = 0; + } + if (ld_1136 > ld_40) { + ld_1560 = 0; + ld_1848 = 1; + } + if (ld_1136 < ld_40) { + ld_1560 = 1; + ld_1848 = 0; + } + if (ld_1144 > ld_40) { + ld_1568 = 0; + ld_1856 = 1; + } + if (ld_1144 < ld_40) { + ld_1568 = 1; + ld_1856 = 0; + } + if (ld_1152 > ld_40) { + ld_1576 = 0; + ld_1864 = 1; + } + if (ld_1152 < ld_40) { + ld_1576 = 1; + ld_1864 = 0; + } + if (ld_1160 > ld_40) { + ld_1584 = 0; + ld_1872 = 1; + } + if (ld_1160 < ld_40) { + ld_1584 = 1; + ld_1872 = 0; + } + if (ld_1168 > ld_40) { + ld_1592 = 0; + ld_1880 = 1; + } + if (ld_1168 < ld_40) { + ld_1592 = 1; + ld_1880 = 0; + } + if (ld_1176 > ld_40) { + ld_1600 = 0; + ld_1888 = 1; + } + if (ld_1176 < ld_40) { + ld_1600 = 1; + ld_1888 = 0; + } + if (ld_1328 > ld_40) { + ld_1608 = 0; + ld_1896 = 1; + } + if (ld_1328 < ld_40) { + ld_1608 = 1; + ld_1896 = 0; + } + if (ld_1336 > ld_40) { + ld_1616 = 0; + ld_1904 = 1; + } + if (ld_1336 < ld_40) { + ld_1616 = 1; + ld_1904 = 0; + } + if (ld_1344 > ld_40) { + ld_1624 = 0; + ld_1912 = 1; + } + if (ld_1344 < ld_40) { + ld_1624 = 1; + ld_1912 = 0; + } + if (ld_1352 > ld_40) { + ld_1632 = 0; + ld_1920 = 1; + } + if (ld_1352 < ld_40) { + ld_1632 = 1; + ld_1920 = 0; + } + if (ld_1360 > ld_40) { + ld_1640 = 0; + ld_1928 = 1; + } + if (ld_1360 < ld_40) { + ld_1640 = 1; + ld_1928 = 0; + } + if (ld_1368 > ld_40) { + ld_1648 = 0; + ld_1936 = 1; + } + if (ld_1368 < ld_40) { + ld_1648 = 1; + ld_1936 = 0; + } + if (ld_1088 > ld_40) { + ld_1656 = 0; + ld_1944 = 1; + } + if (ld_1088 < ld_40) { + ld_1656 = 1; + ld_1944 = 0; + } + if (ld_1096 > ld_40) { + ld_1664 = 0; + ld_1952 = 1; + } + if (ld_1096 < ld_40) { + ld_1664 = 1; + ld_1952 = 0; + } + if (ld_1104 > ld_40) { + ld_1672 = 0; + ld_1960 = 1; + } + if (ld_1104 < ld_40) { + ld_1672 = 1; + ld_1960 = 0; + } + if (ld_1112 > ld_40) { + ld_1680 = 0; + ld_1976 = 1; + } + if (ld_1112 < ld_40) { + ld_1680 = 1; + ld_1976 = 0; + } + if (ld_1120 > ld_40) { + ld_1696 = 0; + ld_1984 = 1; + } + if (ld_1120 < ld_40) { + ld_1696 = 1; + ld_1984 = 0; + } + if (ld_1128 > ld_40) { + ld_1704 = 0; + ld_1992 = 1; + } + if (ld_1128 < ld_40) { + ld_1704 = 1; + ld_1992 = 0; + } + double ld_2000 = ld_1424 + ld_1432 + ld_1440 + ld_1448 + ld_1456 + ld_1464 + ld_1472 + ld_1480 + ld_1488 + ld_1496 + ld_1504 + ld_1512 + ld_1520 + ld_1528 + ld_1536 + ld_1544 + ld_1552 + ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + ld_1688 + ld_1696 + ld_1704 + ld_432 + ld_440 + ld_448 + ld_456 + ld_432 + ld_472 + ld_480 + ld_488 + ld_496 + ld_504 + ld_512 + ld_520 + ld_528 + ld_536 + ld_544 + ld_552 + ld_560 + ld_568 + ld_576 + ld_584 + ld_592 + ld_600 + ld_608 + ld_616 + ld_624 + ld_632 + ld_640 + ld_648 + ld_656 + ld_664 + ld_672 + ld_680 + ld_688 + ld_696 + ld_704 + ld_712; + double ld_2008 = ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_720 + ld_728 + ld_736 + ld_744 + ld_720 + ld_760 + ld_768 + ld_776 + ld_784 + ld_792 + ld_800 + ld_808 + ld_816 + ld_824 + ld_832 + ld_840 + ld_848 + ld_856 + ld_864 + ld_872 + ld_880 + ld_888 + ld_896 + ld_904 + ld_912 + ld_920 + ld_928 + ld_936 + ld_944 + ld_952 + ld_960 + ld_968 + ld_976 + ld_984 + ld_992 + ld_1000; + string l_dbl2str_2016 = DoubleToStr(100.0 * (ld_2000 / 72.0), 0); + string l_dbl2str_2024 = DoubleToStr(100 - StrToDouble(l_dbl2str_2016), 0); + double ld_2032 = (iHigh(Currency_Symbol, PERIOD_M15, 0) + iLow(Currency_Symbol, PERIOD_M15, 0) + iClose(Currency_Symbol, PERIOD_M15, 0)) / 3.0; + double ld_2040 = (iHigh(Currency_Symbol, PERIOD_M15, 1) + iLow(Currency_Symbol, PERIOD_M15, 1) + iClose(Currency_Symbol, PERIOD_M15, 1)) / 3.0; + double ld_2048 = (iHigh(Currency_Symbol, PERIOD_M15, 2) + iLow(Currency_Symbol, PERIOD_M15, 2) + iClose(Currency_Symbol, PERIOD_M15, 2)) / 3.0; + double ld_2056 = (iHigh(Currency_Symbol, PERIOD_M15, 3) + iLow(Currency_Symbol, PERIOD_M15, 3) + iClose(Currency_Symbol, PERIOD_M15, 3)) / 3.0; + double ld_2064 = (iHigh(Currency_Symbol, PERIOD_M15, 4) + iLow(Currency_Symbol, PERIOD_M15, 4) + iClose(Currency_Symbol, PERIOD_M15, 4)) / 3.0; + double ld_2072 = (iHigh(Currency_Symbol, PERIOD_M15, 5) + iLow(Currency_Symbol, PERIOD_M15, 5) + iClose(Currency_Symbol, PERIOD_M15, 5)) / 3.0; + double ld_2080 = 2.0 * ld_2032 + (iHigh(Currency_Symbol, PERIOD_M15, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 0)); + double ld_2088 = 2.0 * ld_2040 + (iHigh(Currency_Symbol, PERIOD_M15, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 1)); + double ld_2096 = 2.0 * ld_2048 + (iHigh(Currency_Symbol, PERIOD_M15, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 2)); + double ld_2104 = 2.0 * ld_2056 + (iHigh(Currency_Symbol, PERIOD_M15, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 3)); + double ld_2112 = 2.0 * ld_2064 + (iHigh(Currency_Symbol, PERIOD_M15, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 4)); + double ld_2120 = 2.0 * ld_2072 + (iHigh(Currency_Symbol, PERIOD_M15, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_M15, 5)); + double ld_2128 = ld_2032 + (iHigh(Currency_Symbol, PERIOD_M15, 0) - iLow(Currency_Symbol, PERIOD_M15, 0)); + double ld_2136 = ld_2040 + (iHigh(Currency_Symbol, PERIOD_M15, 1) - iLow(Currency_Symbol, PERIOD_M15, 1)); + double ld_2144 = ld_2048 + (iHigh(Currency_Symbol, PERIOD_M15, 2) - iLow(Currency_Symbol, PERIOD_M15, 2)); + double ld_2152 = ld_2056 + (iHigh(Currency_Symbol, PERIOD_M15, 3) - iLow(Currency_Symbol, PERIOD_M15, 3)); + double ld_2160 = ld_2064 + (iHigh(Currency_Symbol, PERIOD_M15, 4) - iLow(Currency_Symbol, PERIOD_M15, 4)); + double ld_2168 = ld_2072 + (iHigh(Currency_Symbol, PERIOD_M15, 5) - iLow(Currency_Symbol, PERIOD_M15, 5)); + double ld_2176 = 2.0 * ld_2032 - iLow(Currency_Symbol, PERIOD_M15, 0); + double ld_2184 = 2.0 * ld_2040 - iLow(Currency_Symbol, PERIOD_M15, 1); + double ld_2192 = 2.0 * ld_2048 - iLow(Currency_Symbol, PERIOD_M15, 2); + double ld_2200 = 2.0 * ld_2056 - iLow(Currency_Symbol, PERIOD_M15, 3); + double ld_2208 = 2.0 * ld_2064 - iLow(Currency_Symbol, PERIOD_M15, 4); + double ld_2216 = 2.0 * ld_2072 - iLow(Currency_Symbol, PERIOD_M15, 5); + double ld_2224 = (iHigh(Currency_Symbol, PERIOD_M15, 0) + iLow(Currency_Symbol, PERIOD_M15, 0) + iClose(Currency_Symbol, PERIOD_M15, 0)) / 3.0; + double ld_2232 = (iHigh(Currency_Symbol, PERIOD_M15, 1) + iLow(Currency_Symbol, PERIOD_M15, 1) + iClose(Currency_Symbol, PERIOD_M15, 1)) / 3.0; + double ld_2240 = (iHigh(Currency_Symbol, PERIOD_M15, 2) + iLow(Currency_Symbol, PERIOD_M15, 2) + iClose(Currency_Symbol, PERIOD_M15, 2)) / 3.0; + double ld_2248 = (iHigh(Currency_Symbol, PERIOD_M15, 3) + iLow(Currency_Symbol, PERIOD_M15, 3) + iClose(Currency_Symbol, PERIOD_M15, 3)) / 3.0; + double ld_2256 = (iHigh(Currency_Symbol, PERIOD_M15, 4) + iLow(Currency_Symbol, PERIOD_M15, 4) + iClose(Currency_Symbol, PERIOD_M15, 4)) / 3.0; + double ld_2264 = (iHigh(Currency_Symbol, PERIOD_M15, 5) + iLow(Currency_Symbol, PERIOD_M15, 5) + iClose(Currency_Symbol, PERIOD_M15, 5)) / 3.0; + double ld_2272 = 2.0 * ld_2032 - iHigh(Currency_Symbol, PERIOD_M15, 0); + double ld_2280 = 2.0 * ld_2040 - iHigh(Currency_Symbol, PERIOD_M15, 1); + double ld_2288 = 2.0 * ld_2048 - iHigh(Currency_Symbol, PERIOD_M15, 2); + double ld_2296 = 2.0 * ld_2056 - iHigh(Currency_Symbol, PERIOD_M15, 3); + double ld_2304 = 2.0 * ld_2064 - iHigh(Currency_Symbol, PERIOD_M15, 4); + double ld_2312 = 2.0 * ld_2072 - iHigh(Currency_Symbol, PERIOD_M15, 5); + double ld_2320 = ld_2032 - (iHigh(Currency_Symbol, PERIOD_M15, 0) - iLow(Currency_Symbol, PERIOD_M15, 0)); + double ld_2328 = ld_2040 - (iHigh(Currency_Symbol, PERIOD_M15, 1) - iLow(Currency_Symbol, PERIOD_M15, 1)); + double ld_2336 = ld_2048 - (iHigh(Currency_Symbol, PERIOD_M15, 2) - iLow(Currency_Symbol, PERIOD_M15, 2)); + double ld_2344 = ld_2056 - (iHigh(Currency_Symbol, PERIOD_M15, 3) - iLow(Currency_Symbol, PERIOD_M15, 3)); + double ld_2352 = ld_2064 - (iHigh(Currency_Symbol, PERIOD_M15, 4) - iLow(Currency_Symbol, PERIOD_M15, 4)); + double ld_2360 = ld_2072 - (iHigh(Currency_Symbol, PERIOD_M15, 5) - iLow(Currency_Symbol, PERIOD_M15, 5)); + double ld_2368 = 2.0 * ld_2032 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 0) - iLow(Currency_Symbol, PERIOD_M15, 0)); + double ld_2376 = 2.0 * ld_2040 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 1) - iLow(Currency_Symbol, PERIOD_M15, 1)); + double ld_2384 = 2.0 * ld_2048 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 2) - iLow(Currency_Symbol, PERIOD_M15, 2)); + double ld_2392 = 2.0 * ld_2056 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 3) - iLow(Currency_Symbol, PERIOD_M15, 3)); + double ld_2400 = 2.0 * ld_2064 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 4) - iLow(Currency_Symbol, PERIOD_M15, 4)); + double ld_2408 = 2.0 * ld_2072 - (2.0 * iHigh(Currency_Symbol, PERIOD_M15, 5) - iLow(Currency_Symbol, PERIOD_M15, 5)); + if (ld_2032 > ld_40) { + ld_2416 = 0; + ld_2704 = 1; + } + if (ld_2032 < ld_40) { + ld_2416 = 1; + ld_2704 = 0; + } + if (ld_2040 > ld_40) { + ld_2424 = 0; + ld_2712 = 1; + } + if (ld_2040 < ld_40) { + ld_2424 = 1; + ld_2712 = 0; + } + if (ld_2048 > ld_40) { + ld_2432 = 0; + ld_2720 = 1; + } + if (ld_2048 < ld_40) { + ld_2432 = 1; + ld_2720 = 0; + } + if (ld_2056 > ld_40) { + ld_2440 = 0; + ld_2728 = 1; + } + if (ld_2056 < ld_40) { + ld_2440 = 1; + ld_2728 = 0; + } + if (ld_2064 > ld_40) { + ld_2448 = 0; + ld_2736 = 1; + } + if (ld_2064 < ld_40) { + ld_2448 = 1; + ld_2736 = 0; + } + if (ld_2176 > ld_40) { + ld_2456 = 0; + ld_2744 = 1; + } + if (ld_2176 < ld_40) { + ld_2456 = 1; + ld_2744 = 0; + } + if (ld_2184 > ld_40) { + ld_2464 = 0; + ld_2752 = 1; + } + if (ld_2184 < ld_40) { + ld_2464 = 1; + ld_2752 = 0; + } + if (ld_2192 > ld_40) { + ld_2472 = 0; + ld_2760 = 1; + } + if (ld_2192 < ld_40) { + ld_2472 = 1; + ld_2760 = 0; + } + if (ld_2200 > ld_40) { + ld_2480 = 0; + ld_2768 = 1; + } + if (ld_2200 < ld_40) { + ld_2480 = 1; + ld_2768 = 0; + } + if (ld_2208 > ld_40) { + ld_2488 = 0; + ld_2776 = 1; + } + if (ld_2208 < ld_40) { + ld_2488 = 1; + ld_2776 = 0; + } + if (ld_2216 > ld_40) { + ld_2496 = 0; + ld_2784 = 1; + } + if (ld_2216 < ld_40) { + ld_2496 = 1; + ld_2784 = 0; + } + if (ld_2272 > ld_40) { + ld_2504 = 0; + ld_2792 = 1; + } + if (ld_2272 < ld_40) { + ld_2504 = 1; + ld_2792 = 0; + } + if (ld_2280 > ld_40) { + ld_2512 = 0; + ld_2800 = 1; + } + if (ld_2280 < ld_40) { + ld_2512 = 1; + ld_2800 = 0; + } + if (ld_2288 > ld_40) { + ld_2520 = 0; + ld_2808 = 1; + } + if (ld_2288 < ld_40) { + ld_2520 = 1; + ld_2808 = 0; + } + if (ld_2296 > ld_40) { + ld_2528 = 0; + ld_2816 = 1; + } + if (ld_2296 < ld_40) { + ld_2528 = 1; + ld_2816 = 0; + } + if (ld_2304 > ld_40) { + ld_2536 = 0; + ld_2824 = 1; + } + if (ld_2304 < ld_40) { + ld_2536 = 1; + ld_2824 = 0; + } + if (ld_2312 > ld_40) { + ld_2544 = 0; + ld_2832 = 1; + } + if (ld_2312 < ld_40) { + ld_2544 = 1; + ld_2832 = 0; + } + if (ld_2128 > ld_40) { + ld_2552 = 0; + ld_2840 = 1; + } + if (ld_2128 < ld_40) { + ld_2552 = 1; + ld_2840 = 0; + } + if (ld_2136 > ld_40) { + ld_2560 = 0; + ld_2848 = 1; + } + if (ld_2136 < ld_40) { + ld_2560 = 1; + ld_2848 = 0; + } + if (ld_2144 > ld_40) { + ld_2568 = 0; + ld_2856 = 1; + } + if (ld_2144 < ld_40) { + ld_2568 = 1; + ld_2856 = 0; + } + if (ld_2152 > ld_40) { + ld_2576 = 0; + ld_2864 = 1; + } + if (ld_2152 < ld_40) { + ld_2576 = 1; + ld_2864 = 0; + } + if (ld_2160 > ld_40) { + ld_2584 = 0; + ld_2872 = 1; + } + if (ld_2160 < ld_40) { + ld_2584 = 1; + ld_2872 = 0; + } + if (ld_2168 > ld_40) { + ld_2592 = 0; + ld_2880 = 1; + } + if (ld_2168 < ld_40) { + ld_2592 = 1; + ld_2880 = 0; + } + if (ld_2320 > ld_40) { + ld_2600 = 0; + ld_2888 = 1; + } + if (ld_2320 < ld_40) { + ld_2600 = 1; + ld_2888 = 0; + } + if (ld_2328 > ld_40) { + ld_2608 = 0; + ld_2896 = 1; + } + if (ld_2328 < ld_40) { + ld_2608 = 1; + ld_2896 = 0; + } + if (ld_2336 > ld_40) { + ld_2616 = 0; + ld_2904 = 1; + } + if (ld_2336 < ld_40) { + ld_2616 = 1; + ld_2904 = 0; + } + if (ld_2344 > ld_40) { + ld_2624 = 0; + ld_2912 = 1; + } + if (ld_2344 < ld_40) { + ld_2624 = 1; + ld_2912 = 0; + } + if (ld_2352 > ld_40) { + ld_2632 = 0; + ld_2920 = 1; + } + if (ld_2352 < ld_40) { + ld_2632 = 1; + ld_2920 = 0; + } + if (ld_2360 > ld_40) { + ld_2640 = 0; + ld_2928 = 1; + } + if (ld_2360 < ld_40) { + ld_2640 = 1; + ld_2928 = 0; + } + if (ld_2080 > ld_40) { + ld_2648 = 0; + ld_2936 = 1; + } + if (ld_2080 < ld_40) { + ld_2648 = 1; + ld_2936 = 0; + } + if (ld_2088 > ld_40) { + ld_2656 = 0; + ld_2944 = 1; + } + if (ld_2088 < ld_40) { + ld_2656 = 1; + ld_2944 = 0; + } + if (ld_2096 > ld_40) { + ld_2664 = 0; + ld_2952 = 1; + } + if (ld_2096 < ld_40) { + ld_2664 = 1; + ld_2952 = 0; + } + if (ld_2104 > ld_40) { + ld_2672 = 0; + ld_2968 = 1; + } + if (ld_2104 < ld_40) { + ld_2672 = 1; + ld_2968 = 0; + } + if (ld_2112 > ld_40) { + ld_2688 = 0; + ld_2976 = 1; + } + if (ld_2112 < ld_40) { + ld_2688 = 1; + ld_2976 = 0; + } + if (ld_2120 > ld_40) { + ld_2696 = 0; + ld_2984 = 1; + } + if (ld_2120 < ld_40) { + ld_2696 = 1; + ld_2984 = 0; + } + double ld_2992 = ld_2416 + ld_2424 + ld_2432 + ld_2440 + ld_2448 + ld_2456 + ld_2464 + ld_2472 + ld_2480 + ld_2488 + ld_2496 + ld_2504 + ld_2512 + ld_2520 + ld_2528 + ld_2536 + ld_2544 + ld_2552 + ld_2560 + ld_2568 + ld_2576 + ld_2584 + ld_2592 + ld_2600 + ld_2608 + ld_2616 + ld_2624 + ld_2632 + ld_2640 + ld_2528 + ld_2656 + ld_2664 + ld_2672 + ld_2680 + ld_2688 + ld_2696; + double ld_3000 = ld_2704 + ld_2712 + ld_2720 + ld_2728 + ld_2736 + ld_2744 + ld_2752 + ld_2760 + ld_2768 + ld_2776 + ld_2784 + ld_2792 + ld_2800 + ld_2808 + ld_2816 + ld_2824 + ld_2832 + ld_2840 + ld_2848 + ld_2856 + ld_2864 + ld_2872 + ld_2880 + ld_2888 + ld_2896 + ld_2904 + ld_2912 + ld_2920 + ld_2928 + ld_2816 + ld_2944 + ld_2952 + ld_2960 + ld_2968 + ld_2976 + ld_2984; + string l_dbl2str_3008 = DoubleToStr(100.0 * (ld_2992 / 36.0), 0); + string ls_unused_3016 = DoubleToStr(100 - StrToDouble(l_dbl2str_3008), 0); + double ld_3024 = (iHigh(Currency_Symbol, PERIOD_M30, 0) + iLow(Currency_Symbol, PERIOD_M30, 0) + iClose(Currency_Symbol, PERIOD_M30, 0)) / 3.0; + double ld_3032 = (iHigh(Currency_Symbol, PERIOD_M30, 1) + iLow(Currency_Symbol, PERIOD_M30, 1) + iClose(Currency_Symbol, PERIOD_M30, 1)) / 3.0; + double ld_3040 = (iHigh(Currency_Symbol, PERIOD_M30, 2) + iLow(Currency_Symbol, PERIOD_M30, 2) + iClose(Currency_Symbol, PERIOD_M30, 2)) / 3.0; + double ld_3048 = (iHigh(Currency_Symbol, PERIOD_M30, 3) + iLow(Currency_Symbol, PERIOD_M30, 3) + iClose(Currency_Symbol, PERIOD_M30, 3)) / 3.0; + double ld_3056 = (iHigh(Currency_Symbol, PERIOD_M30, 4) + iLow(Currency_Symbol, PERIOD_M30, 4) + iClose(Currency_Symbol, PERIOD_M30, 4)) / 3.0; + double ld_3064 = (iHigh(Currency_Symbol, PERIOD_M30, 5) + iLow(Currency_Symbol, PERIOD_M30, 5) + iClose(Currency_Symbol, PERIOD_M30, 5)) / 3.0; + double ld_3072 = 2.0 * ld_3024 + (iHigh(Currency_Symbol, PERIOD_M30, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 0)); + double ld_3080 = 2.0 * ld_3032 + (iHigh(Currency_Symbol, PERIOD_M30, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 1)); + double ld_3088 = 2.0 * ld_3040 + (iHigh(Currency_Symbol, PERIOD_M30, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 2)); + double ld_3096 = 2.0 * ld_3048 + (iHigh(Currency_Symbol, PERIOD_M30, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 3)); + double ld_3104 = 2.0 * ld_3056 + (iHigh(Currency_Symbol, PERIOD_M30, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 4)); + double ld_3112 = 2.0 * ld_3064 + (iHigh(Currency_Symbol, PERIOD_M30, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_M30, 5)); + double ld_3120 = ld_3024 + (iHigh(Currency_Symbol, PERIOD_M30, 0) - iLow(Currency_Symbol, PERIOD_M30, 0)); + double ld_3128 = ld_3032 + (iHigh(Currency_Symbol, PERIOD_M30, 1) - iLow(Currency_Symbol, PERIOD_M30, 1)); + double ld_3136 = ld_3040 + (iHigh(Currency_Symbol, PERIOD_M30, 2) - iLow(Currency_Symbol, PERIOD_M30, 2)); + double ld_3144 = ld_3048 + (iHigh(Currency_Symbol, PERIOD_M30, 3) - iLow(Currency_Symbol, PERIOD_M30, 3)); + double ld_3152 = ld_3056 + (iHigh(Currency_Symbol, PERIOD_M30, 4) - iLow(Currency_Symbol, PERIOD_M30, 4)); + double ld_3160 = ld_3064 + (iHigh(Currency_Symbol, PERIOD_M30, 5) - iLow(Currency_Symbol, PERIOD_M30, 5)); + double ld_3168 = 2.0 * ld_3024 - iLow(Currency_Symbol, PERIOD_M30, 0); + double ld_3176 = 2.0 * ld_3032 - iLow(Currency_Symbol, PERIOD_M30, 1); + double ld_3184 = 2.0 * ld_3040 - iLow(Currency_Symbol, PERIOD_M30, 2); + double ld_3192 = 2.0 * ld_3048 - iLow(Currency_Symbol, PERIOD_M30, 3); + double ld_3200 = 2.0 * ld_3056 - iLow(Currency_Symbol, PERIOD_M30, 4); + double ld_3208 = 2.0 * ld_3064 - iLow(Currency_Symbol, PERIOD_M30, 5); + double ld_3216 = (iHigh(Currency_Symbol, PERIOD_M30, 0) + iLow(Currency_Symbol, PERIOD_M30, 0) + iClose(Currency_Symbol, PERIOD_M30, 0)) / 3.0; + double ld_3224 = (iHigh(Currency_Symbol, PERIOD_M30, 1) + iLow(Currency_Symbol, PERIOD_M30, 1) + iClose(Currency_Symbol, PERIOD_M30, 1)) / 3.0; + double ld_3232 = (iHigh(Currency_Symbol, PERIOD_M30, 2) + iLow(Currency_Symbol, PERIOD_M30, 2) + iClose(Currency_Symbol, PERIOD_M30, 2)) / 3.0; + double ld_3240 = (iHigh(Currency_Symbol, PERIOD_M30, 3) + iLow(Currency_Symbol, PERIOD_M30, 3) + iClose(Currency_Symbol, PERIOD_M30, 3)) / 3.0; + double ld_3248 = (iHigh(Currency_Symbol, PERIOD_M30, 4) + iLow(Currency_Symbol, PERIOD_M30, 4) + iClose(Currency_Symbol, PERIOD_M30, 4)) / 3.0; + double ld_3256 = (iHigh(Currency_Symbol, PERIOD_M30, 5) + iLow(Currency_Symbol, PERIOD_M30, 5) + iClose(Currency_Symbol, PERIOD_M30, 5)) / 3.0; + double ld_3264 = 2.0 * ld_3024 - iHigh(Currency_Symbol, PERIOD_M30, 0); + double ld_3272 = 2.0 * ld_3032 - iHigh(Currency_Symbol, PERIOD_M30, 1); + double ld_3280 = 2.0 * ld_3040 - iHigh(Currency_Symbol, PERIOD_M30, 2); + double ld_3288 = 2.0 * ld_3048 - iHigh(Currency_Symbol, PERIOD_M30, 3); + double ld_3296 = 2.0 * ld_3056 - iHigh(Currency_Symbol, PERIOD_M30, 4); + double ld_3304 = 2.0 * ld_3064 - iHigh(Currency_Symbol, PERIOD_M30, 5); + double ld_3312 = ld_3024 - (iHigh(Currency_Symbol, PERIOD_M30, 0) - iLow(Currency_Symbol, PERIOD_M30, 0)); + double ld_3320 = ld_3032 - (iHigh(Currency_Symbol, PERIOD_M30, 1) - iLow(Currency_Symbol, PERIOD_M30, 1)); + double ld_3328 = ld_3040 - (iHigh(Currency_Symbol, PERIOD_M30, 2) - iLow(Currency_Symbol, PERIOD_M30, 2)); + double ld_3336 = ld_3048 - (iHigh(Currency_Symbol, PERIOD_M30, 3) - iLow(Currency_Symbol, PERIOD_M30, 3)); + double ld_3344 = ld_3056 - (iHigh(Currency_Symbol, PERIOD_M30, 4) - iLow(Currency_Symbol, PERIOD_M30, 4)); + double ld_3352 = ld_3064 - (iHigh(Currency_Symbol, PERIOD_M30, 5) - iLow(Currency_Symbol, PERIOD_M30, 5)); + double ld_3360 = 2.0 * ld_3024 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 0) - iLow(Currency_Symbol, PERIOD_M30, 0)); + double ld_3368 = 2.0 * ld_3032 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 1) - iLow(Currency_Symbol, PERIOD_M30, 1)); + double ld_3376 = 2.0 * ld_3040 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 2) - iLow(Currency_Symbol, PERIOD_M30, 2)); + double ld_3384 = 2.0 * ld_3048 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 3) - iLow(Currency_Symbol, PERIOD_M30, 3)); + double ld_3392 = 2.0 * ld_3056 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 4) - iLow(Currency_Symbol, PERIOD_M30, 4)); + double ld_3400 = 2.0 * ld_3064 - (2.0 * iHigh(Currency_Symbol, PERIOD_M30, 5) - iLow(Currency_Symbol, PERIOD_M30, 5)); + if (ld_3024 > ld_40) { + ld_3408 = 0; + ld_3696 = 1; + } + if (ld_3024 < ld_40) { + ld_3408 = 1; + ld_3696 = 0; + } + if (ld_3032 > ld_40) { + ld_3416 = 0; + ld_3704 = 1; + } + if (ld_3032 < ld_40) { + ld_3416 = 1; + ld_3704 = 0; + } + if (ld_3040 > ld_40) { + ld_3424 = 0; + ld_3712 = 1; + } + if (ld_3040 < ld_40) { + ld_3424 = 1; + ld_3712 = 0; + } + if (ld_3048 > ld_40) { + ld_3432 = 0; + ld_3720 = 1; + } + if (ld_3048 < ld_40) { + ld_3432 = 1; + ld_3720 = 0; + } + if (ld_3056 > ld_40) { + ld_3440 = 0; + ld_3728 = 1; + } + if (ld_3056 < ld_40) { + ld_3440 = 1; + ld_3728 = 0; + } + if (ld_3168 > ld_40) { + ld_3448 = 0; + ld_3736 = 1; + } + if (ld_3168 < ld_40) { + ld_3448 = 1; + ld_3736 = 0; + } + if (ld_3176 > ld_40) { + ld_3456 = 0; + ld_3744 = 1; + } + if (ld_3176 < ld_40) { + ld_3456 = 1; + ld_3744 = 0; + } + if (ld_3184 > ld_40) { + ld_3464 = 0; + ld_3752 = 1; + } + if (ld_3184 < ld_40) { + ld_3464 = 1; + ld_3752 = 0; + } + if (ld_3192 > ld_40) { + ld_3472 = 0; + ld_3760 = 1; + } + if (ld_3192 < ld_40) { + ld_3472 = 1; + ld_3760 = 0; + } + if (ld_3200 > ld_40) { + ld_3480 = 0; + ld_3768 = 1; + } + if (ld_3200 < ld_40) { + ld_3480 = 1; + ld_3768 = 0; + } + if (ld_3208 > ld_40) { + ld_3488 = 0; + ld_3776 = 1; + } + if (ld_3208 < ld_40) { + ld_3488 = 1; + ld_3776 = 0; + } + if (ld_3264 > ld_40) { + ld_3496 = 0; + ld_3784 = 1; + } + if (ld_3264 < ld_40) { + ld_3496 = 1; + ld_3784 = 0; + } + if (ld_3272 > ld_40) { + ld_3504 = 0; + ld_3792 = 1; + } + if (ld_3272 < ld_40) { + ld_3504 = 1; + ld_3792 = 0; + } + if (ld_3280 > ld_40) { + ld_3512 = 0; + ld_3800 = 1; + } + if (ld_3280 < ld_40) { + ld_3512 = 1; + ld_3800 = 0; + } + if (ld_3288 > ld_40) { + ld_3520 = 0; + ld_3808 = 1; + } + if (ld_3288 < ld_40) { + ld_3520 = 1; + ld_3808 = 0; + } + if (ld_3296 > ld_40) { + ld_3528 = 0; + ld_3816 = 1; + } + if (ld_3296 < ld_40) { + ld_3528 = 1; + ld_3816 = 0; + } + if (ld_3304 > ld_40) { + ld_3536 = 0; + ld_3824 = 1; + } + if (ld_3304 < ld_40) { + ld_3536 = 1; + ld_3824 = 0; + } + if (ld_3120 > ld_40) { + ld_3544 = 0; + ld_3832 = 1; + } + if (ld_3120 < ld_40) { + ld_3544 = 1; + ld_3832 = 0; + } + if (ld_3128 > ld_40) { + ld_3552 = 0; + ld_3840 = 1; + } + if (ld_3128 < ld_40) { + ld_3552 = 1; + ld_3840 = 0; + } + if (ld_3136 > ld_40) { + ld_3560 = 0; + ld_3848 = 1; + } + if (ld_3136 < ld_40) { + ld_3560 = 1; + ld_3848 = 0; + } + if (ld_3144 > ld_40) { + ld_3568 = 0; + ld_3856 = 1; + } + if (ld_3144 < ld_40) { + ld_3568 = 1; + ld_3856 = 0; + } + if (ld_3152 > ld_40) { + ld_3576 = 0; + ld_3864 = 1; + } + if (ld_3152 < ld_40) { + ld_3576 = 1; + ld_3864 = 0; + } + if (ld_3160 > ld_40) { + ld_3584 = 0; + ld_3872 = 1; + } + if (ld_3160 < ld_40) { + ld_3584 = 1; + ld_3872 = 0; + } + if (ld_3312 > ld_40) { + ld_3592 = 0; + ld_3880 = 1; + } + if (ld_3312 < ld_40) { + ld_3592 = 1; + ld_3880 = 0; + } + if (ld_3320 > ld_40) { + ld_3600 = 0; + ld_3888 = 1; + } + if (ld_3320 < ld_40) { + ld_3600 = 1; + ld_3888 = 0; + } + if (ld_3328 > ld_40) { + ld_3608 = 0; + ld_3896 = 1; + } + if (ld_3328 < ld_40) { + ld_3608 = 1; + ld_3896 = 0; + } + if (ld_3336 > ld_40) { + ld_3616 = 0; + ld_3904 = 1; + } + if (ld_3336 < ld_40) { + ld_3616 = 1; + ld_3904 = 0; + } + if (ld_3344 > ld_40) { + ld_3624 = 0; + ld_3912 = 1; + } + if (ld_3344 < ld_40) { + ld_3624 = 1; + ld_3912 = 0; + } + if (ld_3352 > ld_40) { + ld_3632 = 0; + ld_3920 = 1; + } + if (ld_3352 < ld_40) { + ld_3632 = 1; + ld_3920 = 0; + } + if (ld_3072 > ld_40) { + ld_3640 = 0; + ld_3928 = 1; + } + if (ld_3072 < ld_40) { + ld_3640 = 1; + ld_3928 = 0; + } + if (ld_3080 > ld_40) { + ld_3648 = 0; + ld_3936 = 1; + } + if (ld_3080 < ld_40) { + ld_3648 = 1; + ld_3936 = 0; + } + if (ld_3088 > ld_40) { + ld_3656 = 0; + ld_3944 = 1; + } + if (ld_3088 < ld_40) { + ld_3656 = 1; + ld_3944 = 0; + } + if (ld_3096 > ld_40) { + ld_3664 = 0; + ld_3960 = 1; + } + if (ld_3096 < ld_40) { + ld_3664 = 1; + ld_3960 = 0; + } + if (ld_3104 > ld_40) { + ld_3680 = 0; + ld_3968 = 1; + } + if (ld_3104 < ld_40) { + ld_3680 = 1; + ld_3968 = 0; + } + if (ld_3112 > ld_40) { + ld_3688 = 0; + ld_3976 = 1; + } + if (ld_3112 < ld_40) { + ld_3688 = 1; + ld_3976 = 0; + } + double ld_3984 = ld_3408 + ld_3416 + ld_3424 + ld_3432 + ld_3440 + ld_3448 + ld_3456 + ld_3464 + ld_3472 + ld_3480 + ld_3488 + ld_3496 + ld_3504 + ld_3512 + ld_3520 + ld_3528 + ld_3536 + ld_3544 + ld_3552 + ld_3560 + ld_3568 + ld_3576 + ld_3584 + ld_3592 + ld_3600 + ld_3608 + ld_3616 + ld_3624 + ld_3632 + ld_3640 + ld_3648 + ld_3656 + ld_3664 + ld_3672 + ld_3680 + ld_3688 + ld_2416 + ld_2424 + ld_2432 + ld_2440 + ld_2448 + ld_2456 + ld_2464 + ld_2472 + ld_2480 + ld_2488 + ld_2496 + ld_2504 + ld_2512 + ld_2520 + ld_2528 + ld_2536 + ld_2544 + ld_2552 + ld_2560 + ld_2568 + ld_2576 + ld_2584 + ld_2592 + ld_2600 + ld_2608 + ld_2616 + ld_2624 + ld_2632 + ld_2640 + ld_2648 + ld_2656 + ld_2664 + ld_2672 + ld_2680 + ld_2688 + ld_2696; + double ld_3992 = ld_3696 + ld_3704 + ld_3712 + ld_3720 + ld_3728 + ld_3736 + ld_3744 + ld_3752 + ld_3760 + ld_3768 + ld_3776 + ld_3784 + ld_3792 + ld_3800 + ld_3808 + ld_3816 + ld_3824 + ld_3832 + ld_3840 + ld_3848 + ld_3856 + ld_3864 + ld_3872 + ld_3880 + ld_3888 + ld_3896 + ld_3904 + ld_3912 + ld_3920 + ld_3928 + ld_3936 + ld_3944 + ld_3952 + ld_3960 + ld_3968 + ld_3976 + ld_2704 + ld_2712 + ld_2720 + ld_2728 + ld_2736 + ld_2744 + ld_2752 + ld_2760 + ld_2768 + ld_2776 + ld_2784 + ld_2792 + ld_2800 + ld_2808 + ld_2816 + ld_2824 + ld_2832 + ld_2840 + ld_2848 + ld_2856 + ld_2864 + ld_2872 + ld_2880 + ld_2888 + ld_2896 + ld_2904 + ld_2912 + ld_2920 + ld_2928 + ld_2936 + ld_2944 + ld_2952 + ld_2960 + ld_2968 + ld_2976 + ld_2984; + string l_dbl2str_4000 = DoubleToStr(100.0 * (ld_3984 / 72.0), 0); + string l_dbl2str_4008 = DoubleToStr(100 - StrToDouble(l_dbl2str_4000), 0); + double ld_4016 = (iHigh(Currency_Symbol, PERIOD_H1, 0) + iLow(Currency_Symbol, PERIOD_H1, 0) + iClose(Currency_Symbol, PERIOD_H1, 0)) / 3.0; + double ld_4024 = (iHigh(Currency_Symbol, PERIOD_H1, 1) + iLow(Currency_Symbol, PERIOD_H1, 1) + iClose(Currency_Symbol, PERIOD_H1, 1)) / 3.0; + double ld_4032 = (iHigh(Currency_Symbol, PERIOD_H1, 2) + iLow(Currency_Symbol, PERIOD_H1, 2) + iClose(Currency_Symbol, PERIOD_H1, 2)) / 3.0; + double ld_4040 = (iHigh(Currency_Symbol, PERIOD_H1, 3) + iLow(Currency_Symbol, PERIOD_H1, 3) + iClose(Currency_Symbol, PERIOD_H1, 3)) / 3.0; + double ld_4048 = (iHigh(Currency_Symbol, PERIOD_H1, 4) + iLow(Currency_Symbol, PERIOD_H1, 4) + iClose(Currency_Symbol, PERIOD_H1, 4)) / 3.0; + double ld_4056 = (iHigh(Currency_Symbol, PERIOD_H1, 5) + iLow(Currency_Symbol, PERIOD_H1, 5) + iClose(Currency_Symbol, PERIOD_H1, 5)) / 3.0; + double ld_4064 = 2.0 * ld_4016 + (iHigh(Currency_Symbol, PERIOD_H1, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 0)); + double ld_4072 = 2.0 * ld_4024 + (iHigh(Currency_Symbol, PERIOD_H1, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 1)); + double ld_4080 = 2.0 * ld_4032 + (iHigh(Currency_Symbol, PERIOD_H1, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 2)); + double ld_4088 = 2.0 * ld_4040 + (iHigh(Currency_Symbol, PERIOD_H1, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 3)); + double ld_4096 = 2.0 * ld_4048 + (iHigh(Currency_Symbol, PERIOD_H1, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 4)); + double ld_4104 = 2.0 * ld_4056 + (iHigh(Currency_Symbol, PERIOD_H1, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_H1, 5)); + double ld_4112 = ld_4016 + (iHigh(Currency_Symbol, PERIOD_H1, 0) - iLow(Currency_Symbol, PERIOD_H1, 0)); + double ld_4120 = ld_4024 + (iHigh(Currency_Symbol, PERIOD_H1, 1) - iLow(Currency_Symbol, PERIOD_H1, 1)); + double ld_4128 = ld_4032 + (iHigh(Currency_Symbol, PERIOD_H1, 2) - iLow(Currency_Symbol, PERIOD_H1, 2)); + double ld_4136 = ld_4040 + (iHigh(Currency_Symbol, PERIOD_H1, 3) - iLow(Currency_Symbol, PERIOD_H1, 3)); + double ld_4144 = ld_4048 + (iHigh(Currency_Symbol, PERIOD_H1, 4) - iLow(Currency_Symbol, PERIOD_H1, 4)); + double ld_4152 = ld_4056 + (iHigh(Currency_Symbol, PERIOD_H1, 5) - iLow(Currency_Symbol, PERIOD_H1, 5)); + double ld_4160 = 2.0 * ld_4016 - iLow(Currency_Symbol, PERIOD_H1, 0); + double ld_4168 = 2.0 * ld_4024 - iLow(Currency_Symbol, PERIOD_H1, 1); + double ld_4176 = 2.0 * ld_4032 - iLow(Currency_Symbol, PERIOD_H1, 2); + double ld_4184 = 2.0 * ld_4040 - iLow(Currency_Symbol, PERIOD_H1, 3); + double ld_4192 = 2.0 * ld_4048 - iLow(Currency_Symbol, PERIOD_H1, 4); + double ld_4200 = 2.0 * ld_4056 - iLow(Currency_Symbol, PERIOD_H1, 5); + double ld_4208 = (iHigh(Currency_Symbol, PERIOD_H1, 0) + iLow(Currency_Symbol, PERIOD_H1, 0) + iClose(Currency_Symbol, PERIOD_H1, 0)) / 3.0; + double ld_4216 = (iHigh(Currency_Symbol, PERIOD_H1, 1) + iLow(Currency_Symbol, PERIOD_H1, 1) + iClose(Currency_Symbol, PERIOD_H1, 1)) / 3.0; + double ld_4224 = (iHigh(Currency_Symbol, PERIOD_H1, 2) + iLow(Currency_Symbol, PERIOD_H1, 2) + iClose(Currency_Symbol, PERIOD_H1, 2)) / 3.0; + double ld_4232 = (iHigh(Currency_Symbol, PERIOD_H1, 3) + iLow(Currency_Symbol, PERIOD_H1, 3) + iClose(Currency_Symbol, PERIOD_H1, 3)) / 3.0; + double ld_4240 = (iHigh(Currency_Symbol, PERIOD_H1, 4) + iLow(Currency_Symbol, PERIOD_H1, 4) + iClose(Currency_Symbol, PERIOD_H1, 4)) / 3.0; + double ld_4248 = (iHigh(Currency_Symbol, PERIOD_H1, 5) + iLow(Currency_Symbol, PERIOD_H1, 5) + iClose(Currency_Symbol, PERIOD_H1, 5)) / 3.0; + double ld_4256 = 2.0 * ld_4016 - iHigh(Currency_Symbol, PERIOD_H1, 0); + double ld_4264 = 2.0 * ld_4024 - iHigh(Currency_Symbol, PERIOD_H1, 1); + double ld_4272 = 2.0 * ld_4032 - iHigh(Currency_Symbol, PERIOD_H1, 2); + double ld_4280 = 2.0 * ld_4040 - iHigh(Currency_Symbol, PERIOD_H1, 3); + double ld_4288 = 2.0 * ld_4048 - iHigh(Currency_Symbol, PERIOD_H1, 4); + double ld_4296 = 2.0 * ld_4056 - iHigh(Currency_Symbol, PERIOD_H1, 5); + double ld_4304 = ld_4016 - (iHigh(Currency_Symbol, PERIOD_H1, 0) - iLow(Currency_Symbol, PERIOD_H1, 0)); + double ld_4312 = ld_4024 - (iHigh(Currency_Symbol, PERIOD_H1, 1) - iLow(Currency_Symbol, PERIOD_H1, 1)); + double ld_4320 = ld_4032 - (iHigh(Currency_Symbol, PERIOD_H1, 2) - iLow(Currency_Symbol, PERIOD_H1, 2)); + double ld_4328 = ld_4040 - (iHigh(Currency_Symbol, PERIOD_H1, 3) - iLow(Currency_Symbol, PERIOD_H1, 3)); + double ld_4336 = ld_4048 - (iHigh(Currency_Symbol, PERIOD_H1, 4) - iLow(Currency_Symbol, PERIOD_H1, 4)); + double ld_4344 = ld_4056 - (iHigh(Currency_Symbol, PERIOD_H1, 5) - iLow(Currency_Symbol, PERIOD_H1, 5)); + double ld_4352 = 2.0 * ld_4016 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 0) - iLow(Currency_Symbol, PERIOD_H1, 0)); + double ld_4360 = 2.0 * ld_4024 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 1) - iLow(Currency_Symbol, PERIOD_H1, 1)); + double ld_4368 = 2.0 * ld_4032 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 2) - iLow(Currency_Symbol, PERIOD_H1, 2)); + double ld_4376 = 2.0 * ld_4040 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 3) - iLow(Currency_Symbol, PERIOD_H1, 3)); + double ld_4384 = 2.0 * ld_4048 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 4) - iLow(Currency_Symbol, PERIOD_H1, 4)); + double ld_4392 = 2.0 * ld_4056 - (2.0 * iHigh(Currency_Symbol, PERIOD_H1, 5) - iLow(Currency_Symbol, PERIOD_H1, 5)); + if (ld_4016 > ld_40) { + ld_4400 = 0; + ld_4688 = 1; + } + if (ld_4016 < ld_40) { + ld_4400 = 1; + ld_4688 = 0; + } + if (ld_4024 > ld_40) { + ld_4408 = 0; + ld_4696 = 1; + } + if (ld_4024 < ld_40) { + ld_4408 = 1; + ld_4696 = 0; + } + if (ld_4032 > ld_40) { + ld_4416 = 0; + ld_4704 = 1; + } + if (ld_4032 < ld_40) { + ld_4416 = 1; + ld_4704 = 0; + } + if (ld_4040 > ld_40) { + ld_4424 = 0; + ld_4712 = 1; + } + if (ld_4040 < ld_40) { + ld_4424 = 1; + ld_4712 = 0; + } + if (ld_4048 > ld_40) { + ld_4432 = 0; + ld_4720 = 1; + } + if (ld_4048 < ld_40) { + ld_4432 = 1; + ld_4720 = 0; + } + if (ld_4160 > ld_40) { + ld_4440 = 0; + ld_4728 = 1; + } + if (ld_4160 < ld_40) { + ld_4440 = 1; + ld_4728 = 0; + } + if (ld_4168 > ld_40) { + ld_4448 = 0; + ld_4736 = 1; + } + if (ld_4168 < ld_40) { + ld_4448 = 1; + ld_4736 = 0; + } + if (ld_4176 > ld_40) { + ld_4456 = 0; + ld_4744 = 1; + } + if (ld_4176 < ld_40) { + ld_4456 = 1; + ld_4744 = 0; + } + if (ld_4184 > ld_40) { + ld_4464 = 0; + ld_4752 = 1; + } + if (ld_4184 < ld_40) { + ld_4464 = 1; + ld_4752 = 0; + } + if (ld_4192 > ld_40) { + ld_4472 = 0; + ld_4760 = 1; + } + if (ld_4192 < ld_40) { + ld_4472 = 1; + ld_4760 = 0; + } + if (ld_4200 > ld_40) { + ld_4480 = 0; + ld_4768 = 1; + } + if (ld_4200 < ld_40) { + ld_4480 = 1; + ld_4768 = 0; + } + if (ld_4256 > ld_40) { + ld_4488 = 0; + ld_4776 = 1; + } + if (ld_4256 < ld_40) { + ld_4488 = 1; + ld_4776 = 0; + } + if (ld_4264 > ld_40) { + ld_4496 = 0; + ld_4784 = 1; + } + if (ld_4264 < ld_40) { + ld_4496 = 1; + ld_4784 = 0; + } + if (ld_4272 > ld_40) { + ld_4504 = 0; + ld_4792 = 1; + } + if (ld_4272 < ld_40) { + ld_4504 = 1; + ld_4792 = 0; + } + if (ld_4280 > ld_40) { + ld_4512 = 0; + ld_4800 = 1; + } + if (ld_4280 < ld_40) { + ld_4512 = 1; + ld_4800 = 0; + } + if (ld_4288 > ld_40) { + ld_4520 = 0; + ld_4808 = 1; + } + if (ld_4288 < ld_40) { + ld_4520 = 1; + ld_4808 = 0; + } + if (ld_4296 > ld_40) { + ld_4528 = 0; + ld_4816 = 1; + } + if (ld_4296 < ld_40) { + ld_4528 = 1; + ld_4816 = 0; + } + if (ld_4112 > ld_40) { + ld_4536 = 0; + ld_4824 = 1; + } + if (ld_4112 < ld_40) { + ld_4536 = 1; + ld_4824 = 0; + } + if (ld_4120 > ld_40) { + ld_4544 = 0; + ld_4832 = 1; + } + if (ld_4120 < ld_40) { + ld_4544 = 1; + ld_4832 = 0; + } + if (ld_4128 > ld_40) { + ld_4552 = 0; + ld_4840 = 1; + } + if (ld_4128 < ld_40) { + ld_4552 = 1; + ld_4840 = 0; + } + if (ld_4136 > ld_40) { + ld_4560 = 0; + ld_4848 = 1; + } + if (ld_4136 < ld_40) { + ld_4560 = 1; + ld_4848 = 0; + } + if (ld_4144 > ld_40) { + ld_4568 = 0; + ld_4856 = 1; + } + if (ld_4144 < ld_40) { + ld_4568 = 1; + ld_4856 = 0; + } + if (ld_4152 > ld_40) { + ld_4576 = 0; + ld_4864 = 1; + } + if (ld_4152 < ld_40) { + ld_4576 = 1; + ld_4864 = 0; + } + if (ld_4304 > ld_40) { + ld_4584 = 0; + ld_4872 = 1; + } + if (ld_4304 < ld_40) { + ld_4584 = 1; + ld_4872 = 0; + } + if (ld_4312 > ld_40) { + ld_4592 = 0; + ld_4880 = 1; + } + if (ld_4312 < ld_40) { + ld_4592 = 1; + ld_4880 = 0; + } + if (ld_4320 > ld_40) { + ld_4600 = 0; + ld_4888 = 1; + } + if (ld_4320 < ld_40) { + ld_4600 = 1; + ld_4888 = 0; + } + if (ld_4328 > ld_40) { + ld_4608 = 0; + ld_4896 = 1; + } + if (ld_4328 < ld_40) { + ld_4608 = 1; + ld_4896 = 0; + } + if (ld_4336 > ld_40) { + ld_4616 = 0; + ld_4904 = 1; + } + if (ld_4336 < ld_40) { + ld_4616 = 1; + ld_4904 = 0; + } + if (ld_4344 > ld_40) { + ld_4624 = 0; + ld_4912 = 1; + } + if (ld_4344 < ld_40) { + ld_4624 = 1; + ld_4912 = 0; + } + if (ld_4064 > ld_40) { + ld_4632 = 0; + ld_4920 = 1; + } + if (ld_4064 < ld_40) { + ld_4632 = 1; + ld_4920 = 0; + } + if (ld_4072 > ld_40) { + ld_4640 = 0; + ld_4928 = 1; + } + if (ld_4072 < ld_40) { + ld_4640 = 1; + ld_4928 = 0; + } + if (ld_4080 > ld_40) { + ld_4648 = 0; + ld_4936 = 1; + } + if (ld_4080 < ld_40) { + ld_4648 = 1; + ld_4936 = 0; + } + if (ld_4088 > ld_40) { + ld_4656 = 0; + ld_4952 = 1; + } + if (ld_4088 < ld_40) { + ld_4656 = 1; + ld_4952 = 0; + } + if (ld_4096 > ld_40) { + ld_4672 = 0; + ld_4960 = 1; + } + if (ld_4096 < ld_40) { + ld_4672 = 1; + ld_4960 = 0; + } + if (ld_4104 > ld_40) { + ld_4680 = 0; + ld_4968 = 1; + } + if (ld_4104 < ld_40) { + ld_4680 = 1; + ld_4968 = 0; + } + double ld_4976 = ld_4400 + ld_4408 + ld_4416 + ld_4424 + ld_4432 + ld_4440 + ld_4448 + ld_4456 + ld_4464 + ld_4472 + ld_4480 + ld_4488 + ld_4496 + ld_4504 + ld_4512 + ld_4520 + ld_4528 + ld_4536 + ld_4544 + ld_4552 + ld_4560 + ld_4568 + ld_4576 + ld_4584 + ld_4592 + ld_4600 + ld_4608 + ld_4616 + ld_4624 + ld_4632 + ld_4640 + ld_4648 + ld_4656 + ld_4664 + ld_4672 + ld_4680; + double ld_4984 = ld_4688 + ld_4696 + ld_4704 + ld_4712 + ld_4720 + ld_4728 + ld_4736 + ld_4744 + ld_4752 + ld_4760 + ld_4768 + ld_4776 + ld_4784 + ld_4792 + ld_4800 + ld_4808 + ld_4816 + ld_4824 + ld_4832 + ld_4840 + ld_4848 + ld_4856 + ld_4864 + ld_4872 + ld_4880 + ld_4888 + ld_4896 + ld_4904 + ld_4912 + ld_4920 + ld_4928 + ld_4936 + ld_4944 + ld_4952 + ld_4960 + ld_4968; + string l_dbl2str_4992 = DoubleToStr(100.0 * (ld_4976 / 36.0), 0); + string ls_unused_5000 = DoubleToStr(100 - StrToDouble(l_dbl2str_4992), 0); + double ld_5008 = (iHigh(Currency_Symbol, PERIOD_H4, 0) + iLow(Currency_Symbol, PERIOD_H4, 0) + iClose(Currency_Symbol, PERIOD_H4, 0)) / 3.0; + double ld_5016 = (iHigh(Currency_Symbol, PERIOD_H4, 1) + iLow(Currency_Symbol, PERIOD_H4, 1) + iClose(Currency_Symbol, PERIOD_H4, 1)) / 3.0; + double ld_5024 = (iHigh(Currency_Symbol, PERIOD_H4, 2) + iLow(Currency_Symbol, PERIOD_H4, 2) + iClose(Currency_Symbol, PERIOD_H4, 2)) / 3.0; + double ld_5032 = (iHigh(Currency_Symbol, PERIOD_H4, 3) + iLow(Currency_Symbol, PERIOD_H4, 3) + iClose(Currency_Symbol, PERIOD_H4, 3)) / 3.0; + double ld_5040 = (iHigh(Currency_Symbol, PERIOD_H4, 4) + iLow(Currency_Symbol, PERIOD_H4, 4) + iClose(Currency_Symbol, PERIOD_H4, 4)) / 3.0; + double ld_5048 = (iHigh(Currency_Symbol, PERIOD_H4, 5) + iLow(Currency_Symbol, PERIOD_H4, 5) + iClose(Currency_Symbol, PERIOD_H4, 5)) / 3.0; + double ld_5056 = 2.0 * ld_5008 + (iHigh(Currency_Symbol, PERIOD_H4, 0) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 0)); + double ld_5064 = 2.0 * ld_5016 + (iHigh(Currency_Symbol, PERIOD_H4, 1) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 1)); + double ld_5072 = 2.0 * ld_5024 + (iHigh(Currency_Symbol, PERIOD_H4, 2) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 2)); + double ld_5080 = 2.0 * ld_5032 + (iHigh(Currency_Symbol, PERIOD_H4, 3) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 3)); + double ld_5088 = 2.0 * ld_5040 + (iHigh(Currency_Symbol, PERIOD_H4, 4) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 4)); + double ld_5096 = 2.0 * ld_5048 + (iHigh(Currency_Symbol, PERIOD_H4, 5) - 2.0 * iLow(Currency_Symbol, PERIOD_H4, 5)); + double ld_5104 = ld_5008 + (iHigh(Currency_Symbol, PERIOD_H4, 0) - iLow(Currency_Symbol, PERIOD_H4, 0)); + double ld_5112 = ld_5016 + (iHigh(Currency_Symbol, PERIOD_H4, 1) - iLow(Currency_Symbol, PERIOD_H4, 1)); + double ld_5120 = ld_5024 + (iHigh(Currency_Symbol, PERIOD_H4, 2) - iLow(Currency_Symbol, PERIOD_H4, 2)); + double ld_5128 = ld_5032 + (iHigh(Currency_Symbol, PERIOD_H4, 3) - iLow(Currency_Symbol, PERIOD_H4, 3)); + double ld_5136 = ld_5040 + (iHigh(Currency_Symbol, PERIOD_H4, 4) - iLow(Currency_Symbol, PERIOD_H4, 4)); + double ld_5144 = ld_5048 + (iHigh(Currency_Symbol, PERIOD_H4, 5) - iLow(Currency_Symbol, PERIOD_H4, 5)); + double ld_5152 = 2.0 * ld_5008 - iLow(Currency_Symbol, PERIOD_H4, 0); + double ld_5160 = 2.0 * ld_5016 - iLow(Currency_Symbol, PERIOD_H4, 1); + double ld_5168 = 2.0 * ld_5024 - iLow(Currency_Symbol, PERIOD_H4, 2); + double ld_5176 = 2.0 * ld_5032 - iLow(Currency_Symbol, PERIOD_H4, 3); + double ld_5184 = 2.0 * ld_5040 - iLow(Currency_Symbol, PERIOD_H4, 4); + double ld_5192 = 2.0 * ld_5048 - iLow(Currency_Symbol, PERIOD_H4, 5); + double ld_5200 = (iHigh(Currency_Symbol, PERIOD_H4, 0) + iLow(Currency_Symbol, PERIOD_H4, 0) + iClose(Currency_Symbol, PERIOD_H4, 0)) / 3.0; + double ld_5208 = (iHigh(Currency_Symbol, PERIOD_H4, 1) + iLow(Currency_Symbol, PERIOD_H4, 1) + iClose(Currency_Symbol, PERIOD_H4, 1)) / 3.0; + double ld_5216 = (iHigh(Currency_Symbol, PERIOD_H4, 2) + iLow(Currency_Symbol, PERIOD_H4, 2) + iClose(Currency_Symbol, PERIOD_H4, 2)) / 3.0; + double ld_5224 = (iHigh(Currency_Symbol, PERIOD_H4, 3) + iLow(Currency_Symbol, PERIOD_H4, 3) + iClose(Currency_Symbol, PERIOD_H4, 3)) / 3.0; + double ld_5232 = (iHigh(Currency_Symbol, PERIOD_H4, 4) + iLow(Currency_Symbol, PERIOD_H4, 4) + iClose(Currency_Symbol, PERIOD_H4, 4)) / 3.0; + double ld_5240 = (iHigh(Currency_Symbol, PERIOD_H4, 5) + iLow(Currency_Symbol, PERIOD_H4, 5) + iClose(Currency_Symbol, PERIOD_H4, 5)) / 3.0; + double ld_5248 = 2.0 * ld_5008 - iHigh(Currency_Symbol, PERIOD_H4, 0); + double ld_5256 = 2.0 * ld_5016 - iHigh(Currency_Symbol, PERIOD_H4, 1); + double ld_5264 = 2.0 * ld_5024 - iHigh(Currency_Symbol, PERIOD_H4, 2); + double ld_5272 = 2.0 * ld_5032 - iHigh(Currency_Symbol, PERIOD_H4, 3); + double ld_5280 = 2.0 * ld_5040 - iHigh(Currency_Symbol, PERIOD_H4, 4); + double ld_5288 = 2.0 * ld_5048 - iHigh(Currency_Symbol, PERIOD_H4, 5); + double ld_5296 = ld_5008 - (iHigh(Currency_Symbol, PERIOD_H4, 0) - iLow(Currency_Symbol, PERIOD_H4, 0)); + double ld_5304 = ld_5016 - (iHigh(Currency_Symbol, PERIOD_H4, 1) - iLow(Currency_Symbol, PERIOD_H4, 1)); + double ld_5312 = ld_5024 - (iHigh(Currency_Symbol, PERIOD_H4, 2) - iLow(Currency_Symbol, PERIOD_H4, 2)); + double ld_5320 = ld_5032 - (iHigh(Currency_Symbol, PERIOD_H4, 3) - iLow(Currency_Symbol, PERIOD_H4, 3)); + double ld_5328 = ld_5040 - (iHigh(Currency_Symbol, PERIOD_H4, 4) - iLow(Currency_Symbol, PERIOD_H4, 4)); + double ld_5336 = ld_5048 - (iHigh(Currency_Symbol, PERIOD_H4, 5) - iLow(Currency_Symbol, PERIOD_H4, 5)); + double ld_5344 = 2.0 * ld_5008 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 0) - iLow(Currency_Symbol, PERIOD_H4, 0)); + double ld_5352 = 2.0 * ld_5016 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 1) - iLow(Currency_Symbol, PERIOD_H4, 1)); + double ld_5360 = 2.0 * ld_5024 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 2) - iLow(Currency_Symbol, PERIOD_H4, 2)); + double ld_5368 = 2.0 * ld_5032 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 3) - iLow(Currency_Symbol, PERIOD_H4, 3)); + double ld_5376 = 2.0 * ld_5040 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 4) - iLow(Currency_Symbol, PERIOD_H4, 4)); + double ld_5384 = 2.0 * ld_5048 - (2.0 * iHigh(Currency_Symbol, PERIOD_H4, 5) - iLow(Currency_Symbol, PERIOD_H4, 5)); + if (ld_5008 > ld_40) { + ld_5392 = 0; + ld_5680 = 1; + } + if (ld_5008 < ld_40) { + ld_5392 = 1; + ld_5680 = 0; + } + if (ld_5016 > ld_40) { + ld_5400 = 0; + ld_5688 = 1; + } + if (ld_5016 < ld_40) { + ld_5400 = 1; + ld_5688 = 0; + } + if (ld_5024 > ld_40) { + ld_5408 = 0; + ld_5696 = 1; + } + if (ld_5024 < ld_40) { + ld_5408 = 1; + ld_5696 = 0; + } + if (ld_5032 > ld_40) { + ld_5416 = 0; + ld_5704 = 1; + } + if (ld_5032 < ld_40) { + ld_5416 = 1; + ld_5704 = 0; + } + if (ld_5040 > ld_40) { + ld_5424 = 0; + ld_5712 = 1; + } + if (ld_5040 < ld_40) { + ld_5424 = 1; + ld_5712 = 0; + } + if (ld_5152 > ld_40) { + ld_5432 = 0; + ld_5720 = 1; + } + if (ld_5152 < ld_40) { + ld_5432 = 1; + ld_5720 = 0; + } + if (ld_5160 > ld_40) { + ld_5440 = 0; + ld_5728 = 1; + } + if (ld_5160 < ld_40) { + ld_5440 = 1; + ld_5728 = 0; + } + if (ld_5168 > ld_40) { + ld_5448 = 0; + ld_5736 = 1; + } + if (ld_5168 < ld_40) { + ld_5448 = 1; + ld_5736 = 0; + } + if (ld_5176 > ld_40) { + ld_5456 = 0; + ld_5744 = 1; + } + if (ld_5176 < ld_40) { + ld_5456 = 1; + ld_5744 = 0; + } + if (ld_5184 > ld_40) { + ld_5464 = 0; + ld_5752 = 1; + } + if (ld_5184 < ld_40) { + ld_5464 = 1; + ld_5752 = 0; + } + if (ld_5192 > ld_40) { + ld_5472 = 0; + ld_5760 = 1; + } + if (ld_5192 < ld_40) { + ld_5472 = 1; + ld_5760 = 0; + } + if (ld_5248 > ld_40) { + ld_5480 = 0; + ld_5768 = 1; + } + if (ld_5248 < ld_40) { + ld_5480 = 1; + ld_5768 = 0; + } + if (ld_5256 > ld_40) { + ld_5488 = 0; + ld_5776 = 1; + } + if (ld_5256 < ld_40) { + ld_5488 = 1; + ld_5776 = 0; + } + if (ld_5264 > ld_40) { + ld_5496 = 0; + ld_5784 = 1; + } + if (ld_5264 < ld_40) { + ld_5496 = 1; + ld_5784 = 0; + } + if (ld_5272 > ld_40) { + ld_5504 = 0; + ld_5792 = 1; + } + if (ld_5272 < ld_40) { + ld_5504 = 1; + ld_5792 = 0; + } + if (ld_5280 > ld_40) { + ld_5512 = 0; + ld_5800 = 1; + } + if (ld_5280 < ld_40) { + ld_5512 = 1; + ld_5800 = 0; + } + if (ld_5288 > ld_40) { + ld_5520 = 0; + ld_5808 = 1; + } + if (ld_5288 < ld_40) { + ld_5520 = 1; + ld_5808 = 0; + } + if (ld_5104 > ld_40) { + ld_5528 = 0; + ld_5816 = 1; + } + if (ld_5104 < ld_40) { + ld_5528 = 1; + ld_5816 = 0; + } + if (ld_5112 > ld_40) { + ld_5536 = 0; + ld_5824 = 1; + } + if (ld_5112 < ld_40) { + ld_5536 = 1; + ld_5824 = 0; + } + if (ld_5120 > ld_40) { + ld_5544 = 0; + ld_5832 = 1; + } + if (ld_5120 < ld_40) { + ld_5544 = 1; + ld_5832 = 0; + } + if (ld_5128 > ld_40) { + ld_5552 = 0; + ld_5840 = 1; + } + if (ld_5128 < ld_40) { + ld_5552 = 1; + ld_5840 = 0; + } + if (ld_5136 > ld_40) { + ld_5560 = 0; + ld_5848 = 1; + } + if (ld_5136 < ld_40) { + ld_5560 = 1; + ld_5848 = 0; + } + if (ld_5144 > ld_40) { + ld_5568 = 0; + ld_5856 = 1; + } + if (ld_5144 < ld_40) { + ld_5568 = 1; + ld_5856 = 0; + } + if (ld_5296 > ld_40) { + ld_5576 = 0; + ld_5864 = 1; + } + if (ld_5296 < ld_40) { + ld_5576 = 1; + ld_5864 = 0; + } + if (ld_5304 > ld_40) { + ld_5584 = 0; + ld_5872 = 1; + } + if (ld_5304 < ld_40) { + ld_5584 = 1; + ld_5872 = 0; + } + if (ld_5312 > ld_40) { + ld_5592 = 0; + ld_5880 = 1; + } + if (ld_5312 < ld_40) { + ld_5592 = 1; + ld_5880 = 0; + } + if (ld_5320 > ld_40) { + ld_5600 = 0; + ld_5888 = 1; + } + if (ld_5320 < ld_40) { + ld_5600 = 1; + ld_5888 = 0; + } + if (ld_5328 > ld_40) { + ld_5608 = 0; + ld_5896 = 1; + } + if (ld_5328 < ld_40) { + ld_5608 = 1; + ld_5896 = 0; + } + if (ld_5336 > ld_40) { + ld_5616 = 0; + ld_5904 = 1; + } + if (ld_5336 < ld_40) { + ld_5616 = 1; + ld_5904 = 0; + } + if (ld_5056 > ld_40) { + ld_5624 = 0; + ld_5912 = 1; + } + if (ld_5056 < ld_40) { + ld_5624 = 1; + ld_5912 = 0; + } + if (ld_5064 > ld_40) { + ld_5632 = 0; + ld_5920 = 1; + } + if (ld_5064 < ld_40) { + ld_5632 = 1; + ld_5920 = 0; + } + if (ld_5072 > ld_40) { + ld_5640 = 0; + ld_5928 = 1; + } + if (ld_5072 < ld_40) { + ld_5640 = 1; + ld_5928 = 0; + } + if (ld_5080 > ld_40) { + ld_5648 = 0; + ld_5944 = 1; + } + if (ld_5080 < ld_40) { + ld_5648 = 1; + ld_5944 = 0; + } + if (ld_5088 > ld_40) { + ld_5664 = 0; + ld_5952 = 1; + } + if (ld_5088 < ld_40) { + ld_5664 = 1; + ld_5952 = 0; + } + if (ld_5096 > ld_40) { + ld_5672 = 0; + ld_5960 = 1; + } + if (ld_5096 < ld_40) { + ld_5672 = 1; + ld_5960 = 0; + } + double ld_5968 = ld_5392 + ld_5400 + ld_5408 + ld_5416 + ld_5424 + ld_5432 + ld_5440 + ld_5448 + ld_5456 + ld_5464 + ld_5472 + ld_5480 + ld_5488 + ld_5496 + ld_5504 + ld_5512 + ld_5520 + ld_5528 + ld_5536 + ld_5544 + ld_5552 + ld_5560 + ld_5568 + ld_5576 + ld_5584 + ld_5592 + ld_5600 + ld_5608 + ld_5616 + ld_5624 + ld_5632 + ld_5640 + ld_5648 + ld_5656 + ld_5664 + ld_5672 + ld_4400 + ld_4408 + ld_4416 + ld_4424 + ld_4432 + ld_4440 + ld_4448 + ld_4456 + ld_4464 + ld_4472 + ld_4480 + ld_4488 + ld_4496 + ld_4504 + ld_4512 + ld_4520 + ld_4528 + ld_4536 + ld_4544 + ld_4552 + ld_4560 + ld_4568 + ld_4576 + ld_4584 + ld_4592 + ld_4600 + ld_4608 + ld_4616 + ld_4624 + ld_4632 + ld_4640 + ld_4648 + ld_4656 + ld_4664 + ld_4672 + ld_4680; + double ld_5976 = ld_5680 + ld_5688 + ld_5696 + ld_5704 + ld_5712 + ld_5720 + ld_5728 + ld_5736 + ld_5744 + ld_5752 + ld_5760 + ld_5768 + ld_5776 + ld_5784 + ld_5792 + ld_5800 + ld_5808 + ld_5816 + ld_5824 + ld_5832 + ld_5840 + ld_5848 + ld_5856 + ld_5864 + ld_5872 + ld_5880 + ld_5888 + ld_5896 + ld_5904 + ld_5912 + ld_5920 + ld_5928 + ld_5936 + ld_5944 + ld_5952 + ld_5960 + ld_4688 + ld_4696 + ld_4704 + ld_4712 + ld_4720 + ld_4728 + ld_4736 + ld_4744 + ld_4752 + ld_4760 + ld_4768 + ld_4776 + ld_4784 + ld_4792 + ld_4800 + ld_4808 + ld_4816 + ld_4824 + ld_4832 + ld_4840 + ld_4848 + ld_4856 + ld_4864 + ld_4872 + ld_4880 + ld_4888 + ld_4896 + ld_4904 + ld_4912 + ld_4920 + ld_4928 + ld_4936 + ld_4944 + ld_4952 + ld_4960 + ld_4968; + string l_dbl2str_5984 = DoubleToStr(100.0 * (ld_5968 / 72.0), 0); + string l_dbl2str_5992 = DoubleToStr(100 - StrToDouble(l_dbl2str_5984), 0); + double ld_6000 = ld_1424 + ld_1432 + ld_1440 + ld_1448 + ld_1456 + ld_1464 + ld_1472 + ld_1480 + ld_1488 + ld_1496 + ld_1504 + ld_1512 + ld_1520 + ld_1528 + ld_1536 + ld_1544 + ld_1552 + ld_1560 + ld_1568 + ld_1576 + ld_1584 + ld_1592 + ld_1600 + ld_1608 + ld_1616 + ld_1624 + ld_1632 + ld_1640 + ld_1648 + ld_1656 + ld_1664 + ld_1672 + ld_1680 + ld_1688 + ld_1696 + ld_1704 + ld_432 + ld_440 + ld_448 + ld_456 + ld_432 + ld_472 + ld_480 + ld_488 + ld_496 + ld_504 + ld_512 + ld_520 + ld_528 + ld_536 + ld_544 + ld_552 + ld_560 + ld_568 + ld_576 + ld_584 + ld_592 + ld_600 + ld_608 + ld_616 + ld_624 + ld_632 + ld_640 + ld_648 + ld_656 + ld_664 + ld_672 + ld_680 + ld_688 + ld_696 + ld_704 + ld_712 + ld_3408 + ld_3416 + ld_3424 + ld_3432 + ld_3440 + ld_3448 + ld_3456 + ld_3464 + ld_3472 + ld_3480 + ld_3488 + ld_3496 + ld_3504 + ld_3512 + ld_3520 + ld_3528 + ld_3536 + ld_3544 + ld_3552 + ld_3560 + ld_3568 + ld_3576 + ld_3584 + ld_3592 + ld_3600 + ld_3608 + ld_3616 + ld_3624 + ld_3632 + ld_3640 + ld_3648 + ld_3656 + ld_3664 + ld_3672 + ld_3680 + ld_3688 + ld_2416 + ld_2424 + ld_2432 + ld_2440 + ld_2448 + ld_2456 + ld_2464 + ld_2472 + ld_2480 + ld_2488 + ld_2496 + ld_2504 + ld_2512 + ld_2520 + ld_2528 + ld_2536 + ld_2544 + ld_2552 + ld_2560 + ld_2568 + ld_2576 + ld_2584 + ld_2592 + ld_2600 + ld_2608 + ld_2616 + ld_2624 + ld_2632 + ld_2640 + ld_2648 + ld_2656 + ld_2664 + ld_2672 + ld_2680 + ld_2688 + ld_2696 + ld_5392 + ld_5400 + ld_5408 + ld_5416 + ld_5424 + ld_5432 + ld_5440 + ld_5448 + ld_5456 + ld_5464 + ld_5472 + ld_5480 + ld_5488 + ld_5496 + ld_5504 + ld_5512 + ld_5520 + ld_5528 + ld_5536 + ld_5544 + ld_5552 + ld_5560 + ld_5568 + ld_5576 + ld_5584 + ld_5592 + ld_5600 + ld_5608 + ld_5616 + ld_5624 + ld_5632 + ld_5640 + ld_5648 + ld_5656 + ld_5664 + ld_5672 + ld_4400 + ld_4408 + ld_4416 + ld_4424 + ld_4432 + ld_4440 + ld_4448 + ld_4456 + ld_4464 + ld_4472 + ld_4480 + ld_4488 + ld_4496 + ld_4504 + ld_4512 + ld_4520 + ld_4528 + ld_4536 + ld_4544 + ld_4552 + ld_4560 + ld_4568 + ld_4576 + ld_4584 + ld_4592 + ld_4600 + ld_4608 + ld_4616 + ld_4624 + ld_4632 + ld_4640 + ld_4648 + ld_4656 + ld_4664 + ld_4672 + ld_4680; + double ld_6008 = ld_1712 + ld_1720 + ld_1728 + ld_1736 + ld_1744 + ld_1752 + ld_1760 + ld_1768 + ld_1776 + ld_1784 + ld_1792 + ld_1800 + ld_1808 + ld_1816 + ld_1824 + ld_1832 + ld_1840 + ld_1848 + ld_1856 + ld_1864 + ld_1872 + ld_1880 + ld_1888 + ld_1896 + ld_1904 + ld_1912 + ld_1920 + ld_1928 + ld_1936 + ld_1944 + ld_1952 + ld_1960 + ld_1968 + ld_1976 + ld_1984 + ld_1992 + ld_720 + ld_728 + ld_736 + ld_744 + ld_720 + ld_760 + ld_768 + ld_776 + ld_784 + ld_792 + ld_800 + ld_808 + ld_816 + ld_824 + ld_832 + ld_840 + ld_848 + ld_856 + ld_864 + ld_872 + ld_880 + ld_888 + ld_896 + ld_904 + ld_912 + ld_920 + ld_928 + ld_936 + ld_944 + ld_952 + ld_960 + ld_968 + ld_976 + ld_984 + ld_992 + ld_1000 + ld_3696 + ld_3704 + ld_3712 + ld_3720 + ld_3728 + ld_3736 + ld_3744 + ld_3752 + ld_3760 + ld_3768 + ld_3776 + ld_3784 + ld_3792 + ld_3800 + ld_3808 + ld_3816 + ld_3824 + ld_3832 + ld_3840 + ld_3848 + ld_3856 + ld_3864 + ld_3872 + ld_3880 + ld_3888 + ld_3896 + ld_3904 + ld_3912 + ld_3920 + ld_3928 + ld_3936 + ld_3944 + ld_3952 + ld_3960 + ld_3968 + ld_3976 + ld_2704 + ld_2712 + ld_2720 + ld_2728 + ld_2736 + ld_2744 + ld_2752 + ld_2760 + ld_2768 + ld_2776 + ld_2784 + ld_2792 + ld_2800 + ld_2808 + ld_2816 + ld_2824 + ld_2832 + ld_2840 + ld_2848 + ld_2856 + ld_2864 + ld_2872 + ld_2880 + ld_2888 + ld_2896 + ld_2904 + ld_2912 + ld_2920 + ld_2928 + ld_2936 + ld_2944 + ld_2952 + ld_2960 + ld_2968 + ld_2976 + ld_2984 + ld_5680 + ld_5688 + ld_5696 + ld_5704 + ld_5712 + ld_5720 + ld_5728 + ld_5736 + ld_5744 + ld_5752 + ld_5760 + ld_5768 + ld_5776 + ld_5784 + ld_5792 + ld_5800 + ld_5808 + ld_5816 + ld_5824 + ld_5832 + ld_5840 + ld_5848 + ld_5856 + ld_5864 + ld_5872 + ld_5880 + ld_5888 + ld_5896 + ld_5904 + ld_5912 + ld_5920 + ld_5928 + ld_5936 + ld_5944 + ld_5952 + ld_5960 + ld_4688 + ld_4696 + ld_4704 + ld_4712 + ld_4720 + ld_4728 + ld_4736 + ld_4744 + ld_4752 + ld_4760 + ld_4768 + ld_4776 + ld_4784 + ld_4792 + ld_4800 + ld_4808 + ld_4816 + ld_4824 + ld_4832 + ld_4840 + ld_4848 + ld_4856 + ld_4864 + ld_4872 + ld_4880 + ld_4888 + ld_4896 + ld_4904 + ld_4912 + ld_4920 + ld_4928 + ld_4936 + ld_4944 + ld_4952 + ld_4960 + ld_4968; + string l_dbl2str_6016 = DoubleToStr(100.0 * (ld_6000 / 216.0), 0); + string l_dbl2str_6024 = DoubleToStr(100 - StrToDouble(l_dbl2str_6016), 0); + string l_text_6032 = ""; + string l_text_6040 = ""; + string l_text_6048 = ""; + string l_text_6056 = ""; + string l_text_6064 = ""; + string l_text_6072 = ""; + string l_text_6080 = ""; + string l_text_6088 = ""; + string l_text_6096 = ""; + string l_text_6104 = ""; + string l_text_6112 = ""; + string l_text_6120 = ""; + string l_text_6128 = ""; + string l_text_6136 = ""; + string l_text_6144 = ""; + string l_text_6152 = ""; + string l_text_6160 = ""; + string l_text_6168 = ""; + if (StrToDouble(l_dbl2str_6016) >= 90.0) { + l_text_6032 = "-"; + l_color_6176 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_6016) >= 80.0) { + l_text_6040 = "-"; + l_color_6180 = UPcolor_2; + } + if (StrToDouble(l_dbl2str_6016) >= 70.0) { + l_text_6048 = "-"; + l_color_6184 = UPcolor_3; + } + if (StrToDouble(l_dbl2str_6016) >= 60.0) { + l_text_6056 = "-"; + l_color_6188 = UPcolor_4; + } + if (StrToDouble(l_dbl2str_6016) >= 50.0) { + l_text_6064 = "-"; + l_color_6192 = UPcolor_5; + } + if (StrToDouble(l_dbl2str_6016) >= 40.0) { + l_text_6072 = "-"; + l_color_6196 = UPcolor_6; + } + if (StrToDouble(l_dbl2str_6016) >= 30.0) { + l_text_6080 = "-"; + l_color_6200 = UPcolor_7; + } + if (StrToDouble(l_dbl2str_6016) >= 20.0) { + l_text_6088 = "-"; + l_color_6204 = UPcolor_8; + } + if (StrToDouble(l_dbl2str_6016) >= 0.0) { + l_text_6096 = "-"; + l_color_6208 = UPcolor_9; + } + if (StrToDouble(l_dbl2str_6024) > 90.0) { + l_text_6104 = "-"; + l_color_6212 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_6024) > 80.0) { + l_text_6112 = "-"; + l_color_6216 = DNcolor_2; + } + if (StrToDouble(l_dbl2str_6024) > 70.0) { + l_text_6120 = "-"; + l_color_6220 = DNcolor_3; + } + if (StrToDouble(l_dbl2str_6024) > 60.0) { + l_text_6128 = "-"; + l_color_6224 = DNcolor_4; + } + if (StrToDouble(l_dbl2str_6024) > 50.0) { + l_text_6136 = "-"; + l_color_6228 = DNcolor_5; + } + if (StrToDouble(l_dbl2str_6024) > 40.0) { + l_text_6144 = "-"; + l_color_6232 = DNcolor_6; + } + if (StrToDouble(l_dbl2str_6024) > 30.0) { + l_text_6152 = "-"; + l_color_6236 = DNcolor_7; + } + if (StrToDouble(l_dbl2str_6024) > 20.0) { + l_text_6160 = "-"; + l_color_6240 = DNcolor_8; + } + if (StrToDouble(l_dbl2str_6024) > 0.0) { + l_text_6168 = "-"; + l_color_6244 = DNcolor_9; + } + string l_text_6248 = ""; + if (StrToDouble(l_dbl2str_6016) >= 90.0) { + l_text_6248 = "+ UP Xtreme +"; + l_color_6256 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_6024) >= 90.0) { + l_text_6248 = "+ DN Xtreme +"; + l_color_6256 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_6016) >= 75.0 && StrToDouble(l_dbl2str_6016) < 90.0) { + l_text_6248 = "+ UP Strong +"; + l_color_6256 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_6024) >= 75.0 && StrToDouble(l_dbl2str_6024) < 90.0) { + l_text_6248 = "+ DN Strong +"; + l_color_6256 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_6016) >= 60.0 && StrToDouble(l_dbl2str_6016) < 75.0) { + l_text_6248 = "+ UP Medium +"; + l_color_6256 = UPcolor_4; + } + if (StrToDouble(l_dbl2str_6024) >= 60.0 && StrToDouble(l_dbl2str_6024) < 75.0) { + l_text_6248 = "+ DN Medium +"; + l_color_6256 = DNcolor_5; + } + if (StrToDouble(l_dbl2str_6016) >= 55.0 && StrToDouble(l_dbl2str_6016) < 60.0) { + l_text_6248 = "+ UP Weak +"; + l_color_6256 = UPcolor_7; + } + if (StrToDouble(l_dbl2str_6024) >= 55.0 && StrToDouble(l_dbl2str_6024) < 60.0) { + l_text_6248 = "+ Dn Weak +"; + l_color_6256 = DNcolor_6; + } + if (StrToDouble(l_dbl2str_6024) >= 50.0 && StrToDouble(l_dbl2str_6024) < 55.0) { + l_text_6248 = "+ Neutral +"; + l_color_6256 = EQUALcolor; + } + if (StrToDouble(l_dbl2str_6016) >= 50.0 && StrToDouble(l_dbl2str_6016) < 55.0) { + l_text_6248 = "+ Neutral +"; + l_color_6256 = EQUALcolor; + } + CreateDynamic("SIG_RESULTS" + Dynamic_Number, BarsShift_UP_DN + 106, BarsShift_Side + 18); + ObjectSetText("SIG_RESULTS" + Dynamic_Number, l_text_6248, 10, "Tahoma Bold", l_color_6256); + CreateDynamic("SIG_LEVEL" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL" + Dynamic_Number, l_text_6032, 40, "Tahoma", l_color_6176); + CreateDynamic("SIG_LEVEL_1" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_1" + Dynamic_Number, l_text_6040, 40, "Tahoma", l_color_6180); + CreateDynamic("SIG_LEVEL_2" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_2" + Dynamic_Number, l_text_6048, 40, "Tahoma", l_color_6184); + CreateDynamic("SIG_LEVEL_3" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_3" + Dynamic_Number, l_text_6056, 40, "Tahoma", l_color_6188); + CreateDynamic("SIG_LEVEL_4" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_4" + Dynamic_Number, l_text_6064, 40, "Tahoma", l_color_6192); + CreateDynamic("SIG_LEVEL_5" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_5" + Dynamic_Number, l_text_6072, 40, "Tahoma", l_color_6196); + CreateDynamic("SIG_LEVEL_6" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_6" + Dynamic_Number, l_text_6080, 40, "Tahoma", l_color_6200); + CreateDynamic("SIG_LEVEL_7" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_7" + Dynamic_Number, l_text_6088, 40, "Tahoma", l_color_6204); + CreateDynamic("SIG_LEVEL_8" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_8" + Dynamic_Number, l_text_6096, 40, "Tahoma", l_color_6208); + CreateDynamic("SIG_LEVEL_9" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_9" + Dynamic_Number, l_text_6104, 40, "Tahoma", l_color_6212); + CreateDynamic("SIG_LEVEL_10" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_10" + Dynamic_Number, l_text_6112, 40, "Tahoma", l_color_6216); + CreateDynamic("SIG_LEVEL_11" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_11" + Dynamic_Number, l_text_6120, 40, "Tahoma", l_color_6220); + CreateDynamic("SIG_LEVEL_12" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_12" + Dynamic_Number, l_text_6128, 40, "Tahoma", l_color_6224); + CreateDynamic("SIG_LEVEL_13" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_13" + Dynamic_Number, l_text_6136, 40, "Tahoma", l_color_6228); + CreateDynamic("SIG_LEVEL_14" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_14" + Dynamic_Number, l_text_6144, 40, "Tahoma", l_color_6232); + CreateDynamic("SIG_LEVEL_15" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_15" + Dynamic_Number, l_text_6152, 40, "Tahoma", l_color_6236); + CreateDynamic("SIG_LEVEL_16" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_16" + Dynamic_Number, l_text_6160, 40, "Tahoma", l_color_6240); + CreateDynamic("SIG_LEVEL_17" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 20); + ObjectSetText("SIG_LEVEL_17" + Dynamic_Number, l_text_6168, 40, "Tahoma", l_color_6244); + string l_text_6260 = ""; + string l_text_6268 = ""; + string l_text_6276 = ""; + string l_text_6284 = ""; + string l_text_6292 = ""; + string l_text_6300 = ""; + string l_text_6308 = ""; + string l_text_6316 = ""; + string l_text_6324 = ""; + string l_text_6332 = ""; + string l_text_6340 = ""; + string l_text_6348 = ""; + string l_text_6356 = ""; + string l_text_6364 = ""; + string l_text_6372 = ""; + string l_text_6380 = ""; + string l_text_6388 = ""; + string l_text_6396 = ""; + if (StrToDouble(l_dbl2str_5984) >= 90.0) { + l_text_6260 = "-"; + l_color_6404 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_5984) >= 80.0) { + l_text_6268 = "-"; + l_color_6408 = UPcolor_2; + } + if (StrToDouble(l_dbl2str_5984) >= 70.0) { + l_text_6276 = "-"; + l_color_6412 = UPcolor_3; + } + if (StrToDouble(l_dbl2str_5984) >= 60.0) { + l_text_6284 = "-"; + l_color_6416 = UPcolor_4; + } + if (StrToDouble(l_dbl2str_5984) >= 50.0) { + l_text_6292 = "-"; + l_color_6420 = UPcolor_5; + } + if (StrToDouble(l_dbl2str_5984) >= 40.0) { + l_text_6300 = "-"; + l_color_6424 = UPcolor_6; + } + if (StrToDouble(l_dbl2str_5984) >= 30.0) { + l_text_6308 = "-"; + l_color_6428 = UPcolor_7; + } + if (StrToDouble(l_dbl2str_5984) >= 20.0) { + l_text_6316 = "-"; + l_color_6432 = UPcolor_8; + } + if (StrToDouble(l_dbl2str_5984) >= 0.0) { + l_text_6324 = "-"; + l_color_6436 = UPcolor_9; + } + if (StrToDouble(l_dbl2str_5992) > 90.0) { + l_text_6332 = "-"; + l_color_6440 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_5992) > 80.0) { + l_text_6340 = "-"; + l_color_6444 = DNcolor_2; + } + if (StrToDouble(l_dbl2str_5992) > 70.0) { + l_text_6348 = "-"; + l_color_6448 = DNcolor_3; + } + if (StrToDouble(l_dbl2str_5992) > 60.0) { + l_text_6356 = "-"; + l_color_6452 = DNcolor_4; + } + if (StrToDouble(l_dbl2str_5992) > 50.0) { + l_text_6364 = "-"; + l_color_6456 = DNcolor_5; + } + if (StrToDouble(l_dbl2str_5992) > 40.0) { + l_text_6372 = "-"; + l_color_6460 = DNcolor_6; + } + if (StrToDouble(l_dbl2str_5992) > 30.0) { + l_text_6380 = "-"; + l_color_6464 = DNcolor_7; + } + if (StrToDouble(l_dbl2str_5992) > 20.0) { + l_text_6388 = "-"; + l_color_6468 = DNcolor_8; + } + if (StrToDouble(l_dbl2str_5992) > 0.0) { + l_text_6396 = "-"; + l_color_6472 = DNcolor_9; + } + CreateDynamic("H4_LEVEL" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL" + Dynamic_Number, l_text_6260, 40, "Tahoma", l_color_6404); + CreateDynamic("H4_LEVEL_1" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_1" + Dynamic_Number, l_text_6268, 40, "Tahoma", l_color_6408); + CreateDynamic("H4_LEVEL_2" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_2" + Dynamic_Number, l_text_6276, 40, "Tahoma", l_color_6412); + CreateDynamic("H4_LEVEL_3" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_3" + Dynamic_Number, l_text_6284, 40, "Tahoma", l_color_6416); + CreateDynamic("H4_LEVEL_4" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_4" + Dynamic_Number, l_text_6292, 40, "Tahoma", l_color_6420); + CreateDynamic("H4_LEVEL_5" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_5" + Dynamic_Number, l_text_6300, 40, "Tahoma", l_color_6424); + CreateDynamic("H4_LEVEL_6" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_6" + Dynamic_Number, l_text_6308, 40, "Tahoma", l_color_6428); + CreateDynamic("H4_LEVEL_7" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_7" + Dynamic_Number, l_text_6316, 40, "Tahoma", l_color_6432); + CreateDynamic("H4_LEVEL_8" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_8" + Dynamic_Number, l_text_6324, 40, "Tahoma", l_color_6436); + CreateDynamic("H4_LEVEL_9" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_9" + Dynamic_Number, l_text_6332, 40, "Tahoma", l_color_6440); + CreateDynamic("H4_LEVEL_10" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_10" + Dynamic_Number, l_text_6340, 40, "Tahoma", l_color_6444); + CreateDynamic("H4_LEVEL_11" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_11" + Dynamic_Number, l_text_6348, 40, "Tahoma", l_color_6448); + CreateDynamic("H4_LEVEL_12" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_12" + Dynamic_Number, l_text_6356, 40, "Tahoma", l_color_6452); + CreateDynamic("H4_LEVEL_13" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_13" + Dynamic_Number, l_text_6364, 40, "Tahoma", l_color_6456); + CreateDynamic("H4_LEVEL_14" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_14" + Dynamic_Number, l_text_6372, 40, "Tahoma", l_color_6460); + CreateDynamic("H4_LEVEL_15" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_15" + Dynamic_Number, l_text_6380, 40, "Tahoma", l_color_6464); + CreateDynamic("H4_LEVEL_16" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_16" + Dynamic_Number, l_text_6388, 40, "Tahoma", l_color_6468); + CreateDynamic("H4_LEVEL_17" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 36); + ObjectSetText("H4_LEVEL_17" + Dynamic_Number, l_text_6396, 40, "Tahoma", l_color_6472); + string l_text_6476 = ""; + string l_text_6484 = ""; + string l_text_6492 = ""; + string l_text_6500 = ""; + string l_text_6508 = ""; + string l_text_6516 = ""; + string l_text_6524 = ""; + string l_text_6532 = ""; + string l_text_6540 = ""; + string l_text_6548 = ""; + string l_text_6556 = ""; + string l_text_6564 = ""; + string l_text_6572 = ""; + string l_text_6580 = ""; + string l_text_6588 = ""; + string l_text_6596 = ""; + string l_text_6604 = ""; + string l_text_6612 = ""; + if (StrToDouble(l_dbl2str_4000) >= 90.0) { + l_text_6476 = "-"; + l_color_6620 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_4000) >= 80.0) { + l_text_6484 = "-"; + l_color_6624 = UPcolor_2; + } + if (StrToDouble(l_dbl2str_4000) >= 70.0) { + l_text_6492 = "-"; + l_color_6628 = UPcolor_3; + } + if (StrToDouble(l_dbl2str_4000) >= 60.0) { + l_text_6500 = "-"; + l_color_6632 = UPcolor_4; + } + if (StrToDouble(l_dbl2str_4000) >= 50.0) { + l_text_6508 = "-"; + l_color_6636 = UPcolor_5; + } + if (StrToDouble(l_dbl2str_4000) >= 40.0) { + l_text_6516 = "-"; + l_color_6640 = UPcolor_6; + } + if (StrToDouble(l_dbl2str_4000) >= 30.0) { + l_text_6524 = "-"; + l_color_6644 = UPcolor_7; + } + if (StrToDouble(l_dbl2str_4000) >= 20.0) { + l_text_6532 = "-"; + l_color_6648 = UPcolor_8; + } + if (StrToDouble(l_dbl2str_4000) >= 0.0) { + l_text_6540 = "-"; + l_color_6652 = UPcolor_9; + } + if (StrToDouble(l_dbl2str_4008) > 90.0) { + l_text_6548 = "-"; + l_color_6656 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_4008) > 80.0) { + l_text_6556 = "-"; + l_color_6660 = DNcolor_2; + } + if (StrToDouble(l_dbl2str_4008) > 70.0) { + l_text_6564 = "-"; + l_color_6664 = DNcolor_3; + } + if (StrToDouble(l_dbl2str_4008) > 60.0) { + l_text_6572 = "-"; + l_color_6668 = DNcolor_4; + } + if (StrToDouble(l_dbl2str_4008) > 50.0) { + l_text_6580 = "-"; + l_color_6672 = DNcolor_5; + } + if (StrToDouble(l_dbl2str_4008) > 40.0) { + l_text_6588 = "-"; + l_color_6676 = DNcolor_6; + } + if (StrToDouble(l_dbl2str_4008) > 30.0) { + l_text_6596 = "-"; + l_color_6680 = DNcolor_7; + } + if (StrToDouble(l_dbl2str_4008) > 20.0) { + l_text_6604 = "-"; + l_color_6684 = DNcolor_8; + } + if (StrToDouble(l_dbl2str_4008) > 0.0) { + l_text_6612 = "-"; + l_color_6688 = DNcolor_9; + } + CreateDynamic("M30_LEVEL" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL" + Dynamic_Number, l_text_6476, 40, "Tahoma", l_color_6620); + CreateDynamic("M30_LEVEL_1" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_1" + Dynamic_Number, l_text_6484, 40, "Tahoma", l_color_6624); + CreateDynamic("M30_LEVEL_2" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_2" + Dynamic_Number, l_text_6492, 40, "Tahoma", l_color_6628); + CreateDynamic("M30_LEVEL_3" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_3" + Dynamic_Number, l_text_6500, 40, "Tahoma", l_color_6632); + CreateDynamic("M30_LEVEL_4" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_4" + Dynamic_Number, l_text_6508, 40, "Tahoma", l_color_6636); + CreateDynamic("M30_LEVEL_5" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_5" + Dynamic_Number, l_text_6516, 40, "Tahoma", l_color_6640); + CreateDynamic("M30_LEVEL_6" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_6" + Dynamic_Number, l_text_6524, 40, "Tahoma", l_color_6644); + CreateDynamic("M30_LEVEL_7" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_7" + Dynamic_Number, l_text_6532, 40, "Tahoma", l_color_6648); + CreateDynamic("M30_LEVEL_8" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_8" + Dynamic_Number, l_text_6540, 40, "Tahoma", l_color_6652); + CreateDynamic("M30_LEVEL_9" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_9" + Dynamic_Number, l_text_6548, 40, "Tahoma", l_color_6656); + CreateDynamic("M30_LEVEL_10" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_10" + Dynamic_Number, l_text_6556, 40, "Tahoma", l_color_6660); + CreateDynamic("M30_LEVEL_11" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_11" + Dynamic_Number, l_text_6564, 40, "Tahoma", l_color_6664); + CreateDynamic("M30_LEVEL_12" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_12" + Dynamic_Number, l_text_6572, 40, "Tahoma", l_color_6668); + CreateDynamic("M30_LEVEL_13" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_13" + Dynamic_Number, l_text_6580, 40, "Tahoma", l_color_6672); + CreateDynamic("M30_LEVEL_14" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_14" + Dynamic_Number, l_text_6588, 40, "Tahoma", l_color_6676); + CreateDynamic("M30_LEVEL_15" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_15" + Dynamic_Number, l_text_6596, 40, "Tahoma", l_color_6680); + CreateDynamic("M30_LEVEL_16" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_16" + Dynamic_Number, l_text_6604, 40, "Tahoma", l_color_6684); + CreateDynamic("M30_LEVEL_17" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 52); + ObjectSetText("M30_LEVEL_17" + Dynamic_Number, l_text_6612, 40, "Tahoma", l_color_6688); + string l_text_6692 = ""; + string l_text_6700 = ""; + string l_text_6708 = ""; + string l_text_6716 = ""; + string l_text_6724 = ""; + string l_text_6732 = ""; + string l_text_6740 = ""; + string l_text_6748 = ""; + string l_text_6756 = ""; + string l_text_6764 = ""; + string l_text_6772 = ""; + string l_text_6780 = ""; + string l_text_6788 = ""; + string l_text_6796 = ""; + string l_text_6804 = ""; + string l_text_6812 = ""; + string l_text_6820 = ""; + string l_text_6828 = ""; + if (StrToDouble(l_dbl2str_2016) >= 90.0) { + l_text_6692 = "-"; + l_color_6836 = UPcolor_1; + } + if (StrToDouble(l_dbl2str_2016) >= 80.0) { + l_text_6700 = "-"; + l_color_6840 = UPcolor_2; + } + if (StrToDouble(l_dbl2str_2016) >= 70.0) { + l_text_6708 = "-"; + l_color_6844 = UPcolor_3; + } + if (StrToDouble(l_dbl2str_2016) >= 60.0) { + l_text_6716 = "-"; + l_color_6848 = UPcolor_4; + } + if (StrToDouble(l_dbl2str_2016) >= 50.0) { + l_text_6724 = "-"; + l_color_6852 = UPcolor_5; + } + if (StrToDouble(l_dbl2str_2016) >= 40.0) { + l_text_6732 = "-"; + l_color_6856 = UPcolor_6; + } + if (StrToDouble(l_dbl2str_2016) >= 30.0) { + l_text_6740 = "-"; + l_color_6860 = UPcolor_7; + } + if (StrToDouble(l_dbl2str_2016) >= 20.0) { + l_text_6748 = "-"; + l_color_6864 = UPcolor_8; + } + if (StrToDouble(l_dbl2str_2016) >= 0.0) { + l_text_6756 = "-"; + l_color_6868 = UPcolor_9; + } + if (StrToDouble(l_dbl2str_2024) > 90.0) { + l_text_6764 = "-"; + l_color_6872 = DNcolor_1; + } + if (StrToDouble(l_dbl2str_2024) > 80.0) { + l_text_6772 = "-"; + l_color_6876 = DNcolor_2; + } + if (StrToDouble(l_dbl2str_2024) > 70.0) { + l_text_6780 = "-"; + l_color_6880 = DNcolor_3; + } + if (StrToDouble(l_dbl2str_2024) > 60.0) { + l_text_6788 = "-"; + l_color_6884 = DNcolor_4; + } + if (StrToDouble(l_dbl2str_2024) > 50.0) { + l_text_6796 = "-"; + l_color_6888 = DNcolor_5; + } + if (StrToDouble(l_dbl2str_2024) > 40.0) { + l_text_6804 = "-"; + l_color_6892 = DNcolor_6; + } + if (StrToDouble(l_dbl2str_2024) > 30.0) { + l_text_6812 = "-"; + l_color_6896 = DNcolor_7; + } + if (StrToDouble(l_dbl2str_2024) > 20.0) { + l_text_6820 = "-"; + l_color_6900 = DNcolor_8; + } + if (StrToDouble(l_dbl2str_2024) > 0.0) { + l_text_6828 = "-"; + l_color_6904 = DNcolor_9; + } + CreateDynamic("M5_LEVEL" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL" + Dynamic_Number, l_text_6692, 40, "Tahoma", l_color_6836); + CreateDynamic("M5_LEVEL_1" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_1" + Dynamic_Number, l_text_6700, 40, "Tahoma", l_color_6840); + CreateDynamic("M5_LEVEL_2" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_2" + Dynamic_Number, l_text_6708, 40, "Tahoma", l_color_6844); + CreateDynamic("M5_LEVEL_3" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_3" + Dynamic_Number, l_text_6716, 40, "Tahoma", l_color_6848); + CreateDynamic("M5_LEVEL_4" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_4" + Dynamic_Number, l_text_6724, 40, "Tahoma", l_color_6852); + CreateDynamic("M5_LEVEL_5" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_5" + Dynamic_Number, l_text_6732, 40, "Tahoma", l_color_6856); + CreateDynamic("M5_LEVEL_6" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_6" + Dynamic_Number, l_text_6740, 40, "Tahoma", l_color_6860); + CreateDynamic("M5_LEVEL_7" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_7" + Dynamic_Number, l_text_6748, 40, "Tahoma", l_color_6864); + CreateDynamic("M5_LEVEL_8" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_8" + Dynamic_Number, l_text_6756, 40, "Tahoma", l_color_6868); + CreateDynamic("M5_LEVEL_9" + Dynamic_Number, BarsShift_UP_DN + 65, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_9" + Dynamic_Number, l_text_6764, 40, "Tahoma", l_color_6872); + CreateDynamic("M5_LEVEL_10" + Dynamic_Number, BarsShift_UP_DN + 60, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_10" + Dynamic_Number, l_text_6772, 40, "Tahoma", l_color_6876); + CreateDynamic("M5_LEVEL_11" + Dynamic_Number, BarsShift_UP_DN + 55, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_11" + Dynamic_Number, l_text_6780, 40, "Tahoma", l_color_6880); + CreateDynamic("M5_LEVEL_12" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_12" + Dynamic_Number, l_text_6788, 40, "Tahoma", l_color_6884); + CreateDynamic("M5_LEVEL_13" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_13" + Dynamic_Number, l_text_6796, 40, "Tahoma", l_color_6888); + CreateDynamic("M5_LEVEL_14" + Dynamic_Number, BarsShift_UP_DN + 40, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_14" + Dynamic_Number, l_text_6804, 40, "Tahoma", l_color_6892); + CreateDynamic("M5_LEVEL_15" + Dynamic_Number, BarsShift_UP_DN + 35, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_15" + Dynamic_Number, l_text_6812, 40, "Tahoma", l_color_6896); + CreateDynamic("M5_LEVEL_16" + Dynamic_Number, BarsShift_UP_DN + 30, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_16" + Dynamic_Number, l_text_6820, 40, "Tahoma", l_color_6900); + CreateDynamic("M5_LEVEL_17" + Dynamic_Number, BarsShift_UP_DN + 25, BarsShift_Side + 68); + ObjectSetText("M5_LEVEL_17" + Dynamic_Number, l_text_6828, 40, "Tahoma", l_color_6904); + CreateDynamic("TREND_Display" + Dynamic_Number, BarsShift_UP_DN + 10, BarsShift_Side + 21); + ObjectSetText("TREND_Display" + Dynamic_Number, "Dynamic Trend", 10, "Tahoma Bold", DynamicTitle_color); + CreateDynamic("TREND_Display1" + Dynamic_Number, BarsShift_UP_DN + 23, BarsShift_Side + 21); + ObjectSetText("TREND_Display1" + Dynamic_Number, "" + Currency_Symbol + "", 17, "Tahoma Narrow", Currency_color); + CreateDynamic("TREND_Display2" + Dynamic_Number, BarsShift_UP_DN + 45, BarsShift_Side + 20); + ObjectSetText("TREND_Display2" + Dynamic_Number, "Curr H4 / H1 to M5 / M1", 6, "Tahoma Narrow", PeriodTitles_color); + CreateDynamic("TREND_Display3" + Dynamic_Number, BarsShift_UP_DN + 4, BarsShift_Side + 19); + ObjectSetText("TREND_Display3" + Dynamic_Number, "--------------------------------", 7, "Tahoma Narrow", DottedSeparator_color); + CreateDynamic("TREND_Display4" + Dynamic_Number, BarsShift_UP_DN + 82, BarsShift_Side + 88); + ObjectSetText("TREND_Display4" + Dynamic_Number, l_dbl2str_6016 + "%", 10, "Tahoma Narrow", UPcolor_4); + CreateDynamic("TREND_Display5" + Dynamic_Number, BarsShift_UP_DN + 62, BarsShift_Side + 88); + ObjectSetText("TREND_Display5" + Dynamic_Number, l_dbl2str_6024 + "%", 10, "Tahoma Narrow", DNcolor_4); + CreateDynamic("TREND_Display6" + Dynamic_Number, BarsShift_UP_DN + 99, BarsShift_Side + 20); + ObjectSetText("TREND_Display6" + Dynamic_Number, "-------------------------------- ", 7, "Tahoma", DottedSeparator_color); + CreateDynamic("TREND_Display7" + Dynamic_Number, BarsShift_UP_DN + 50, BarsShift_Side + 20); + ObjectSetText("TREND_Display7" + Dynamic_Number, "-------------------------------- ", 7, "Tahoma", DottedSeparator_color); + CreateDynamic("TREND_Display8" + Dynamic_Number, BarsShift_UP_DN + 117, BarsShift_Side + 20); + ObjectSetText("TREND_Display8" + Dynamic_Number, "-------------------------------- ", 7, "Tahoma", DottedSeparator_color); + return (0); +} diff --git a/gann_hilo_arrow_alert_colin.mq4 b/gann_hilo_arrow_alert_colin.mq4 new file mode 100644 index 0000000..e729b8c --- /dev/null +++ b/gann_hilo_arrow_alert_colin.mq4 @@ -0,0 +1,579 @@ +//+------------------------------------------------------------------+ +//| gann_hilo_arrow_alert_colin.mq4 | +//| Zoltan Laszlo Ferenci | +//| http://www.metatraderprogrammer.com | +//+------------------------------------------------------------------+ +#property copyright "Zoltan Laszlo Ferenci" +#property link "http://www.metatraderprogrammer.com" + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 White +#property indicator_color2 White +//--- buffers +double ExtMapBuffer1[]; +double ExtMapBuffer2[]; + +#include +#include + +#define SIGNAL_NO 0 +#define SIGNAL_BUY 1 +#define SIGNAL_SELL 2 +#define SIGNAL_BOTH 3 + +extern bool email_alert = true; +extern bool sound_alert = true; +extern bool popup_alert = true; +extern bool show_on_comment = true; + +extern bool sound_repeat = true; +extern bool popup_repeat = false; + +extern string sound_filename = "alert.wav"; +extern double alertevery = 5; +extern int maxrepeat = 5; + +extern int signal_bar = 0; +extern int alert_bar = 1; +//extern int _tf_bar = 1; +//extern int tf_bar = 1; +//extern int timeframe = 0; + +extern int entry_from_hl = 5; +extern int sl_from_hl = 5; +extern double tp_from_sl = 1; + +bool alert_on_change = true; +bool alert_on_firsttick = true; +bool disable_if_nochange = true; + +bool reverse_signal = false; + +//bool isfirsttick = false; +//datetime lasttick = 0; +datetime lastalert = 0; +int last_signal = 0; // -1: no alert at first signal +bool alert_enabled = true; +bool alert_norepeat = true; +int alertcount = 0; +int atrforarrows = 200; + +extern int maxbars = 900; + +extern bool gannhilo_enabled = true; + +extern string gannhilo_name = "###Gann_HiLo_Activator_v2###"; +extern int gannhilo_lookback = 5; +extern int ma_period = 5; +extern int ma_mode = MODE_EMA; + +extern bool gannhilo_mtf1_enabled = true; +extern int gannhilo_mtf1_timeframe = PERIOD_D1; +extern int gannhilo_mtf1_lookback = 5; + +extern bool gannhilo_mtf2_enabled = true; +extern int gannhilo_mtf2_timeframe = PERIOD_D1; +extern int gannhilo_mtf2_lookback = 5; + +extern bool rsi1_enabled = true; +extern int rsi1_period = 10; +extern bool rsi2_enabled = true; +extern int rsi2_period = 60; + +extern int arrow_size = 1; +extern double arrow_dist = 0.3; + +string comment = ""; +string commentstring = ""; + +extern bool comment_enabled = true; +extern bool comment_formatting = true; +string objname_comment = "comment_textbox"; +extern int comment_corner = 1; +extern int comment_fontsize = 9; +extern string comment_font = "Tahoma"; +extern color comment_color = White; +extern int comment_x = 10; +extern int comment_y = 10; +extern int comment_lineheight = 15; + +extern color entryColor = Blue; +extern int entryStyle = 1; +extern int entryThickness = 1; +extern color stopColor = Red; +extern int stopStyle = 1; +extern int stopThickness = 1; +extern int profitColor = Green; +extern color profitStyle = 1; +extern int profitThickness = 1; + +double entry, stoploss, takeprofit; +datetime signalbartime; +string lastalertstring; + +int init() +{ + variables_init(); + + SetIndexStyle(0,DRAW_ARROW,EMPTY,arrow_size); + SetIndexArrow(0,217); + SetIndexBuffer(0,ExtMapBuffer1); + SetIndexEmptyValue(0,0.0); + SetIndexStyle(1,DRAW_ARROW,EMPTY,arrow_size); + SetIndexArrow(1,218); + SetIndexBuffer(1,ExtMapBuffer2); + SetIndexEmptyValue(1,0.0); + return(0); +} + +int deinit() +{ + return(0); +} + +int start() +{ + variables_priceinit(); + + addcomment("alphatrader.ca\n"); + + obj_loadbool("sound_repeat", sound_repeat); + + int counted_bars=IndicatorCounted(); + //if(counted_bars>0) counted_bars--; + int limit=Bars-counted_bars; + if (limit > maxbars) limit = maxbars; + + for(int i=limit-1; i>=0; i--) + { + int signal = signal(i+signal_bar); + + if (signal == SIGNAL_SELL) + { + ExtMapBuffer2[i] = High[i]+(iATR(Symbol(),0,atrforarrows,i))*arrow_dist; + ExtMapBuffer1[i] = EMPTY_VALUE; + } + + if (signal == SIGNAL_BUY) + { + ExtMapBuffer1[i] = Low[i]-(iATR(Symbol(),0,atrforarrows,i))*arrow_dist; + ExtMapBuffer2[i] = EMPTY_VALUE; + } + if (signal == SIGNAL_NO) + { + ExtMapBuffer1[i] = EMPTY_VALUE; + ExtMapBuffer2[i] = EMPTY_VALUE; + } + } + + double entry, stoploss, tp; + + for(i = 0; i 0 && timecurrent - lastalert > alertevery && alertcount < maxrepeat)) + { + if (email_alert && alert_norepeat) + SendMail(alertstring,alertstring); + if (popup_alert && (alert_norepeat || popup_repeat)) + Alert(alertstring); + if (sound_alert && (alert_norepeat || sound_repeat)) + PlaySound(sound_filename); + lastalertstring = alertstring; + lastalert = timecurrent; + alertcount++; + } + +} + +/*bool isfirsttick() +{ + datetime bartime = iTime(Symbol(),0,0); + if (bartime == lasttick) + { + isfirsttick = false; + return(isfirsttick); + } + else + { + lasttick = bartime; + isfirsttick = true; + return(isfirsttick); + } +} +*/ + +/*int signal_tf(int bar, int timeframe) +{ + int tf_bar = iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar-1)-1)+tf_bar; + int tf_bar_last = iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar))+tf_bar; + + int mainsignal = SIGNAL_NO; + for (;tf_bar<=tf_bar_last;tf_bar++){ + int signal = -1; + signal_addsignal(signal,signal_tf_rule(tf_bar,timeframe),true); + addsignal_or(mainsignal,signal); + } + return(mainsignal); +}*/ + +int signal_gannhilo(int bar, int timeframe) +{ + int signal = SIGNAL_NO; + double gannhilo = iCustom(Symbol(),timeframe,gannhilo_name,gannhilo_lookback,0,bar); + double gannhilo1 = iCustom(Symbol(),timeframe,gannhilo_name,gannhilo_lookback,0,bar+1); + double ma = iMA(Symbol(),timeframe,ma_period,0,ma_mode,PRICE_CLOSE,bar); + double ma1 = iMA(Symbol(),timeframe,ma_period,0,ma_mode,PRICE_CLOSE,bar+1); + if (ma > gannhilo && ma1 <= gannhilo1) signal = SIGNAL_BUY; + if (ma < gannhilo && ma1 >= gannhilo1) signal = SIGNAL_SELL; + return(signal); +} + + +int signal_gannhilo_confirm(int gann_lookback, int bar, int timeframe) +{ + double close = iClose(Symbol(),timeframe,bar); + double gann = iCustom(Symbol(),timeframe,gannhilo_name,gann_lookback,0,bar); + if (close > gann) return(SIGNAL_BUY); + if (close < gann) return(SIGNAL_SELL); + return(SIGNAL_NO); +} + + +int signal_gannhilo_mtf(int gann_timeframe, int gann_lookback, int bar) +{ + int tf_bar = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar)); + //int tf_bar = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar-1)-1)+_tf_bar; + //int tf_bar_last = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar))+_tf_bar; + int signal = signal_gannhilo_confirm(gann_lookback,tf_bar,gann_timeframe); + //Alert(bar," ",tf_bar," ",gann_timeframe," ",signal); + return(signal); + //Alert(tf_bar, tf_bar_last); + /*int mainsignal = SIGNAL_NO; + for (;tf_bar<=tf_bar_last;tf_bar++){ + int signal = -1; + signal_addsignal(signal,signal_gannhilo_confirm(gann_lookback,tf_bar,gann_timeframe),true); + addsignal_or(mainsignal,signal); + }*/ + //return(mainsignal); +} + +int signal_rsi(int rsi_period, int bar, int timeframe) +{ + double rsi = iRSI(Symbol(),timeframe,rsi_period,PRICE_CLOSE,bar); + if (rsi > 50) return(SIGNAL_BUY); + if (rsi < 50) return(SIGNAL_SELL); + return(SIGNAL_NO); +} + +int signal(int bar) +{ + int signal = -1; + signal_addsignal(signal,signal_gannhilo(bar,0),gannhilo_enabled); + signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf1_timeframe,gannhilo_mtf1_lookback,bar),gannhilo_mtf1_enabled); + signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf2_timeframe,gannhilo_mtf2_lookback,bar),gannhilo_mtf2_enabled); + signal_addsignal(signal,signal_rsi(rsi1_period,bar,0),rsi1_enabled); + signal_addsignal(signal,signal_rsi(rsi2_period,bar,0),rsi2_enabled); + + if (reverse_signal) signal = signal_reverse(signal); + + if (signal != SIGNAL_NO) { + double high = iHigh(Symbol(),0,bar); + double low = iLow(Symbol(),0,bar); + if (signal == SIGNAL_BUY) { + entry = priceround(high+(entry_from_hl+spread_inticks)*ticksize); + stoploss = priceround((low-(iATR(Symbol(),0,atrforarrows,bar))*arrow_dist)-entry_from_hl*ticksize); + takeprofit = priceround(entry+(entry-stoploss)*tp_from_sl); + } + if (signal == SIGNAL_SELL) { + entry = priceround(low-entry_from_hl*ticksize); + stoploss = priceround((high+(iATR(Symbol(),0,atrforarrows,bar))*arrow_dist)+(sl_from_hl+spread_inticks)*ticksize); + takeprofit = priceround(entry-(stoploss-entry)*tp_from_sl); + } + signalbartime = iTime(Symbol(),0,bar); + } + + string alertstring; + + if (signal != SIGNAL_NO) { + if (signal == SIGNAL_BUY) + alertstring = "BUY signal on "; + if (signal == SIGNAL_SELL) + alertstring = "SELL signal on "; + + alertstring = alertstring + Symbol(); + alertstring = alertstring + " on bar at " + TimeToStr(signalbartime,TIME_DATE|TIME_MINUTES); + alertstring = alertstring + "\nEntry: " + DoubleToStr(entry,Digits) + " StopLoss: " + DoubleToStr(stoploss,Digits) + " TakeProfit: " + DoubleToStr(takeprofit,Digits); + + lastalertstring = alertstring; + } + + //signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf2_timeframe,gannhilo_mtf2_lookback,bar,0),gannhilo_mtf2_enabled); + return(signal); +} + + +int signal_addsignal(int& signal, int this_signal, bool signal_enabled = true) +{ + if (signal_enabled) + { + if (signal == -1) + signal = this_signal; + if (signal != this_signal) { + if (signal == SIGNAL_BOTH) signal = this_signal; + else if (this_signal != SIGNAL_BOTH) signal = SIGNAL_NO; + } + } +} + +int addsignal_or(int& signal, int this_signal) +{ + if (this_signal == SIGNAL_BUY) { + if (signal == SIGNAL_SELL || signal == SIGNAL_BOTH) signal = SIGNAL_BOTH; + else signal = this_signal; + } + if (this_signal == SIGNAL_SELL) { + if (signal == SIGNAL_BUY || signal == SIGNAL_BOTH) signal = SIGNAL_BOTH; + else signal = this_signal; + } + if (this_signal == SIGNAL_BOTH) { + signal = this_signal; + } +} + +int signal_reverse(int signal) +{ + if (signal == SIGNAL_BUY) + return(SIGNAL_SELL); + else if (signal == SIGNAL_SELL) + return(SIGNAL_BUY); + + return(signal); +} + +/*int getbar(int bar, int timeframe) +{ + return(iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar)) +}*/ + +int addcomment(string c1, string c2="", string c3="", string c4="", string c5="", string c6="", string c7="", string c8="", + string c9="", string c10="", string c11="", string c12="", string c13="", string c14="", string c15="", string c16="") +{ + clear0(c1); + clear0(c2); + clear0(c3); + clear0(c4); + clear0(c5); + clear0(c6); + clear0(c7); + clear0(c8); + clear0(c9); + clear0(c10); + clear0(c11); + clear0(c12); + clear0(c13); + clear0(c14); + clear0(c15); + clear0(c16); + commentstring = commentstring+c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12+c13+c14+c15+c16; +} + +void clear0(string& str) +{ + for (int i = 0; i < StringLen(str); i++) + { + string chr = StringSubstr(str,i,1); + if (chr != "0" && chr != "." && chr != "1" && chr != "2" && chr != "3" && chr != "4" + && chr != "5" && chr != "6" && chr != "7" && chr != "8" && chr != "9") + return(0); + } + if (StringFind(str,".",1)>=0) + { + while (StringFind(str,"0",StringLen(str)-1)>=0) + { + str = StringSubstr(str,0,StringLen(str)-1); + } + if (StringFind(str,".",StringLen(str)-1)>=0) + str = StringSubstr(str,0,StringLen(str)-1); + } +} + +int writecomment() +{ + if (comment_formatting) { + int cnt_line = 0; + int pos = 0; + int lineend = 0; + string currentline = ""; + string name_currentline; + int ypos_currentline; + while (pos < StringLen(commentstring)) { + lineend = StringFind(commentstring,"\n",pos); + if (lineend < 0) lineend = StringLen(commentstring); + currentline = StringSubstr(commentstring,pos,lineend-pos); + pos = lineend+1; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + ypos_currentline = comment_y+comment_lineheight*cnt_line; + ObjectCreate(name_currentline,OBJ_LABEL,0,0,0,0,0); + ObjectSet(name_currentline,OBJPROP_CORNER,comment_corner); + ObjectSet(name_currentline,OBJPROP_XDISTANCE,comment_x); + ObjectSet(name_currentline,OBJPROP_YDISTANCE,ypos_currentline); + ObjectSetText(name_currentline,currentline,comment_fontsize,comment_font,comment_color); + cnt_line++; + } + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + while (ObjectFind(name_currentline) >= 0) { + ObjectDelete(name_currentline); + cnt_line++; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + } + Comment(""); + } else { + Comment(commentstring); + cnt_line = 0; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + while (ObjectFind(name_currentline) >= 0) { + ObjectDelete(name_currentline); + cnt_line++; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + } + } +} + +int delcomment() +{ + commentstring = ""; +} \ No newline at end of file diff --git a/gann_hilo_arrow_alert_colin11.mq4 b/gann_hilo_arrow_alert_colin11.mq4 new file mode 100644 index 0000000..e5a6289 --- /dev/null +++ b/gann_hilo_arrow_alert_colin11.mq4 @@ -0,0 +1,579 @@ +//+------------------------------------------------------------------+ +//| gann_hilo_arrow_alert_colin.mq4 | +//| Zoltan Laszlo Ferenci | +//| http://www.metatraderprogrammer.com | +//+------------------------------------------------------------------+ +#property copyright "Zoltan Laszlo Ferenci" +#property link "http://www.metatraderprogrammer.com" + +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_color1 White +#property indicator_color2 White +//--- buffers +double ExtMapBuffer1[]; +double ExtMapBuffer2[]; + +#include +#include + +#define SIGNAL_NO 0 +#define SIGNAL_BUY 1 +#define SIGNAL_SELL 2 +#define SIGNAL_BOTH 3 + +extern bool email_alert = true; +extern bool sound_alert = true; +extern bool popup_alert = true; +extern bool show_on_comment = true; + +extern bool sound_repeat = true; +extern bool popup_repeat = false; + +extern string sound_filename = "alert.wav"; +extern double alertevery = 5; +extern int maxrepeat = 5; + +extern int signal_bar = 0; +extern int alert_bar = 1; +//extern int _tf_bar = 1; +//extern int tf_bar = 1; +//extern int timeframe = 0; + +extern int entry_from_hl = 5; +extern int sl_from_hl = 5; +extern double tp_from_sl = 1; + +bool alert_on_change = true; +bool alert_on_firsttick = true; +bool disable_if_nochange = true; + +bool reverse_signal = false; + +//bool isfirsttick = false; +//datetime lasttick = 0; +datetime lastalert = 0; +int last_signal = 0; // -1: no alert at first signal +bool alert_enabled = true; +bool alert_norepeat = true; +int alertcount = 0; +int atrforarrows = 200; + +extern int maxbars = 900; + +extern bool gannhilo_enabled = true; + +extern string gannhilo_name = "###Gann_HiLo_Activator_v2###"; +extern int gannhilo_lookback = 5; +extern int ma_period = 5; +extern int ma_mode = MODE_EMA; + +extern bool gannhilo_mtf1_enabled = true; +extern int gannhilo_mtf1_timeframe = PERIOD_D1; +extern int gannhilo_mtf1_lookback = 5; + +extern bool gannhilo_mtf2_enabled = true; +extern int gannhilo_mtf2_timeframe = PERIOD_D1; +extern int gannhilo_mtf2_lookback = 5; + +extern bool rsi1_enabled = true; +extern int rsi1_period = 10; +extern bool rsi2_enabled = true; +extern int rsi2_period = 60; + +extern int arrow_size = 1; +extern double arrow_dist = 0.3; + +string comment = ""; +string commentstring = ""; + +extern bool comment_enabled = true; +extern bool comment_formatting = true; +string objname_comment = "comment_textbox"; +extern int comment_corner = 1; +extern int comment_fontsize = 9; +extern string comment_font = "Tahoma"; +extern color comment_color = White; +extern int comment_x = 10; +extern int comment_y = 10; +extern int comment_lineheight = 15; + +extern color entryColor = Black; +extern int entryStyle = 1; +extern int entryThickness = 1; +extern color stopColor = Red; +extern int stopStyle = 1; +extern int stopThickness = 1; +extern int profitColor = Green; +extern color profitStyle = 1; +extern int profitThickness = 1; + +double entry, stoploss, takeprofit; +datetime signalbartime; +string lastalertstring; + +int init() +{ + variables_init(); + + SetIndexStyle(0,DRAW_ARROW,EMPTY,arrow_size); + SetIndexArrow(0,217); + SetIndexBuffer(0,ExtMapBuffer1); + SetIndexEmptyValue(0,0.0); + SetIndexStyle(1,DRAW_ARROW,EMPTY,arrow_size); + SetIndexArrow(1,218); + SetIndexBuffer(1,ExtMapBuffer2); + SetIndexEmptyValue(1,0.0); + return(0); +} + +int deinit() +{ + return(0); +} + +int start() +{ + variables_priceinit(); + + addcomment("alphatrader.ca\n"); + + obj_loadbool("sound_repeat", sound_repeat); + + int counted_bars=IndicatorCounted(); + //if(counted_bars>0) counted_bars--; + int limit=Bars-counted_bars; + if (limit > maxbars) limit = maxbars; + + for(int i=limit-1; i>=0; i--) + { + int signal = signal(i+signal_bar); + + if (signal == SIGNAL_SELL) + { + ExtMapBuffer2[i] = High[i]+(iATR(Symbol(),0,atrforarrows,i))*arrow_dist; + ExtMapBuffer1[i] = EMPTY_VALUE; + } + + if (signal == SIGNAL_BUY) + { + ExtMapBuffer1[i] = Low[i]-(iATR(Symbol(),0,atrforarrows,i))*arrow_dist; + ExtMapBuffer2[i] = EMPTY_VALUE; + } + if (signal == SIGNAL_NO) + { + ExtMapBuffer1[i] = EMPTY_VALUE; + ExtMapBuffer2[i] = EMPTY_VALUE; + } + } + + double entry, stoploss, tp; + + for(i = 0; i 0 && timecurrent - lastalert > alertevery && alertcount < maxrepeat)) + { + if (email_alert && alert_norepeat) + SendMail(alertstring,alertstring); + if (popup_alert && (alert_norepeat || popup_repeat)) + Alert(alertstring); + if (sound_alert && (alert_norepeat || sound_repeat)) + PlaySound(sound_filename); + lastalertstring = alertstring; + lastalert = timecurrent; + alertcount++; + } + +} + +/*bool isfirsttick() +{ + datetime bartime = iTime(Symbol(),0,0); + if (bartime == lasttick) + { + isfirsttick = false; + return(isfirsttick); + } + else + { + lasttick = bartime; + isfirsttick = true; + return(isfirsttick); + } +} +*/ + +/*int signal_tf(int bar, int timeframe) +{ + int tf_bar = iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar-1)-1)+tf_bar; + int tf_bar_last = iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar))+tf_bar; + + int mainsignal = SIGNAL_NO; + for (;tf_bar<=tf_bar_last;tf_bar++){ + int signal = -1; + signal_addsignal(signal,signal_tf_rule(tf_bar,timeframe),true); + addsignal_or(mainsignal,signal); + } + return(mainsignal); +}*/ + +int signal_gannhilo(int bar, int timeframe) +{ + int signal = SIGNAL_NO; + double gannhilo = iCustom(Symbol(),timeframe,gannhilo_name,gannhilo_lookback,0,bar); + double gannhilo1 = iCustom(Symbol(),timeframe,gannhilo_name,gannhilo_lookback,0,bar+1); + double ma = iMA(Symbol(),timeframe,ma_period,0,ma_mode,PRICE_CLOSE,bar); + double ma1 = iMA(Symbol(),timeframe,ma_period,0,ma_mode,PRICE_CLOSE,bar+1); + if (ma > gannhilo && ma1 <= gannhilo1) signal = SIGNAL_BUY; + if (ma < gannhilo && ma1 >= gannhilo1) signal = SIGNAL_SELL; + return(signal); +} + + +int signal_gannhilo_confirm(int gann_lookback, int bar, int timeframe) +{ + double close = iClose(Symbol(),timeframe,bar); + double gann = iCustom(Symbol(),timeframe,gannhilo_name,gann_lookback,0,bar); + if (close > gann) return(SIGNAL_BUY); + if (close < gann) return(SIGNAL_SELL); + return(SIGNAL_NO); +} + + +int signal_gannhilo_mtf(int gann_timeframe, int gann_lookback, int bar) +{ + int tf_bar = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar)); + //int tf_bar = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar-1)-1)+_tf_bar; + //int tf_bar_last = iBarShift(Symbol(),gann_timeframe,iTime(Symbol(),0,bar))+_tf_bar; + int signal = signal_gannhilo_confirm(gann_lookback,tf_bar,gann_timeframe); + //Alert(bar," ",tf_bar," ",gann_timeframe," ",signal); + return(signal); + //Alert(tf_bar, tf_bar_last); + /*int mainsignal = SIGNAL_NO; + for (;tf_bar<=tf_bar_last;tf_bar++){ + int signal = -1; + signal_addsignal(signal,signal_gannhilo_confirm(gann_lookback,tf_bar,gann_timeframe),true); + addsignal_or(mainsignal,signal); + }*/ + //return(mainsignal); +} + +int signal_rsi(int rsi_period, int bar, int timeframe) +{ + double rsi = iRSI(Symbol(),timeframe,rsi_period,PRICE_CLOSE,bar); + if (rsi > 50) return(SIGNAL_BUY); + if (rsi < 50) return(SIGNAL_SELL); + return(SIGNAL_NO); +} + +int signal(int bar) +{ + int signal = -1; + signal_addsignal(signal,signal_gannhilo(bar,0),gannhilo_enabled); + signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf1_timeframe,gannhilo_mtf1_lookback,bar),gannhilo_mtf1_enabled); + signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf2_timeframe,gannhilo_mtf2_lookback,bar),gannhilo_mtf2_enabled); + signal_addsignal(signal,signal_rsi(rsi1_period,bar,0),rsi1_enabled); + signal_addsignal(signal,signal_rsi(rsi2_period,bar,0),rsi2_enabled); + + if (reverse_signal) signal = signal_reverse(signal); + + if (signal != SIGNAL_NO) { + double high = iHigh(Symbol(),0,bar); + double low = iLow(Symbol(),0,bar); + if (signal == SIGNAL_BUY) { + entry = high+(entry_from_hl+spread_inticks)*ticksize; + stoploss = low-entry_from_hl*ticksize; + takeprofit = priceround(entry+(entry-stoploss)*tp_from_sl); + } + if (signal == SIGNAL_SELL) { + entry = low-entry_from_hl*ticksize; + stoploss = high+(sl_from_hl+spread_inticks)*ticksize; + takeprofit = priceround(entry-(stoploss-entry)*tp_from_sl); + } + signalbartime = iTime(Symbol(),0,bar); + } + + string alertstring; + + if (signal != SIGNAL_NO) { + if (signal == SIGNAL_BUY) + alertstring = "BUY signal on "; + if (signal == SIGNAL_SELL) + alertstring = "SELL signal on "; + + alertstring = alertstring + Symbol(); + alertstring = alertstring + " on bar at " + TimeToStr(signalbartime,TIME_DATE|TIME_MINUTES); + alertstring = alertstring + "\nEntry: " + DoubleToStr(entry,Digits) + " StopLoss: " + DoubleToStr(stoploss,Digits) + " TakeProfit: " + DoubleToStr(takeprofit,Digits); + + lastalertstring = alertstring; + } + + //signal_addsignal(signal,signal_gannhilo_mtf(gannhilo_mtf2_timeframe,gannhilo_mtf2_lookback,bar,0),gannhilo_mtf2_enabled); + return(signal); +} + + +int signal_addsignal(int& signal, int this_signal, bool signal_enabled = true) +{ + if (signal_enabled) + { + if (signal == -1) + signal = this_signal; + if (signal != this_signal) { + if (signal == SIGNAL_BOTH) signal = this_signal; + else if (this_signal != SIGNAL_BOTH) signal = SIGNAL_NO; + } + } +} + +int addsignal_or(int& signal, int this_signal) +{ + if (this_signal == SIGNAL_BUY) { + if (signal == SIGNAL_SELL || signal == SIGNAL_BOTH) signal = SIGNAL_BOTH; + else signal = this_signal; + } + if (this_signal == SIGNAL_SELL) { + if (signal == SIGNAL_BUY || signal == SIGNAL_BOTH) signal = SIGNAL_BOTH; + else signal = this_signal; + } + if (this_signal == SIGNAL_BOTH) { + signal = this_signal; + } +} + +int signal_reverse(int signal) +{ + if (signal == SIGNAL_BUY) + return(SIGNAL_SELL); + else if (signal == SIGNAL_SELL) + return(SIGNAL_BUY); + + return(signal); +} + +/*int getbar(int bar, int timeframe) +{ + return(iBarShift(Symbol(),timeframe,iTime(Symbol(),0,bar)) +}*/ + +int addcomment(string c1, string c2="", string c3="", string c4="", string c5="", string c6="", string c7="", string c8="", + string c9="", string c10="", string c11="", string c12="", string c13="", string c14="", string c15="", string c16="") +{ + clear0(c1); + clear0(c2); + clear0(c3); + clear0(c4); + clear0(c5); + clear0(c6); + clear0(c7); + clear0(c8); + clear0(c9); + clear0(c10); + clear0(c11); + clear0(c12); + clear0(c13); + clear0(c14); + clear0(c15); + clear0(c16); + commentstring = commentstring+c1+c2+c3+c4+c5+c6+c7+c8+c9+c10+c11+c12+c13+c14+c15+c16; +} + +void clear0(string& str) +{ + for (int i = 0; i < StringLen(str); i++) + { + string chr = StringSubstr(str,i,1); + if (chr != "0" && chr != "." && chr != "1" && chr != "2" && chr != "3" && chr != "4" + && chr != "5" && chr != "6" && chr != "7" && chr != "8" && chr != "9") + return(0); + } + if (StringFind(str,".",1)>=0) + { + while (StringFind(str,"0",StringLen(str)-1)>=0) + { + str = StringSubstr(str,0,StringLen(str)-1); + } + if (StringFind(str,".",StringLen(str)-1)>=0) + str = StringSubstr(str,0,StringLen(str)-1); + } +} + +int writecomment() +{ + if (comment_formatting) { + int cnt_line = 0; + int pos = 0; + int lineend = 0; + string currentline = ""; + string name_currentline; + int ypos_currentline; + while (pos < StringLen(commentstring)) { + lineend = StringFind(commentstring,"\n",pos); + if (lineend < 0) lineend = StringLen(commentstring); + currentline = StringSubstr(commentstring,pos,lineend-pos); + pos = lineend+1; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + ypos_currentline = comment_y+comment_lineheight*cnt_line; + ObjectCreate(name_currentline,OBJ_LABEL,0,0,0,0,0); + ObjectSet(name_currentline,OBJPROP_CORNER,comment_corner); + ObjectSet(name_currentline,OBJPROP_XDISTANCE,comment_x); + ObjectSet(name_currentline,OBJPROP_YDISTANCE,ypos_currentline); + ObjectSetText(name_currentline,currentline,comment_fontsize,comment_font,comment_color); + cnt_line++; + } + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + while (ObjectFind(name_currentline) >= 0) { + ObjectDelete(name_currentline); + cnt_line++; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + } + Comment(""); + } else { + Comment(commentstring); + cnt_line = 0; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + while (ObjectFind(name_currentline) >= 0) { + ObjectDelete(name_currentline); + cnt_line++; + name_currentline = objname_comment+DoubleToStr(cnt_line,0); + } + } +} + +int delcomment() +{ + commentstring = ""; +} \ No newline at end of file diff --git a/i-Sessions.mq4 b/i-Sessions.mq4 new file mode 100644 index 0000000..4eb1ee1 --- /dev/null +++ b/i-Sessions.mq4 @@ -0,0 +1,167 @@ +//+----------------------------------------------------------------------------+ +//| i-Sessions.mq4 | +//| | +//| Ким Игорь В. aka KimIV | +//| http://www.kimiv.ru | +//| | +//| 16.11.2005 Индикатор торговых сессий. | +//| 04.06.2008 Исправлена ошибка учёта первого бара в сессии. | +//| 25.10.2008 Добавлены параметры: Style - Стиль линий объектов и | +//| FillBack - Заливка объектов. | +//+----------------------------------------------------------------------------+ +#property copyright "Ким Игорь В. aka KimIV" +#property link "http://www.kimiv.ru" + +#property indicator_chart_window + +//------- Внешние параметры индикатора ----------------------------------------+ +extern int NumberOfDays = 5; // Количество дней +extern string AsiaBegin = "01:00"; // Открытие азиатской сессии +extern string AsiaEnd = "10:00"; // Закрытие азиатской сессии +extern color AsiaColor = Goldenrod; // Цвет азиатской сессии +extern string EurBegin = "07:00"; // Открытие европейской сессии +extern string EurEnd = "16:00"; // Закрытие европейской сессии +extern color EurColor = Tan; // Цвет европейской сессии +extern string USABegin = "14:00"; // Открытие американской сессии +extern string USAEnd = "23:00"; // Закрытие американской сессии +extern color USAColor = Pink; // Цвет американской сессии +extern int Style = 2; // Стиль линий объектов +extern bool FillBack = True; // Заливать объекты +extern bool ShowPrice = True; // Показывать ценовые уровни +extern color clFont = Blue; // Цвет шрифта +extern int SizeFont = 8; // Размер шрифта +extern int OffSet = 10; // Смещение + + +//+----------------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+----------------------------------------------------------------------------+ +void init() { + DeleteObjects(); + for (int i=0; i5) dt-=24*60*60; + } +} + +//+----------------------------------------------------------------------------+ +//| Прорисовка объектов на графике | +//| Параметры: | +//| dt - дата торгового дня | +//| no - наименование объекта | +//| tb - время начала сессии | +//| te - время окончания сессии | +//+----------------------------------------------------------------------------+ +void DrawObjects(datetime dt, string no, string tb, string te) { + datetime t1, t2; + double p1, p2; + int b1, b2; + + t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb); + t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te); + b1=iBarShift(NULL, 0, t1); + b2=iBarShift(NULL, 0, t2); + p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2+1, b2)]; + p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2+1, b2)]; + ObjectSet(no, OBJPROP_TIME1 , t1); + ObjectSet(no, OBJPROP_PRICE1, p1); + ObjectSet(no, OBJPROP_TIME2 , t2); + ObjectSet(no, OBJPROP_PRICE2, p2); +} + +//+----------------------------------------------------------------------------+ +//| Прорисовка ценовых меток на графике | +//| Параметры: | +//| dt - дата торгового дня | +//| no - наименование объекта | +//| tb - время начала сессии | +//| te - время окончания сессии | +//+----------------------------------------------------------------------------+ +void DrawPrices(datetime dt, string no, string tb, string te) { + datetime t1, t2; + double p1, p2; + int b1, b2; + + t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb); + t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te); + b1=iBarShift(NULL, 0, t1); + b2=iBarShift(NULL, 0, t2); + p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)]; + p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)]; + + if (ObjectFind(no+"up")<0) ObjectCreate(no+"up", OBJ_TEXT, 0, 0,0); + ObjectSet(no+"up", OBJPROP_TIME1 , t2); + ObjectSet(no+"up", OBJPROP_PRICE1 , p1+(OffSet+SizeFont)*Point); + ObjectSet(no+"up", OBJPROP_COLOR , clFont); + ObjectSet(no+"up", OBJPROP_FONTSIZE, SizeFont); + ObjectSetText(no+"up", DoubleToStr(p1+Ask-Bid, Digits)); + + if (ObjectFind(no+"dn")<0) ObjectCreate(no+"dn", OBJ_TEXT, 0, 0,0); + ObjectSet(no+"dn", OBJPROP_TIME1 , t2); + ObjectSet(no+"dn", OBJPROP_PRICE1 , p2-OffSet*Point); + ObjectSet(no+"dn", OBJPROP_COLOR , clFont); + ObjectSet(no+"dn", OBJPROP_FONTSIZE, SizeFont); + ObjectSetText(no+"dn", DoubleToStr(p2, Digits)); +} +//+----------------------------------------------------------------------------+ + diff --git a/i_Trend.mq4 b/i_Trend.mq4 new file mode 100644 index 0000000..48b93d2 --- /dev/null +++ b/i_Trend.mq4 @@ -0,0 +1,92 @@ +//+------------------------------------------------------------------+ +//| iTrend.mq4 | +//| Copyright © 2004, MetaQuotes Software Corp. | +//| http://www.metaquotes.net | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2004, MetaQuotes Software Corp." +#property link "http://www.metaquotes.net" + +#property indicator_separate_window +#property indicator_buffers 2 +#property indicator_color1 LimeGreen +#property indicator_color2 Red +//---- input parameters +extern int Bands_Mode_0_2=0; // =0-2 MODE_MAIN, MODE_LOW, MODE_HIGH +extern int Power_Price_0_6=0; // =0-6 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW,PRICE_MEDIAN,PRICE_TYPICAL,PRICE_WEIGHTED +extern int Price_Type_0_3=0; // =0-3 PRICE_CLOSE,PRICE_OPEN,PRICE_HIGH,PRICE_LOW +extern int Bands_Period=20; +extern int Bands_Deviation=2; +extern int Power_Period=13; +extern int CountBars=20000; +//---- buffers +double value[]; +double value2[]; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int init() + { +// string short_name; +//---- indicator line + IndicatorBuffers(2); + SetIndexStyle(0,DRAW_LINE); + SetIndexStyle(1,DRAW_LINE); + SetIndexBuffer(0,value); + SetIndexBuffer(1,value2); +//---- + +//---- + return(0); + } +//+------------------------------------------------------------------+ +//| Trend | +//+------------------------------------------------------------------+ +int start() + { + SetIndexDrawBegin(0,Bars-CountBars+Bands_Period+1); + SetIndexDrawBegin(1,Bars-CountBars+Bands_Period+1); + int i,CurrentBar,Bands_Mode,counted_bars=IndicatorCounted(); + double Power_Price,CurrentPrice; +//---- + if(Bars<=Bands_Period) return(0); +//---- initial zero + if(counted_bars=Bands_Period) i=Bars-counted_bars-1; + + +if (Bands_Mode_0_2==1) Bands_Mode=MODE_LOW; +if (Bands_Mode_0_2==2) Bands_Mode=MODE_HIGH; +if (Bands_Mode_0_2==0) Bands_Mode=MODE_MAIN; + +if (Power_Price_0_6==1) Power_Price=PRICE_OPEN; +if (Power_Price_0_6==2) Power_Price=PRICE_HIGH; +if (Power_Price_0_6==3) Power_Price=PRICE_LOW; +if (Power_Price_0_6==4) Power_Price=PRICE_MEDIAN; +if (Power_Price_0_6==5) Power_Price=PRICE_TYPICAL; +if (Power_Price_0_6==6) Power_Price=PRICE_WEIGHTED; +if (Power_Price_0_6==6) Power_Price=PRICE_CLOSE; + +for (i=CountBars-1; i>=0; i--) +{ + if (Price_Type_0_3==1) CurrentPrice=Open[i]; + + if (Price_Type_0_3==2) CurrentPrice=High[i]; + + if (Price_Type_0_3==3) CurrentPrice=Low[i]; + if (Price_Type_0_3==0) CurrentPrice=Close[i]; + + value[i]=CurrentPrice-iBands(NULL,0,Bands_Period,Bands_Deviation,0,Bands_Mode,Power_Price,i); + value2[i]=-(iBearsPower(NULL,0,Power_Period,Power_Price,i)+iBullsPower(NULL,0,Power_Period,Power_Price,i)); + +} + + + return(0); + } +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/nonlagdot.mq4 b/nonlagdot.mq4 new file mode 100644 index 0000000..ff69f3a --- /dev/null +++ b/nonlagdot.mq4 @@ -0,0 +1,150 @@ +//+------------------------------------------------------------------+ +//| NonLagDOT.mq4 | +//| Copyright © 2006, TrendLaboratory | +//| http://finance.groups.yahoo.com/group/TrendLaboratory | +//| E-mail: igorad2003@yahoo.co.uk | +//+------------------------------------------------------------------+ +#property copyright "Copyright © 2006, TrendLaboratory" +#property link "http://finance.groups.yahoo.com/group/TrendLaboratory" + + +#property indicator_chart_window +#property indicator_buffers 3 +#property indicator_color1 Yellow +#property indicator_width1 1 +#property indicator_color2 RoyalBlue +#property indicator_width2 1 +#property indicator_color3 Red +#property indicator_width3 1 + + +//---- input parameters +extern int Price = 0; +extern int Length = 20; +extern int Displace = 0; +extern int Filter = 0; +extern int Color = 1; +extern int ColorBarBack = 0; +extern double Deviation = 0; + +double Cycle = 4; + +//---- indicator buffers +double MABuffer[]; +double UpBuffer[]; +double DnBuffer[]; +double price[]; +double trend[]; + +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ + int init() + { + int ft=0; + string short_name; +//---- indicator line + IndicatorBuffers(5); + SetIndexStyle(0,DRAW_ARROW); + SetIndexBuffer(0,MABuffer); + SetIndexStyle(1,DRAW_ARROW); + SetIndexBuffer(1,UpBuffer); + SetIndexStyle(2,DRAW_ARROW); + SetIndexBuffer(2,DnBuffer); + SetIndexBuffer(3,price); + SetIndexBuffer(4,trend); + IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); + SetIndexArrow(0,159); + SetIndexArrow(1,159); + SetIndexArrow(2,159); + SetIndexArrow(3,159); +//---- name for DataWindow and indicator subwindow label + short_name="NonLagDot("+Length+")"; + IndicatorShortName(short_name); + SetIndexLabel(0,"NLD"); + SetIndexLabel(1,"Up"); + SetIndexLabel(2,"Dn"); +//---- + SetIndexShift(0,Displace); + SetIndexShift(1,Displace); + SetIndexShift(2,Displace); + + SetIndexDrawBegin(0,Length*Cycle+Length); + SetIndexDrawBegin(1,Length*Cycle+Length); + SetIndexDrawBegin(2,Length*Cycle+Length); +//---- + return(0); + } + +//+------------------------------------------------------------------+ +//| NonLagMA_v4 | +//+------------------------------------------------------------------+ +int start() +{ + int i,shift, counted_bars=IndicatorCounted(),limit; + double alfa, beta, t, Sum, Weight, step,g; + double pi = 3.1415926535; + + double Coeff = 3*pi; + int Phase = Length-1; + double Len = Length*Cycle + Phase; + + if ( counted_bars > 0 ) limit=Bars-counted_bars; + if ( counted_bars < 0 ) return(0); + if ( counted_bars ==0 ) limit=Bars-Len-1; + if ( counted_bars < 1 ) + for(i=1;i=0;shift--) + { + Weight=0; Sum=0; t=0; + + for (i=0;i<=Len-1;i++) + { + g = 1.0/(Coeff*t+1); + if (t <= 0.5 ) g = 1; + beta = MathCos(pi*t); + alfa = g * beta; + //if (shift>=1) price[i] = iMA(NULL,0,Per,Displace,Mode,Price,shift+i); + //else + price[i] = iMA(NULL,0,1,0,MODE_SMA,Price,shift+i); + Sum += alfa*price[i]; + Weight += alfa; + if ( t < 1 ) t += 1.0/(Phase-1); + else if ( t < Len-1 ) t += (2*Cycle-1)/(Cycle*Length-1); + } + + if (Weight > 0) MABuffer[shift] = (1.0+Deviation/100)*Sum/Weight; + + if (Filter>0) + { + if( MathAbs(MABuffer[shift]-MABuffer[shift+1]) < Filter*Point ) MABuffer[shift]=MABuffer[shift+1]; + } + + if (Color>0) + { + trend[shift]=trend[shift+1]; + if (MABuffer[shift]-MABuffer[shift+1] > Filter*Point) trend[shift]= 1; + if (MABuffer[shift+1]-MABuffer[shift] > Filter*Point) trend[shift]=-1; + if (trend[shift]>0) + { + UpBuffer[shift] = MABuffer[shift]; + if (trend[shift+ColorBarBack]<0) UpBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack]; + DnBuffer[shift] = 0; + } + if (trend[shift]<0) + { + DnBuffer[shift] = MABuffer[shift]; + if (trend[shift+ColorBarBack]>0) DnBuffer[shift+ColorBarBack]=MABuffer[shift+ColorBarBack]; + UpBuffer[shift] = 0; + } + } + } + return(0); +} + diff --git a/x-ZZ.mq4 b/x-ZZ.mq4 new file mode 100644 index 0000000..fe3cf07 --- /dev/null +++ b/x-ZZ.mq4 @@ -0,0 +1,133 @@ +#property indicator_chart_window +#property indicator_buffers 1 +#property indicator_color1 Silver + +extern bool AlarmWithBox = FALSE; +extern string SoundWAV = "alert.wav"; +extern int ExtDepth = 33; +extern int ExtDeviation = 5; +extern int ExtBackstep = 3; +extern int barn = 1500; +extern int from = 0; +double g_ibuf_108[]; +double g_ibuf_112[]; +int g_time_116 = 0; + +int init() { + IndicatorBuffers(2); + SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 0); + SetIndexArrow(0, 108); + SetIndexBuffer(0, g_ibuf_108); + SetIndexBuffer(1, g_ibuf_112); + SetIndexEmptyValue(0, 0.0); + ArraySetAsSeries(g_ibuf_108, TRUE); + ArraySetAsSeries(g_ibuf_112, TRUE); + IndicatorShortName("ZigZag(" + ExtDepth + "," + ExtDeviation + "," + ExtBackstep + ")"); + return (0); +} + +int start() { + double ld_16; + double ld_24; + double ld_32; + double ld_40; + double ld_48; + double ld_56; + int lia_64[2]; + double ld_72; + int li_0 = barn; + for (li_0 = barn - ExtDepth; li_0 > from; li_0--) { + ld_16 = Low[iLowest(NULL, 0, MODE_LOW, ExtDepth, li_0)]; + if (ld_16 == ld_56) ld_16 = 0.0; + else { + ld_56 = ld_16; + if (Low[li_0] - ld_16 > ExtDeviation * Point) ld_16 = 0.0; + else { + for (int li_4 = 1; li_4 <= ExtBackstep; li_4++) { + ld_24 = g_ibuf_108[li_0 + li_4]; + if (ld_24 != 0.0 && ld_24 > ld_16) g_ibuf_108[li_0 + li_4] = 0.0; + } + } + } + g_ibuf_108[li_0] = ld_16; + ld_16 = High[iHighest(NULL, 0, MODE_HIGH, ExtDepth, li_0)]; + if (ld_16 == ld_48) ld_16 = 0.0; + else { + ld_48 = ld_16; + if (ld_16 - High[li_0] > ExtDeviation * Point) ld_16 = 0.0; + else { + for (li_4 = 1; li_4 <= ExtBackstep; li_4++) { + ld_24 = g_ibuf_112[li_0 + li_4]; + if (ld_24 != 0.0 && ld_24 < ld_16) g_ibuf_112[li_0 + li_4] = 0.0; + } + } + } + g_ibuf_112[li_0] = ld_16; + } + ld_48 = -1; + int li_8 = -1; + ld_56 = -1; + int li_12 = -1; + for (li_0 = barn - ExtDepth; li_0 > from; li_0--) { + ld_32 = g_ibuf_108[li_0]; + ld_40 = g_ibuf_112[li_0]; + if (ld_32 == 0.0 && ld_40 == 0.0) continue; + if (ld_40 != 0.0) { + if (ld_48 > 0.0) { + if (ld_48 < ld_40) g_ibuf_112[li_8] = 0; + else g_ibuf_112[li_0] = 0; + } + if (ld_48 < ld_40 || ld_48 < 0.0) { + ld_48 = ld_40; + li_8 = li_0; + } + ld_56 = -1; + } + if (ld_32 != 0.0) { + if (ld_56 > 0.0) { + if (ld_56 > ld_32) g_ibuf_108[li_12] = 0; + else g_ibuf_108[li_0] = 0; + } + if (ld_32 < ld_56 || ld_56 < 0.0) { + ld_56 = ld_32; + li_12 = li_0; + } + ld_48 = -1; + } + } + for (li_0 = barn - 1; li_0 > from; li_0--) { + if (li_0 >= barn - ExtDepth) g_ibuf_108[li_0] = 0.0; + else { + ld_24 = g_ibuf_112[li_0]; + if (ld_24 != 0.0) g_ibuf_108[li_0] = ld_24; + } + } + int l_index_68 = 0; + for (li_0 = from + 1; l_index_68 < 2 && li_0 < barn; li_0++) { + if (g_ibuf_108[li_0] != 0.0) { + lia_64[l_index_68] = li_0; + l_index_68++; + } + } + if (l_index_68 > 0) { + if (g_time_116 != Time[lia_64[0]]) { + g_time_116 = Time[lia_64[0]]; + ld_72 = g_ibuf_108[lia_64[0]] - g_ibuf_108[lia_64[1]]; + /*if (ld_72 > 0.0) { + Alert("Tada! ", Symbol(), " ", Period(), " @ ", Bid); + PlaySound(SoundWAV); + } else { + if (ld_72 < 0.0) { + Alert("Tada! ", Symbol(), " ", Period(), " @ ", Bid); + PlaySound(SoundWAV); + } else { + if (l_index_68 == 1) { + Alert("Tada! ", Symbol(), " ", Period(), " @ ", Bid); + PlaySound(SoundWAV); + } + } + }*/ + } + } + return (0); +} \ No newline at end of file diff --git "a/\320\222\302\251 Profit_$.mq4" "b/\320\222\302\251 Profit_$.mq4" new file mode 100644 index 0000000..c4164fd --- /dev/null +++ "b/\320\222\302\251 Profit_$.mq4" @@ -0,0 +1,45 @@ +//+---------------------------------------------------------------- +//| "Прибыль на графике в $" © Profit_$.mq4 +//+----------------------------------------------------------------- +#property indicator_chart_window + //+---------------------------------------------------------------- + extern int Corner = 1; // values [0-3] - опорный угол + extern int XDistance = 10; // x расстояние от опорного угла + extern int YDistance = 10; // y расстояние от опорного угла + extern color Color1 = Lime; // цвет линии для Прибыль + extern color Color2 = Maroon; // White цвет линии для убыток + extern int FontSize = 21; + extern string FontName = "Tahoma" ; // "Arial" "Arial Black" + double profit=0; double nPoint = 0; +//+----------------------------------------------------------- +int init(){ + return(0);} +//+----------------------------------------------------------- +int deinit() + { ObjectDelete("Прибыль"); + return(0); } +//+----------------------------------------------------------- + int start(){ + double nPoint = GetPoint(Symbol()); profit=0; + for (int w1=0; w10) colir = Color1 ; else colir = Color2; + // ======================================================================================== + ObjectCreate ("Прибыль", OBJ_LABEL, 0,0,0); + ObjectSetText("Прибыль", DoubleToStr(profit,2)+"$" ,FontSize, FontName, colir); + ObjectSet( "Прибыль", OBJPROP_CORNER, Corner); + ObjectSet( "Прибыль", OBJPROP_XDISTANCE, XDistance); + ObjectSet( "Прибыль", OBJPROP_YDISTANCE, YDistance); + ObjectSet("Прибыль",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M1 |OBJ_PERIOD_M5| OBJ_PERIOD_M15 | OBJ_PERIOD_M30 | OBJ_PERIOD_H1 ); + // ======================================================================================== + return(0); } + //======================================================================================== + double GetPoint(string vSymbol){ + int vres = StringFind(vSymbol,"JPY"); + if (vres == -1) return(0.0001); return(0.01);} +//+------------------------------------------------------------------ + //======================================================================================== \ No newline at end of file