admin 管理员组

文章数量: 887031


2024年1月10日发(作者:浮点计算)

【MQL4】MQL4常用自定义函数

索引

1、在屏幕上显示文字标签

void iDisplayInfo(string LableName,string LableDoc,int

Corner,int LableX,int LableY,int DocSize,string DocStyle,color

DocColor);

2、金额转换手数

double iFundsToHands(string mySymbol,double myFunds);

3、订单净值转换点数

int iOrderEquitToPoint(int myTicket);

4、显示错误信息

string iGetErrorInfo(int myErrorNum);

5、交易繁忙,程序等待,更新缓存数据

void iWait(int myDelayTime);

6、有效时间段

bool iValidTime(string myStartTime,string myEndTime,bool

myServerTime);

7、计算特定条件的订单

int iOrdersSort(int myOrderType,int myOrderSort,int

myMaxMin,int myMagicNum);

8、持仓单数量统计

int iOrderStatistics(int myOrderType,int myMagicNum);

9、物件颜色

color iObjectColor(double myInput);

10、持仓单开仓量总计

int iGroupLots(int myOrderType,int myMagicNum);

11、持仓单净值总计

double iGroupEquity(int myOrderType,int myMagicNum);

12、开仓量整形

double iLotsFormat(double myLots);

13、批量清仓

void iBatchClose(int myType,double myLots,int

myMagicNum);

14、标注符号和画线、文字

void iDrawSign(string

myColor,int

myType,int myBarPos,double

myString,int myPrice,color

myDocSize);

15、时间周期转换字符

string iTimeFrameToString(int myTimeFrame);

16、文件操作

void iFileOperation(string myFileName,string myString,int

myFileType,int myFileMode);

void iFileOperation(string myFileName,int myFileType,int

myFileMode,string myFileString)

{

int myHandle; //文件序列号

if (myFileMode==0 && myFileString=="") //新建文件

{

if

if

FileClose(myHandle);

}

if (myFileMode==1 && myFileString!="") //创建写入字符串

{

if

if

(myFileType==0)

(myFileType==1)

myHandle=FileOpen(myFileName,FILE_BIN|FILE_WRITE);

(myFileType==0)

(myFileType==1)

myHandle=FileOpen(myFileName,FILE_BIN|FILE_WRITE);

myHandle=FileOpen(myFileName,FILE_CSV|FILE_WRITE,";");

mySymbol,string

myHandle=FileOpen(myFileName,FILE_CSV|FILE_WRITE,";");

FileWrite(myHandle,myFileString);

FileClose(myHandle);

}

if (myFileMode==2 && myFileString!="") //追加写入字符串

{

if (myFileType==0)

{

myHandle=FileOpen(myFileName,FILE_BIN|FILE_READ|FILE_WRITE);

FileSeek(myHandle,0,SEEK_END);

FileWrite(myHandle,myFileString);

FileClose(myHandle);

}

if (myFileType==1)

{

myHandle=FileOpen(myFileName,FILE_CSV|FILE_READ|FILE_WRITE,";");

FileSeek(myHandle,SEEK_SET,SEEK_END);

FileWrite(myHandle,myFileString);

FileClose(myHandle);

}

}

return(0);

}

string iTimeFrameToString(int myTimeFrame)

{

switch(myTimeFrame)

{

case 1:

return("M1");

break;

case 5:

return("M5");

break;

case 15:

return("M15");

break;

case 30:

return("M30");

break;

case 60:

return("H1");

break;

case 240:

return("H4");

break;

case 1440:

return("D1");

break;

case 10080:

return("W1");

break;

case 43200:

return("MN1");

break;

}

}

void iDrawSign(string

myPrice,color myColor,int

myType,int myBarPos,double

myString,int mySymbol,string

myDocSize)

