Kamis, 18 Agustus 2011

macd jawa top

//+------------------------------------------------------------------+
//| GMACD_Signals.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| Author: Muhammad Hamizi Jaminan (hymns) |
//| Original Author: CJA |
//| |
//| Date: December 14, 2006 |
//| Custom Indicator: GMACD_Signals.mq4 |
//| Version: 1.0.1 |
//| Description: Multi TimeFrame MACD Signal |
//| |
//| Change Logs |
//| Version 1.0.1 |
//| - Rewriting Code. Using less variable & ObjectCreate. Reduce CPU |
//| Usage. Solve multiple object label show on load. |
//| |
//| Version G#MACD_Signal #2 |
//| - Release by CJA |
//+------------------------------------------------------------------+
#property indicator_separate_window
//----
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern bool Show_MAJOR_TREND=false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorShortName("GMACD");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0,OBJ_LABEL);
ObjectDelete("Label1"); ObjectDelete("Label2"); ObjectDelete("Label3");
ObjectDelete("DataM1"); ObjectDelete("DataM5"); ObjectDelete("DataM15");
ObjectDelete("DataM30"); ObjectDelete("DataH1"); ObjectDelete("DataH4");
ObjectDelete("DataD1"); ObjectDelete("DataW1"); ObjectDelete("DataMN");
ObjectDelete("Trend1"); ObjectDelete("Trend2"); ObjectDelete("Level1");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
double macd_M1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_MM1=iMACD(NULL,PERIOD_M1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_M5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_MM5=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_M15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_MM15=iMACD(NULL,PERIOD_M15,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_M30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_MM30=iMACD(NULL,PERIOD_M30,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_H1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_HH1=iMACD(NULL,PERIOD_H1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_H4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_HH4=iMACD(NULL,PERIOD_H4,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
//----
if (Show_MAJOR_TREND==true)
{
double macd_D1=iMACD(NULL,PERIOD_D1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_DD1=iMACD(NULL,PERIOD_D1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_W1=iMACD(NULL,PERIOD_W1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_WW1=iMACD(NULL,PERIOD_W1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
double macd_MN1=iMACD(NULL,PERIOD_MN1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double macd_MMN1=iMACD(NULL,PERIOD_MN1,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
}
string trend_signal="", trend_main="", trend_level="";
color color_m1, color_m5, color_m15, color_m30, color_h1, color_h4, color_d1, color_w1, color_mn,
color_signal, color_main, color_level;
// UP Data
if ((macd_M5 > macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal="AYO TUKU"; color_signal=Lime;}
//Down Data
if ((macd_M5 < macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal="AYO ADOL"; color_signal=Red; }
//Consolidation Data
if ((macd_M5 < macd_MM5) && (macd_M1 > macd_MM1)) { trend_signal="SABAR SIK"; color_signal=Orange; }
if ((macd_M5 > macd_MM5) && (macd_M1 < macd_MM1)) { trend_signal="SABAR SIK"; color_signal=Orange; }
if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)&& (macd_H4 < macd_HH4)) { trend_level="WEAK"; color_level=Tomato; }
if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)&& (macd_H4 > macd_HH4)) { trend_level="WEAK"; color_level=Tomato; }
if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1) && (macd_H4 > macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 >macd_HH1) && (macd_H4 < macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 > macd_HH1)) { trend_main="MUNGGAH"; color_main=YellowGreen; }
if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 < macd_HH1)) { trend_main="MUDUN"; color_main=Tomato; }
if ((macd_M15 < macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main="MUDUN"; color_main=Tomato; }
if ((macd_M15 > macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main="MUNGGAH"; color_main=YellowGreen; }
if ((macd_M15 < macd_MM15) && (macd_M30 > macd_MM30) && (macd_H1 < macd_HH1)) { trend_main="MUDUN"; color_main=Red; }
if ((macd_M15 > macd_MM15) && (macd_M30 < macd_MM30) && (macd_H1 > macd_HH1)) { trend_main="MUNGGAH"; color_main=Lime; }
if ((macd_M5 < macd_MM5) && (macd_M15 < macd_MM15) && (macd_H1 > macd_HH1) && (macd_H4 > macd_HH4)) { trend_level="WEAK"; color_level=Tomato; }
if ((macd_M5 > macd_MM5) && (macd_M15 > macd_MM15) && (macd_H1 < macd_HH1) && (macd_H4 < macd_HH4)) { trend_level="WEAK"; color_level=Tomato; }
if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_level="MEDIUM"; color_level=Orange; }
if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_level="STRONG"; color_level=Yellow; }
if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_level="STRONG"; color_level=Yellow; }
if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 > macd_HH4)) { trend_main="MUNGGAH"; color_main=Lime; }
if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 < macd_HH4)) { trend_main="MUDUN"; color_main=Red; }
if ((macd_M15 > macd_MM15) && (macd_H1 > macd_HH1) && (macd_M30 > macd_MM30) && (macd_H4 < macd_HH4)) { trend_main="MUNGGAH"; color_main=Lime; }
if ((macd_M15 < macd_MM15) && (macd_H1 < macd_HH1) && (macd_M30 < macd_MM30) && (macd_H4 > macd_HH4)) { trend_main="MUDUN"; color_main=Red; }
//MACD Direction
if ((macd_M1 > macd_MM1)) { color_m1=Lime; }
if ((macd_M1 < macd_MM1)) { color_m1=Red; }
if ((macd_M5 > macd_MM5)) { color_m5=Lime; }
if ((macd_M5 < macd_MM5)) { color_m5=Red; }
if ((macd_M15 > macd_MM15)) { color_m15=Lime; }
if ((macd_M15 < macd_MM15)) { color_m15=Red; }
if ((macd_M30 > macd_MM30)) { color_m30=Lime; }
if ((macd_M30 < macd_MM30)) { color_m30=Red; }
if ((macd_H1 > macd_HH1)) { color_h1=Lime; }
if ((macd_H1 < macd_HH1)) { color_h1=Red; }
if ((macd_H4 > macd_HH4)) { color_h4=Lime; }
if ((macd_H4 < macd_HH4)) { color_h4=Red; }
if (Show_MAJOR_TREND==true)
{
if ((macd_D1 > macd_DD1)) { color_d1=Lime; }
if ((macd_D1 < macd_DD1)) { color_d1=Red; }
if ((macd_W1 > macd_WW1)) { color_w1=Lime; }
if ((macd_W1 < macd_WW1)) { color_w1=Red; }
if ((macd_MN1 > macd_MMN1)) { color_mn=Lime; }
if ((macd_MN1 < macd_MMN1)) { color_mn=Red; }
}
//Signal Labels
ObjectCreate("Label1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Label1","SIGNAL",8, "Arial Bold", Silver);
ObjectSet("Label1", OBJPROP_CORNER, 0);
ObjectSet("Label1", OBJPROP_XDISTANCE, 105);
ObjectSet("Label1", OBJPROP_YDISTANCE, 4);
//MACD Direction M1-M5
ObjectCreate("DataM1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//M1 SIGNAL
ObjectSetText("DataM1","M1",9, "Arial Bold", color_m1);
ObjectSet("DataM1", OBJPROP_CORNER, 0);
ObjectSet("DataM1", OBJPROP_XDISTANCE, 150);
ObjectSet("DataM1", OBJPROP_YDISTANCE, 4);
//----
ObjectCreate("DataM5", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//M5 SIGNAL
ObjectSetText("DataM5","M5",9, "Arial Bold", color_m5);
ObjectSet("DataM5", OBJPROP_CORNER, 0);
ObjectSet("DataM5", OBJPROP_XDISTANCE, 175);
ObjectSet("DataM5", OBJPROP_YDISTANCE, 4);
//M1 & M5 TREND Data
ObjectCreate("Trend1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Trend1",trend_signal,12, "Arial Bold", color_signal);
ObjectSet("Trend1", OBJPROP_CORNER, 0);
ObjectSet("Trend1", OBJPROP_XDISTANCE, 200);
ObjectSet("Trend1", OBJPROP_YDISTANCE, 4);
//Main Trend Label
ObjectCreate("Label2", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Label2","MAIN TREND", 8, "Arial Bold", Silver);
ObjectSet("Label2", OBJPROP_CORNER, 0);
ObjectSet("Label2", OBJPROP_XDISTANCE, 300);
ObjectSet("Label2", OBJPROP_YDISTANCE, 4);
//MACD Direction M15-H4
ObjectCreate("DataM15", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//M15 SIGNAL
ObjectSetText("DataM15","M15",9, "Arial Bold", color_m15);
ObjectSet("DataM15", OBJPROP_CORNER, 0);
ObjectSet("DataM15", OBJPROP_XDISTANCE, 370);
ObjectSet("DataM15", OBJPROP_YDISTANCE, 4);
ObjectCreate("DataM30", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//M30 SIGNAL
ObjectSetText("DataM30","M30",9, "Arial Bold", color_m30);
ObjectSet("DataM30", OBJPROP_CORNER, 0);
ObjectSet("DataM30", OBJPROP_XDISTANCE, 400);
ObjectSet("DataM30", OBJPROP_YDISTANCE, 4);
ObjectCreate("DataH1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//H1 SIGNAL
ObjectSetText("DataH1","H1",9, "Arial Bold", color_h1);
ObjectSet("DataH1", OBJPROP_CORNER, 0);
ObjectSet("DataH1", OBJPROP_XDISTANCE, 430);
ObjectSet("DataH1", OBJPROP_YDISTANCE, 4);
ObjectCreate("DataH4", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//H4 SIGNAL
ObjectSetText("DataH4","H4",9, "Arial Bold", color_h4);
ObjectSet("DataH4", OBJPROP_CORNER, 0);
ObjectSet("DataH4", OBJPROP_XDISTANCE, 450);
ObjectSet("DataH4", OBJPROP_YDISTANCE, 4);
//M15 - H4 TREND Data
ObjectCreate("Trend2", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Trend2",trend_main,12, "Arial Bold", color_main);
ObjectSet("Trend2", OBJPROP_CORNER, 0);
ObjectSet("Trend2", OBJPROP_XDISTANCE, 475);
ObjectSet("Trend2", OBJPROP_YDISTANCE, 4);
//Level Data
ObjectCreate("Level1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Level1",trend_level,8, "Arial Bold", color_level);
ObjectSet("Level1", OBJPROP_CORNER, 0);
ObjectSet("Level1", OBJPROP_XDISTANCE, 565);
ObjectSet("Level1", OBJPROP_YDISTANCE, 4);
if (Show_MAJOR_TREND==true)
{
ObjectCreate("Label3", OBJ_LABEL, WindowFind("GMACD"), 0, 0);
ObjectSetText("Label3","MAJOR TREND", 8, "Arial Bold", Silver);
ObjectSet("Label3", OBJPROP_CORNER, 0);
ObjectSet("Label3", OBJPROP_XDISTANCE, 615);
ObjectSet("Label3", OBJPROP_YDISTANCE, 4);
//----
ObjectCreate("DataD1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//D1 SIGNAL
ObjectSetText("DataD1","D1",9, "Arial Bold", color_d1);
ObjectSet("DataD1", OBJPROP_CORNER, 0);
ObjectSet("DataD1", OBJPROP_XDISTANCE, 695);
ObjectSet("DataD1", OBJPROP_YDISTANCE, 4);
//----
ObjectCreate("DataW1", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//W1 SIGNAL
ObjectSetText("DataW1","W1",9, "Arial Bold", color_w1);
ObjectSet("DataW1", OBJPROP_CORNER, 0);
ObjectSet("DataW1", OBJPROP_XDISTANCE, 715);
ObjectSet("DataW1", OBJPROP_YDISTANCE, 4);
//----
ObjectCreate("DataMN", OBJ_LABEL, WindowFind("GMACD"), 0, 0);//MN SIGNAL
ObjectSetText("DataMN","MN",9, "Arial Bold", color_mn);
ObjectSet("DataMN", OBJPROP_CORNER, 0);
ObjectSet("DataMN", OBJPROP_XDISTANCE, 740);
ObjectSet("DataMN", OBJPROP_YDISTANCE, 4);
}
//----
return(0);
}
//+------------------------------------------------------------------+

Selasa, 09 Agustus 2011

ea fabturbo

/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2008, FAPTURBO48 Build 225. Licensed till 2011.01.16"
#property link "http://fapturbo.com"

#import "FapTurbo3.dll"
int fun1(int a0, int a1, double a2, double 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[], int& a17[], int& a18[], int a19, int& a20[], int& a21[], int a22, int& a23[]);
int fun2(double a0, int a1, double a2, double a3, int a4, int a5, double a6, int a7, int a8, int& a9[], int& a10[], int& a11[], int a12, int& a13[], int& a14[], int a15, int& a16[]);
int fun3(double a0, int a1, double a2, double a3, int a4, int a5, double a6, int a7, int a8, int& a9[], int& a10[], int& a11[], int a12, int& a13[], int& a14[], int a15, int& a16[]);
bool fun4(double a0, int a1, int a2);
#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

int gi_76 = 0;
extern string ____Scalper___________ = "--- Scalper EURCHF, EURGPB, GBPCHF or USDCAD M15 ---";
extern bool UseScalperStrategy = TRUE;
extern double Scalper_Lots = 0.1;
extern bool Scalper_UseMM = TRUE;
extern double Scalper_LotsRiskReductor = 5.0;
extern double Scalper_MaxLots = 10.0;
extern bool Scalper_UseAutoGMToffset = TRUE;
extern int Scalper_ManualGMToffset = 1;
extern int Scalper_StartWorkTimeHour = 21;
extern int Scalper_StartSessionMinute = 0;
extern int Scalper_EndWorkTimeHour = 23;
extern int Scalper_EndSessionMinute = 30;
extern int Scalper_EURGBP_TakeProfit = 6;
extern int Scalper_EURGBP_StopLoss = 35;
extern int Scalper_EURCHF_TakeProfit = 5;
extern int Scalper_EURCHF_StopLoss = 49;
extern int Scalper_GBPCHF_TakeProfit = 10;
extern int Scalper_GBPCHF_StopLoss = 81;
extern int Scalper_USDCAD_TakeProfit = 10;
extern int Scalper_USDCAD_StopLoss = 58;
extern bool Scalper_StealthMode = TRUE;
extern double Scalper_ProfitLimit = 0.0;
extern double Scalper_LossLimit = 0.0;
extern bool Scalper_UseCustomLevels = TRUE;
extern int Scalper_RelaxHours = 0;
extern bool Scalper_SimpleHeightFilter = TRUE;
extern bool Scalper_TrendFilter = TRUE;
extern bool Scalper_TradeMonday = TRUE;
extern bool Scalper_TradeFriday = FALSE;
extern int Scalper_OneTrade = 0;
extern bool Scalper_OneOpenTrade = FALSE;
extern int Scalper_ReverseTrade = 0;
extern bool Scalper_UseFilterMA = FALSE;
extern int Scalper_PeriodFilterMA = 100;
extern int Scalper_PriceFilterMA = 0;
extern int Scalper_MethodFilterMA = 0;
extern double Scalper_MaxSpread = 5.0;
extern int Scalper_Slippage = 6;
int gi_260 = 8;
extern string Scalper_ExpertComment = "TradingRobot";
extern int Scalper_MagicNumber = 12464336;
extern string ____FapTurbo__________ = "---------- FapTurbo EUR/USD M1 ----------";
extern double FapTurbo_Lots = 0.01;
extern double FapTurbo_LotsRiskReductor = 1.0;
extern int FapTurbo_MaxOrders = 1;
extern int FapTurbo_MaxLots = 10;
extern int FapTurbo_StopTime = 9;
extern int FapTurbo_aaa = 35;
extern int FapTurbo_bbb = 48;
extern double FapTurbo_TakeProfit = 140.0;
extern double FapTurbo_StopLoss = 500.0;
extern double FapTurbo_TrailingStop = 0.0;
extern int FapTurbo_DurationInHours = 0;
extern int FapTurbo_CloseAfterXmonths = 1;
extern int FapTurbo_PeriodMALarge = 100;
extern int FapTurbo_PeriodMASmall = 30;
extern int FapTurbo_PriceMA_0_6 = 0;
extern int FapTurbo_TypeMA_0_3 = 0;
extern int FapTurbo_ShiftMALarge = 3;
extern int FapTurbo_ShiftMASmall = 1;
extern int FapTurbo_LookForDays = 2;
extern int FapTurbo_CriticalDays = 45;
extern int FapTurbo_RelaxDays = 0;
extern double FapTurbo_AlterPosLotReducer = 0.0;
extern int FapTurbo_AlterPositions = 0;
extern int FapTurbo_TradeNFP = 1;
extern int FapTurbo_TradeFriday = 1;
extern int FapTurbo_Prudent = 0;
extern int FapTurbo_SymAlligatorOnCritica = 1;
extern int FapTurbo_FixedDirection = 1;
extern int FapTurbo_ClsLsrOnMrktChnge = 0;
extern int FapTurbo_AlwaysTrade = 0;
extern double FapTurbo_LowLot = 0.1;
extern int FapTurbo_TooGoodToBeTrue = 50;
extern int FapTurbo_PrudentPeriod = 30;
extern int FapTurbo_StartWorkTimeHour = 0;
extern int FapTurbo_StartWorkTimeMin = 0;
extern int FapTurbo_EndWorkTimeHour = 0;
extern int FapTurbo_EndWorkTimeMin = 0;
extern int FapTurbo_OneTrade = 0;
extern double FapTurbo_SpanGator = 0.5;
extern int FapTurbo_SlipPage = 3;
extern string FapTurbo_ExpertComment = "FapTurboEA";
extern int FapTurbo_MagicNumber = 12464337;
extern string ____Other_Parameters__ = "-----------------------------------------";
extern bool TradeMicroLots = TRUE;
extern bool SendEmail = FALSE;
extern bool SoundAlert = FALSE;
extern string SoundFileAtOpen = "alert.wav";
extern string SoundFileAtClose = "alert.wav";
extern color ColorBuy = Blue;
extern color ColorSell = Red;
extern bool WriteLog = TRUE;
extern bool WriteDebugLog = FALSE;
extern bool PrintLogOnChart = TRUE;
extern string KEY = "012345";
int gi_552 = 25;
int gi_556 = 60;
int gi_560 = 3;
int gi_564 = 140;
int gi_568 = 2;
int gi_572 = 170;
int gi_576 = 0;
int gi_580 = 200;
int gi_584 = -1;
int gi_588 = 240;
int gi_592 = -4;
double gd_596 = 0.3;
int gi_604 = 25;
int gi_608 = 75;
int gi_612 = 3;
int gi_616 = 100;
int gi_620 = 2;
int gi_624 = 135;
int gi_628 = 0;
int gi_632 = 210;
int gi_636 = -1;
int gi_640 = 245;
int gi_644 = -4;
double gd_648 = 0.2;
int gi_656 = 75;
int gi_660 = 80;
int gi_664 = 3;
int gi_668 = 145;
int gi_672 = 2;
int gi_676 = 180;
int gi_680 = 0;
int gi_684 = 205;
int gi_688 = -1;
int gi_692 = 250;
int gi_696 = -4;
double gd_700 = 0.35;
int gi_708 = 23;
int gi_712 = 80;
int gi_716 = 3;
int gi_720 = 145;
int gi_724 = 2;
int gi_728 = 180;
int gi_732 = 0;
int gi_736 = 205;
int gi_740 = -1;
int gi_744 = 250;
int gi_748 = -4;
double gd_752 = 0.35;
int gi_760 = 10;
int g_period_764 = 8;
int g_period_768 = 6;
int gi_772 = 30;
int g_period_776 = 20;
int gi_780 = 36;
int gi_784 = 20;
int g_period_788 = 5;
int g_applied_price_792 = PRICE_CLOSE;
int g_ma_method_796 = MODE_SMA;
int gi_800 = 4;
int gi_804 = 3;
int gi_808 = 150;
int gi_812 = 21;
int gi_816 = 40;
int gi_820 = 21;
bool gi_824 = FALSE;
int gi_828 = 0;
string gs_832 = "http://fapturbo.com/gmt.php";
string gs_840 = "AlexGmtOffset 1.0";
int gi_848 = -1;
bool gi_852 = TRUE;
bool gi_856 = TRUE;
bool gi_860;
bool gi_864;
int g_bool_868;
int gi_872;
int g_magic_876;
int gi_880;
int gia_884[1];
int gia_888[1];
int g_acc_number_892;
int gia_896[100];
int gia_900[100];
int gia_904[100];
int gia_908[100];
int gi_912 = 2;
int gi_916 = 1;
int g_slippage_920;
double gd_924;
double g_maxlot_932;
double g_minlot_940;
double g_lotstep_948;
double gd_956;
double gd_964;
string g_symbol_972;
string gs_980 = "New Trade Information";
string gs_988 = "New Trade Information";
string gs_996 = "Íîâàÿ òîðãîâàÿ èíôîðìàöèÿ";
string gs_1004 = "Íîâàÿ òîðãîâàÿ èíôîðìàöèÿ";
bool gi_1012;
bool gi_1016 = TRUE;
bool gi_1020 = TRUE;
int g_datetime_1024;
int g_datetime_1028;
int g_datetime_1032;
int gi_1036;
int gi_1040;
int gi_1044;
int gi_1048;
int gi_1052;
int gi_1056;
int gi_1060;
int gi_1064;
int gi_1068;
int gi_1072;
int gi_1076;
int gi_1080;
int gi_1084;
int gi_1088;
int gi_1092;
int gi_1096;
int gi_1100;
int gi_1104;
int gi_1108;
int gi_1112;
int gi_1116;
int gi_1120;
int gi_1124;
int gi_1128;
double gd_1132;
double gd_1140;
double gd_1148;
double gd_1156;
double gd_1164;
double gd_1172;
double gd_1180;
double gd_1188;
double gd_1196;
double gd_1204;
double gd_1212;
double gd_1220;
string g_str_concat_1228;
bool gi_1236;
bool gi_1240;
bool gi_1244;
bool gi_1248;
bool gi_1252;
bool gi_1256;
int g_datetime_1260;
int g_datetime_1268;
int gi_1272;
int gi_1276;
double g_icustom_1280;
double g_icustom_1288;
double g_icustom_1296;
double g_digits_1304;
double g_str2dbl_1312;
double g_ifractals_1320;
double g_ifractals_1328;
double g_ima_1336;
double g_ima_1344;
double g_ima_1352;
double g_ima_1360;
double g_ima_1368;
double g_ima_1376;
double gda_1384[];
double gda_1388[];
string g_dbl2str_1392;
string gs_1400;
string gs_1408;
bool gi_1416 = TRUE;
bool gi_1420 = TRUE;

int init() {
double l_leverage_0;
string ls_8;
gi_860 = TRUE;
if (!PrintLogOnChart) Comment("");
if (!IsDllsAllowed()) {
if (gi_828 == 0) Comment("Warning: Set Parameter \"AllowDLL Imports\" ON in menu Tools -> Options -> ExpertAdvisors.");
else Comment("Ïðåäóïðåæäåíèå: Óñòàíîâèòå ïàðàìåòåð \"AllowDLL Imports\" ÂÊË â ìåíþ Ñåðâèñ -> Íàñòðîéêè -> Ñîâåòíèêè.");
gi_852 = FALSE;
return (0);
}
gi_852 = TRUE;
if (gi_852 < 0) Comment("Ëîãè÷åñêàÿ ïåðåìåííàÿ ìåíüøå íóëÿ.");
g_symbol_972 = Symbol();
if (Digits < 4) {
gd_924 = 0.01;
gi_880 = 2;
} else {
gd_924 = 0.0001;
gi_880 = 4;
}
if (gi_880 == 0) Comment("Íåâåðíîå çíà÷åíèå ïåðåìåííîé.");
g_maxlot_932 = MarketInfo(g_symbol_972, MODE_MAXLOT);
g_minlot_940 = MarketInfo(g_symbol_972, MODE_MINLOT);
g_lotstep_948 = MarketInfo(g_symbol_972, MODE_LOTSTEP);
gd_956 = MarketInfo(g_symbol_972, MODE_MARGINREQUIRED) * g_lotstep_948;
if (TradeMicroLots) gi_872 = 2;
else gi_872 = 1;
if (!UseScalperStrategy) {
if (StringSubstr(g_symbol_972, 0, 6) != "EURUSD") {
if (gi_828 == 0) {
Alert("Use Fapturbo system only on EURUSD M1.");
Print("Use Fapturbo system only on EURUSD M1.");
Comment("Error: Wrong Currency Pair! Read instructions!");
} else {
Alert("Èñïîëüçóéòå Fapturbo ñèñòåìó òîëüêî íà EURUSD M1.");
Print("Èñïîëüçóéòå Fapturbo ñèñòåìó òîëüêî íà EURUSD M1.");
Comment("Îøèáêà: Íåâåðíàÿ âàëþòíàÿ ïàðà! ×èòàéòå èíñòðóêöèè!");
}
gi_852 = FALSE;
return (0);
}
gi_852 = TRUE;
if (FapTurbo_StartWorkTimeHour < 0 || FapTurbo_StartWorkTimeHour > 23) FapTurbo_StartWorkTimeHour = 0;
if (FapTurbo_StartWorkTimeMin < 0 || FapTurbo_StartWorkTimeMin > 59) FapTurbo_StartWorkTimeMin = 0;
if (FapTurbo_EndWorkTimeHour < 0 || FapTurbo_EndWorkTimeHour > 23) FapTurbo_EndWorkTimeHour = 0;
if (FapTurbo_EndWorkTimeMin < 0 || FapTurbo_EndWorkTimeMin > 59) FapTurbo_EndWorkTimeMin = 0;
if (FapTurbo_CloseAfterXmonths < 0) FapTurbo_CloseAfterXmonths = 0;
if (FapTurbo_CloseAfterXmonths > 12) FapTurbo_CloseAfterXmonths = 12;
l_leverage_0 = AccountLeverage();
gd_964 = NormalizeDouble(FapTurbo_LotsRiskReductor * (100 / l_leverage_0), 2);
g_magic_876 = FapTurbo_MagicNumber;
g_slippage_920 = FapTurbo_SlipPage * MathPow(10, Digits - gi_880);
} else {
ls_8 = StringSubstr(g_symbol_972, 0, 6);
if (gi_76 == 0 && ls_8 == "EURUSD") {
if (gi_828 == 0) {
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!");
} else {
Alert("Èñïîëüçóéòå Scalper ñèñòåìó òîëüêî íà EURCHF, EURGPB, GBPCHF èëè USDCAD M15.");
Print("Èñïîëüçóéòå Scalper ñèñòåìó òîëüêî íà EURCHF, EURGPB, GBPCHF èëè USDCAD M15.");
Comment("Îøèáêà: Íåâåðíûé òàéìôðåéì èëè âàëþòíàÿ ïàðà! ×èòàéòå èíñòðóêöèè!");
}
gi_852 = FALSE;
return (0);
}
if ((ls_8 != "EURGBP" && ls_8 != "EURCHF" && ls_8 != "GBPCHF" && ls_8 != "USDCAD") || Period() != PERIOD_M15) {
if (gi_828 == 0) {
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!");
} else {
Alert("Èñïîëüçóéòå Scalper ñèñòåìó òîëüêî íà EURCHF, EURGPB, GBPCHF èëè USDCAD M15.");
Print("Èñïîëüçóéòå Scalper ñèñòåìó òîëüêî íà EURCHF, EURGPB, GBPCHF èëè USDCAD M15.");
Comment("Îøèáêà: Íåâåðíûé òàéìôðåéì èëè âàëþòíàÿ ïàðà! ×èòàéòå èíñòðóêöèè!");
}
gi_852 = FALSE;
return (0);
}
gi_852 = TRUE;
if (gi_852 < 0) Comment("Ëîãè÷åñêàÿ ïåðåìåííàÿ ìåíüøå íóëÿ.");
if (ls_8 == "EURGBP") {
gi_1052 = Scalper_EURGBP_TakeProfit;
gi_1056 = Scalper_EURGBP_StopLoss;
gi_1060 = gi_552;
gd_1132 = gd_596;
gi_1064 = gi_556;
gi_1072 = gi_564;
gi_1080 = gi_572;
gi_1088 = gi_580;
gi_1096 = gi_588;
gi_1068 = gi_560;
gi_1076 = gi_568;
gi_1084 = gi_576;
gi_1092 = gi_584;
gi_1100 = gi_592;
} else {
if (ls_8 == "EURCHF") {
gi_1052 = Scalper_EURCHF_TakeProfit;
gi_1056 = Scalper_EURCHF_StopLoss;
gi_1060 = gi_604;
gd_1132 = gd_648;
gi_1064 = gi_608;
gi_1072 = gi_616;
gi_1080 = gi_624;
gi_1088 = gi_632;
gi_1096 = gi_640;
gi_1068 = gi_612;
gi_1076 = gi_620;
gi_1084 = gi_628;
gi_1092 = gi_636;
gi_1100 = gi_644;
} else {
if (ls_8 == "GBPCHF") {
gi_1052 = Scalper_GBPCHF_TakeProfit;
gi_1056 = Scalper_GBPCHF_StopLoss;
gi_1060 = gi_656;
gd_1132 = gd_700;
gi_1064 = gi_660;
gi_1072 = gi_668;
gi_1080 = gi_676;
gi_1088 = gi_684;
gi_1096 = gi_692;
gi_1068 = gi_664;
gi_1076 = gi_672;
gi_1084 = gi_680;
gi_1092 = gi_688;
gi_1100 = gi_696;
} else {
if (ls_8 == "USDCAD") {
gi_1052 = Scalper_USDCAD_TakeProfit;
gi_1056 = Scalper_USDCAD_StopLoss;
gi_1060 = gi_708;
gd_1132 = gd_752;
gi_1064 = gi_712;
gi_1072 = gi_720;
gi_1080 = gi_728;
gi_1088 = gi_736;
gi_1096 = gi_744;
gi_1068 = gi_716;
gi_1076 = gi_724;
gi_1084 = gi_732;
gi_1092 = gi_740;
gi_1100 = gi_748;
}
}
}
}
gd_1148 = NormalizeDouble((-1 * gi_1056) * gd_924, gi_880);
gd_1140 = NormalizeDouble(gi_1052 * gd_924, gi_880);
gi_1104 = 60 * gi_1064;
gi_1108 = 60 * gi_1072;
gi_1112 = 60 * gi_1080;
gi_1116 = 60 * gi_1088;
gi_1120 = 60 * gi_1096;
gd_1156 = gi_1068 * gd_924;
gd_1164 = gi_1076 * gd_924;
gd_1172 = gi_1084 * gd_924;
gd_1180 = gi_1092 * gd_924;
gd_1188 = gi_1100 * gd_924;
gd_1220 = NormalizeDouble(gi_1060 * gd_924, gi_880);
gd_1196 = NormalizeDouble(Scalper_MaxSpread * gd_924, gi_880 + 1);
gd_1204 = NormalizeDouble(gi_1056 * gd_924, gi_880);
gd_1212 = NormalizeDouble(gd_1204 / 2.0, Digits);
gi_1036 = 100 - gi_772;
gi_1040 = 100 - gi_780;
gi_1044 = gi_784 / 2 + 50;
gi_1048 = 50 - gi_784 / 2;
if (Scalper_PeriodFilterMA <= 0) Scalper_UseFilterMA = FALSE;
if (Scalper_PriceFilterMA < PRICE_CLOSE || Scalper_PriceFilterMA > PRICE_WEIGHTED) Scalper_UseFilterMA = FALSE;
if (Scalper_MethodFilterMA < MODE_SMA || Scalper_MethodFilterMA > MODE_LWMA) Scalper_UseFilterMA = FALSE;
l_leverage_0 = AccountLeverage();
gd_964 = NormalizeDouble(Scalper_LotsRiskReductor * (100 / l_leverage_0), 2);
g_magic_876 = Scalper_MagicNumber;
g_slippage_920 = Scalper_Slippage * MathPow(10, Digits - gi_880);
}
return (0);
}

int deinit() {
return (0);
}

int start() {
string ls_0;
int li_8;
if (gi_860) {
if (Scalper_UseAutoGMToffset) {
if (!IsTesting()) {
Scalper_ManualGMToffset = AutoGMTCalculation();
if (Scalper_ManualGMToffset == -2147483648) {
Sleep(60000);
return (0);
}
}
Comment("Warning, use manual GMToffsets only on backtest.",
"\n", "Automatic GMT offset calculation works only on live/demo trading",
"\n", "and should be set as FALSE for backtests - strategy testing.");
Alert("Warning, use manual GMToffsets only on backtest.",
"\n", "Automatic GMT offset calculation works only on live/demo trading",
"\n", "and should be set as FALSE for backtests - strategy testing.");
if (WriteLog) Print("Warning, use manual GMToffsets only on backtest! Set Scalper_UseAutoGMToffset = False.");
gi_852 = FALSE;
ls_0 = " (automatic)";
} else ls_0 = " (manual)";
g_str_concat_1228 = StringConcatenate("GmtOffset: ", DoubleToStr(Scalper_ManualGMToffset, 1), ls_0,
"\n");
gi_1124 = Scalper_StartWorkTimeHour + Scalper_ManualGMToffset;
gi_1128 = Scalper_EndWorkTimeHour + Scalper_ManualGMToffset;
while (true) {
if (gi_1124 >= 24) {
gi_1124 -= 24;
continue;
}
if (gi_1124 >= 0) break;
gi_1124 += 24;
}
while (true) {
if (gi_1128 >= 24) {
gi_1128 -= 24;
continue;
}
if (gi_1128 >= 0) break;
gi_1128 += 24;
}
if (Scalper_StartSessionMinute < 0 || Scalper_StartSessionMinute > 59) Scalper_StartSessionMinute = 0;
if (Scalper_EndSessionMinute < 0 || Scalper_EndSessionMinute > 59) Scalper_EndSessionMinute = 0;
if (gi_1124 != gi_1128 || Scalper_StartSessionMinute != Scalper_EndSessionMinute) {
if (gi_760 > 0) {
Scalper_EndSessionMinute -= gi_760;
if (Scalper_EndSessionMinute < 0) {
Scalper_EndSessionMinute += 60;
gi_1128--;
if (gi_1128 < 0) gi_1128 += 24;
}
}
}
if (StringLen(AccountName()) <= 0) {
if (gi_828 == 0) {
Comment("FapTurbo EA need have on-line Terminal.");
if (gi_1416) Alert("FapTurbo EA need have on-line Terminal.");
if (WriteLog) Print("FapTurbo EA need have on-line Terminal.");
} else {
Comment("Ñîâåòíèêó FapTurbo íóæíî, ÷òîáû Òåðìèíàë áûë on-line.");
if (gi_1416) Alert("Ñîâåòíèêó FapTurbo íóæíî, ÷òîáû Òåðìèíàë áûë on-line.");
if (WriteLog) Print("Ñîâåòíèêó FapTurbo íóæíî, ÷òîáû Òåðìèíàë áûë on-line.");
}
gi_1416 = FALSE;
return (0);
}
Comment("");
g_bool_868 = IsDemo();
/*g_acc_number_892 = AccountNumber();
Compress(gia_896, AccountName());
Compress(gia_900, AccountCompany());
Compress(gia_904, AccountCurrency());
Compress(gia_908, KEY);
li_8 = fun3(Bid - 0.0002, ExistPosition(), 53.2489, 67.8991, 33, 84, 1.3481, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, TimeCurrent(), gia_908, gia_884, g_bool_868, gia_888);
if (li_8 == 16) {
if (gi_828 == 0) {
Alert("Your copy is not activated. Please activate your copy."
+ "\n"
+ " Your expert ID = " + gia_884[0]);
} else {
Alert("Âàøà êîïèÿ íå àêòèâèðîâàíà. Ïîæàëóéñòà, àêòèâèðóéòå Âàøó êîïèþ."
+ "\n"
+ " ID Âàøåãî ñîâåòíèêà = " + gia_884[0]);
}
gi_856 = FALSE;
} else gi_856 = TRUE;*/

li_8 = fun2(Ask + 0.0002, ExistPosition(), 45.4511, 34.1139, 67, 16, 1.3483, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, TimeCurrent(), gia_908, gia_884, g_bool_868, gia_888);
if (li_8 == 32) gi_864 = TRUE;
gi_860 = FALSE;
}
/*
if (!gi_852) return (0);
if (gi_852 < 0) Comment("Ïðèâåò ñ áîëüøîãî áîäóíà.");
if (!gi_856) {
if (gi_828 == 0) {
Comment("Your copy is not activated. Please activate your copy."
+ "\n"
+ "Your expert ID = " + gia_884[0]);
} else {
Comment("Âàøà êîïèÿ íå àêòèâèðîâàíà. Ïîæàëóéñòà, àêòèâèðóéòå Âàøó êîïèþ."
+ "\n"
+ "ID Âàøåãî ñîâåòíèêà = " + gia_884[0]);
}
return (0);
}
if (gi_856 < 0) Comment("Õðåíü êàêàÿ-òî.");
if (gi_864) {
if (gi_828 == 0) {
Comment("FapTurbo EA has Expired."
+ "\n"
+ "Download new version in the member area.");
if (gi_1420) Alert("FapTurbo License has Expired. Download new version in the member area.");
if (WriteLog) Print("FapTurbo License has Expired. Download new version in the member area.");
} else {
Comment("Ëèöåíçèÿ ñîâåòíèêà FapTurbo óñòàðåëà."
+ "\n"
+ "Ñêà÷àéòå íîâóþ âåðñèþ.");
if (gi_1420) Alert("Ëèöåíçèÿ ñîâåòíèêà FapTurbo óñòàðåëà. Ñêà÷àéòå íîâóþ âåðñèþ.");
if (WriteLog) Print("Ëèöåíçèÿ ñîâåòíèêà FapTurbo óñòàðåëà. Ñêà÷àéòå íîâóþ âåðñèþ.");
}
gi_1420 = FALSE;
}
*/
if (gi_864 < 0) Comment("Äà¸øü ïèðàòñòâó áîé!");
if (!UseScalperStrategy) FapTurbo();
else Scalper();
return (0);
}

void FapTurbo() {
int l_datetime_0;
bool li_4;
bool li_8;
bool li_12;
bool li_16;
bool li_20;
string ls_24;
int li_36;
int li_40;
double l_price_44;
double l_price_52;
g_digits_1304 = MarketInfo(g_symbol_972, MODE_DIGITS);
g_dbl2str_1392 = DoubleToStr(g_str2dbl_1312, g_digits_1304);
g_str2dbl_1312 = StrToDouble(g_dbl2str_1392);
if (IsTradeAllowed()) {
if (IsConnected()) {
if (IsStopped() == 0) {
if (IsTradeContextBusy()) {
if (WriteLog) {
if (gi_828 == 0) Print("Trade context is busy!");
else Print("Òîðãîâûé êîíòåêñò çàíÿò!");
}
} else {
if (IsDateTimeEnabled(TimeCurrent())) {
if (CheckParams()) {
if (PrepareIndicators()) {
l_datetime_0 = iTime(NULL, PERIOD_D1, 0);
if (g_datetime_1268 != l_datetime_0) {
g_datetime_1268 = l_datetime_0;
gs_1408 = "";
if (WriteLog) {
if (gi_828 == 0) Print("---------------------- Start New Daily Bar: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS), " ----------------------");
else Print("---------------------- Ñòàðò íîâîãî äíåâíîãî áàðà: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS), " ----------------------");
}
if (WriteDebugLog) PrintDebugLog();
gi_1240 = FALSE;
gi_1244 = FALSE;
gi_1248 = FALSE;
gi_1252 = FALSE;
if (FapTurbo_FixedDirection != 0) gi_1256 = TRUE;
li_4 = TRUE;
li_8 = TRUE;
li_12 = FALSE;
li_16 = TRUE;
li_20 = FALSE;
if (!Rule1(0)) {
if (gi_828 == 0) ls_24 = "Critical Day. Expected Cross in " + gi_1272 + " days.";
else ls_24 = "Êðèòè÷åñêèé äåíü. Îæèäàåòñÿ ïåðåñå÷åíèå â áëèæàéøèå " + gi_1272 + " ñóòîê.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_4 = FALSE;
} else {
if (!Relax1()) {
if (gi_828 == 0) ls_24 = "Relax Days Left = " + gi_1276 + " (after Cross).";
else ls_24 = "Relax Days Left = " + gi_1276 + " (ïîñëå ïåðåñå÷åíèÿ).";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_4 = FALSE;
} else {
if (gi_828 == 0) ls_24 = "NO Expected Cross. -> Possible to trade.";
else ls_24 = "Íå îæèäàåòñÿ ïåðåñå÷åíèÿ. -> Âîçìîæíî òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
}
}
if (!Rule2(0)) {
if (FapTurbo_Prudent != 0) {
if (gi_828 == 0) ls_24 = "Prudent Day. No Trading.";
else ls_24 = "Prudent Day. Íå òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_8 = FALSE;
} else {
if (gi_828 == 0) ls_24 = "Prudent Day Trading.";
else ls_24 = "Prudent Day Trading.";
if (FapTurbo_SymAlligatorOnCritica != 0) {
if (gi_828 == 0) ls_24 = ls_24 + " Trading SymAlligator today.";
else ls_24 = ls_24 + " Ñåãîäíÿ òîðãîâàòü SymAlligator.";
gi_1240 = TRUE;
} else {
if (gi_828 == 0) ls_24 = ls_24 + " Simple Trading today.";
else ls_24 = ls_24 + " Ñåãîäíÿ îáû÷íàÿ òîðãîâëÿ.";
}
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1244 = TRUE;
li_12 = TRUE;
}
} else {
if (!Relax2()) {
if (gi_828 == 0) ls_24 = "Relax Days Left = " + gi_1276 + " (after Prudent).";
else ls_24 = "Relax Days Left = " + gi_1276 + " (ïîñëå Prudent).";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_8 = FALSE;
} else {
if (gi_828 == 0) ls_24 = "NO Prudent Day. -> Possible to trade.";
else ls_24 = "Íå Prudent äåíü. -> Âîçìîæíî òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
}
}
if (!Rule3(0)) {
gi_1256 = FALSE;
if (gi_828 == 0) ls_24 = "TooGoodToBeTrue Day (Start from " + TimeToStr(iTime(NULL, PERIOD_D1, gi_1276), TIME_DATE) + ").";
else ls_24 = "TooGoodToBeTrue äåíü (íà÷àëî ñ " + TimeToStr(iTime(NULL, PERIOD_D1, gi_1276), TIME_DATE) + ").";
if (FapTurbo_Prudent != 0) {
if (gi_828 == 0) ls_24 = ls_24 + " No Trading.";
else ls_24 = ls_24 + " Íå òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_16 = FALSE;
} else {
if (FapTurbo_SymAlligatorOnCritica != 0) {
if (gi_828 == 0) ls_24 = ls_24 + " Trading SymAlligator today.";
else ls_24 = ls_24 + " Ñåãîäíÿ òîðãîâàòü SymAlligator.";
gi_1240 = TRUE;
} else {
if (gi_828 == 0) ls_24 = ls_24 + " Simple Trading today.";
else ls_24 = ls_24 + " Ñåãîäíÿ îáû÷íàÿ òîðãîâëÿ.";
}
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1244 = TRUE;
li_20 = TRUE;
}
} else {
if (!Relax3()) {
gi_1256 = FALSE;
if (gi_828 == 0) ls_24 = "Prudent Period TooGoodToBeTrue day left = " + gi_1276 + ".";
else ls_24 = "Prudent ïåðèîä TooGoodToBeTrue îñòàëîñü äíåé = " + gi_1276 + ".";
if (FapTurbo_Prudent != 0) {
if (gi_828 == 0) ls_24 = ls_24 + " No Trading.";
else ls_24 = ls_24 + " Íå òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
li_16 = FALSE;
} else {
if (FapTurbo_SymAlligatorOnCritica != 0) {
if (gi_828 == 0) ls_24 = ls_24 + " Trading SymAlligator today.";
else ls_24 = ls_24 + " Ñåãîäíÿ òîðãîâàòü SymAlligator.";
gi_1240 = TRUE;
} else {
if (gi_828 == 0) ls_24 = ls_24 + " Simple Trading today.";
else ls_24 = ls_24 + " Ñåãîäíÿ îáû÷íàÿ òîðãîâëÿ.";
}
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1244 = TRUE;
li_20 = TRUE;
}
} else {
if (gi_828 == 0) ls_24 = "NO TooGoodToBeTrue Day. -> Possible to trade.";
else ls_24 = "Íå TooGoodToBeTrue äåíü. -> Âîçìîæíî òîðãîâàòü.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
}
}
if (li_4 && li_8 && !li_12 && li_16 && !li_20) {
if (gi_828 == 0) ls_24 = "Simple Trading Day.";
else ls_24 = "Ñåãîäíÿ îáû÷íàÿ òîðãîâëÿ.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1244 = TRUE;
gi_1236 = TRUE;
gi_1248 = FALSE;
} else {
if (FapTurbo_AlwaysTrade != 0) {
gi_1248 = TRUE;
gi_1240 = TRUE;
if (gi_828 == 0) ls_24 = "AlwaysTrade: Trading SymAlligator today with LowLot.";
else ls_24 = "AlwaysTrade: Ñåãîäíÿ òîðãîâàòü SymAlligator c LowLot.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
}
}
if (li_12 || li_20) gi_1236 = TRUE;
if (!li_4 || !li_8 || !li_16) gi_1236 = FALSE;
if (FapTurbo_TradeNFP == 0) {
if (TimeDayOfWeek(l_datetime_0) == 5 && TimeDay(l_datetime_0) <= 7) {
if (gi_828 == 0) ls_24 = "Does not trade on the first Friday of month.";
else ls_24 = "Íå òîðãîâàòü â ïåðâóþ ïÿòíèöó ìåñÿöà.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1252 = TRUE;
}
}
if (FapTurbo_TradeFriday == 0) {
if (TimeDayOfWeek(l_datetime_0) == 5) {
if (gi_828 == 0) ls_24 = "Does not trade on the Friday.";
else ls_24 = "Íå òîðãîâàòü â ïÿòíèöó.";
gs_1408 = gs_1408 + ls_24
+ "\n";
if (WriteLog) Print(ls_24);
gi_1252 = TRUE;
}
}
if (gi_1252) {
if (gi_828 == 0) ls_24 = "The final resolution: NO TRADE today.";
else ls_24 = "Èòîãîâîå ðåøåíèå: Íå òîðãîâàòü ñåãîäíÿ.";
} else {
if (!gi_1236) {
if (!gi_1248) {
if (gi_828 == 0) ls_24 = "The final resolution: NO TRADE today.";
else ls_24 = "Èòîãîâîå ðåøåíèå: Íå òîðãîâàòü ñåãîäíÿ.";
} else {
if (gi_828 == 0) ls_24 = "The final resolution: to TRADE WITH LOWLOT today.";
else ls_24 = "Èòîãîâîå ðåøåíèå: Ñåãîäíÿ òîðãîâàòü ñ LowLot.";
}
} else {
if (gi_828 == 0) ls_24 = "The final resolution: to TRADE today.";
else ls_24 = "Èòîãîâîå ðåøåíèå: Ñåãîäíÿ òîðãîâàòü.";
}
}
gs_1408 = gs_1408 + ls_24;
if (WriteLog) {
Print(ls_24);
Print("------------------------------------------------------------------------------------------------");
}
}
if (PrintLogOnChart) {
if (gi_828 == 0) {
Comment(""
+ "\n"
+ "FapTurbo"
+ "\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"
+ "Licensed Till: " + TimeToStr(gia_888[0], TIME_DATE)
+ "\n"
+ "Current Spread: " + DoubleToStr(MarketInfo(g_symbol_972, MODE_SPREAD) / MathPow(10, Digits - gi_880), Digits - gi_880)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "STRATEGY INFORMATION:"
+ "\n"
+ gs_1408
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "DEBUG INFORMATION:"
+ "\n"
+ "lastMALarge = " + DoubleToStr(g_ima_1344, gi_880) + ", prevMALarge = " + DoubleToStr(g_ima_1336, gi_880) + ", farMALarge = " + DoubleToStr(g_ima_1368, gi_880)
+ "\n"
+ "lastMASmall = " + DoubleToStr(g_ima_1360, gi_880) + ", prevMASmall = " + DoubleToStr(g_ima_1352, gi_880) + ", farMASmall = " + DoubleToStr(g_ima_1376, gi_880));
} else {
Comment(""
+ "\n"
+ "FapTurbo"
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î áðîêåðå:"
+ "\n"
+ "Áðîêåðñêàÿ êîìïàíèÿ: " + AccountCompany()
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î ñ÷¸òå:"
+ "\n"
+ "Íàçâàíèå ñ÷¸òà: " + AccountName()
+ "\n"
+ "Íîìåð ñ÷¸òà: " + AccountNumber()
+ "\n"
+ "Ïëå÷î ñ÷¸òà: " + DoubleToStr(AccountLeverage(), 0)
+ "\n"
+ "Áàëàíñ: " + DoubleToStr(AccountBalance(), 2)
+ "\n"
+ "Âàëþòà ñ÷¸òà: " + AccountCurrency()
+ "\n"
+ "Ñðåäñòâà: " + DoubleToStr(AccountEquity(), 2)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î ìàðæå:"
+ "\n"
+ "Ñâîáîäíàÿ ìàðæà: " + DoubleToStr(AccountFreeMargin(), 2)
+ "\n"
+ "Èñïîëüçóåìàÿ ìàðæà: " + DoubleToStr(AccountMargin(), 2)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Òåêóùåå âðåìÿ ñåðâåðà: " + TimeToStr(TimeCurrent(), TIME_SECONDS)
+ "\n"
+ "Ëèöåíçèÿ äî: " + TimeToStr(gia_888[0], TIME_DATE)
+ "\n"
+ "Òåêóùèé ñïðåä: " + DoubleToStr(MarketInfo(g_symbol_972, MODE_SPREAD) / MathPow(10, Digits - gi_880), Digits - gi_880)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ ñòðàòåãèè:"
+ "\n"
+ gs_1408
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Îòëàäî÷íàÿ èíôîðìàöèÿ:"
+ "\n"
+ "lastMALarge = " + DoubleToStr(g_ima_1344, gi_880) + ", prevMALarge = " + DoubleToStr(g_ima_1336, gi_880) + ", farMALarge = " + DoubleToStr(g_ima_1368, gi_880)
+ "\n"
+ "lastMASmall = " + DoubleToStr(g_ima_1360, gi_880) + ", prevMASmall = " + DoubleToStr(g_ima_1352, gi_880) + ", farMASmall = " + DoubleToStr(g_ima_1376, gi_880));
}
}
li_36 = CalculateCurrentOrders();
if (li_36 > 0) {
for (int li_32 = li_36 - 1; li_32 >= 0; li_32--) {
if (GetOrderByPos(li_32)) {
if (OrderMagicNumber() == g_magic_876) {
if (TradeSignalCloseOrder() || TradeSignalCloseOrderOnTime(li_32)) CloseOrder(OrderTicket(), OrderLots(), OrderType(), g_slippage_920);
else {
if (FapTurbo_TakeProfit != 0.0 && NormalizeDouble(OrderTakeProfit(), gi_880) == 0.0) {
if (OrderType() == OP_BUY) {
li_40 = NormalizeDouble((OrderClosePrice() - OrderOpenPrice()) / gd_924, gi_880);
l_price_44 = NormalizeDouble(OrderOpenPrice() + FapTurbo_TakeProfit * gd_924, gi_880);
} else {
li_40 = NormalizeDouble((OrderOpenPrice() - OrderClosePrice()) / gd_924, gi_880);
l_price_44 = NormalizeDouble(OrderOpenPrice() - FapTurbo_TakeProfit * gd_924, gi_880);
}
if (li_40 >= FapTurbo_TakeProfit) {
if (gi_828 == 0) gs_1400 = "Price at level TakeProfit.";
else gs_1400 = "Öåíà äîñòèãëà óðîâíÿ TakeProfit.";
CloseOrder(OrderTicket(), OrderLots(), OrderType(), g_slippage_920);
return;
}
if (FapTurbo_TakeProfit * gd_924 > MarketInfo(g_symbol_972, MODE_STOPLEVEL) * Point) {
while (!IsTradeAllowed()) Sleep(1000);
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_price_44, 0, Red);
}
}
if (FapTurbo_StopLoss != 0.0 && NormalizeDouble(OrderStopLoss(), gi_880) == 0.0) {
if (OrderType() == OP_BUY) {
li_40 = NormalizeDouble((OrderClosePrice() - OrderOpenPrice()) / gd_924, gi_880);
l_price_52 = NormalizeDouble(OrderOpenPrice() - FapTurbo_StopLoss * gd_924, gi_880);
} else {
li_40 = NormalizeDouble((OrderOpenPrice() - OrderClosePrice()) / gd_924, gi_880);
l_price_52 = NormalizeDouble(OrderOpenPrice() + FapTurbo_StopLoss * gd_924, gi_880);
}
if (li_40 <= -1.0 * FapTurbo_StopLoss) {
if (gi_828 == 0) gs_1400 = "Price at level StopLoss.";
else gs_1400 = "Öåíà äîñòèãëà óðîâíÿ StopLoss.";
CloseOrder(OrderTicket(), OrderLots(), OrderType(), g_slippage_920);
return;
}
if (FapTurbo_StopLoss * gd_924 > MarketInfo(g_symbol_972, MODE_STOPLEVEL) * Point) {
while (!IsTradeAllowed()) Sleep(1000);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_52, OrderTakeProfit(), 0, Red);
}
}
if (FapTurbo_TrailingStop > 0.0) TrailOrderStop();
}
}
}
}
if (li_36 < FapTurbo_MaxOrders)
if ((TimeCurrent() - g_datetime_1260) / 60 >= FapTurbo_StopTime) TrueOpen();
} else TrueOpen();
}
}
}
}
}
}
}
}

int CalculateCurrentOrders() {
int li_ret_0;
for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES))
if (OrderMagicNumber() == g_magic_876 && OrderSymbol() == g_symbol_972) li_ret_0++;
}
return (li_ret_0);
}

int TrueOpen() {
int li_4;
int li_8;
double l_minlot_12;
double l_minlot_20;
double ld_28;
if (gi_864) return (0);
if (!IsTradeTime(TimeCurrent())) return (0);
int li_0 = TradeSignalOpenOrder();
if (li_0 == 0) return (0);
if (FapTurbo_OneTrade != 0) {
if (HaveTrade()) {
if (WriteDebugLog) {
if (gi_828 == 0) Print("Already have one trade inside this interval of time.");
else Print("Óæå åñòü îäíà ñäåëêà â òå÷åíèè ýòîãî èíòåðâàëà âðåìåíè.");
}
return (0);
}
}
if (FapTurbo_AlterPositions != 0) {
li_4 = FapTurbo_MaxOrders / 2;
if (FapTurbo_MaxOrders % 2 != 0) li_4++;
if (li_0 == 1) {
li_8 = HavePositions(OP_BUY);
if (li_8 >= li_4) {
if (WriteLog) {
if (gi_828 == 0) Print("AlterPositions: already there are open " + li_8 + " orders. The signal to BUY is blocked.");
else Print("AlterPositions: óæå åñòü îòêðûòûõ " + li_8 + " îðäåðîâ. Ñèãíàë ê ïîêóïêå áëîêèðóåòñÿ.");
}
return (0);
}
} else {
li_8 = HavePositions(OP_SELL);
if (li_8 >= li_4) {
if (WriteLog) {
if (gi_828 == 0) Print("AlterPositions: already there are open " + li_8 + " orders. The signal to SELL is blocked.");
else Print("AlterPositions: óæå åñòü îòêðûòûõ " + li_8 + " îðäåðîâ. Ñèãíàë ê ïðîäàæå áëîêèðóåòñÿ.");
}
return (0);
}
}
}
if (FapTurbo_AlterPosLotReducer != 0.0) {
if (li_0 == 1) l_minlot_12 = NormalizeDouble(OpenPosVol(OP_BUY) / FapTurbo_AlterPosLotReducer, gi_872);
else l_minlot_12 = NormalizeDouble(OpenPosVol(OP_SELL) / FapTurbo_AlterPosLotReducer, gi_872);
if (l_minlot_12 != 0.0) {
l_minlot_20 = MarketInfo(g_symbol_972, MODE_MINLOT);
if (l_minlot_12 < l_minlot_20) l_minlot_12 = l_minlot_20;
if (!gi_1248) {
ld_28 = l_minlot_12;
if (WriteLog) {
if (gi_828 == 0) Print("HedgingLot: the order will be open by the reduced lots.");
else Print("HedgingLot: îðäåð áóäåò îòêðûò ñ óìåíüøåííûì ëîòîì.");
}
} else {
if (l_minlot_12 > FapTurbo_LowLot) {
ld_28 = FapTurbo_LowLot;
if (WriteLog) {
if (gi_828 == 0) Print("HedgingLot: the reduced lots more than LowLot, the order will be open by the LowLot lots.");
else Print("HedgingLot: óìåíüøåííûé ëîò áîëüøå ÷åì LowLot, îðäåð áóäåò îòêðûò ñ LowLot ëîòîì.");
}
} else {
ld_28 = l_minlot_12;
if (WriteLog) {
if (gi_828 == 0) Print("HedgingLot: the order will be open by the reduced lots.");
else Print("HedgingLot: îðäåð áóäåò îòêðûò ñ óìåíüøåííûì ëîòîì.");
}
}
}
} else {
if (!gi_1248) ld_28 = CalcLotsVolume();
else ld_28 = FapTurbo_LowLot;
}
} else {
if (!gi_1248) ld_28 = CalcLotsVolume();
else ld_28 = FapTurbo_LowLot;
}
if (ld_28 == 0.0 || !CheckAccount(DirectionOrderType(li_0), ld_28)) return (0);
int li_36 = OpenOrder(li_0, ld_28, FapTurbo_ExpertComment);
return (0);
}

bool CheckParams() {
if (Bars < 100) {
if (gi_828 == 0) Print("Bars less than 100");
else Print("Íà ãðàôèêå ìåíüøå 100 áàðîâ");
return (FALSE);
}
if (FapTurbo_TakeProfit < 10.0) {
if (gi_828 == 0) Print("FapTurbo_TakeProfit is less than 10");
else Print("FapTurbo_TakeProfit ìåíüøå 10");
return (FALSE);
}
if (FapTurbo_Lots <= 0.0 && FapTurbo_LotsRiskReductor < 0.0) {
if (gi_828 == 0) Print("FapTurbo_LotsRiskReductor is less than 0");
else Print("FapTurbo_LotsRiskReductor ìåíüøå 0");
return (FALSE);
}
return (TRUE);
}

bool CheckAccount(int a_cmd_0, double ad_4) {
bool li_ret_12 = TRUE;
double ld_16 = AccountFreeMarginCheck(g_symbol_972, a_cmd_0, ad_4);
if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) li_ret_12 = FALSE;
if (!li_ret_12) {
if (gi_828 == 0) Print("No money to open more orders.", " Lot=", ad_4, " Free Margin = ", AccountFreeMargin(), " Balance = ", AccountBalance());
else Print("Íåò äåíåã äëÿ îòêðûòèÿ îðäåðîâ.", " Lot=", ad_4, " Ñâîáîäíàÿ ìàðæà = ", AccountFreeMargin(), " Áàëàíñ = ", AccountBalance());
}
return (li_ret_12);
}

double CalcLotsVolume() {
double ld_ret_0;
if (FapTurbo_Lots > 0.0) ld_ret_0 = NormalizeLot(FapTurbo_Lots, 0, "");
else {
ld_ret_0 = NormalizeDouble(MathFloor(AccountFreeMargin() * gd_964 / 100.0 / gd_956) * g_lotstep_948, gi_872);
if (ld_ret_0 < g_minlot_940) ld_ret_0 = g_minlot_940;
if (ld_ret_0 > g_maxlot_932) ld_ret_0 = g_maxlot_932;
}
if (ld_ret_0 > FapTurbo_MaxLots) ld_ret_0 = FapTurbo_MaxLots;
return (ld_ret_0);
}

bool PrepareIndicators() {
double l_ifractals_20;
g_icustom_1280 = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 0, 0);
g_icustom_1288 = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 1, 0);
g_icustom_1296 = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 2, 0);
int li_8 = 3;
g_ifractals_1320 = 0;
g_ifractals_1328 = 0;
for (int li_4 = 0; li_4 <= li_8; li_4++) {
l_ifractals_20 = iFractals(NULL, 0, MODE_LOWER, li_4);
if (l_ifractals_20 != 0.0) g_ifractals_1320 = l_ifractals_20;
l_ifractals_20 = iFractals(NULL, 0, MODE_UPPER, li_4);
if (l_ifractals_20 != 0.0) g_ifractals_1328 = l_ifractals_20;
}
li_8 = 0;
ArrayResize(gda_1384, li_8 + 1);
ArrayResize(gda_1388, li_8 + 1);
for (li_4 = 0; li_4 <= li_8; li_4++) {
gda_1384[li_4] = iDeMarker(NULL, 0, FapTurbo_aaa, li_4);
gda_1388[li_4] = (-iWPR(NULL, 0, FapTurbo_bbb, li_4 + 1)) / 100.0;
}
g_ima_1336 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMALarge);
g_ima_1344 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, 0);
g_ima_1352 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMASmall);
g_ima_1360 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, 0);
g_ima_1368 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_LookForDays + FapTurbo_ShiftMALarge);
g_ima_1376 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_LookForDays + FapTurbo_ShiftMASmall);
return (TRUE);
}

