论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1068回复:0
草龙
注册时间2004-12-17
[MT4-EA]20-pips-per-day日挣20点1.5版本
楼主发表于:2014-01-01 18:08只看该作者倒序浏览
1楼 电梯直达
电梯直达
[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]
//+------------------------------------------------------------------+
//|                                              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);
  }
//+------------------------------------------------------------------+
TK29帖子1楼右侧xm竖版广告90-240
个性签名

阅尽天下指标
搬砖开始,始于2014

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]