[MT4-EA]20-pips-per-day日挣20点1.5版本
[backcolor=rgb(245, 245, 245)]/ | 20点每day.mq4 |
[/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |版权2007, LEGRUPO | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | http://www.legrupo.com | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |版本: 1.5 | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |历史: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.0 = > Release版本向公众| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.1 = >修复的错误戴夫( [email protected] ) : | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )止损是错误的; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )止损是互相冲突; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3) is_able_to_continue现在好多了编码; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3.1 )的is_able_to_continue现在可以在任何一对; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 4 )现在的错误,有说明,而不是数字。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.2 = > LASTRUN现在是由戴维人类可读的格式显示。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.3 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )增加了StartOpenOrdersOn到在打开的订单| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |蜡烛具体时间。[/backcolor]
[backcolor=rgb(245, 245, 245)]它是一件好事,因为有时候你| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |需要关闭plataform并重新打开,并用此| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |函数的EA不要再因为打开订单| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |允许的时间没有达到。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )添加使用止损与否的选项。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3 )添加使用BuyStop和SellStop选项| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 4)否是烦人的警报了。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.4 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1)幻数的订单。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )更正StartOpenOrdersOn现在工作得很好。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.5 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )设置ticket_buy_20PPD = 0 | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )复位ticket_buy_20PPD和ticket_sell_20PPD零| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |上延续在一天结束。[/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |版权2007, LEGRUPO | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | http://www.legrupo.com | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |版本: 1.5 | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |历史: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.0 = > Release版本向公众| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.1 = >修复的错误戴夫( [email protected] ) : | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )止损是错误的; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )止损是互相冲突; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3) is_able_to_continue现在好多了编码; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3.1 )的is_able_to_continue现在可以在任何一对; | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 4 )现在的错误,有说明,而不是数字。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.2 = > LASTRUN现在是由戴维人类可读的格式显示。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.3 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )增加了StartOpenOrdersOn到在打开的订单| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |蜡烛具体时间。[/backcolor]
[backcolor=rgb(245, 245, 245)]它是一件好事,因为有时候你| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |需要关闭plataform并重新打开,并用此| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |函数的EA不要再因为打开订单| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |允许的时间没有达到。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )添加使用止损与否的选项。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 3 )添加使用BuyStop和SellStop选项| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 4)否是烦人的警报了。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.4 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1)幻数的订单。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )更正StartOpenOrdersOn现在工作得很好。 [/backcolor]
[backcolor=rgb(245, 245, 245)]| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1.5 = >添加这些功能: | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 1 )设置ticket_buy_20PPD = 0 | [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / | 2 )复位ticket_buy_20PPD和ticket_sell_20PPD零| [/backcolor]
[backcolor=rgb(245, 245, 245)]/ / |上延续在一天结束。[/backcolor]
//+------------------------------------------------------------------+ //| 20-pips-per-day.mq4 | //| Copyright 2007, LEGRUPO | //| http://www.legrupo.com | //| Version: 1.5 | //| History: | //| 1.0 => Release version to the public | //| 1.1 => bugs fixed by Dave ([email protected]): | //| 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. | //| 1.3 => Added these features: | //| 1) Added the StartOpenOrdersOn to open orders at a | //| specific candle time. It's is good because sometimes you | //| need to close the plataform and reopen, and with this | //| function the EA do not open the orders again since the | //| time allowed is not reached. | //| 2) Added the option to use StopLoss or not. | //| 3) Added the option to use BuyStop and SellStop | //| 4) No anoying alerts anymore. | //| 1.4 => Added these features: | //| 1) Magic Numbers for the orders. | //| 2) Corrected StartOpenOrdersOn now works fine. | //| 1.5 => Added these features: | //| 1) Set ticket_buy_20PPD = 0 | //| 2) Reset ticket_buy_20PPD and ticket_sell_20PPD to zero | //| on continuation at the end of the day. | //+------------------------------------------------------------------+ #include#include #property copyright "Copyright 2007, LEGRUPO Version 1.4" #property link "http://www.legrupo.com" extern string StartOpenOrdersOn = "FROM 00:00 UNTIL 01:00"; // look on your chart to see when your daily bar open extern bool UseStopLoss = true; extern bool IPreferStopOrders = true; extern int DistanceFromOpen = 20; // Distance the Limit Orders Should be placed 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; extern int MagicNumber = 123456789; static int LASTRUN_v1_1; // verifica se uma nova bar for aberta int ticket_buy_20PPD = 0, ticket_sell_20PPD = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- int total_orders = OrdersTotal(); int minute = TimeMinute(TimeCurrent()); int hour = TimeHour(TimeCurrent()); //"FROM 02:14 UNTIL 03:15" string temp_variable = ""; // variable used for conversions temp_variable = StringSubstr(StartOpenOrdersOn,5,6); int start_allowed_time_hour = StrToInteger(temp_variable); temp_variable = StringSubstr(StartOpenOrdersOn,8,9); int start_allowed_time_minute = StrToInteger(temp_variable); temp_variable = StringSubstr(StartOpenOrdersOn,17,18); int end_allowed_time_hour = StrToInteger(temp_variable); temp_variable = StringSubstr(StartOpenOrdersOn,20,21); int end_allowed_time_minute = StrToInteger(temp_variable); if (hour >= start_allowed_time_hour && //minute >= start_allowed_time_minute && hour <= end_allowed_time_hour // && minute <= end_allowed_time_minute ) { Comment("EA Start 20-pips-per-day:", TimeDay(TimeCurrent()),"/",TimeMonth(TimeCurrent()),"/",TimeYear(TimeCurrent())); } else { Comment("EA will trade only on this time: ", StartOpenOrdersOn); return(0); } ticket_buy_20PPD = 0; ticket_sell_20PPD = 0; 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); Comment("is_able_to_continue: ", is_able_to_continue); if (is_able_to_continue < MinimumToContinue) { Comment("EA is not able to continue previous bar moved less than ", MinimumToContinue, " pips"); return(0); } else { Comment("EA is able to continue :). Good trade."); } double buy_stoploss,sell_stoploss, buy_price, sell_price, buy_take_profit, sell_take_profit; int order_buy_type,order_sell_type; // now we choose depending on what people want if (IPreferStopOrders) { buy_price = curr_open+DistanceFromOpen*Point; sell_price = curr_open-DistanceFromOpen*Point; order_buy_type = OP_BUYSTOP; order_sell_type = OP_SELLSTOP; } else { buy_price = Ask; sell_price = Bid; order_buy_type = OP_BUY; order_sell_type = OP_SELL; } if (UseStopLoss) { buy_stoploss = buy_price-(StopLoss*Point); sell_stoploss = sell_price+(StopLoss*Point); } else { buy_stoploss = 0; sell_stoploss = 0; } buy_take_profit = buy_price+(TakeProfit*Point); sell_take_profit = sell_price-(TakeProfit*Point); if (OrderSelect(ticket_buy_20PPD, SELECT_BY_TICKET, MODE_TRADES) == false) { ticket_buy_20PPD = OrderSend(Symbol(),order_buy_type,LotSize,buy_price,Slippage,buy_stoploss,buy_take_profit,BuyComment,MagicNumber,0,clOpenBuy); if (ticket_buy_20PPD < 0) { Alert("Open BUY order error: ", ErrorDescription(GetLastError())); } } if (OrderSelect(ticket_sell_20PPD, SELECT_BY_TICKET, MODE_TRADES) == false) { ticket_sell_20PPD = OrderSend(Symbol(),order_sell_type,LotSize,sell_price,Slippage,sell_stoploss,sell_take_profit,SellComment,MagicNumber,0,clOpenSell); if (ticket_sell_20PPD < 0) { Alert("Open SELL order error: ", ErrorDescription(GetLastError())); } } //---- return(0); } //+------------------------------------------------------------------+