int TradeSignalOpenOrder() {
int li_ret_0 = fun1(gi_1252, gi_1236, g_ima_1336, g_ima_1344, gi_1248, gi_1240, IsGatorActiveUp(), IsGatorActiveDown(), WasWPROverBuy(), WasWPROverSell(), IsFractalLower(), IsFractalUpper(), WasDemarkerHigh(), WasDemarkerLow(), g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, TimeCurrent(), gia_908, gia_884, g_bool_868, gia_888);
if (li_ret_0 == 16) {
gi_856 = FALSE;
return (0);
}
if (li_ret_0 == 32) {
gi_864 = TRUE;
return (0);
}
if (li_ret_0 == 0) return (0);
if (gi_1256) {
if (li_ret_0 == 1) {
if (g_ima_1336 > g_ima_1344 && g_ima_1352 > g_ima_1360) li_ret_0 = 0;
else {
if (WriteLog) {
if (gi_828 == 0) Print("Filter FixedDirection allow a signal to BUY.");
else Print("Ôèëüòð FixedDirection ïðîïóñêàåò ñèãíàë ê ïîêóïêå.");
}
}
} else {
if (g_ima_1336 < g_ima_1344 && g_ima_1352 < g_ima_1360) li_ret_0 = 0;
else {
if (WriteLog) {
if (gi_828 == 0) Print("Filter FixedDirection allow a signal to SELL.");
else Print("Ôèëüòð FixedDirection ïðîïóñêàåò ñèãíàë ê ïðîäàæå.");
}
}
}
}
if (li_ret_0 == 0) return (0);
if (gi_1244 && WriteLog) {
if (IsGatorActiveUp()) {
if (gi_828 == 0) Print("Alligator on BUY.");
else Print("Alligator ðàñêðûò ê ïîêóïêå.");
} else {
if (gi_828 == 0) Print("Alligator on SELL.");
else Print("Alligator ðàñêðûò ê ïðîäàæå.");
}
}
if (WriteDebugLog) PrintDebugLog();
return (li_ret_0);
}

