//+------------------------------------------------------------------+ //| 20-pips-per-day.mq4 | //| Copyright © 2007, LEGRUPO | //| http://www.legrupo.com | //| Version: 1.2 | //| History: | //| 1.0 => Release version to the public | //| 1.1 => bugs fixed by Dave (dmieluk@exemail.com.au): | //| 1) StopLoss was wrong; | //| 2) StopLoss was conflicting with each other; | //| 3) The is_able_to_continue is now much better coded; | //| 3.1) The is_able_to_continue now works on any pair; | //| 4) Now the errors have descriptions instead of numbers. | //| 1.2 => LASTRUN now is display in human readable format by Dave. | //+------------------------------------------------------------------+ #include #include #property copyright "MT4Íâ»ã¸úµ¥ÏµÍ³(www.fx789.com)" #property link "http://www.fx789.com" extern string Tips="www.fx789.comÕвÙÅÌÊÖ"; extern string Tips1="MT4±¾µØÍâ»ã×Ô¶¯¸úµ¥ÏµÍ³"; extern string Tips2="Ìṩº°µ¥·þÎñQQ:278118436"; ObjectCreate("label_object_B1", OBJ_LABEL, 0, 0, 0); ObjectSetText("label_object_B1","MT4±¾µØÍâ»ã×Ô¶¯¸úµ¥ÏµÍ³Ãâ·ÑÊÔÓà £ºwww.fx789.com/gendan.rar ",9,"Arial",Yellow); ObjectSet("label_object_B1", OBJPROP_XDISTANCE, 5); ObjectSet("label_object_B1", OBJPROP_YDISTANCE, 10); extern double TakeProfit = 40; extern double StopLoss = 20; extern double StopAndReverseOnLossOf = 100; extern int MinimumToContinue = 100; // pips the daily bar must have extern double LotSize = 0.1; extern double Slippage = 15; extern string BuyComment = "20 pips per day BUY"; extern string SellComment = "20 pips per day SELL"; extern color clOpenBuy = Blue; extern color clOpenSell = Red; static int LASTRUN_v1_1; // verifica se uma nova bar for aberta int ticket_buy, ticket_sell = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int total_orders = OrdersTotal(); if (LASTRUN_v1_1==Time[0]) return(0); LASTRUN_v1_1 = Time[0]; Alert("EA Start 20-pips-per-day:", TimeDay(LASTRUN_v1_1),"/",TimeMonth(LASTRUN_v1_1),"/",TimeYear(LASTRUN_v1_1)); double curr_open = iOpen(NULL, 0, 0); double last_high = iHigh(NULL, 0, 1); double last_low = iLow(NULL, 0, 1); double last_close = iClose(NULL, 0, 1); double is_able_to_continue = (last_high - last_low)*MathPow(10,Digits); Print("is_able_to_continue: ", is_able_to_continue); if (is_able_to_continue < MinimumToContinue) { return(0); } //if (total_orders == 0) { ticket_buy = OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,Ask-(StopLoss*Point),Ask+(TakeProfit*Point),BuyComment,0,0,clOpenBuy); if (ticket_buy < 0) { Alert("Open BUY order error: ", ErrorDescription(GetLastError())); } ticket_sell = OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slippage,Bid+(StopLoss*Point),Bid-(TakeProfit*Point),SellComment,0,0,clOpenSell); if (ticket_sell < 0) { Alert("Open SELL order error: ", ErrorDescription(GetLastError())); } //} //---- return(0); } //+------------------------------------------------------------------+