|
新鲜不
- #property copyright "Copyright ?2007okw,China."
- int SignalBS =0;
- datetime startTime=NULL, endTime = NULL;
- color SignalPriceBUY = Blue;//Yellow;
- color SignalPriceSELL = Black;//Cyan;//起点的标签
- double startPrice, endprice;
- int TicketNumber; //定单号:为了防止挂单/取消的时间间隔太小以至于无法区分识别定单而新添加的参数
- int start()
- {
- int orders=HistoryTotal(); Print("Ord=",orders);
- int i;
- for(i=orders-1;i>=0;i--)
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
- {
- if ((OrderType( )==OP_BUYSTOP || OrderType( )==OP_BUY) && OrderSymbol()==Symbol()) //过滤出本货币的OP_BUYLIMIT以及OP_BUYSTOP的单子
- {
- SignalBS =1;
- startTime= OrderOpenTime();endTime = OrderCloseTime ();
- startPrice= OrderOpenPrice(); endprice = OrderClosePrice ();
- TicketNumber = OrderTicket();
- SetBS();
- }
- else if (( OrderType( )==OP_SELLSTOP || OrderType( )==OP_SELL) && OrderSymbol()==Symbol())
- {
- SignalBS =-1;
- startTime= OrderOpenTime();endTime = OrderCloseTime ();
- startPrice= OrderOpenPrice(); endprice = OrderClosePrice ();
- TicketNumber = OrderTicket();
- SetBS();
- }
- }
- }
- return(0);
- }
- void SetBS()
- {
- int BarShift=WindowBarsPerChart()/50;
- datetime TimeShift=WindowBarsPerChart()/50*Period()*60;
- if (SignalBS == 1)//做多
- {
- ObjectDelete("BUY SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)); //在以下所有的标签中都添加了唯一的DoubleToStr(TicketNumber,0)<--定单号,可区分识别所有定单
- ObjectDelete("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime));
- ObjectDelete("BUY Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime));
- //ObjectCreate("BUY SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),OBJ_TEXT,0,startTime-TimeShift,startPrice);
- //ObjectSetText("BUY SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),DoubleToStr(startPrice,2), 9, "Arial", SignalPriceBUY);
- ObjectSet("BUY SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),OBJPROP_COLOR,SignalPriceBUY);
- ObjectCreate("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJ_TREND,0,startTime,startPrice,endTime,endprice);
- ObjectSet("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_COLOR,SignalPriceBUY);
- ObjectSet("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_RAY,false);
- ObjectSet("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_STYLE,STYLE_SOLID);
- ObjectSet("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_COLOR,Blue);
- ObjectSet("BUY : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_WIDTH,2);//变粗
- // ObjectCreate("BUY Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),OBJ_TEXT,0,endTime-TimeShift,endprice);
- //ObjectSetText("BUY Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),DoubleToStr(endprice,2), 9, "Arial", SignalPriceBUY);
- ObjectSet("BUY Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),OBJPROP_COLOR,SignalPriceBUY);
- }
- if (SignalBS == -1)//做空
- {
- ObjectDelete("SELL SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime));
- ObjectDelete("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime));
- ObjectDelete("SELL Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime));
- // ObjectCreate("SELL SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),OBJ_TEXT,0,startTime-TimeShift,startPrice);
- //ObjectSetText("SELL SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),DoubleToStr(startPrice,2), 9, "Arial", SignalPriceSELL);
- ObjectSet("SELL SIGNAL: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime),OBJPROP_COLOR,SignalPriceSELL);
- ObjectCreate("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJ_TREND,0,startTime,startPrice,endTime,endprice);
- ObjectSet("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_COLOR,SignalPriceSELL);
- ObjectSet("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_RAY,false);
- ObjectSet("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_STYLE,STYLE_SOLID);
- ObjectSet("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_COLOR,Black);
- ObjectSet("SELL : " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(startTime)+"--"+TimeToStr(endTime),OBJPROP_WIDTH,2);//变粗
- // ObjectCreate("SELL Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),OBJ_TEXT,0,endTime-TimeShift,endprice);
- //ObjectSetText("SELL Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),DoubleToStr(endprice,2), 9, "Arial", SignalPriceSELL);
- ObjectSet("SELL Close: " + DoubleToStr(TicketNumber,0) + " : " + TimeToStr(endTime),OBJPROP_COLOR,SignalPriceSELL);
- }
- }
复制代码 |
|