int TradeSignalCloseOrder() {
if (FapTurbo_ClsLsrOnMrktChnge != 0) {
if (OrderProfit() < 0.0 && TimeDay(OrderOpenTime()) != TimeDay(Time[0])) {
if (OrderType() == OP_BUY) {
if (g_ima_1352 > g_ima_1360) {
if (WriteDebugLog) PrintDebugLog();
if (gi_828 == 0) gs_1400 = "MASmall going down.";
else gs_1400 = "MASmall íàïðàâëåíà âíèç.";
return (1);
}
}
if (g_ima_1352 < g_ima_1360) {
if (WriteDebugLog) PrintDebugLog();
if (gi_828 == 0) gs_1400 = "MASmall going up.";
else gs_1400 = "MASmall íàïðàâëåíà ââåðõ.";
return (1);
}
}
}
return (!IsOrderProfitable());
}

double NormalizeLot(double ad_0, bool ai_8 = FALSE, string a_symbol_12 = "") {
double ld_ret_20;
double ld_28;
if (a_symbol_12 == "" || a_symbol_12 == "0") a_symbol_12 = g_symbol_972;
double l_lotstep_36 = MarketInfo(a_symbol_12, MODE_LOTSTEP);
double l_minlot_44 = MarketInfo(a_symbol_12, MODE_MINLOT);
double l_maxlot_52 = MarketInfo(a_symbol_12, MODE_MAXLOT);
if (l_minlot_44 == 0.0) l_minlot_44 = 0.1;
if (l_maxlot_52 == 0.0) l_maxlot_52 = 100;
if (l_lotstep_36 > 0.0) ld_28 = 1 / l_lotstep_36;
else ld_28 = 1 / l_minlot_44;
if (ai_8) ld_ret_20 = MathCeil(ad_0 * ld_28) / ld_28;
else ld_ret_20 = MathFloor(ad_0 * ld_28) / ld_28;
if (ld_ret_20 < l_minlot_44) ld_ret_20 = l_minlot_44;
if (ld_ret_20 > l_maxlot_52) ld_ret_20 = l_maxlot_52;
return (ld_ret_20);
}

