#property copyright "Copyright © forexeasystems" #property link "http://www.forexeasystems.com" #include #import "EA_GRIFFIN3.0_ULTIMATE_Proxy.dll" int Init(string a0, string a1, int a2, double a3, double a4, int a5, double a6, double a7, int a8, int a9, string a10, int a11, double a12, int a13, string a14); double GetBid(string a0, double a1); double MoneyManagement(double a0, double a1, double a2); #import "EA_GRIFFIN3.0_ULTIMATE_Version.dll" string Version(string a0); #import extern string TRADINGPARAMETER = ""; extern int MagicNumber = 853953; extern double Lots = 0.1; extern bool Moneymanagement = TRUE; extern int MaximumRisk = 1; extern int MaxSlippage = 10; extern bool Fridaymode = FALSE; extern double MaxTradesize = 100.0; extern bool ShowMarketInfo = FALSE; extern bool FractionalLots = FALSE; extern bool ST_TP_Pending_Mode = FALSE; int gi_132 = 33; int gi_136 = 7; bool gi_unused_140 = FALSE; int gi_unused_144 = 9; int gi_unused_148 = 1; string gs_152 = "ExpertAdvisor_G"; string gs_160 = "EA GRIFFIN ULTIMATE 3.0 Build 01"; int gi_168 = 1; double gd_172; string g_symbol_180; int gi_188 = 1; int gi_192; int gi_196; int gi_200 = 1; bool gi_204 = TRUE; int gi_208 = 0; int GetMarketInfo() { double l_time_0; double l_bid_8; double l_ask_16; double l_spread_24; double l_swaplong_32; double l_swapshort_40; HideTestIndicators(TRUE); if (ShowMarketInfo == TRUE) { l_time_0 = MarketInfo(Symbol(), MODE_TIME); l_bid_8 = MarketInfo(Symbol(), MODE_BID); l_ask_16 = MarketInfo(Symbol(), MODE_ASK); l_spread_24 = MarketInfo(Symbol(), MODE_SPREAD); l_swaplong_32 = MarketInfo(Symbol(), MODE_SWAPLONG); l_swapshort_40 = MarketInfo(Symbol(), MODE_SWAPSHORT); Print("ModeTime:", l_time_0); Print("ModeBid:", l_bid_8); Print("ModeAsk:", l_ask_16); Print("ModeSpread:", l_spread_24); Print("ModeSwapLong:", l_swaplong_32); Print("ModeSwapShort:", l_swapshort_40); } return (0); } int init() { double l_lotstep_0; if (IsLibrariesAllowed() == FALSE) { Print("EA GRIFFIN 3.0>> PLEASE ALLOW EX4 IMPORT"); Alert("EA GRIFFIN 3.0>> PLEASE ALLOW EX4 IMPORT"); return (0); } if (IsDllsAllowed() == FALSE) { Print("EA GRIFFIN 3.0>> PLEASE ALLOW DLL IMPORT"); Alert("EA GRIFFIN 3.0 >> PLEASE ALLOW DLL IMPORT"); return (0); } if (FractionalLots == TRUE) { l_lotstep_0 = MarketInfo(Symbol(), MODE_LOTSTEP); if (l_lotstep_0 != 0.01) Alert("EA GRIFFIN 3.0 ULTIMATE >> NOT SUPPORTED FRACTIONAL LOT"); } if (IsTradeContextBusy() == TRUE) Alert("EA GRIFFIN 3.0 ULTIMATE >> TRADE CONTEX BUSY"); if (IsStopped() == TRUE) Alert("EA GRIFFIN 3.0 ULTIMATE >> AUTO TRADING STOPPED BY BROKERSERVER"); if (Period() != PERIOD_M30) Alert("EA GRIFFIN 3.0 ULTIMATE >> PLEASE PLACE THE EA ON THE 30 MIN EURUSD CHART"); if (Bars < 1000) Alert("EA GRIFFIN 3.0 ULTIMATE >> LESS THEN 1000 BARS IN THE CHART - EA CANNOT WORK"); if (StringSubstr(Symbol(), 0, 6) != "EURUSD") Alert("EA GRIFFIN 3.0 ULTIMATE >> PLEASE PLACE THE EA ON THE 30 MIN EURUSD CHART"); if (MaximumRisk == 0) { Alert("EA GRIFFIN 3.0 ULTIMATE >> MAXIMUM RISK IS EQUAL NULL"); MaximumRisk = 1; } if (MaximumRisk > 100) { Alert("EA GRIFFIN 3.0 ULTIMATE >> MAXIMUM RISK OVER 100"); MaximumRisk = 100; } CheckVersion(); if (FractionalLots == TRUE && MarketInfo(Symbol(), MODE_LOTSTEP) == 0.01) gi_168 = 2; if (Digits == 5) gd_172 = 10.0 * Point; else gd_172 = Point; string ls_8 = StringSubstr(Symbol(), 0, 3); string ls_16 = StringSubstr(Symbol(), 3, 3); string ls_24 = ""; if (StringLen(Symbol()) > 6) ls_24 = StringSubstr(Symbol(), 6, StringLen(Symbol()) - 6); g_symbol_180 = AccountCurrency() + ls_16 + ls_24; double ld_32 = GetBid(g_symbol_180, MarketInfo(g_symbol_180, MODE_BID)); if (ld_32 == 0.0) { g_symbol_180 = ls_16 + AccountCurrency() + ls_24; ld_32 = GetBid(g_symbol_180, MarketInfo(g_symbol_180, MODE_BID)); if (ld_32 == 0.0) g_symbol_180 = ""; } Registered(); Comments(); return (0); } int deinit() { return (0); } void CheckVersion() { string ls_0; string ls_8; if (gi_204 != FALSE) { if (TimeCurrent() > gi_208) { ls_0 = ".........................................................."; ls_0 = Version(gs_152); if (ls_0 != gs_160) { Print("Current System Version: " + gs_160); Print("Actual System Version: " + ls_0); ls_8 = "Please close this application and run EA_GRIFFIN3.0_ULTIMATE_UPDATE.exe for updating the build version"; Print(ls_8); Alert(ls_8); gi_204 = FALSE; } gi_208 = TimeCurrent(); gi_208 += 3600 * gi_200; } } } void Registered() { Print("registering with Advisor:" + gs_152 + " Account:" + AccountName() + "..."); int l_bool_0 = IsTesting(); int l_bool_4 = IsOptimization(); gi_192 = Init(gs_152, AccountName(), Moneymanagement, Lots, MaxTradesize, MaximumRisk, MarketInfo(Symbol(), MODE_MINLOT), MarketInfo(Symbol(), MODE_MAXLOT), l_bool_0, l_bool_4, AccountCurrency(), AccountLeverage(), MarketInfo(Symbol(), MODE_LOTSIZE), gi_132, Symbol()); if (gi_192 == 0) { Print("You have registered"); return; } if (gi_192 == 1) { Print("No license for this account"); Alert("EA GRIFFIN 3.0 ULTIMATE >> No license for this account"); return; } if (gi_192 == -1) { Print("Error connect to DB for registrated"); Alert("EA GRIFFIN 3.0 ULTIMATE >> Error connect to DB for registrated"); gi_196 = TimeCurrent(); gi_196 += 3600 * gi_188; return; } Print("Unknown error"); } void Comments() { string ls_0 = "" + "\n" + "GRIFFIN 3.0 Ultimate © " + "\n" + "------------------------------------------------" + "\n" + "BROKER INFORMATIONS:" + "\n" + "Broker Company: " + AccountCompany() + "\n" + "------------------------------------------------" + "\n" + "ACCOUNT INFORMATIONS:" + "\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 INFORMATIONS:" + "\n" + "Free Margin: " + DoubleToStr(AccountFreeMargin(), 2) + "\n" + "Used Margin: " + DoubleToStr(AccountMargin(), 2) + "\n" + "------------------------------------------------" + "\n" + "Actual Server Time " + TimeToStr(TimeCurrent(), TIME_SECONDS); Comment(ls_0); } int start() { int li_0; double ld_4; if (gi_192 == 1) return (0); if (gi_192 == -1) { if (TimeCurrent() > gi_196) { Registered(); if (gi_192 != 0) gi_192 = 1; } } if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) CheckVersion(); GetMarketInfo(); if (StringSubstr(Symbol(), 0, 6) == "EURUSD") { Comments(); if (ST_TP_Pending_Mode == TRUE) SL_TP_Corrected(gi_132, gi_136, MagicNumber, gd_172); HandleOpenPositions(MagicNumber, MaxSlippage); li_0 = countPositions(MagicNumber); if (li_0 > 0) return (0); ld_4 = Moneymanagement(); if (AccountFreeMargin() < ld_4 * MarketInfo(Symbol(), MODE_LOTSTEP) / AccountLeverage()) { Alert("EA GRIFFIN 3.0 ULTIMATE >> NOT ENOUGH MARGIN!", AccountFreeMargin()); return (0); } OpenBuyOrder(ld_4, gi_132, gi_136, MaxSlippage, MagicNumber, gd_172, ST_TP_Pending_Mode, Fridaymode); OpenSellOrder(ld_4, gi_132, gi_136, MaxSlippage, MagicNumber, gd_172, ST_TP_Pending_Mode, Fridaymode); } return (0); } double Moneymanagement() { double ld_0 = MoneyManagement(AccountFreeMargin(), Bid, MarketInfo(g_symbol_180, MODE_BID)); return (NormalizeDouble(ld_0, gi_168)); }