首页 > > 详细

代做公式选股、MT4策略公式调试、代做公式选股、exp_Amstell-SL 指标源码



源码:
//+------------------------------------------------------------------+
//|exp_Amstell.mq4 |
//| Copyright � 2009, Yuriy Tokman |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright � 2009, Yuriy Tokman"
#property link""
extern intTakeProfit = 30;
extern intStopLoss = 30;
extern double Lots = 0.01;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function|
//+------------------------------------------------------------------+
int start()
{
int Magic=0;
for(int cnt=0;
cntTakeProfit*Point || OrderOpenPrice()-Ask>StopLoss*Point)//
{
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
//玎牮噱� 铕溴�
return(0);
// 恹躅滂�
}//StopLoss
}
if(OrderType()==OP_SELL){
if(OrderOpenPrice()-Ask>TakeProfit*Point || Bid-OrderOpenPrice()>StopLoss*Point)//
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
return(0);
}
}
}
}
//----
int buy = 0, sell = 0;
//----
if(!ExistPositions(NULL,OP_BUY))buy=1;
else if(PriceOpenLastPos(NULL,OP_BUY)-Ask>10*Point)buy=1;


if(!ExistPositions(NULL,OP_SELL))sell=1;
else if(Bid-PriceOpenLastPos(NULL,OP_SELL)>10*Point)sell=1;

//----
if(buy==1)
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",0,0,Green);
if(sell==1)
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"",0,0,Red);
//----
return(0);
}
bool ExistPositions(string sy="", int p=-1, int mn=-1, datetime t=0) {
int i, k=OrdersTotal();
if (sy=="0") sy=Symbol();
for (i=0;
i i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (ot<=OrderOpenTime()) return(True);
}
}
}
}
}
}
return(False);
}
double PriceOpenLastPos(string sy="", int p=-1, int mn=-1) {
datetime t;
double r=0;
inti, k=OrdersTotal();
if (sy=="0") sy=Symbol();
for (i=0;
i i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==sy || sy=="") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
if (tt=OrderOpenTime();
r=OrderOpenPrice();
}
}
}
}
}
}
}
return(r);
}

联系我们 - QQ: 88652583
© 2014 www.93stock.com
代写选股公式网!
声明:警惕假冒分子冒充本站提供证券咨询服务,选股公式网为非证券咨询机构,本站不提供有关股评、投资分析报告、股市预测,证券咨询等服务。本站仅提供股票、期货、黄金、外汇的软件技术交流与分享。本站文章为互联网文章,其仅供参考,并不构成投资建议。