int TradeSignalCloseOrderOnTime(int ai_unused_0) {
int l_month_4;
int li_8;
if (FapTurbo_DurationInHours > 0) {
if (TimeCurrent() - OrderOpenTime() >= 3600 * FapTurbo_DurationInHours) {
if (gi_828 == 0) gs_1400 = "Limite duration of open position, after " + FapTurbo_DurationInHours + " hours.";
else gs_1400 = "Îãðàíè÷åíèå äëèòåëüíîñòè îòêðûòîé ïîçèöèè, ïîñëå " + FapTurbo_DurationInHours + " ÷àñîâ.";
return (1);
}
}
if (FapTurbo_CloseAfterXmonths > 0) {
l_month_4 = TimeMonth(OrderOpenTime());
li_8 = TimeMonth(TimeCurrent());
if (l_month_4 != li_8) {
if (l_month_4 > li_8) li_8 += 12;
if (li_8 - l_month_4 >= FapTurbo_CloseAfterXmonths) {
if (gi_828 == 0) gs_1400 = "Start new month, after " + FapTurbo_CloseAfterXmonths + " months.";
else gs_1400 = "Íà÷àëî íîâîãî ìåñÿöà, ïîñëå " + FapTurbo_CloseAfterXmonths + " ìåñÿöåâ.";
return (1);
}
}
}
return (0);
}

