[MT4-EA]请懂EA的看看哪里有问题 ? 有止损但不跟踪止损
下单有止损但不跟踪止损,比如 1.020开仓,止损100点为0.920,当价格到1.040时止损也应该提升20点到0.940,现在没有向上跟踪上抬止损.
请懂EA编程的帮忙解决!谢谢!
extern string 自动止损参数="默认打开";
extern bool AutoStoploss=True;
extern double stoploss= 800;
extern string 自动止盈参数="默认打开"
extern bool AutoTakeProfit=True;
extern double takeprofit=2000;
extern string 盈利后移动止损="默认打开";
extern bool AutoTrailingStop=true;
extern double TrailingStop = 800;
extern string 分次离场参数="按比例分步撤退";
extern bool Gradually = False;
extern int GraduallyNum = 3;
double OriginalLot;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
for(int cnt=0;cnt Point*TrailingStop))
{
if((Bid-stp)>TrailingStop*Point )
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
if(OrderType()==OP_SELL)
{
CraduallySell ();
if (AutoStoploss && AutoTakeProfit && stp==0 && tpt==0)
OrderModify(OrderTicket(),OrderOpenPrice(),Bid+Point*stoploss,Bid-Point*takeprofit,0,Green);
else
{
if (AutoStoploss && stp==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid+Point*stoploss,OrderTakeProfit(),0,Green);
}
if (AutoTakeProfit && tpt==0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Bid-Point*takeprofit,0,Green);
}
if(AutoTrailingStop && ((OpenPrice-Ask) > Point*TrailingStop ))
{
if((stp-Ask)>TrailingStop*Point)
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
}
}
else
{
OriginalLot=0;
}
}
}
void CraduallyBuy ()
{
double OpenPrice = OrderOpenPrice();
double lot=OrderLots();
for (int yi=1;yi<=GraduallyNum;yi++)
{
if (NormalizeDouble((Bid - OpenPrice)/Point,0) == NormalizeDouble(TrailingStop/GraduallyNum*yi,0))
{
if (lot != NormalizeDouble(OriginalLot*(1-yi/GraduallyNum),2))
{
OrderClose(OrderTicket(),NormalizeDouble(OriginalLot/GraduallyNum,2),Bid,3,CLR_NONE);
}
}
}
}
void CraduallySell ()
{
double OpenPrice = OrderOpenPrice();
double lot=OrderLots();
for (int yi=1;yi<=GraduallyNum;yi++)
{
if (NormalizeDouble((OpenPrice - Ask)/Point,0) == NormalizeDouble(TrailingStop/GraduallyNum*yi,0))
{
if (lot != NormalizeDouble(OriginalLot*(1-yi/GraduallyNum),2))
{
OrderClose(OrderTicket(),NormalizeDouble(OriginalLot/GraduallyNum,2),Ask,3,CLR_NONE);
}
}
}
}
3楼
瑞讯银行开户 发表于 2017-10-12 14:10
你自己写的代码不检查的?
4楼
瑞讯银行开户 发表于 2017-10-12 14:10
你自己写的代码不检查的?
发表于:2017-10-23 14:40只看该作者
5楼
好牛啊!!!上去10年能看懂,现在百搭了