这个是MT4自带的MACd后半部分的源码,烦请老师标注一下上面意思!
自由的风
|
4362 人阅读
|
17 人评论
|
2012-12-08
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && // check for opened position
OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_BUY) // long position is opened
{
// should it be closed?
if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
MacdCurrent>(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{
// should it be closed?
if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Point))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
return(0); // exit
}
// check for trailing stop
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
return(0);
}
// the end. |
|
|
|
|
if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
上面的“ MathAbs(MacdCurrent)>(MACDOpenLevel*Point) ”看不懂上面意思,请老师指教一下,在前面没有“MathAbs”呀,这里突然冒出来。郁闷!
|
|
|
|
|
0线下方:MacdCurrent<0
macd指标金叉:MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious
Diff线向上运行:MaCurrent>MaPrevious
extern double MACDOpenLevel=3;
MathAbs(MacdCurrent)>(MACDOpenLevel*Point)
由于Diff在0线下方,所以MacdCurrent为负数。因此需要MathAbs()取其绝对值。MACDOpenLevel初始值为3;Point随币种、mt4行情服务器的不同,值各不相同。一般在0.01到0.00001之间。
|
|
|
|
|
最好的,我们一般很难遇到,否则全球通用了,那谁亏呢 |
|
|
|
|