|
- //+------------------------------------------------------------------+
- //| 简易版循环挂单v20130808.mq4 |
- //+------------------------------------------------------------------+
- double 第一单价格=0;
- int 第一单多空=-1;
- double 全体止盈线=0;
- //+------------------------------------------------------------------+
- //| expert initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| expert start function |
- //+------------------------------------------------------------------+
- int start()
- {
- //----
-
- if(OrdersTotal()==1){ //当只有一张定单时执行
- if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)//选中这唯一一张定单
- {
- if(OrderType()==OP_BUY || OrderType()==OP_SELL)//当这张定单为多单或空单时执行(挂单则不执行)
- {
- int ticket;
-
- if(OrderType()==OP_BUY){
- 第一单多空=OP_BUYSTOP;
- 第一单价格=OrderOpenPrice();
- for (int i=1; i<=100; i++){
- ticket=OrderSend(Symbol(),第一单多空,0.02,第一单价格+i*0.0002,0,0,全体止盈线,"",0,CLR_NONE);
- if(ticket<0)Print("挂多: "+DoubleToStr(第一单价格+i*0.0002,4)+"失败");
- Sleep(3000);
- }
- }
- else if(OrderType()==OP_SELL){
- 第一单多空=OP_SELLSTOP;
- 第一单价格=OrderOpenPrice();
- for (int j=1; j<=100; j++){
- ticket=OrderSend(Symbol(),第一单多空,0.02,第一单价格-j*0.0002,0,0,全体止盈线,"",0,CLR_NONE);
- if(ticket<0)Print("挂空: "+DoubleToStr(第一单价格-j*0.0002,4)+"失败");
- Sleep(3000);
- }
- }
- }
-
- }
- else
- {
- Print("OrderSelect返回的错误:",GetLastError());
- }
- }
- else{
- return(0);
- }
-
- /*
- for (int i=1; i<=20; i++){
- OrderSend(Symbol(),OP_SELLSTOP,0.02,第一单价格-i*0.0002,0,0,全体止盈线,"",0,CLR_NONE);
- }
- */
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
复制代码 |
|