//+------------------------------------------------------------------+ //| Copyright 2010 OpenThinking Systems, LLC //| http://www.openthinkingsystems.com //| //| LICENSING: This is free, open source software, licensed under //| Version 3 of the GNU General Public License (GPL) //| (the "License"). You may obtain a copy of the License //| at http://www.gnu.org/licenses/gpl.html //| //| //| 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). //| //| Unless required by applicable law or agreed to in writing, //| software distributed under the License is distributed on an //| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY //| KIND, either express or implied. See the License for the //| specific language governing permissions and limitations under //| the License. //+------------------------------------------------------------------+ extern int RiskPercentage = 50; #include #include //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return (0); } //+----------------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+----------------------------------------------------------------------------+ void deinit() { } //+------------------------------------------------------------------+ //| Here is where the server is polled | //+------------------------------------------------------------------+ int start() { int k=OrdersTotal(); double OptimalLots = 0.0; int i = 0; for (i=0; i MM_MaxLotSize) { OrderLotSize = MM_MaxLotSize; } return(OrderLotSize); } int PipsDeviated(double price1, double price2, string symbol, int signalCmd) { double decimals; int pipsSpread; decimals = 0.0001; if(MarketInfo(symbol, MODE_DIGITS)==2) decimals = 0.01; if(MarketInfo(symbol, MODE_DIGITS)==3) decimals = 0.001; if(MarketInfo(symbol, MODE_DIGITS)==4) decimals = 0.0001; if(MarketInfo(symbol, MODE_DIGITS)==5) decimals = 0.00001; if(MarketInfo(symbol, MODE_DIGITS)==6) decimals = 0.000001; if(MarketInfo(symbol, MODE_DIGITS)==7) decimals = 0.0000001; if (signalCmd == OP_BUY) { pipsSpread = (price1 - price2) / decimals; return (pipsSpread); } if (signalCmd == OP_SELL) { pipsSpread = (price2 - price1) / decimals; return (pipsSpread); } pipsSpread = MathAbs(price1 - price2) / decimals; return (pipsSpread); }