//+------------------------------------------------------------------+ //| patternmatcher.definitions.mqh | //| Copyright © 2010, Bernd Kreuss | //| Version: 2010.1.27.1 | //+------------------------------------------------------------------+ #property copyright "Bernd Kreuss" #property link "mailto:7ibt@arcor.de" /** This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ extern double stop_factor = 0.3; // stoploss relative to total pattern size extern double target_factor = 0.3; // takeprofit relative to total pattern size extern double max_error = 0.10; // the lower the value, the better the pattern must match extern bool reverse = False; // reverse all trades double patternTest(double x){ // this was one of the first pattern i tried, // it is the one visible in the first screenshot in the FF thread x *= 0.7; // change the x range if (x < 8) return(ab(0,0,8,8-50,x)); if (x < 13) return(ab(8,8-50,13,-13-50,x)); if (x < 21) return(ab(13,-13-50,21,21-50,x)); if (x < 34) return(ab(21,21-50,34,-34-50,x)); if (x < 55) return(ab(34,-34-50,55,55-50,x)); return(ab(55,55-50,70,-45-50,x)); } double patternTripleBottom(double x){ // another experimantal pattern, // could need some improvement. if (x < 12) return(ab(0,0, 12,-30,x)); if (x < 24) return(ab(12,-30, 24,0,x)); if (x < 36) return(ab(24,0, 36,-30,x)); if (x < 48) return(ab(36,-30, 48,0,x)); if (x < 60) return(ab(48,0, 60,-30,x)); return(ab(60,-30, 100,70,x)); } /** * A helper for the pattern. defines a straight line from a to b. */ double ab(double ax, double ay, double bx, double by, double x){ return (ay + (by-ay)*(x-ax)/(bx-ax)); } /** * This function is used by the EA and it will call one of the pattern * functions above. We can quickly switch to another pattern function here * by simply changing this function. */ double pattern(double x){ return (patternTripleBottom(x)); // return (patternTest(x)); }