求助,MT$4均线自动交易系统的问题,编译通过不能执行?
最简单的均线交叉系统测试一下,程序编译通过可是不能下单!!
哪里的问题?请高手们指点一下!!
用两跟均线交叉来发出交易。
//+------------------------------------------------------------------+
//| Moving Average.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#define MAGICMA 20050610
// extern的全局变量,编译后可以直接在MT中修改
extern int FasterMode = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int FasterMA = 5;
extern int SlowerMode = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern int SlowerMA = 6;
extern double Lots = 0.1;
//| 检查现有仓位
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i0) return(buys); // 有至少一张买单,返回买单数量
else return(-sells);// 否则,返回卖单数量的负值
}
//检查是否建仓
void CheckForOpen()
{
int limit, i, counter,res;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i = 0; i <= limit; i++)
{
counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
fasterMAnow = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
fasterMAprevious = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
fasterMAafter = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);
slowerMAnow = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i);
slowerMAprevious = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i+1);
slowerMAafter = iMA(NULL, 0, SlowerMA, 0, SlowerMode, PRICE_CLOSE, i-1);
//空
if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
{
for( i=0;i slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
{
for( i=0;i
发表于:2006-06-10 07:05只看该作者
2楼
要学习MT4上的编程,应该买什么编程的电脑书呢
韬客社区www.talkfx.co
发表于:2006-06-17 04:43只看该作者
4楼
知道英语的重要性了,看不懂了!
南无阿弥陀佛 南无观世音菩萨
发表于:2006-07-27 04:15只看该作者
5楼
很有用的东西,我正学习着个呢,先研究研究, 研究好了和楼主聊聊
韬客社区www.talkfx.co