bool IsDateTimeEnabled(int ai_0) {
int l_day_of_year_4 = TimeDayOfYear(ai_0);
int l_day_of_week_8 = TimeDayOfWeek(ai_0);
return (l_day_of_week_8 > 0 && l_day_of_week_8 < 6 && l_day_of_year_4 > 7 && l_day_of_year_4 < 360);
}

bool IsGatorActiveUp() {
return (g_icustom_1296 - g_icustom_1288 >= FapTurbo_SpanGator * gd_924 && g_icustom_1288 - g_icustom_1280 >= FapTurbo_SpanGator * gd_924 && g_icustom_1296 - g_icustom_1280 >= FapTurbo_SpanGator * gd_924);
}

int IsGatorActiveDown() {
return (g_icustom_1288 - g_icustom_1296 >= FapTurbo_SpanGator * gd_924 && g_icustom_1280 - g_icustom_1288 >= FapTurbo_SpanGator * gd_924 && g_icustom_1280 - g_icustom_1296 >= FapTurbo_SpanGator * gd_924);
}

int IsFractalLower() {
return (g_ifractals_1320 != 0.0);
}

int IsFractalUpper() {
return (g_ifractals_1328 != 0.0);
}

bool IsOrderProfitable() {
return (TRUE);
}

int WasDemarkerLow() {
return (ArrayMinValue(gda_1384) < 0.5);
}

int WasDemarkerHigh() {
return (ArrayMaxValue(gda_1384) > 0.5);
}

int WasWPROverBuy() {
return (ArrayMinValue(gda_1388) <= 0.25);
}

int WasWPROverSell() {
return (ArrayMaxValue(gda_1388) >= 0.75);
}

int OpenOrder(int ai_0, double a_lots_4, string a_comment_12 = "") {
int l_ticket_44;
int li_56;
int l_error_60;
string ls_64;
double l_price_72;
double l_price_28 = 0;
double l_price_36 = 0;
double l_price_20 = PriceOpen(ai_0);
l_price_36 = l_price_20 + FapTurbo_TakeProfit * gd_924 * ai_0;
if (FapTurbo_StopLoss > 0.0) l_price_28 = PriceClose(ai_0) - FapTurbo_StopLoss * gd_924 * ai_0;
int l_cmd_48 = DirectionOrderType(ai_0);
int li_52 = gi_912;
while (li_52 > 0) {
l_ticket_44 = OrderSend(g_symbol_972, l_cmd_48, a_lots_4, l_price_20, g_slippage_920, 0, 0, a_comment_12, g_magic_876, 0, ColorOpen(ai_0));
Sleep(MathRand() / 1000);
if (l_ticket_44 >= 0) {
if (OrderSelect(l_ticket_44, SELECT_BY_TICKET)) l_price_20 = OrderOpenPrice();
if (SendEmail) {
if (gi_828 == 0) {
SendMail(gs_980, StringConcatenate("Fapturbo Trade Information\nCurrency Pair: ", StringSubstr(g_symbol_972, 0, 6),
"\nTime: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nOrder Type: ", OrderTypeToStr(l_cmd_48),
"\nPrice: ", DoubleToStr(l_price_20, Digits),
"\nLot size: ", DoubleToStr(a_lots_4, gi_872),
"\nEvent: Trade Opened",
"\n\nCurrent Balance: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nCurrent Equity: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
} else {
SendMail(gs_996, StringConcatenate("Fapturbo òîðãîâàÿ èíôîðìàöèÿ\nÂàëþòíàÿ ïàðà: ", StringSubstr(g_symbol_972, 0, 6),
"\nÂðåìÿ: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nÒèï îðäåðà: ", OrderTypeToStr(l_cmd_48),
"\nÖåíà: ", DoubleToStr(l_price_20, Digits),
"\nÐàçìåð ëîòà: ", DoubleToStr(a_lots_4, gi_872),
"\nÑîáûòèå: îòêðûòèå îðäåðà",
"\n\nÒåêóùèé áàëàíñ: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nÒåêóùèå ñðåäñòâà: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
}
}
if (SoundAlert) PlaySound(SoundFileAtOpen);
li_56 = MarketInfo(g_symbol_972, MODE_STOPLEVEL) * Point;
if (FapTurbo_TakeProfit * gd_924 > li_56 || FapTurbo_TakeProfit == 0.0)
if (FapTurbo_StopLoss * gd_924 > li_56 || FapTurbo_StopLoss == 0.0) OrderModify(l_ticket_44, l_price_20, l_price_28, l_price_36, 0, Red);
g_datetime_1260 = iTime(g_symbol_972, 0, 0);
break;
}
l_error_60 = GetLastError();
if (WriteDebugLog) {
if (l_cmd_48 == OP_BUY) ls_64 = "OP_BUY";
else ls_64 = "OP_SELL";
Print("Open: OrderSend(", ls_64, ") error = ", ErrorDescription(l_error_60));
}
if (l_error_60 != 136/* OFF_QUOTES */) break;
Sleep(6000);
RefreshRates();
if (l_cmd_48 == OP_BUY) l_price_72 = Ask;
else l_price_72 = Bid;
if (NormalizeDouble(MathAbs((l_price_72 - l_price_20) / gd_924), 0) > gi_916) break;
l_price_20 = l_price_72;
li_52--;
if (li_52 > 0) {
if (gi_828 == 0) Print("... Possible to open order.");
else Print("... Âîçìîæíî îòêðûòü îðäåð.");
}
a_lots_4 = NormalizeDouble(a_lots_4 / 2.0, gi_872);
if (a_lots_4 < g_minlot_940) a_lots_4 = g_minlot_940;
}
return (0);
}

bool GetOrderByPos(int a_pos_0) {
return (OrderSelect(a_pos_0, SELECT_BY_POS, MODE_TRADES) && OrderType() <= OP_SELL && OrderSymbol() == g_symbol_972);
}

void TrailOrderStop() {
int li_0;
double ld_4;
double ld_12;
double l_price_20;
double ld_28;
double ld_36;
int li_44;
if (OrderTicket() > 0) {
li_0 = OrderTypeDirection();
ld_4 = NormalizeDouble(FapTurbo_TrailingStop * gd_924 * li_0, gi_880);
ld_12 = NormalizeDouble(iif(li_0 > 0 || OrderStopLoss() != 0.0, OrderStopLoss(), 999999), gi_880);
l_price_20 = NormalizeDouble(PriceClose(li_0) - ld_4, gi_880);
ld_28 = NormalizeDouble(l_price_20 - OrderOpenPrice(), gi_880);
ld_36 = NormalizeDouble(l_price_20 - ld_12, gi_880);
if (ld_28 * li_0 > 0.0 && ld_36 * li_0 >= gd_924) {
if (OrderType() == OP_BUY) li_44 = (Bid - l_price_20) / gd_924;
else li_44 = (l_price_20 - Ask) / gd_924;
if (li_44 > MarketInfo(g_symbol_972, MODE_STOPLEVEL) * Point) {
while (!IsTradeAllowed()) Sleep(1000);
OrderModify(OrderTicket(), OrderOpenPrice(), l_price_20, OrderTakeProfit(), 0, ColorOpen(li_0));
}
}
}
}

int OrderTypeDirection() {
int li_ret_0 = 0;
if (OrderType() == OP_BUY) li_ret_0 = 1;
if (OrderType() == OP_SELL) li_ret_0 = -1;
return (li_ret_0);
}

int DirectionOrderType(int ai_0) {
return (iif(ai_0 > 0, 0, 1));
}

int ColorOpen(int ai_0) {
return (iif(ai_0 > 0, ColorBuy, ColorSell));
}

double PriceOpen(int ai_0) {
return (iif(ai_0 > 0, Ask, Bid));
}

double PriceClose(int ai_0) {
return (iif(ai_0 > 0, Bid, Ask));
}

double iif(bool ai_0, double ad_4, double ad_12) {
if (ai_0) return (ad_4);
return (ad_12);
}

string ErrorDescription(int ai_0) {
string ls_ret_4;
switch (ai_0) {
case 0:
case 1:
ls_ret_4 = "no error";
break;
case 2:
ls_ret_4 = "common error";
break;
case 3:
ls_ret_4 = "invalid trade parameters";
break;
case 4:
ls_ret_4 = "trade server is busy";
break;
case 5:
ls_ret_4 = "old version of the client terminal";
break;
case 6:
ls_ret_4 = "no connection with trade server";
break;
case 7:
ls_ret_4 = "not enough rights";
break;
case 8:
ls_ret_4 = "too frequent requests";
break;
case 9:
ls_ret_4 = "malfunctional trade operation (never returned error)";
break;
case 64:
ls_ret_4 = "account disabled";
break;
case 65:
ls_ret_4 = "invalid account";
break;
case 128:
ls_ret_4 = "trade timeout";
break;
case 129:
ls_ret_4 = "invalid price";
break;
case 130:
ls_ret_4 = "invalid stops";
break;
case 131:
ls_ret_4 = "invalid trade volume";
break;
case 132:
ls_ret_4 = "market is closed";
break;
case 133:
ls_ret_4 = "trade is disabled";
break;
case 134:
ls_ret_4 = "not enough money";
break;
case 135:
ls_ret_4 = "price changed";
break;
case 136:
ls_ret_4 = "off quotes";
break;
case 137:
ls_ret_4 = "broker is busy (never returned error)";
break;
case 138:
ls_ret_4 = "requote";
break;
case 139:
ls_ret_4 = "order is locked";
break;
case 140:
ls_ret_4 = "long positions only allowed";
break;
case 141:
ls_ret_4 = "too many requests";
break;
case 145:
ls_ret_4 = "modification denied because order too close to market";
break;
case 146:
ls_ret_4 = "trade context is busy";
break;
case 147:
ls_ret_4 = "expirations are denied by broker";
break;
case 148:
ls_ret_4 = "amount of open and pending orders has reached the limit";
break;
case 4000:
ls_ret_4 = "no error (never generated code)";
break;
case 4001:
ls_ret_4 = "wrong function pointer";
break;
case 4002:
ls_ret_4 = "array index is out of range";
break;
case 4003:
ls_ret_4 = "no memory for function call stack";
break;
case 4004:
ls_ret_4 = "recursive stack overflow";
break;
case 4005:
ls_ret_4 = "not enough stack for parameter";
break;
case 4006:
ls_ret_4 = "no memory for parameter string";
break;
case 4007:
ls_ret_4 = "no memory for temp string";
break;
case 4008:
ls_ret_4 = "not initialized string";
break;
case 4009:
ls_ret_4 = "not initialized string in array";
break;
case 4010:
ls_ret_4 = "no memory for array\' string";
break;
case 4011:
ls_ret_4 = "too long string";
break;
case 4012:
ls_ret_4 = "remainder from zero divide";
break;
case 4013:
ls_ret_4 = "zero divide";
break;
case 4014:
ls_ret_4 = "unknown command";
break;
case 4015:
ls_ret_4 = "wrong jump (never generated error)";
break;
case 4016:
ls_ret_4 = "not initialized array";
break;
case 4017:
ls_ret_4 = "dll calls are not allowed";
break;
case 4018:
ls_ret_4 = "cannot load library";
break;
case 4019:
ls_ret_4 = "cannot call function";
break;
case 4020:
ls_ret_4 = "expert function calls are not allowed";
break;
case 4021:
ls_ret_4 = "not enough memory for temp string returned from function";
break;
case 4022:
ls_ret_4 = "system is busy (never generated error)";
break;
case 4050:
ls_ret_4 = "invalid function parameters count";
break;
case 4051:
ls_ret_4 = "invalid function parameter value";
break;
case 4052:
ls_ret_4 = "string function internal error";
break;
case 4053:
ls_ret_4 = "some array error";
break;
case 4054:
ls_ret_4 = "incorrect series array using";
break;
case 4055:
ls_ret_4 = "custom indicator error";
break;
case 4056:
ls_ret_4 = "arrays are incompatible";
break;
case 4057:
ls_ret_4 = "global variables processing error";
break;
case 4058:
ls_ret_4 = "global variable not found";
break;
case 4059:
ls_ret_4 = "function is not allowed in testing mode";
break;
case 4060:
ls_ret_4 = "function is not confirmed";
break;
case 4061:
ls_ret_4 = "send mail error";
break;
case 4062:
ls_ret_4 = "string parameter expected";
break;
case 4063:
ls_ret_4 = "integer parameter expected";
break;
case 4064:
ls_ret_4 = "double parameter expected";
break;
case 4065:
ls_ret_4 = "array as parameter expected";
break;
case 4066:
ls_ret_4 = "requested history data in update state";
break;
case 4099:
ls_ret_4 = "end of file";
break;
case 4100:
ls_ret_4 = "some file error";
break;
case 4101:
ls_ret_4 = "wrong file name";
break;
case 4102:
ls_ret_4 = "too many opened files";
break;
case 4103:
ls_ret_4 = "cannot open file";
break;
case 4104:
ls_ret_4 = "incompatible access to a file";
break;
case 4105:
ls_ret_4 = "no order selected";
break;
case 4106:
ls_ret_4 = "unknown symbol";
break;
case 4107:
ls_ret_4 = "invalid price parameter for trade function";
break;
case 4108:
ls_ret_4 = "invalid ticket";
break;
case 4109:
ls_ret_4 = "trade is not allowed in the expert properties";
break;
case 4110:
ls_ret_4 = "longs are not allowed in the expert properties";
break;
case 4111:
ls_ret_4 = "shorts are not allowed in the expert properties";
break;
case 4200:
ls_ret_4 = "object is already exist";
break;
case 4201:
ls_ret_4 = "unknown object property";
break;
case 4202:
ls_ret_4 = "object is not exist";
break;
case 4203:
ls_ret_4 = "unknown object type";
break;
case 4204:
ls_ret_4 = "no object name";
break;
case 4205:
ls_ret_4 = "object coordinates error";
break;
case 4206:
ls_ret_4 = "no specified subwindow";
break;
default:
ls_ret_4 = "unknown error";
}
return (ls_ret_4);
}

double ArrayMinValue(double ada_0[]) {
return (ada_0[ArrayMinimum(ada_0)]);
}

double ArrayMaxValue(double ada_0[]) {
return (ada_0[ArrayMaximum(ada_0)]);
}

bool Rule1(int ai_0) {
if (FapTurbo_CriticalDays <= 0) return (TRUE);
double l_ima_4 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMALarge + ai_0);
double l_ima_12 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_LookForDays + FapTurbo_ShiftMALarge + ai_0);
double l_ima_20 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMASmall + ai_0);
double l_ima_28 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_LookForDays + FapTurbo_ShiftMASmall + ai_0);
double ld_36 = (l_ima_4 - l_ima_12) / FapTurbo_LookForDays;
double ld_44 = l_ima_4 + ld_36;
double ld_52 = (l_ima_20 - l_ima_28) / FapTurbo_LookForDays;
double ld_60 = l_ima_20 + ld_52;
gi_1272 = (ld_60 - ld_44) / (ld_36 - ld_52);
if (gi_1272 > 0 && gi_1272 < FapTurbo_CriticalDays) return (FALSE);
return (TRUE);
}

