[MT4-EA]请问哪一位编程高手可以解释一下这个EA的进出场规矩?
我对MT4编程不熟悉,想了解和优化此EA,不知道哪一位编程高手可以解释其进出场规矩?
先行谢谢!
extern int MagicNumber=10001;
extern double Lots =0.01;
extern double StopLoss=200;
extern double TakeProfit=50;
extern int TrailingStop=0;
extern int Slippage=3;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{
double MyPoint=Point;
if(Digits==3 || Digits==5) MyPoint=Point*10;
double TheStopLoss=0;
double TheTakeProfit=0;
if( TotalOrdersCount()==0 )
{
int result=0;
if((iBands(NULL,PERIOD_M5,10,2,2,PRICE_CLOSE,MODE_LOWER,2)www.ForexEAdvisor.com",MagicNumber,0,Blue);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}
if((iStochastic(NULL,PERIOD_M5,40,5,1,MODE_EMA,1,MODE_MAIN,2)>iStochastic(NULL,0,40,5,1,MODE_EMA,1,MODE_SIGNAL,1))) // Here is your open Sell rule
{
result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"EA Generator www.ForexEAdvisor.com",MagicNumber,0,Red);
if(result>0)
{
TheStopLoss=0;
TheTakeProfit=0;
if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);
}
return(0);
}
}
for(int cnt=0;cntiStochastic(NULL,0,40,5,1,MODE_EMA,1,MODE_SIGNAL,1))) //here is your close buy rule
{
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{
if(OrderStopLoss()iStochastic(NULL,0,40,5,1,MODE_EMA,1,MODE_MAIN,1))) // here is your close sell rule
{
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage,Red);
}
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
{
if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
return(0);
}
int TotalOrdersCount()
{
int result=0;
for(int i=0;i
发表于:2013-07-02 10:38只看该作者
2楼
band下轨收缩 stochastic信号线 大于 主线,两个条件满足开多,平多条件:收盘出现stochastic死叉
3楼
波动心不动,心动波不动,心动波也动!
5楼
波动心不动,心动波不动,心动波也动!
发表于:2013-07-03 04:04只看该作者
6楼
OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;
orderselect()用错了。那样调用实际上ordermagicnumber()不知道判断哪个订单的 改成:if(orderselect(i,SELECT_BY_POS ,MODE_TRADES)==true) {if (OrderMagicNumber()==MagicNumber) result++;}
orderselect()用错了。那样调用实际上ordermagicnumber()不知道判断哪个订单的 改成:if(orderselect(i,SELECT_BY_POS ,MODE_TRADES)==true) {if (OrderMagicNumber()==MagicNumber) result++;}
7楼
8楼
波动心不动,心动波不动,心动波也动!
发表于:2013-07-03 13:24只看该作者
9楼
static datetime lasttime;
if(Time[0]==lasttime) return;
lasttime=Time[0];
把这个代码加到 start()主程序 第一句。这样就只会在新K线出现时运行一次开仓判断了,不知道是不是你要的。
10楼
波动心不动,心动波不动,心动波也动!