跟单源码

楼主  收藏   举报   帖子创建时间:  2019-05-05 10:35 回复:0 关注量:621
////////////////////////信号发送的源码:
int start()
{
if (OrdersTotal()==1 && OrderSelect(0, SELECT_BY_POS, MODE_TRADES))
{
int myHandle = FileOpen("TradeInfo.csv", FILE_CSV | FILE_WRITE, ",");
FileWrite(myHandle, OrderOpenTime(), OrderTicket(), OrderSymbol(), OrderType(),
OrderLots(), OrderOpenPrice(), OrderComment(), OrderMagicNumber());
FileClose(myHandle);
}
if (OrdersTotal()==0) FileDelete("TradeInfo.csv");
return(0);

///////////////////////信号接收的源码:
string myType, myLots, mySymobl;
int myHandle;

int start()
{
if (iReadFile() == 1 && OrdersTotal()==0)
{
int mycmd1 = StrToInteger(myType);
string mySymobl1 = mySymobl;
double mylots1 = NormalizeDouble(StrToDouble(myLots),2);
double myOpenPrice=0 ;
if (mycmd1 == 0) myOpenPrice = MarketInfo(mySymobl1, MODE_ASK);
if (mycmd1 == 1) myOpenPrice = MarketInfo(mySymobl1, MODE_BID);
OrderSend(mySymobl, mycmd1, mylots1, myOpenPrice, 0, 0, 0);
}
if (iReadFile() == 0 && OrderSelect(0, SELECT_BY_POS, MODE_TRADES))
{
double myClosePrice=0 ;
if (OrderType()==OP_BUY) myClosePrice=Bid;
if (OrderType()==OP_SELL) myClosePrice=Ask;
OrderClose(OrderTicket(), OrderLots(), myClosePrice, 0);
}
return(0);
}
int iReadFile()
{
myHandle = FileOpen("myMT4SignalexpertsfilesTradeInfo.csv", FILE_BIN | FILE_READ);
if (myHandle == -1) return(0);
string myValue;
myValue = FileReadString(myHandle, 60);
int myDatecnt = StringFind(myValue, ",", 0);
string myDate = StringSubstr(myValue, 0 ,myDatecnt);
int myTicketcnt = StringFind(myValue, ",", myDatecnt+1);
string myTicket = StringSubstr(myValue, myDatecnt+1, myTicketcnt-myDatecnt-1);
int mySymbolcnt = StringFind(myValue, ",", myTicketcnt+1);
mySymobl = StringSubstr(myValue, myTicketcnt+1, mySymbolcnt-myTicketcnt-1);
int myTypecnt = StringFind(myValue, ",", mySymbolcnt+1);
myType = StringSubstr(myValue, mySymbolcnt+1, myTypecnt-mySymbolcnt-1);
int myLotscnt = StringFind(myValue, ",", myTypecnt+1);
myLots = StringSubstr(myValue, myTypecnt+1, myLotscnt-myTypecnt-1);
int myPricecnt = StringFind(myValue, ",", myLotscnt+1);
string myPrice = StringSubstr(myValue, myLotscnt+1, myPricecnt-myLotscnt-1);
FileClose(myHandle);
return(1);
}

打赏