bool Rule2(int ai_0) {
double l_ima_4 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMASmall + ai_0);
double l_ima_12 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0);
double l_ima_20 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, FapTurbo_ShiftMALarge + ai_0);
double l_ima_28 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0);
if ((l_ima_20 > l_ima_28 && l_ima_4 < l_ima_12) || (l_ima_20 < l_ima_28 && l_ima_4 > l_ima_12)) return (FALSE);
return (TRUE);
}

bool Rule3(int ai_0) {
if (FapTurbo_TooGoodToBeTrue <= 0) return (TRUE);
gi_1276 = 0;
double ld_4 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0 + 1), gi_880);
double ld_12 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0), gi_880);
double ld_20 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0 + 1), gi_880);
double ld_28 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, ai_0), gi_880);
bool li_ret_36 = TRUE;
if (ld_4 > ld_12 && ld_20 > ld_28) {
for (int li_40 = ai_0; li_40 < Bars; li_40++) {
ld_4 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40 + 1), gi_880);
ld_12 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40), gi_880);
ld_20 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40 + 1), gi_880);
ld_28 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40), gi_880);
if (ld_4 < ld_12 || ld_20 < ld_28) break;
}
gi_1276 = ai_0 + li_40;
} else {
if (ld_4 < ld_12 && ld_20 < ld_28) {
for (li_40 = ai_0; li_40 < Bars; li_40++) {
ld_4 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40 + 1), gi_880);
ld_12 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40), gi_880);
ld_20 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40 + 1), gi_880);
ld_28 = NormalizeDouble(iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_40), gi_880);
if (ld_4 > ld_12 || ld_20 > ld_28) break;
}
gi_1276 = ai_0 + li_40;
} else return (li_ret_36);
}
if (FapTurbo_TooGoodToBeTrue <= gi_1276) li_ret_36 = FALSE;
return (li_ret_36);
}

bool Rule31(int ai_0) {
double l_ima_12;
double l_ima_20;
double l_ima_28;
double l_ima_36;
if (FapTurbo_TooGoodToBeTrue <= 0) return (TRUE);
bool li_4 = TRUE;
for (int li_8 = ai_0; li_8 < FapTurbo_TooGoodToBeTrue + ai_0; li_8++) {
l_ima_12 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_8 + 1);
l_ima_20 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMASmall, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_8);
l_ima_28 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_8 + 1);
l_ima_36 = iMA(NULL, PERIOD_D1, FapTurbo_PeriodMALarge, 0, FapTurbo_TypeMA_0_3, FapTurbo_PriceMA_0_6, li_8);
if ((l_ima_12 > l_ima_20 && l_ima_28 < l_ima_36) || (l_ima_12 < l_ima_20 && l_ima_28 > l_ima_36)) li_4 = FALSE;
}
if (li_4) return (FALSE);
return (TRUE);
}

bool Relax1() {
if (FapTurbo_RelaxDays <= 0) return (TRUE);
for (int li_0 = 1; li_0 < FapTurbo_RelaxDays + 1; li_0++)
if (!(Rule1(li_0))) break;
gi_1276 = FapTurbo_RelaxDays + 1 - li_0;
if (gi_1276 == 0) return (TRUE);
return (FALSE);
}

bool Relax2() {
if (FapTurbo_RelaxDays <= 0 || FapTurbo_Prudent == 0) return (TRUE);
for (int li_0 = 1; li_0 < FapTurbo_RelaxDays + 1; li_0++)
if (!(Rule2(li_0))) break;
gi_1276 = FapTurbo_RelaxDays + 1 - li_0;
if (gi_1276 == 0) return (TRUE);
return (FALSE);
}

bool Relax3() {
if (FapTurbo_TooGoodToBeTrue <= 0) return (TRUE);
if (FapTurbo_PrudentPeriod <= 0) return (TRUE);
for (int li_0 = 1; li_0 < FapTurbo_PrudentPeriod + 1; li_0++)
if (!(Rule31(li_0))) break;
gi_1276 = FapTurbo_PrudentPeriod + 1 - li_0;
if (gi_1276 == 0) return (TRUE);
return (FALSE);
}

void PrintDebugLog() {
Print("lastMALarge = ", g_ima_1344, ", prevMALarge = ", g_ima_1336, ", farMALarge = ", g_ima_1368);
Print("lastMASmall = ", g_ima_1360, ", prevMASmall = ", g_ima_1352, ", farMASmall = ", g_ima_1376);
}

int HavePositions(int a_cmd_0) {
int l_count_4 = 0;
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 (OrderMagicNumber() == g_magic_876) {
if (OrderType() == a_cmd_0)
if (OrderSymbol() == g_symbol_972) l_count_4++;
}
}
}
return (l_count_4);
}

