码迷,mamicode.com
首页 > 其他好文 > 详细

显示历史交易订单的开仓平仓点

时间:2015-06-02 13:02:17      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

#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);
  }
//+------------------------------------------------------------------+

 

显示历史交易订单的开仓平仓点

标签:

原文地址:http://www.cnblogs.com/wzlmzy/p/4546044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!