{

if (myType=="Text")

{

string TextBarString=myType+Time[myBarPos];

ObjectCreate(TextBarString,OBJ_TEXT,0,Time[myBarPos],myPrice);

ObjectSet(TextBarString,OBJPROP_COLOR,myColor);//颜色

ObjectSet(TextBarString,OBJPROP_FONTSIZE,myDocSize);//大小

ObjectSetText(TextBarString,myString);//文字内容

ObjectSet(TextBarString,OBJPROP_BACK,false);

}

if (myType=="Dot")

{

string DotBarString=myType+Time[myBarPos];

ObjectCreate(DotBarString,OBJ_ARROW,0,Time[myBarPos],myPrice);

ObjectSet(DotBarString,OBJPROP_COLOR,myColor);

ObjectSet(DotBarString,OBJPROP_ARROWCODE,mySymbol);

ObjectSet(DotBarString,OBJPROP_BACK,false);

}

if (myType=="HLine")

{

string HLineBarString=myType+Time[myBarPos];

ObjectCreate(HLineBarString,OBJ_HLINE,0,Time[myBarPos],myPrice);

ObjectSet(HLineBarString,OBJPROP_COLOR,myColor);

ObjectSet(HLineBarString,OBJPROP_BACK,false);

}

if (myType=="VLine")

{

string VLineBarString=myType+Time[myBarPos];

ObjectCreate(VLineBarString,OBJ_VLINE,0,Time[myBarPos],myPrice);

ObjectSet(VLineBarString,OBJPROP_COLOR,myColor);

ObjectSet(VLineBarString,OBJPROP_BACK,false);

}

}

void

{

for (int cnt=0;cnt

{

if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES) &&

&& OrderMagicNumber()==myMagicNum

OrderSymbol()==Symbol())

{

iWait(1000);

if

{

myLots=OrderLots();

OrderClose(OrderTicket(),myLots,Bid,0);

}

if ((myType==OP_SELL ||

&&

(myType==9

(myLots==0

&&

|| OrderType()==OP_SELL))

myLots>OrderLots()))

{

myLots=OrderLots();

((myType==OP_BUY || (myType==9 &&

OrderType()==OP_BUY)) && (myLots==0 || myLots>OrderLots()))

iBatchClose(int myType,double myLots,int

myMagicNum)

OrderClose(OrderTicket(),myLots,Ask,0);

}

if (myType==OP_BUYLIMIT || myType==OP_SELLLIMIT ||

myType==OP_BUYSTOP || myType==OP_SELLSTOP

|| (myType==9 && (OrderType()==OP_BUYLIMIT ||

OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP ||

OrderType()==OP_SELLSTOP)))

{

OrderDelete(OrderTicket());

}

}

}

return(0);

}

double iLotsFormat(double myLots)

{

myLots=MathRound(myLots/MarketInfo(Symbol(),

MODE_MINLOT))*MarketInfo(Symbol(), MODE_MINLOT);//开仓量整形

return(myLots);

}

double iGroupEquity(int myOrderType,int myMagicNum)

{

double myReturn;

if (OrdersTotal()==0) return(0);

for (int cnt=0;cnt

{

if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)

&& OrderMagicNumber()==myMagicNum &&

OrderSymbol()==Symbol() && OrderType()==myOrderType)

{

myReturn=myReturn+OrderProfit();

}

}

return(myReturn);

}

double iGroupLots(int myOrderType,int myMagicNum)

{

double myReturn;

if (OrdersTotal()==0) return(0);

for (int cnt=0;cnt

{

if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)

&&

{

myReturn=myReturn+OrderLots();

}

}

return(myReturn);

}

color iObjectColor(double myInput)

{

color myColor;

if (myInput > 0)

myColor = Green; //正数颜色为绿色

if (myInput < 0)

myColor = Red; //负数颜色为红色

if (myInput == 0)

myColor = DarkGray; //0颜色为灰色

OrderMagicNumber()==myMagicNum &&

OrderSymbol()==Symbol() && OrderType()==myOrderType)