double OpenPosVol(int a_cmd_0) {
int l_datetime_24;
double l_ord_lots_4 = 0;
int l_datetime_12 = -2147483648;
int l_ord_total_16 = OrdersTotal();
for (int l_pos_20 = 0; l_pos_20 < l_ord_total_16; l_pos_20++) {
if (OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
if (OrderMagicNumber() == g_magic_876) {
if (OrderType() == a_cmd_0) {
if (OrderSymbol() == g_symbol_972) {
l_datetime_24 = OrderOpenTime();
if (l_datetime_24 > l_datetime_12) {
l_datetime_12 = l_datetime_24;
l_ord_lots_4 = OrderLots();
}
}
}
}
}
return (l_ord_lots_4);
}

bool IsTradeTime(int ai_0) {
int li_12;
int li_16;
int l_hour_4 = TimeHour(ai_0);
int l_minute_8 = TimeMinute(ai_0);
if (FapTurbo_StartWorkTimeHour == FapTurbo_EndWorkTimeHour && FapTurbo_StartWorkTimeMin == FapTurbo_EndWorkTimeMin) return (TRUE);
if (FapTurbo_EndWorkTimeMin == 0) {
if (FapTurbo_EndWorkTimeHour == 0) li_12 = 23;
else li_12 = FapTurbo_EndWorkTimeHour - 1;
li_16 = 59;
} else {
li_12 = FapTurbo_EndWorkTimeHour;
li_16 = FapTurbo_EndWorkTimeMin - 1;
}
if (FapTurbo_StartWorkTimeHour == li_12) {
if (FapTurbo_StartWorkTimeMin == li_16) return (TRUE);
if (FapTurbo_StartWorkTimeMin < li_16) {
if (l_hour_4 != FapTurbo_StartWorkTimeHour) return (FALSE);
if (l_minute_8 < FapTurbo_StartWorkTimeMin || l_minute_8 > li_16) return (FALSE);
return (TRUE);
}
if (FapTurbo_StartWorkTimeMin > li_16) {
if (l_hour_4 == FapTurbo_StartWorkTimeHour)
if (l_minute_8 < FapTurbo_StartWorkTimeMin && l_minute_8 > li_16) return (FALSE);
return (TRUE);
}
}
if (FapTurbo_StartWorkTimeHour < li_12) {
if (l_hour_4 < FapTurbo_StartWorkTimeHour || l_hour_4 > li_12) return (FALSE);
if (l_hour_4 == FapTurbo_StartWorkTimeHour && l_minute_8 < FapTurbo_StartWorkTimeMin) return (FALSE);
if (l_hour_4 == li_12 && l_minute_8 > li_16) return (FALSE);
return (TRUE);
}
if (FapTurbo_StartWorkTimeHour > li_12) {
if (l_hour_4 < FapTurbo_StartWorkTimeHour && l_hour_4 > li_12) return (FALSE);
if (l_hour_4 == FapTurbo_StartWorkTimeHour && l_minute_8 < FapTurbo_StartWorkTimeMin) return (FALSE);
if (l_hour_4 == li_12 && l_minute_8 > li_16) return (FALSE);
return (TRUE);
}
return (TRUE);
}

bool HaveTrade() {
int l_datetime_28;
if (FapTurbo_StartWorkTimeHour == FapTurbo_EndWorkTimeHour && FapTurbo_StartWorkTimeMin == FapTurbo_EndWorkTimeMin) return (FALSE);
int l_datetime_0 = TimeCurrent();
int li_4 = iTime(NULL, PERIOD_D1, 0);
int l_hour_8 = TimeHour(l_datetime_0);
bool li_12 = FALSE;
if (FapTurbo_StartWorkTimeHour > FapTurbo_EndWorkTimeHour) {
if (l_hour_8 < FapTurbo_StartWorkTimeHour) li_12 = TRUE;
} else {
if (FapTurbo_StartWorkTimeHour == FapTurbo_EndWorkTimeHour) {
if (FapTurbo_StartWorkTimeMin > FapTurbo_EndWorkTimeMin) {
if (l_hour_8 < FapTurbo_StartWorkTimeHour) {
if (l_hour_8 < FapTurbo_StartWorkTimeHour) li_12 = TRUE;
} else {
if (l_hour_8 == FapTurbo_StartWorkTimeHour)
if (TimeMinute(l_datetime_0) < FapTurbo_EndWorkTimeMin) li_12 = TRUE;
}
}
}
}
if (li_12) li_4 -= 86400;
li_4 += 3600 * FapTurbo_StartWorkTimeHour + 60 * FapTurbo_StartWorkTimeMin;
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() == g_magic_876) {
if (OrderSymbol() == g_symbol_972) {
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() == g_magic_876) {
if (OrderSymbol() == g_symbol_972) {
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);
}

void Scalper() {
double ld_8;
int l_day_of_week_16;
double l_irsi_20;
double l_irsi_28;
double l_ima_36;
int li_44;
int l_count_48;
double l_ima_52;
g_datetime_1024 = TimeCurrent();
string l_str_concat_0 = "";
if (Scalper_ProfitLimit > 0.0 || Scalper_LossLimit > 0.0) {
if (gi_1124 != gi_1128 || Scalper_StartSessionMinute != Scalper_EndSessionMinute) {
ld_8 = CalculateProfitSession();
if (gi_828 == 0) {
l_str_concat_0 = StringConcatenate("Current Profit: ", DoubleToStr(ld_8, 2), " ", AccountCurrency(),
"\n");
} else {
l_str_concat_0 = StringConcatenate("Òåêóùàÿ ïðèáûëü: ", DoubleToStr(ld_8, 2), " ", AccountCurrency(),
"\n");
}
if (Scalper_ProfitLimit > 0.0) {
if (gi_828 == 0) {
l_str_concat_0 = StringConcatenate(l_str_concat_0, "Profit Limit: ", DoubleToStr(Scalper_ProfitLimit, 2), " ", AccountCurrency(),
"\n");
} else {
l_str_concat_0 = StringConcatenate(l_str_concat_0, "Îãðàíè÷åíèå ïðèáûëè: ", DoubleToStr(Scalper_ProfitLimit, 2), " ", AccountCurrency(),
"\n");
}
}
if (Scalper_LossLimit > 0.0) {
if (gi_828 == 0) {
l_str_concat_0 = StringConcatenate(l_str_concat_0, "Loss Limit: ", DoubleToStr(-1.0 * Scalper_LossLimit, 2), " ", AccountCurrency(),
"\n");
} else {
l_str_concat_0 = StringConcatenate(l_str_concat_0, "Îãðàíè÷åíèå óáûòêà: ", DoubleToStr(-1.0 * Scalper_LossLimit, 2), " ", AccountCurrency(),
"\n");
}
}
}
}
if (PrintLogOnChart) {
if (gi_828 == 0) {
Comment(""
+ "\n"
+ "Scalper"
+ "\n"
+ "Current Spread: " + DoubleToStr(MarketInfo(g_symbol_972, MODE_SPREAD) / MathPow(10, Digits - gi_880), Digits - gi_880)
+ "\n"
+ "MaxSpread: " + DoubleToStr(Scalper_MaxSpread, Digits - gi_880)
+ "\n"
+ g_str_concat_1228 + l_str_concat_0 + "------------------------------------------------"
+ "\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"
+ "Licensed Till: " + TimeToStr(gia_888[0], TIME_DATE)
+ "\n"
+ "------------------------------------------------");
} else {
Comment(""
+ "\n"
+ "Scalper"
+ "\n"
+ "Òåêóùèé ñïðåä: " + DoubleToStr(MarketInfo(g_symbol_972, MODE_SPREAD) / MathPow(10, Digits - gi_880), Digits - gi_880)
+ "\n"
+ "MaxSpread: " + DoubleToStr(Scalper_MaxSpread, Digits - gi_880)
+ "\n"
+ g_str_concat_1228 + l_str_concat_0 + "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î áðîêåðå:"
+ "\n"
+ "Áðîêåðñêàÿ êîìïàíèÿ: " + AccountCompany()
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î ñ÷¸òå:"
+ "\n"
+ "Íàçâàíèå ñ÷¸òà: " + AccountName()
+ "\n"
+ "Íîìåð ñ÷¸òà: " + AccountNumber()
+ "\n"
+ "Ïëå÷î ñ÷¸òà: " + DoubleToStr(AccountLeverage(), 0)
+ "\n"
+ "Áàëàíñ: " + DoubleToStr(AccountBalance(), 2)
+ "\n"
+ "Âàëþòà ñ÷¸òà: " + AccountCurrency()
+ "\n"
+ "Ñðåäñòâà: " + DoubleToStr(AccountEquity(), 2)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Èíôîðìàöèÿ î ìàðæå:"
+ "\n"
+ "Ñâîáîäíàÿ ìàðæà: " + DoubleToStr(AccountFreeMargin(), 2)
+ "\n"
+ "Èñïîëüçóåìàÿ ìàðæà: " + DoubleToStr(AccountMargin(), 2)
+ "\n"
+ "------------------------------------------------"
+ "\n"
+ "Òåêóùåå âðåìÿ ñåðâåðà: " + TimeToStr(TimeCurrent(), TIME_SECONDS)
+ "\n"
+ "Ëèöåíçèÿ äî: " + TimeToStr(gia_888[0], TIME_DATE)
+ "\n"
+ "------------------------------------------------");
}
}
if (Scalper_StealthMode) WatchLevels();
if (Scalper_UseCustomLevels) NoiseFilter();
SetOrderLevels();
if (gi_1124 != gi_1128 || Scalper_StartSessionMinute != Scalper_EndSessionMinute) {
if (Scalper_ProfitLimit > 0.0) {
if (ld_8 >= Scalper_ProfitLimit) {
CloseAllSymbols();
return;
}
}
if (Scalper_LossLimit > 0.0) {
if (ld_8 <= -1.0 * Scalper_LossLimit) {
CloseAllSymbols();
return;
}
}
}
if (gi_864 == 0) {
if (NormalizeDouble(Ask - Bid, Digits) > gd_1196) {
if (WriteLog && !gi_1012) {
if (gi_828 == 0) {
Print("Trade signal is missed due to invalid high spread.");
Print("Current spread = ", DoubleToStr(NormalizeDouble(Ask - Bid, Digits), Digits), ", MaxSpread = ", DoubleToStr(gd_1196, Digits));
Print("Fapturbo will try again later when spreads come to normal.");
} else {
Print("Òîðãîâûé ñèãíàë ïðîïóùåí èç-çà áîëüøîãî ñïðåäà.");
Print("Òåêóùèé ñïðåä = ", DoubleToStr(NormalizeDouble(Ask - Bid, Digits), Digits), ", MaxSpread = ", DoubleToStr(gd_1196, Digits));
Print("Fapturbo áóäåò ïðîáîâàòü ïîçæå, êîãäà ñïðåä ñòàíåò äîïóñòèìûì.");
}
}
gi_1012 = TRUE;
} else {
gi_1012 = FALSE;
l_day_of_week_16 = TimeDayOfWeek(g_datetime_1024 - 3600 * Scalper_ManualGMToffset);
if (l_day_of_week_16 == 0 || l_day_of_week_16 > 5) return;
if (!Scalper_TradeFriday)
if (l_day_of_week_16 >= 5) return;
if (!Scalper_TradeMonday)
if (l_day_of_week_16 <= 1) return;
if (l_day_of_week_16 == 1 && TimeHour(g_datetime_1024 - 3600 * Scalper_ManualGMToffset) < Scalper_StartWorkTimeHour || (TimeHour(g_datetime_1024 - 3600 * Scalper_ManualGMToffset) == Scalper_StartWorkTimeHour &&
TimeMinute(g_datetime_1024) < Scalper_StartSessionMinute)) return;
if (Scalper_IsTradeTime(g_datetime_1024, gi_1124, Scalper_StartSessionMinute, gi_1128, Scalper_EndSessionMinute)) {
if (Scalper_RelaxHours > 0)
if (Scalper_IsRelaxHours()) return;
if (Scalper_SimpleHeightFilter)
if (Scalper_CheckSimpleHeightFilter()) return;
if (Scalper_TrendFilter)
if (Scalper_CheckTrendFilter()) return;
if (Scalper_OneTrade != 0) {
if (Scalper_HaveTrade()) {
if (!(WriteDebugLog)) return;
if (gi_828 == 0) {
Print("Already have one trade inside this interval of time.");
return;
}
Print("Óæå åñòü îäíà ñäåëêà âíóòðè ýòîãî èíòåðâàëà âðåìåíè.");
return;
}
}
if (Scalper_OneOpenTrade) {
if (HaveAllOrders() > 0) {
if (!(WriteDebugLog)) return;
if (gi_828 == 0) {
Print("Already have open order with MagicNumber = ", g_magic_876);
return;
}
Print("Óæå åñòü îäèí îðäåð ñ MagicNumber = ", g_magic_876);
return;
}
}
HideTestIndicators(TRUE);
l_irsi_20 = iRSI(NULL, 0, g_period_768, PRICE_CLOSE, 0);
l_irsi_28 = iRSI(NULL, PERIOD_M1, g_period_776, PRICE_CLOSE, 0);
l_ima_36 = iMA(NULL, 0, g_period_764, 0, MODE_SMA, PRICE_MEDIAN, 1);
HideTestIndicators(FALSE);
if (Scalper_ReverseTrade == 0) li_44 = fun2(Ask + 0.0002, ExistPosition(), l_irsi_20, l_irsi_28, gi_780, gi_772, l_ima_36, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, g_datetime_1024, gia_908, gia_884, g_bool_868, gia_888);
else li_44 = fun3(Bid - 0.0002, ExistPosition(), l_irsi_20, l_irsi_28, gi_1040, gi_1036, l_ima_36, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, g_datetime_1024, gia_908, gia_884, g_bool_868, gia_888);
if (li_44 == 16) gi_856 = FALSE;
else {
if (li_44 == 32) gi_864 = TRUE;
else {
if (li_44 == 1) {
if (gi_1016) {
if (!Scalper_UseFilterMA) l_count_48 = 0;
else {
l_ima_52 = iMA(NULL, 0, Scalper_PeriodFilterMA, 0, Scalper_MethodFilterMA, Scalper_PriceFilterMA, 0);
if (Close[0] <= l_ima_52) l_count_48++;
}
if (l_count_48 == 0) {
OpenPosition(OP_BUY, gi_1052, gi_1056);
gi_1016 = FALSE;
gi_1020 = TRUE;
}
}
}
if (Scalper_ReverseTrade == 0) li_44 = fun3(Bid - 0.0002, ExistPosition(), l_irsi_20, l_irsi_28, gi_1040, gi_1036, l_ima_36, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, g_datetime_1024, gia_908, gia_884, g_bool_868, gia_888);
else li_44 = fun2(Ask + 0.0002, ExistPosition(), l_irsi_20, l_irsi_28, gi_780, gi_772, l_ima_36, g_acc_number_892, g_acc_number_892, gia_896, gia_900, gia_904, g_datetime_1024, gia_908, gia_884, g_bool_868, gia_888);
if (li_44 == 16) gi_856 = FALSE;
else {
if (li_44 == 32) gi_864 = TRUE;
else {
if (li_44 == 1) {
if (gi_1020) {
if (!Scalper_UseFilterMA) l_count_48 = 0;
else {
l_ima_52 = iMA(NULL, 0, Scalper_PeriodFilterMA, 0, Scalper_MethodFilterMA, Scalper_PriceFilterMA, 0);
if (Close[0] >= l_ima_52) l_count_48++;
}
if (l_count_48 == 0) {
OpenPosition(OP_SELL, gi_1052, gi_1056);
gi_1020 = FALSE;
gi_1016 = TRUE;
}
}
}
if (fun4(l_irsi_20, gi_1044, gi_1048)) {
gi_1020 = TRUE;
gi_1016 = 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() == g_magic_876) {
if (OrderSymbol() == g_symbol_972) {
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(), Digits);
ld_32 = NormalizeDouble(OrderClosePrice(), Digits);
ld_40 = NormalizeDouble(OrderStopLoss(), Digits);
if (OrderType() == OP_BUY) {
if (ld_32 <= ld_40 && ld_40 != 0.0) li_20 = TRUE;
else
if (NormalizeDouble(ld_24 - ld_32, Digits) >= gd_1212) li_20 = TRUE;
} else {
if (ld_32 >= ld_40 && ld_40 != 0.0) li_20 = TRUE;
else
if (NormalizeDouble(ld_32 - ld_24, Digits) >= gd_1212) 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 < Scalper_RelaxHours) {
l_datetime_52 = iTime(NULL, PERIOD_H1, 0);
if (g_datetime_1032 != l_datetime_52) {
if (WriteLog) {
if (gi_828 == 0) Print("Relax Hours Left = " + DoubleToStr(l_shift_48 - Scalper_RelaxHours, 0) + " (after StopLoss).");
else Print("Îñòàëîñü Relax ÷àñîâ = " + DoubleToStr(l_shift_48 - Scalper_RelaxHours, 0) + " (ïîñëå StopLoss).");
}
g_datetime_1032 = l_datetime_52;
}
return (TRUE);
}
return (FALSE);
}

bool Scalper_CheckTrendFilter() {
double ld_4;
double ld_12;
double ld_20;
if (gi_800 <= 0) return (FALSE);
for (int li_0 = 0; li_0 <= gi_804; li_0++) {
ld_4 = NormalizeDouble(iMA(NULL, 0, g_period_788, 0, g_ma_method_796, g_applied_price_792, li_0), gi_880);
ld_12 = NormalizeDouble(iMA(NULL, 0, g_period_788, 0, g_ma_method_796, g_applied_price_792, li_0 + gi_800), gi_880);
ld_20 = 100.0 * MathAbs(ld_4 - ld_12) / ld_12;
if (ld_20 > gd_1132) break;
}
if (li_0 > gi_804) return (FALSE);
if (WriteDebugLog) {
if (gi_828 == 0) Print("Today market is in risky conditions. Trading is forbidden by the filter TrendFilter.");
else Print("Ñåãîäíÿ ðûíîê â îïàñíîì ñîñòîÿíèè. Òîðãîâëÿ çàïðåùåíà ôèëüòðîì TrendFilter.");
if (li_0 != 0) {
if (gi_828 == 0) Print("Relax Bars Left = " + DoubleToStr(gi_804 - li_0, 0) + " (after MaxPercentMove).");
else Print("Îñòàëîñü Relax áàðîâ = " + DoubleToStr(gi_804 - li_0, 0) + " (ïîñëå 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_880) > gd_1220) li_0 = TRUE;
if (NormalizeDouble(iHigh(NULL, PERIOD_M15, 2) - iLow(NULL, PERIOD_M15, 2), gi_880) > gd_1220) li_0 = TRUE;
if (li_0) {
l_datetime_4 = iTime(NULL, PERIOD_M15, 0);
if (g_datetime_1028 != l_datetime_4) {
if (WriteLog) {
if (gi_828 == 0) Print("Today market is in risky conditions. Trade is forbidden by the filter SimpleHeightFilter.");
else Print("Ñåãîäíÿ ðûíîê â îïàñíîì ñîñòîÿíèè. Òîðãîâëÿ çàïðåùåíà ôèëüòðîì SimpleHeightFilter.");
}
g_datetime_1028 = l_datetime_4;
}
return (TRUE);
}
return (FALSE);
}

bool Scalper_IsTradeTime(int ai_0, int ai_4, int ai_8, int ai_12, int ai_16) {
int li_28;
int li_32;
int l_hour_20 = TimeHour(ai_0);
int l_minute_24 = TimeMinute(ai_0);
if (ai_4 == ai_12 && ai_8 == ai_16) return (TRUE);
if (ai_16 == 0) {
if (ai_12 == 0) li_28 = 23;
else li_28 = ai_12 - 1;
li_32 = 59;
} else {
li_28 = ai_12;
li_32 = ai_16 - 1;
}
if (ai_4 == li_28) {
if (ai_8 == li_32) return (TRUE);
if (ai_8 < li_32) {
if (l_hour_20 != ai_4) return (FALSE);
if (l_minute_24 < ai_8 || l_minute_24 > li_32) return (FALSE);
return (TRUE);
}
if (ai_8 > li_32) {
if (l_hour_20 == ai_4)
if (l_minute_24 < ai_8 && l_minute_24 > li_32) return (FALSE);
return (TRUE);
}
}
if (ai_4 < li_28) {
if (l_hour_20 < ai_4 || l_hour_20 > li_28) return (FALSE);
if (l_hour_20 == ai_4 && l_minute_24 < ai_8) return (FALSE);
if (l_hour_20 == li_28 && l_minute_24 > li_32) return (FALSE);
return (TRUE);
}
if (ai_4 > li_28) {
if (l_hour_20 < ai_4 && l_hour_20 > li_28) return (FALSE);
if (l_hour_20 == ai_4 && l_minute_24 < ai_8) return (FALSE);
if (l_hour_20 == li_28 && l_minute_24 > li_32) return (FALSE);
return (TRUE);
}
return (TRUE);
}

int ExistPosition() {
int li_0 = OrdersTotal() - 1;
for (int l_pos_4 = li_0; l_pos_4 >= 0; l_pos_4--) {
if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
if (OrderMagicNumber() == g_magic_876) {
if (OrderSymbol() == g_symbol_972)
if (OrderType() <= OP_SELL) return (1);
}
}
}
return (0);
}

int OpenPosition(int a_cmd_0, int ai_unused_4, int ai_unused_8) {
int li_12;
double l_price_24;
color l_color_32;
int l_ticket_40;
int l_error_44;
string ls_48;
double l_price_56;
if (gi_260 > 0) {
MathSrand(TimeLocal());
li_12 = MathRand() % gi_260;
if (WriteDebugLog) {
if (gi_828 == 0) Print("DelayRandomiser: delay ", li_12, " seconds.");
else Print("DelayRandomiser: çàäåðæêà ", li_12, " ñåêóíä.");
}
Sleep(1000 * li_12);
}
double ld_16 = LotsOptimized();
if (AccountFreeMarginCheck(g_symbol_972, a_cmd_0, ld_16) <= 0.0 || GetLastError() == 134/* NOT_ENOUGH_MONEY */)
{
if (gi_828 == 0) {
Print("You don\'t have free margin.");
Comment("You don\'t have free margin.");
} else {
Print("Äëÿ îòêðûòèÿ îðäåðà íåäîñòàòî÷íî ñâîáîäíîé ìàðæè.");
Comment("Äëÿ îòêðûòèÿ îðäåðà íåäîñòàòî÷íî ñâîáîäíîé ìàðæè.");
}
return (-1);
}
RefreshRates();
if (a_cmd_0 == OP_BUY) {
l_price_24 = Ask;
l_color_32 = ColorBuy;
} else {
l_price_24 = Bid;
l_color_32 = ColorSell;
}
int li_36 = gi_912;
while (li_36 > 0) {
l_ticket_40 = OrderSend(g_symbol_972, a_cmd_0, ld_16, l_price_24, g_slippage_920, 0, 0, Scalper_ExpertComment, g_magic_876, 0, l_color_32);
Sleep(MathRand() / 1000);
if (l_ticket_40 < 0) {
l_error_44 = GetLastError();
if (WriteDebugLog) {
if (a_cmd_0 == OP_BUY) ls_48 = "OP_BUY";
else ls_48 = "OP_SELL";
Print("Open: OrderSend(", ls_48, ") error = ", ErrorDescription(l_error_44));
}
if (l_error_44 != 136/* OFF_QUOTES */) break;
if (!(gi_824)) break;
Sleep(6000);
RefreshRates();
if (a_cmd_0 == OP_BUY) l_price_56 = Ask;
else l_price_56 = Bid;
if (NormalizeDouble(MathAbs((l_price_56 - l_price_24) / gd_924), 0) > gi_916) break;
l_price_24 = l_price_56;
li_36--;
if (li_36 > 0) {
if (gi_828 == 0) Print("... Possible to open order.");
else Print("... Âîçìîæíî îòêðûòü îðäåð.");
}
ld_16 = NormalizeDouble(ld_16 / 2.0, gi_872);
if (ld_16 < g_minlot_940) ld_16 = g_minlot_940;
} else {
if (OrderSelect(l_ticket_40, SELECT_BY_TICKET)) l_price_24 = OrderOpenPrice();
if (SendEmail) {
if (gi_828 == 0) {
SendMail(gs_980, StringConcatenate("Fapturbo Trade Information\nCurrency Pair: ", StringSubstr(g_symbol_972, 0, 6),
"\nTime: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nOrder Type: ", OrderTypeToStr(a_cmd_0),
"\nPrice: ", DoubleToStr(l_price_24, Digits),
"\nLot size: ", DoubleToStr(ld_16, gi_872),
"\nEvent: Trade Opened",
"\n\nCurrent Balance: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nCurrent Equity: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
} else {
SendMail(gs_996, StringConcatenate("Fapturbo òîðãîâàÿ èíôîðìàöèÿ\nÂàëþòíàÿ ïàðà: ", StringSubstr(g_symbol_972, 0, 6),
"\nÂðåìÿ: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nÒèï îðäåðà: ", OrderTypeToStr(a_cmd_0),
"\nÖåíà: ", DoubleToStr(l_price_24, Digits),
"\nÐàçìåð ëîòà: ", DoubleToStr(ld_16, gi_872),
"\nÑîáûòèå: îòêðûòèå îðäåðà",
"\n\nÒåêóùèé áàëàíñ: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nÒåêóùèå ñðåäñòâà: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
}
}
if (!(SoundAlert)) break;
PlaySound(SoundFileAtOpen);
break;
}
}
return (l_ticket_40);
}

void NoiseFilter() {
int li_12;
double ld_16;
double ld_24;
int li_32;
double ld_36;
int li_unused_0 = MarketInfo(g_symbol_972, 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() == g_magic_876) {
if (OrderType() <= OP_SELL) {
if (OrderSymbol() == g_symbol_972) {
li_12 = g_datetime_1024 - OrderOpenTime();
if (li_12 > gi_1104) {
ld_16 = NormalizeDouble(OrderClosePrice(), Digits);
ld_24 = NormalizeDouble(OrderOpenPrice(), Digits);
li_32 = 0;
if (OrderType() == OP_BUY) ld_36 = ld_16 - ld_24;
else ld_36 = ld_24 - ld_16;
if (li_12 < gi_1108 && ld_36 >= gd_1156) li_32 = 1;
else {
if (li_12 > gi_1108 && li_12 < gi_1112 && ld_36 >= gd_1164) li_32 = 2;
else {
if (li_12 > gi_1112 && li_12 < gi_1116 && ld_36 >= gd_1172) li_32 = 3;
else {
if (li_12 > gi_1116 && li_12 < gi_1120 && ld_36 >= gd_1180) li_32 = 4;
else
if (li_12 > gi_1120 && ld_36 >= gd_1188) li_32 = 5;
}
}
}
if (li_32 != 0) CloseOrder(OrderTicket(), OrderLots(), OrderType(), g_slippage_920);
}
}
}
}
}
}
}

void WatchLevels() {
double ld_12;
double ld_20;
double ld_28;
if (gi_1052 <= 0 && gi_1056 <= 0) return;
int li_unused_0 = MarketInfo(g_symbol_972, 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() == g_magic_876) {
if (OrderType() <= OP_SELL) {
if (OrderSymbol() == g_symbol_972) {
ld_12 = NormalizeDouble(OrderClosePrice(), Digits);
ld_20 = NormalizeDouble(OrderOpenPrice(), Digits);
if (OrderType() == OP_BUY) {
ld_28 = ld_12 - ld_20;
if ((gd_1140 > 0.0 && ld_28 >= gd_1140) || (gd_1148 < 0.0 && ld_28 <= gd_1148)) {
if (WriteDebugLog) {
if (gi_828 == 0) Print("WatchLevels: level for close BUY");
else Print("WatchLevels: óðîâåíü äëÿ çàêðûòèÿ BUY");
}
CloseOrder(OrderTicket(), OrderLots(), 0, g_slippage_920);
}
} else {
ld_28 = ld_20 - ld_12;
if ((gd_1140 > 0.0 && ld_28 >= gd_1140) || (gd_1148 < 0.0 && ld_28 <= gd_1148)) {
if (WriteDebugLog) {
if (gi_828 == 0) Print("WatchLevels: level for close SELL");
else Print("WatchLevels: óðîâåíü äëÿ çàêðûòèÿ SELL");
}
CloseOrder(OrderTicket(), OrderLots(), 1, g_slippage_920);
}
}
}
}
}
}
}
}

double LotsOptimized() {
if (!Scalper_UseMM) return (Scalper_Lots);
double ld_0 = AccountFreeMargin() * gd_964 / 100.0;
double ld_ret_8 = NormalizeDouble(MathFloor(ld_0 / gd_956) * g_lotstep_948, gi_872);
if (ld_ret_8 < g_minlot_940) ld_ret_8 = g_minlot_940;
if (ld_ret_8 > g_maxlot_932) ld_ret_8 = g_maxlot_932;
if (ld_ret_8 > Scalper_MaxLots) ld_ret_8 = Scalper_MaxLots;
return (ld_ret_8);
}

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_972, 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() == g_magic_876) {
if (OrderType() <= OP_SELL) {
if (OrderSymbol() == g_symbol_972) {
ld_16 = NormalizeDouble(OrderClosePrice(), gi_880);
l_price_24 = NormalizeDouble(OrderOpenPrice(), gi_880);
ld_32 = NormalizeDouble(OrderStopLoss(), gi_880);
ld_40 = NormalizeDouble(OrderTakeProfit(), gi_880);
li_48 = TRUE;
li_52 = 0;
li_56 = 0;
if (ld_32 == 0.0) {
if (Scalper_StealthMode) li_52 = gi_808 + MathRand() % gi_812;
else li_52 = gi_1056;
if (li_52 != 0) {
if (OrderType() == OP_BUY) {
l_price_60 = NormalizeDouble(l_price_24 - li_52 * gd_924, gi_880);
if (ld_16 - l_price_60 <= ld_0) li_48 = FALSE;
} else {
l_price_60 = NormalizeDouble(l_price_24 + li_52 * gd_924, gi_880);
if (l_price_60 - ld_16 <= ld_0) li_48 = FALSE;
}
}
} else l_price_60 = ld_32;
if (ld_40 == 0.0) {
if (Scalper_StealthMode) li_56 = gi_816 + MathRand() % gi_820;
else li_56 = gi_1052;
if (li_56 != 0) {
if (OrderType() == OP_BUY) {
l_price_68 = NormalizeDouble(l_price_24 + li_56 * gd_924, gi_880);
if (l_price_68 - ld_16 <= ld_0) li_48 = FALSE;
} else {
l_price_68 = NormalizeDouble(l_price_24 - li_56 * gd_924, gi_880);
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) {
while (!IsTradeAllowed()) Sleep(1000);
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: OrderModify(OP_SELL) error = ", GetLastError());
}
}
}
}
}
}
}

bool Scalper_HaveTrade() {
int l_datetime_28;
if (gi_1124 == gi_1128 && Scalper_StartSessionMinute == Scalper_EndSessionMinute) 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_1124 > gi_1128)
if (l_hour_8 < gi_1124) li_4 -= 86400;
li_4 += 3600 * gi_1124 + 60 * Scalper_StartSessionMinute;
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() == g_magic_876) {
if (OrderSymbol() == g_symbol_972) {
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() == g_magic_876) {
if (OrderSymbol() == g_symbol_972) {
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);
}

int CloseOrder(int a_ticket_0, double a_lots_4, int ai_12, int a_slippage_16) {
color l_color_20;
double l_price_40;
bool l_ord_close_48;
int l_error_52;
string ls_56;
bool li_64;
if (ai_12 == 0) l_color_20 = ColorBuy;
else l_color_20 = ColorSell;
int l_count_24 = 0;
int l_count_28 = 0;
int l_count_32 = 0;
int l_count_36 = 0;
while (true) {
while (!IsTradeAllowed()) Sleep(1000);
RefreshRates();
if (ai_12 == 0) l_price_40 = NormalizeDouble(Bid, Digits);
else l_price_40 = NormalizeDouble(Ask, Digits);
l_ord_close_48 = OrderClose(a_ticket_0, a_lots_4, l_price_40, a_slippage_16, l_color_20);
if (!l_ord_close_48) {
l_error_52 = GetLastError();
if (WriteDebugLog) {
if (ai_12 == 0) ls_56 = "BUY";
else ls_56 = "SELL";
Print("OrderClose(", ls_56, ",", a_ticket_0, ") error = ", ErrorDescription(l_error_52));
}
li_64 = FALSE;
switch (l_error_52) {
case 0/* NO_ERROR */:
Sleep(10000);
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET))
if (OrderCloseTime() == 0) li_64 = TRUE;
break;
case 1/* NO_RESULT */: break;
case 2/* COMMON_ERROR */: break;
case 3/* INVALID_TRADE_PARAMETERS */: break;
case 4/* SERVER_BUSY */: break;
case 5/* OLD_VERSION */: break;
case 6/* NO_CONNECTION */:
Sleep(10000);
if (IsConnected()) li_64 = TRUE;
break;
case 7/* NOT_ENOUGH_RIGHTS */: break;
case 8/* TOO_FREQUENT_REQUESTS */: break;
case 9/* MALFUNCTIONAL_TRADE */: break;
case 64/* ACCOUNT_DISABLED */: break;
case 65/* INVALID_ACCOUNT */: break;
case 128/* TRADE_TIMEOUT */:
Sleep(70000);
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET))
if (OrderCloseTime() == 0) li_64 = TRUE;
break;
case 129/* INVALID_PRICE */:
Sleep(6000);
l_count_24++;
if (l_count_24 <= 3) li_64 = TRUE;
break;
case 130/* INVALID_STOPS */:
Sleep(6000);
l_count_28++;
if (l_count_28 <= 3) li_64 = TRUE;
break;
case 131/* INVALID_TRADE_VOLUME */: break;
case 132/* MARKET_CLOSED */: break;
case 133/* TRADE_DISABLED */: break;
case 134/* NOT_ENOUGH_MONEY */: break;
case 135/* PRICE_CHANGED */:
li_64 = TRUE;
break;
case 136/* OFF_QUOTES */:
Sleep(6000);
li_64 = TRUE;
break;
case 137/* BROKER_BUSY */:
Sleep(20000);
l_count_32++;
if (l_count_32 <= 3) li_64 = TRUE;
break;
case 138/* REQUOTE */:
l_count_36++;
if (l_count_36 <= 3) li_64 = TRUE;
break;
case 139/* ORDER_LOCKED */: break;
case 140/* LONG_POSITIONS_ONLY_ALLOWED */: break;
case 141/* TOO_MANY_REQUESTS */: break;
case 142:
Sleep(70000);
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET))
if (OrderCloseTime() == 0) li_64 = TRUE;
break;
case 143:
Sleep(70000);
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET))
if (OrderCloseTime() == 0) li_64 = TRUE;
break;
case 144: break;
case 145/* TRADE_MODIFY_DENIED */:
Sleep(20000);
li_64 = TRUE;
break;
case 146/* TRADE_CONTEXT_BUSY */:
while (IsTradeContextBusy()) Sleep(1000);
li_64 = TRUE;
break;
case 147/* ERR_TRADE_EXPIRATION_DENIED */: break;
case 148/* ERR_TRADE_TOO_MANY_ORDERS */: break;
case 4000/* NO_MQLERROR */:
Sleep(10000);
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET))
if (OrderCloseTime() == 0) li_64 = TRUE;
case 4051/* INVALID_FUNCTION_PARAMETER_VALUE */: break;
case 4062/* STRING_PARAMETER_EXPECTED */: break;
case 4063/* INTEGER_PARAMETER_EXPECTED */: break;
case 4064/* DOUBLE_PARAMETER_EXPECTED */: break;
case 4105/* NO_ORDER_SELECTED */: break;
case 4106/* UNKNOWN_SYMBOL */: break;
case 4107/* INVALID_PRICE_PARAM */: break;
case 4108/* INVALID_TICKET */: break;
case 4109/* TRADE_NOT_ALLOWED */: break;
case 4110/* LONGS__NOT_ALLOWED */: break;
case 4111/* SHORTS_NOT_ALLOWED */: break;
}
if (!(li_64)) break;
continue;
}
if (OrderSelect(a_ticket_0, SELECT_BY_TICKET)) l_price_40 = OrderClosePrice();
if (SendEmail) {
if (gi_828 == 0) {
SendMail(gs_988, StringConcatenate("Fapturbo Trade Information\nCurrency Pair: ", StringSubstr(g_symbol_972, 0, 6),
"\nTime: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nOrder Type: ", OrderTypeToStr(ai_12),
"\nPrice: ", DoubleToStr(l_price_40, Digits),
"\nLot size: ", DoubleToStr(a_lots_4, gi_872),
"\nEvent: Trade Closed",
"\n\nCurrent Balance: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nCurrent Equity: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
} else {
SendMail(gs_1004, StringConcatenate("Fapturbo òîðãîâàÿ èíôîðìàöèÿ\nÂàëþòíàÿ ïàðà: ", StringSubstr(g_symbol_972, 0, 6),
"\nÂðåìÿ: ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS),
"\nÒèï îðäåðà: ", OrderTypeToStr(ai_12),
"\nÖåíà: ", DoubleToStr(l_price_40, Digits),
"\nÐàçìåð ëîòà: ", DoubleToStr(a_lots_4, gi_872),
"\nÑîáûòèå: çàêðûòèå îðäåðà",
"\n\nÒåêóùèé áàëàíñ: ", DoubleToStr(AccountBalance(), 2), " ", AccountCurrency(),
"\nÒåêóùèå ñðåäñòâà: ", DoubleToStr(AccountEquity(), 2), " ", AccountCurrency()));
}
}
if (!(SoundAlert)) break;
PlaySound(SoundFileAtClose);
break;
}
return (l_ord_close_48);
}

void Compress(int &aia_0[100], string as_4) {
int li_24;
int li_28;
int li_32;
int li_36;
int li_12 = StringLen(as_4);
int li_16 = 0;
for (int l_index_20 = 0; li_12 > 0; l_index_20++) {
if (li_12 < 4) li_24 = 0;
else {
li_24 = StringGetChar(as_4, li_16 + 3);
li_24 <<= 24;
}
if (li_12 < 3) li_28 = 0;
else {
li_28 = StringGetChar(as_4, li_16 + 2);
li_28 <<= 16;
}
if (li_12 < 2) li_32 = 0;
else {
li_32 = StringGetChar(as_4, li_16 + 1);
li_32 <<= 8;
}
if (li_12 < 1) li_36 = 0;
else li_36 = StringGetChar(as_4, li_16);
aia_0[l_index_20] = li_24 | li_28 | li_32 | li_36;
li_12 -= 4;
li_16 += 4;
}
aia_0[l_index_20] = 0;
}

int HaveAllOrders() {
int l_count_0 = 0;
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 (OrderMagicNumber() == g_magic_876) l_count_0++;
}
return (l_count_0);
}

string OrderTypeToStr(int ai_0) {
string ls_ret_8;
switch (ai_0) {
case 0:
ls_ret_8 = "Buy";
break;
case 1:
ls_ret_8 = "Sell";
break;
case 2:
ls_ret_8 = "BuyLimit";
break;
case 3:
ls_ret_8 = "SellLimit";
break;
case 4:
ls_ret_8 = "BuyStop";
break;
case 5:
ls_ret_8 = "SellStop";
break;
default:
ls_ret_8 = "Unknown";
}
return (ls_ret_8);
}

double CalculateProfitSession() {
int li_16;
int l_datetime_20;
int l_hour_24;
int li_unused_28;
double ld_ret_0 = 0;
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("CalculateProfitSession: OrderSelect() error = ", GetLastError());
} else
if (OrderMagicNumber() == g_magic_876) ld_ret_0 += OrderProfit() + OrderSwap() + OrderCommission();
}
if (gi_1124 == gi_1128 && Scalper_StartSessionMinute == Scalper_EndSessionMinute) li_16 = 0;
else {
l_datetime_20 = TimeCurrent();
li_16 = iTime(NULL, PERIOD_D1, 0);
l_hour_24 = TimeHour(l_datetime_20);
li_unused_28 = 0;
if (gi_1124 > gi_1128)
if (l_hour_24 < gi_1124) li_16 -= 86400;
li_16 += 3600 * gi_1124 + 60 * Scalper_StartSessionMinute;
}
li_8 = OrdersHistoryTotal() - 1;
for (l_pos_12 = li_8; l_pos_12 >= 0; l_pos_12--) {
if (!OrderSelect(l_pos_12, SELECT_BY_POS, MODE_HISTORY)) {
if (WriteDebugLog) Print("CalculateProfitSession: OrderSelect() error = ", GetLastError());
} else {
if (OrderMagicNumber() == g_magic_876)
if (OrderCloseTime() >= li_16) ld_ret_0 += OrderProfit() + OrderSwap() + OrderCommission();
}
}
return (ld_ret_0);
}

