任意货币对自动添加止损和平包
1. 在任意一个k线窗口运行,对所有挂单和持仓单有效2. 如果发现未设置止损,则添加止损。
3.如果浮盈超过一定点数,自动平保。
4. 手动调整止损后本ea不再起作用
参数: 1. 平保点数
2. 止损点数
3. 止盈点数
//+------------------------------------------------------------------+
//| MoveEven.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
extern int PointWin = 50;
extern int TakeProfit = 200;
extern int StopLoss = 35;
int PointScale = 10; //在5位小数点报价平台为10,在4位小数点报价平台为1
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
//调整止损
if(OrdersTotal()>0)
{
ChangeStopLoss();
}
//----
return(0);
}
void ChangeStopLoss ()
{
int i;
for(i = OrdersTotal()-1; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
int tick = OrderTicket();
double point = MarketInfo(OrderSymbol(), MODE_POINT);
if((OrderType()==OP_BUY )|| (OrderType()==OP_BUYLIMIT))
{
if(OrderStopLoss()== 0)
{
if(OrderModify(tick, OrderOpenPrice(), (OrderOpenPrice()- StopLoss*PointScale*point), (OrderOpenPrice()+ TakeProfit*PointScale*point ),0, Red))
{
Print("++++++++++Currency pair: ", Symbol(), "Add StopLoss to ticket: ", tick, " successfully!!!");
Sleep(5000);
}
}
else if( (Bid > (OrderOpenPrice()+PointWin*PointScale*point))&&(OrderStopLoss()<OrderOpenPrice()) && (OrderType()==OP_BUY ) )
{
if(OrderModify(tick, OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(),0, Red))
{
Print("*********Currency pair: ", OrderSymbol(), "MoveEvento ticket: ", tick, " successfully!!!");
Sleep(5000);
}
}
} else
if((OrderType() == OP_SELL) || (OrderType() == OP_SELLLIMIT))
{
if(OrderStopLoss()== 0)
{
if(OrderModify(tick, OrderOpenPrice(), (OrderOpenPrice()+ StopLoss*PointScale*point), (OrderOpenPrice()- TakeProfit*PointScale*point ),0, Red))
{
Print("++++++++++Currency pair: ", OrderSymbol(), "Add StopLoss to ticket: ", tick, " successfully!!!");
Sleep(5000);
}
}
else if( (Ask < (OrderOpenPrice()-PointWin*PointScale*point )) && (OrderStopLoss()>OrderOpenPrice()) && (OrderType() == OP_SELL))
{
if(OrderModify(tick, OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(),0, Red))
{
Print("*********Currency pair: ", OrderSymbol(), "MoveEvento ticket: ", tick, " successfully!!!");
Sleep(5000);
}
}
}
}
}
//+------------------------------------------------------------------+
5555555555555 66666666666666666666666666 :lol不错 学习了,不错 谢谢楼主分享 这个可以有 谢谢楼主分享 支持下 怎么下载呢?
页:
[1]
2