您需要 登录 才可以下载或查看,没有帐号?注册
// 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之间。
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!