int CloseAllSymbols() {
int l_cmd_12;
bool l_ord_delete_16;
int li_ret_0 = 0;
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("CloseAllSymbols: OrderSelect() error = ", GetLastError());
} else {
if (OrderMagicNumber() == g_magic_876) {
l_cmd_12 = OrderType();
RefreshRates();
while (!IsTradeAllowed()) Sleep(1000);
if (l_cmd_12 <= OP_SELL) l_ord_delete_16 = CloseOrder(OrderTicket(), OrderLots(), l_cmd_12, g_slippage_920);
else {
l_ord_delete_16 = OrderDelete(OrderTicket());
if (!l_ord_delete_16)
if (WriteDebugLog) Print("CloseAllSymbols: OrderDelete() error = ", GetLastError());
}
if (!l_ord_delete_16) li_ret_0 = -1;
}
}
}
return (li_ret_0);
}

int AutoGMTCalculation() {
string ls_8;
int li_ret_16;
int li_20;
gi_848 = InternetOpenA(gs_840, 0, "0", "0", 0);
string ls_0 = "XXXXXXXXXX";
if (!GetData(gs_832, ls_0)) {
if (gi_828 == 0) ls_8 = "Error getting data to server.";
else ls_8 = "Îøèáêà ïðè ïîëó÷åíèè äàííûõ ñ ñåðâåðà.";
Comment(ls_8);
Print(ls_8);
li_ret_16 = -2147483648;
} else {
li_20 = TimeCurrent() - StrToInteger(ls_0);
li_ret_16 = MathFloor((li_20 + 1800) / 3600);
}
InternetCloseHandle(gi_848);
return (li_ret_16);
}

bool GetData(string as_0, string &as_8) {
int li_16 = InternetOpenUrlA(gi_848, as_0, "0", 0, -2080374528, 0);
if (li_16 == 0) return (FALSE);
int lia_20[] = {1};
string ls_24 = "xxxxxxxxxx";
int li_32 = InternetReadFile(li_16, ls_24, 10, lia_20);
if (li_16 != 0) InternetCloseHandle(li_16);
as_8 = ls_24;
return (TRUE);
}