【EA智能交易】移动止损EA 源代码
源代码如下:--------------------------------------------------------------------------------- //+------------------------------------------------------------------+
//| 移动止损EA.mq4 |
//| 混沌趋势 |
//| http://blog.sina.com.cn/hdczdy |
//+------------------------------------------------------------------+
#property copyright "混沌趋势"
#property link "http://blog.sina.com.cn/hdczdy"
extern double Stoploss=30;///止损点数设置
extern double MoveStop=30;///移动止盈设置
extern int Maxslippage=5;//最大滑点数
extern bool FollwStop=true; //是否开启追踪止盈止损
extern double FollwMoveStop=0;///移动止盈点数 int tempStopBP=0;
int tempStopSP=0;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int con;
int allLots= OrdersTotal();
if(allLots>0){
for(con=0;conMarketInfo(OrderSymbol(),MODE_POINT)*MoveStop){
if((iClose(OrderSymbol(),0,0)-OrderStopLoss())/MarketInfo(OrderSymbol(),MODE_POINT) > tempStopBP )
// Print("tempStopBP========>>="+tempStopBP);
RefreshRates();
bool modify_b= OrderModify(OrderTicket(),OrderOpenPrice(), iClose(OrderSymbol(),0,0) -MarketInfo(OrderSymbol(),MODE_POINT)*(MoveStop+Stoploss),OrderTakeProfit(),0,Green);
tempStopBP= (iClose(OrderSymbol(),0,0)-OrderStopLoss())/MarketInfo(OrderSymbol(),MODE_POINT);
if(modify_b) {
Print("多单向上自动设置止成功");
} else{
Print("多单向上自动设置止损失败"+GetLastError());
}
}
if(iClose(OrderSymbol(),0,0)-OrderOpenPrice()MarketInfo(OrderSymbol(),MODE_POINT)*MoveStop){
{
RefreshRates() ;
bool modify_s= OrderModify(OrderTicket(),OrderOpenPrice(), iClose(OrderSymbol(),0,0)+MarketInfo(OrderSymbol(),MODE_POINT)*(MoveStop+Stoploss),OrderTakeProfit(),0,Green);
tempStopSP= (OrderOpenPrice()-iClose(OrderSymbol(),0,0))/MarketInfo(OrderSymbol(),MODE_POINT);
if(modify_s) {
Print("空单单向下自动设置止成功");
} else{
Print("空单单向下自动设置止损失败"+GetLastError());
}
}
}
if((iClose(OrderSymbol(),0,0)-OrderOpenPrice()) >(MarketInfo(OrderSymbol(),MODE_POINT)*Stoploss))
{
RefreshRates();
if(OrderClose(OrderTicket(), OrderLots(),iClose(OrderSymbol(),0,0)+(MarketInfo(OrderSymbol(),MODE_POINT)),Maxslippage,Red))
{
Print("空单止损成功==============");
}else{
Print("空单止损失败========="+GetLastError());
} }
}
}
return(0);
}
return(0);
}-----------------------------------------------------
不会弄。请帮我看看这个源码。谢谢。
|