return(myColor);

}

int iOrderStatistics(int myOrderType,int myMagicNum)

{

int myReturn;

if (OrdersTotal()==0) return(0);

for (int cnt=0;cnt

{

if (OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)

&&

{

myReturn=myReturn+1;

}

}

return(myReturn);

}

int

{

int myReturn,myArrayRange,cnt,i,j;

if (OrdersTotal()<=0) return(myReturn);

myArrayRange=OrdersTotal();

//持仓订单基本信息:0订单号,1开仓时间,2订单利润,3订单类型,4开仓量,5开仓价,

// 6止损价,7止赢价,8订单特征码,9订单佣金,10掉期,11挂单有效日期

double myOrdersArray[][12]; //定义订单数组,第1维:订单序号;第2维:订单信息

ArrayResize(myOrdersArray,myArrayRange); //重新界定订单iOrdersSort(int myOrderType,int myOrderSort,int

myMaxMin,int myMagicNum)

OrderMagicNumber()==myMagicNum &&

OrderSymbol()==Symbol() && OrderType()==myOrderType)

数组

ArrayInitialize(myOrdersArray, 0.0); //初始化订单数组

//订单数组赋值

for (cnt=0; cnt

{

//选中当前货币对相关持仓订单

if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) &&

OrderSymbol()==Symbol()

OrderMagicNumber()==myMagicNum)

{

myOrdersArray[cnt][0]=OrderTicket();//0订单号

myOrdersArray[cnt][1]=OrderOpenTime();//1开仓时间

myOrdersArray[cnt][2]=OrderProfit();//2订单利润

myOrdersArray[cnt][3]=OrderType();//3订单类型

myOrdersArray[cnt][4]=OrderLots();//4开仓量

myOrdersArray[cnt][5]=OrderOpenPrice();//5开仓价

myOrdersArray[cnt][6]=OrderStopLoss();//6止损价

myOrdersArray[cnt][7]=OrderTakeProfit();//7止赢价

myOrdersArray[cnt][8]=OrderMagicNumber();//8订单特征码

myOrdersArray[cnt][9]=OrderCommission();//9订单佣金

myOrdersArray[cnt][10]=OrderSwap();//10掉期

myOrdersArray[cnt][11]=OrderExpiration();//11挂单有效日期

}

}

double myTempArray[12]; //定义临时数组

//ArrayResize(myTempArray,myArrayRange); //重新界定临时数组

ArrayInitialize(myTempArray, 0.0); //初始化临时数组

//开始按条件排序

//---- 按时间降序排列数组,原始数组重新排序

&&

if (myOrderSort==0)

