zoukankan      html  css  js  c++  java
  • 显示历史交易订单的开仓平仓点

    #property link      "http://www.haoib.com"
    
    #property indicator_chart_window
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function                         |
    //+------------------------------------------------------------------+
    int init()
      {
    //---- indicators
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custom indicator deinitialization function                       |
    //+------------------------------------------------------------------+
    int deinit()
      {
    //----
       
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function                              |
    //+------------------------------------------------------------------+
    int start()
      {
       int    counted_bars=IndicatorCounted();
       
       int i,hstTotal=OrdersHistoryTotal(); 
    /*
       for(i=0;i<283;i++)
       {
       ObjectCreate("arrow"+i, OBJ_ARROW,0,Time[i],Low[i]);
       ObjectSet("arrow"+i,OBJPROP_ARROWCODE,i);
       ObjectSet("arrow1",OBJPROP_COLOR,Green);
       
       }
    */
      for(i=0;i<hstTotal;i++)
      {
          OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
          if(Symbol()==OrderSymbol() && OrderType()<=OP_SELL)
          {
             int tk=OrderTicket();
             if(ObjectFind("aopen"+tk)==-1)
             {
                ObjectCreate("aopen"+tk,OBJ_ARROW,0,OrderOpenTime(),OrderOpenPrice());
                ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,1);
                if(OrderType()==OP_BUY) ObjectSet("aopen"+tk,OBJPROP_COLOR,Green);
                if(OrderType()==OP_SELL) ObjectSet("aopen"+tk,OBJPROP_COLOR,Red);
             }
             if(ObjectFind("aclose"+tk)==-1)
             {
                ObjectCreate("aclose"+tk,OBJ_ARROW,0,OrderCloseTime(),OrderClosePrice());
                ObjectSet("aclose"+tk,OBJPROP_ARROWCODE,3);
                ObjectSet("aclose"+tk,OBJPROP_COLOR,Goldenrod);
             }
             if(ObjectFind("#"+tk)==-1)
             {
                if(ObjectFind("##"+tk)!=-1)ObjectDelete( "##"+tk) ;
                ObjectCreate("#"+tk,OBJ_TREND,0,OrderOpenTime(),OrderOpenPrice(),OrderCloseTime(),OrderClosePrice());
                ObjectSet("#"+tk,OBJPROP_STYLE,STYLE_DOT);
                ObjectSet("#"+tk,OBJPROP_RAY,0);
                if(OrderType()==OP_BUY) ObjectSet("#"+tk,OBJPROP_COLOR,Green);
                if(OrderType()==OP_SELL) ObjectSet("#"+tk,OBJPROP_COLOR,Red);
             }
             
          }
          
          if(Symbol()==OrderSymbol() && OrderType()>OP_SELL)
          {
             tk=OrderTicket();
             if(ObjectFind("aopen"+tk)==-1)
             {
                ObjectCreate("aopen"+tk,OBJ_ARROW,0,OrderOpenTime(),OrderOpenPrice());
                
                if(OrderType()<=OP_BUYSTOP) ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,217);
                else                        ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,218);
             }
             if(ObjectFind("aclose"+tk)==-1)
             {
                ObjectCreate("aclose"+tk,OBJ_ARROW,0,OrderCloseTime(),OrderOpenPrice());
                ObjectSet("aclose"+tk,OBJPROP_ARROWCODE,251);
             }
             if(ObjectFind("#"+tk)==-1)
             {
    
                ObjectCreate("#"+tk,OBJ_TREND,0,OrderOpenTime(),OrderOpenPrice(),OrderCloseTime(),OrderOpenPrice());
                ObjectSet("#"+tk,OBJPROP_STYLE,STYLE_DOT);
                ObjectSet("#"+tk,OBJPROP_RAY,0);
                ObjectSet("#"+tk,OBJPROP_COLOR,White);
    
             }
             
          }
    
      }
    
    
       int total=OrdersTotal();
       for(i=0;i<total;i++)
       {
          OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
          if(Symbol()==OrderSymbol() && OrderType()<=OP_SELL)
          {
             tk=OrderTicket();
             if(ObjectFind("aopen"+tk)==-1)
             {
                ObjectCreate("aopen"+tk,OBJ_ARROW,0,OrderOpenTime(),OrderOpenPrice());
                ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,1);
                if(OrderType()==OP_BUY) ObjectSet("aopen"+tk,OBJPROP_COLOR,Green);
                if(OrderType()==OP_SELL) ObjectSet("aopen"+tk,OBJPROP_COLOR,Red);
             }
             if(ObjectFind("##"+tk)==-1)
             {
                ObjectCreate("##"+tk,OBJ_TREND,0,OrderOpenTime(),OrderOpenPrice(),Time[0],Bid);
                ObjectSet("##"+tk,OBJPROP_STYLE,STYLE_DOT);
                ObjectSet("##"+tk,OBJPROP_RAY,0);
             }
             else
             {
                ObjectSet("##"+tk,OBJPROP_TIME2,Time[0]);
                ObjectSet("##"+tk,OBJPROP_PRICE2,Bid);
                if(OrderType()==OP_BUY) 
                {
                   ObjectSet("##"+tk,OBJPROP_COLOR,Green);
                   ObjectSet("##"+tk,OBJPROP_PRICE2,Bid);
                   
                }
                if(OrderType()==OP_SELL) 
                {
                   ObjectSet("##"+tk,OBJPROP_COLOR,Red);
                   ObjectSet("##"+tk,OBJPROP_PRICE2,Ask);
                   
                }
             }
          }
    
          if(Symbol()==OrderSymbol() && OrderType()>OP_SELL)
          {
             tk=OrderTicket();
             if(ObjectFind("aopen"+tk)==-1)
             {
                ObjectCreate("aopen"+tk,OBJ_ARROW,0,OrderOpenTime(),OrderOpenPrice());
                if(OrderType()<=OP_BUYSTOP) ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,217);
                else                        ObjectSet("aopen"+tk,OBJPROP_ARROWCODE,218);
             }
             
          }
       }
       
    
    
    //----
       
    //----
       return(0);
      }
    //+------------------------------------------------------------------+
  • 相关阅读:
    css实现截取文本
    ob_clean()解决php验证码图片无法显示
    JS获取url参数,修改url参数
    mysql模糊查询特殊字符(\,%和_)处理
    apache反向代理和监听多个端口设置
    页面底部自适应浏览器窗口高度
    变量相关考虑
    php非法输入数据类型
    php socket模拟http中post或get提交数据
    华为专利的 hybrid 端口
  • 原文地址:https://www.cnblogs.com/wzlmzy/p/4546044.html
Copyright © 2011-2022 走看看