//============================================================================= // LibDerksUtils.mqh // Copyright © 2006, Derk Wehler // ashwoods155@yahoo.com // // Companion header file for LibDerksUtils.mq4 // // // *************************************************************************** // *************************************************************************** // LICENSING: This is free, open source software, licensed under // Version 2 of the GNU General Public License (GPL). // // In particular, this means that distribution of this software in a binary // format, e.g. as compiled in as part of a .ex4 format, must be accompanied // by the non-obfuscated source code of both this file, AND the .mq4 source // files which it is compiled with, or you must make such files available at // no charge to binary recipients. If you do not agree with such terms you // must not use this code. Detailed terms of the GPL are widely available // on the Internet. The Library GPL (LGPL) was intentionally not used, // therefore the source code of files which link to this are subject to // terms of the GPL if binaries made from them are publicly distributed or // sold. // // ANY USE OF THIS CODE NOT CONFORMING TO THIS LICENSE MUST FIRST RECEIVE // PRIOR AUTHORIZATION FROM THE AUTHOR(S). ANY COMMERCIAL USE MUST FIRST // OBTAIN A COMMERCIAL LICENSE FROM THE AUTHOR(S). // // Copyright (2007), Derk Wehler, derkwehler@gmail.com // *************************************************************************** // *************************************************************************** // //============================================================================= #property copyright "Copyright © 2006, Derk Wehler" #property link "no site" #import "LibDerksUtils.ex4" #define OP_BOTH -1 #define ALL_OPEN -1 #define ALL_PENDING -1 #define ALL_PENDING_BUYS -2 #define ALL_PENDING_SELLS -3 // Money Management Helper Functions double CalcLotsMM(double TradeSizePercent, double MinLots, double MaxLots); double CalcLotsGivenRisk(double RiskPercent, double MinLots, double MaxLots, int StopLoss); double GetDualWinLots(double begLots, int magic, int TP_Pips, int SL_Pips); double CalcLotsFixedLotCost(double TradeSizePercent, double MinLots, double MaxLots,double FixedPricePerLot); void DU_SetErrorLevel(int level); void DU_Log(int level, string s); bool IsMakeUpTrade(); int GetLotDigits(); // These 2 are obsolete! Do not use. //double LotsOptimized(double TradeSizePercent, double Lots, double MaxLots); //double GetLots(bool MoneyManagement, double TradeSizePercent, double Lots, double MaxLots); // Magic Number Helper & Conversion Functions int TimeFrameConst2Val(int TF_In_Minutes); string TimeFrameVal2String(int value); int SymbolConst2Val(string symbol); string OrderType2String(int type); int OrderString2Num(string type); string GetBoolText(bool value); // Trading Functions bool IsNewCandle(); int NumOpenPositions(int magic, int dir); int NumPendingOrders(int magic, int dir); int ClosePendingOrders(int magic, int dir); bool AdjTrailOnAllOrders(int TrailType, int TrailVal, int Magic, int Direction, int FirstMove, int FirstStopLoss, int SecondMove, int SecondStopLoss, int ThirdMove); double GetTrailingSLValue(int Ticket, int TrailType, int TrailPips, double CurSL, int FirstMove, int FirstStopLoss, int SecondMove, int SecondStopLoss, int ThirdMove); int PlacePendingBreakouts(string symbol, double buyPrice, double sellPrice, int magic, int dir, bool allSameSL, bool allSameTP, int SL, int TP, int qtyOrders, int distBetween, double lots, int slippage, string comment, color clr); int ReplenishOrders(int quantity, string symbol, int dir[], double lots, double price[], int slippage, double sls[], double tps[], string comment, int magic, datetime expir, color arrowClr, bool& orderPlaced[]); // Other utilities string ErrorDescription(int error_code);