{

for (i=0;i<=myArrayRange;i++)

{

for (j=myArrayRange;j>i;j--)

{

if (myOrdersArray[j][1]>myOrdersArray[j-1][1])

{

myTempArray[0]=myOrdersArray[j-1][0];

myTempArray[1]=myOrdersArray[j-1][1];

myTempArray[2]=myOrdersArray[j-1][2];

myTempArray[3]=myOrdersArray[j-1][3];

myTempArray[4]=myOrdersArray[j-1][4];

myTempArray[5]=myOrdersArray[j-1][5];

myTempArray[6]=myOrdersArray[j-1][6];

myTempArray[7]=myOrdersArray[j-1][7];

myTempArray[8]=myOrdersArray[j-1][8];

myTempArray[9]=myOrdersArray[j-1][9];

myTempArray[10]=myOrdersArray[j-1][10];

myTempArray[11]=myOrdersArray[j-1][11];

myOrdersArray[j-1][0]=myOrdersArray[j][0];

myOrdersArray[j-1][1]=myOrdersArray[j][1];

myOrdersArray[j-1][2]=myOrdersArray[j][2];

myOrdersArray[j-1][3]=myOrdersArray[j][3];

myOrdersArray[j-1][4]=myOrdersArray[j][4];

myOrdersArray[j-1][5]=myOrdersArray[j][5];

myOrdersArray[j-1][6]=myOrdersArray[j][6];

myOrdersArray[j-1][7]=myOrdersArray[j][7];

myOrdersArray[j-1][8]=myOrdersArray[j][8];

myOrdersArray[j-1][9]=myOrdersArray[j][9];

myOrdersArray[j-1][10]=myOrdersArray[j][10];

myOrdersArray[j-1][11]=myOrdersArray[j][11];

myOrdersArray[j][0]=myTempArray[0];

myOrdersArray[j][1]=myTempArray[1];

myOrdersArray[j][2]=myTempArray[2];

myOrdersArray[j][3]=myTempArray[3];

myOrdersArray[j][4]=myTempArray[4];

myOrdersArray[j][5]=myTempArray[5];

myOrdersArray[j][6]=myTempArray[6];

myOrdersArray[j][7]=myTempArray[7];

myOrdersArray[j][8]=myTempArray[8];

myOrdersArray[j][9]=myTempArray[9];

myOrdersArray[j][10]=myTempArray[10];

myOrdersArray[j][11]=myTempArray[11];

}

}

}

if (myMaxMin==0) //x,0,0

{

for (cnt=myArrayRange;cnt>=0;cnt--)

{

if

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

if (myMaxMin==1) //x,0,1

(myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0))

{

for (cnt=0;cnt

{

if

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

}

//---- 按订单净值降序排列数组,原始数组重新排序

if (myOrderSort==1 || myOrderSort==2)

{

ArrayInitialize(myTempArray, 0.0); //初始化临时数组

for (i=0;i<=myArrayRange;i++)

{

for (j=myArrayRange-1;j>i;j--)

{

if (myOrdersArray[j][2]>myOrdersArray[j-1][2])

{

myTempArray[0]=myOrdersArray[j-1][0];

myTempArray[1]=myOrdersArray[j-1][1];

myTempArray[2]=myOrdersArray[j-1][2];

myTempArray[3]=myOrdersArray[j-1][3];

myTempArray[4]=myOrdersArray[j-1][4];

myTempArray[5]=myOrdersArray[j-1][5];

myTempArray[6]=myOrdersArray[j-1][6];

myTempArray[7]=myOrdersArray[j-1][7];

(myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0))

myTempArray[8]=myOrdersArray[j-1][8];

myTempArray[9]=myOrdersArray[j-1][9];

myTempArray[10]=myOrdersArray[j-1][10];

myTempArray[11]=myOrdersArray[j-1][11];

myOrdersArray[j-1][0]=myOrdersArray[j][0];

myOrdersArray[j-1][1]=myOrdersArray[j][1];

myOrdersArray[j-1][2]=myOrdersArray[j][2];

myOrdersArray[j-1][3]=myOrdersArray[j][3];

myOrdersArray[j-1][4]=myOrdersArray[j][4];

myOrdersArray[j-1][5]=myOrdersArray[j][5];

myOrdersArray[j-1][6]=myOrdersArray[j][6];

myOrdersArray[j-1][7]=myOrdersArray[j][7];

myOrdersArray[j-1][8]=myOrdersArray[j][8];

myOrdersArray[j-1][9]=myOrdersArray[j][9];

myOrdersArray[j-1][10]=myOrdersArray[j][10];

myOrdersArray[j-1][11]=myOrdersArray[j][11];

myOrdersArray[j][0]=myTempArray[0];

myOrdersArray[j][1]=myTempArray[1];

myOrdersArray[j][2]=myTempArray[2];

myOrdersArray[j][3]=myTempArray[3];

myOrdersArray[j][4]=myTempArray[4];

myOrdersArray[j][5]=myTempArray[5];

myOrdersArray[j][6]=myTempArray[6];

myOrdersArray[j][7]=myTempArray[7];

myOrdersArray[j][8]=myTempArray[8];

myOrdersArray[j][9]=myTempArray[9];

myOrdersArray[j][10]=myTempArray[10];

myOrdersArray[j][11]=myTempArray[11];

}

}

}

if (myOrderSort==1 && myMaxMin==1) //x,1,1

{

for (cnt=myArrayRange;cnt>=0;cnt--)

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][2]>0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

if (myOrderSort==1 && myMaxMin==0) //x,1,0

{

for (cnt=0;cnt

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][2]>0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

if (myOrderSort==2 && myMaxMin==0) //x,2,1

{

for (cnt=myArrayRange;cnt>=0;cnt--)

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][2]<0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

if (myOrderSort==2 && myMaxMin==1) //x,2,0

{

for (cnt=0;cnt

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][2]<0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

}

//---- 按开仓价降序排列数组,原始数组重新排序

if (myOrderSort==3)

{

for (i=0;i<=myArrayRange;i++)

{

for (j=myArrayRange;j>i;j--)

{

if (myOrdersArray[j][5]>myOrdersArray[j-1][5])

{

myTempArray[0]=myOrdersArray[j-1][0];

myTempArray[1]=myOrdersArray[j-1][1];

myTempArray[2]=myOrdersArray[j-1][2];

myTempArray[3]=myOrdersArray[j-1][3];

myTempArray[4]=myOrdersArray[j-1][4];

myTempArray[5]=myOrdersArray[j-1][5];

myTempArray[6]=myOrdersArray[j-1][6];

myTempArray[7]=myOrdersArray[j-1][7];

myTempArray[8]=myOrdersArray[j-1][8];

myTempArray[9]=myOrdersArray[j-1][9];

myTempArray[10]=myOrdersArray[j-1][10];

myTempArray[11]=myOrdersArray[j-1][11];

myOrdersArray[j-1][0]=myOrdersArray[j][0];

myOrdersArray[j-1][1]=myOrdersArray[j][1];

myOrdersArray[j-1][2]=myOrdersArray[j][2];

myOrdersArray[j-1][3]=myOrdersArray[j][3];

myOrdersArray[j-1][4]=myOrdersArray[j][4];

myOrdersArray[j-1][5]=myOrdersArray[j][5];

myOrdersArray[j-1][6]=myOrdersArray[j][6];

myOrdersArray[j-1][7]=myOrdersArray[j][7];

myOrdersArray[j-1][8]=myOrdersArray[j][8];

myOrdersArray[j-1][9]=myOrdersArray[j][9];

myOrdersArray[j-1][10]=myOrdersArray[j][10];

myOrdersArray[j-1][11]=myOrdersArray[j][11];

myOrdersArray[j][0]=myTempArray[0];

myOrdersArray[j][1]=myTempArray[1];

myOrdersArray[j][2]=myTempArray[2];

myOrdersArray[j][3]=myTempArray[3];

myOrdersArray[j][4]=myTempArray[4];

myOrdersArray[j][5]=myTempArray[5];

myOrdersArray[j][6]=myTempArray[6];

myOrdersArray[j][7]=myTempArray[7];

myOrdersArray[j][8]=myTempArray[8];

myOrdersArray[j][9]=myTempArray[9];

myOrdersArray[j][10]=myTempArray[10];

myOrdersArray[j][11]=myTempArray[11];

}

}

}

if (myMaxMin==1) //x,3,0

{

for (cnt=myArrayRange;cnt>=0;cnt--)

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][5]>0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

if (myMaxMin==0) //x,3,1

{

for (cnt=0;cnt

{

if (myOrdersArray[cnt][0]!=0 &&

myOrderType==NormalizeDouble(myOrdersArray[cnt][3],0) &&

myOrdersArray[cnt][5]>0)

{

myReturn=NormalizeDouble(myOrdersArray[cnt][0],0);

break;

}

}

}

}

return(myReturn);

}

bool iValidTime(string myStartTime,string myEndTime,bool

myServerTime)

{

bool myValue=false;

int myST,myET;

if (myServerTime==true)

{

myST=StrToTime(Year()+"."+Month()+"."+Day()+"

"+myStartTime);

myET=StrToTime(Year()+"."+Month()+"."+Day()+"

"+myEndTime);

}

if (myServerTime==false)

{

myST=StrToTime(myStartTime);

myET=StrToTime(myEndTime);

}

if (myST>myET) myET=myET+1440*60;

if (TimeCurrent()>myST && TimeCurrent()

{

myValue=true;

}

if (TimeLocal()>myST && TimeLocal()

{

myValue=true;

}

if (myST==myET) myValue=true;

return(myValue);

}

void iWait(int myDelayTime)

{

while (!IsTradeAllowed() || IsTradeContextBusy())

Sleep(myDelayTime);

RefreshRates();

return(0);

}

string iGetErrorInfo(int myErrorNum)

{

string myLastErrorStr;

if(myErrorNum>=0)

{

switch (myErrorNum)

{

case 0:myLastErrorStr="错误代码:"+0+"-没有错误返回";break;

case 1:myLastErrorStr="错误代码:"+1+"-没有错误返回但结果不明";break;

case 2:myLastErrorStr="错误代码:"+2+"-一般错误";break;

case 3:myLastErrorStr="错误代码:"+3+"-无效交易参量";break;

case 4:myLastErrorStr="错误代码:"+4+"-交易服务器繁忙

";break;

case 5:myLastErrorStr="错误代码:"+5+"-客户终端旧版本";break;

case 6:myLastErrorStr="错误代码:"+6+"-没有连接服务器";break;

case 7:myLastErrorStr="错误代码:"+7+"-没有权限";break;

case 8:myLastErrorStr="错误代码:"+8+"-请求过于频繁";break;

case 9:myLastErrorStr="错误代码:"+9+"-交易运行故障";break;

case 64:myLastErrorStr="错误代码:"+64+"-账户禁止";break;

case 65:myLastErrorStr="错误代码:"+65+"-无效账户";break;

case 128:myLastErrorStr="错误代码:"+128+"-交易超时";break;

case 129:myLastErrorStr="错误代码:"+129+"-无效价格";break;

case 130:myLastErrorStr="错误代码:"+130+"-无效停止";break;

case 131:myLastErrorStr="错误代码:"+131+"-无效交易量";break;

case 132:myLastErrorStr="错误代码:"+132+"-市场关闭";break;

case 133:myLastErrorStr="错误代码:"+133+"-交易被禁止";break;

case 134:myLastErrorStr="错误代码:"+134+"-资金不足";break;

case 135:myLastErrorStr="错误代码:"+135+"-价格改变";break;

case 136:myLastErrorStr="错误代码:"+136+"-开价";break;

case 137:myLastErrorStr="错误代码:"+137+"-经纪繁忙";break;

case 138:myLastErrorStr="错误代码:"+138+"-重新开价";break;

case 139:myLastErrorStr="错误代码:"+139+"-定单被锁定";break;

case 140:myLastErrorStr="错误代码:"+140+"-只允许看涨仓位";break;

case 141:myLastErrorStr="错误代码:"+141+"-过多请求";break;

case 145:myLastErrorStr="错误代码:"+145+"-因为过于接近市场,修改无效";break;

case 146:myLastErrorStr="错误代码:"+146+"-交易文本已满";break;

case 147:myLastErrorStr="错误代码:"+147+"-时间周期被经纪否定";break;

case 148:myLastErrorStr="错误代码:"+148+"-开单和挂单总数已被经纪限定";break;

case 149:myLastErrorStr="错误代码:"+149+"-当对冲被拒绝时,打开相对于现有的一个单量";break;

case 150:myLastErrorStr="错误代码:"+150+"-把为反FIFO规定的单子平掉";break;

case 4000:myLastErrorStr="错误代码:"+4000+"-没有错误";break;

case 4001:myLastErrorStr="错误代码:"+4001+"-错误函数指示";break;

case 4002:myLastErrorStr="错误代码:"+4002+"-数组索引超出范围";break;

case 4003:myLastErrorStr="错误代码:"+4003+"-对于调用堆栈储存器函数没有足够内存";break;

case 4004:myLastErrorStr="错误代码:"+4004+"-循环堆栈储存器溢出";break;

case 4005:myLastErrorStr="错误代码:"+4005+"-对于堆栈储存器参量没有内存";break;

case 4006:myLastErrorStr="错误代码:"+4006+"-对于字行参量没有足够内存";break;

case 4007:myLastErrorStr="错误代码:"+4007+"-对于字行没有足够内存";break;

case 4008:myLastErrorStr="错误代码:"+4008+"-没有初始字行";break;

case 4009:myLastErrorStr="错误代码:"+4009+"-在数组中没有初始字串符";break;

case 4010:myLastErrorStr="错误代码:"+4010+"-对于数组没有内存";break;

case 4011:myLastErrorStr="错误代码:"+4011+"-字行过长";break;

case 4012:myLastErrorStr="错误代码:"+4012+"-余数划分为零";break;

case 4013:myLastErrorStr="错误代码:"+4013+"-零划分";break;

case 4014:myLastErrorStr="错误代码:"+4014+"-不明命令";break;

case 4015:myLastErrorStr="错误代码:"+4015+"-错误转换(没有常规错误)";break;

case 4016:myLastErrorStr="错误代码:"+4016+"-没有初始数组";break;

case 4017:myLastErrorStr="错误代码:"+4017+"-禁止调用DLL

";break;

case 4018:myLastErrorStr="错误代码:"+4018+"-数据库不能下载";break;

case 4019:myLastErrorStr="错误代码:"+4019+"-不能调用函数";break;

case 4020:myLastErrorStr="错误代码:"+4020+"-禁止调用智能交易函数";break;

case 4021:myLastErrorStr="错误代码:"+4021+"-对于来自函数的字行没有足够内存";break;

case 4022:myLastErrorStr="错误代码:"+4022+"-系统繁忙 (没有常规错误)";break;

case 4050:myLastErrorStr="错误代码:"+4050+"-无效计数参量函数";break;

case 4051:myLastErrorStr="错误代码:"+4051+"-无效开仓量";break;

case 4052:myLastErrorStr="错误代码:"+4052+"-字行函数内部错误";break;

case 4053:myLastErrorStr="错误代码:"+4053+"-一些数组错误";break;

case 4054:myLastErrorStr="错误代码:"+4054+"-应用不正确数组";break;

case 4055:myLastErrorStr="错误代码:"+4055+"-自定义指标错误";break;

case 4056:myLastErrorStr="错误代码:"+4056+"-不协调数组";break;

case 4057:myLastErrorStr="错误代码:"+4057+"-整体变量过程错误";break;

case 4058:myLastErrorStr="错误代码:"+4058+"-整体变量未找到";break;

case 4059:myLastErrorStr="错误代码:"+4059+"-测试模式函数禁止";break;

case 4060:myLastErrorStr="错误代码:"+4060+"-没有确认函数";break;

case 4061:myLastErrorStr="错误代码:"+4061+"-发送邮件错误";break;

case 4062:myLastErrorStr="错误代码:"+4062+"-字行预计参量";break;

case 4063:myLastErrorStr="错误代码:"+4063+"-整数预计参量";break;

case 4064:myLastErrorStr="错误代码:"+4064+"-双预计参量";break;

case 4065:myLastErrorStr="错误代码:"+4065+"-数组作为预计参量";break;

case 4066:myLastErrorStr="错误代码:"+4066+"-刷新状态请求历史数据";break;

case 4067:myLastErrorStr="错误代码:"+4067+"-交易函数错误";break;

case 4099:myLastErrorStr="错误代码:"+4099+"-文件结束";break;

case 4100:myLastErrorStr="错误代码:"+4100+"-一些文件错误";break;

case 4101:myLastErrorStr="错误代码:"+4101+"-错误文件名称";break;

case 4102:myLastErrorStr="错误代码:"+4102+"-打开文件过多";break;

case 4103:myLastErrorStr="错误代码:"+4103+"-不能打开文件";break;

case 4104:myLastErrorStr="错误代码:"+4104+"-不协调文件";break;

case 4105:myLastErrorStr="错误代码:"+4105+"-没有选择定单";break;

case 4106:myLastErrorStr="错误代码:"+4106+"-不明货币对";break;

case 4107:myLastErrorStr="错误代码:"+4107+"-无效价格";break;

case 4108:myLastErrorStr="错误代码:"+4108+"-无效定单编码";break;

case 4109:myLastErrorStr="错误代码:"+4109+"-不允许交易";break;

case 4110:myLastErrorStr="错误代码:"+4110+"-不允许长期";break;

case 4111:myLastErrorStr="错误代码:"+4111+"-不允许短期";break;

case 4200:myLastErrorStr="错误代码:"+4200+"-定单已经存在";break;

case 4201:myLastErrorStr="错误代码:"+4201+"-不明定单属性";break;

case 4202:myLastErrorStr="错误代码:"+4202+"-定单不存在";break;

case 4203:myLastErrorStr="错误代码:"+4203+"-不明定单类型";break;

case 4204:myLastErrorStr="错误代码:"+4204+"-没有定单名称";break;

case 4205:myLastErrorStr="错误代码:"+4205+"-定单坐标错误";break;

case 4206:myLastErrorStr="错误代码:"+4206+"-没有指定子窗口";break;

case 4207:myLastErrorStr="错误代码:"+4207+"-定单一些函数错误";break;

case 4250:myLastErrorStr="错误代码:"+4250+"-错误设定发送通知到队列中";break;

case 4251:myLastErrorStr="错误代码:"+4251+"-无效参量- 空字符串传递到SendNotification()函数";break;

case 4252:myLastErrorStr="错误代码:"+4252+"-无效设置发送通知(未指定ID或未启用通知)";break;

case 4253:myLastErrorStr="错误代码:"+4253+"-通知发送过于频繁";break;

}

}

return(myLastErrorStr);

}

int iOrderEquitToPoint(int myTicket)

{

int myPoint=0;

if (OrderSelect(myTicket,SELECT_BY_TICKET,MODE_TRADES))

{

if (OrderType()==OP_BUY)

{

myPoint=(Bid-OrderOpenPrice())/Point;

}

if (OrderType()==OP_SELL)

{

myPoint=(OrderOpenPrice()-Ask)/Point;

}

}

return(myPoint);

}

double iFundsToHands(string mySymbol,double myFunds)

{

double myLots=myFunds/MarketInfo(mySymbol,

MODE_MARGINREQUIRED);//换算可开仓手数

myLots=MathRound(myLots/MarketInfo(mySymbol,

MODE_MINLOT))*MarketInfo(Symbol(), MODE_MINLOT);//手数整形

return(myLots);

}

void iDisplayInfo(string LableName,string LableDoc,int

Corner,int LableX,int LableY,int DocSize,string DocStyle,color

DocColor)

{

if (Corner == -1) return(0);

ObjectCreate(LableName, OBJ_LABEL, 0, 0, 0);

ObjectSetText(LableName,

DocStyle,DocColor);

ObjectSet(LableName, OBJPROP_CORNER, Corner);

LableDoc, DocSize,

ObjectSet(LableName, OBJPROP_XDISTANCE, LableX);

ObjectSet(LableName, OBJPROP_YDISTANCE, LableY);

}


本文标签: 没有 数组 错误