下载MetaTrader 5
要添加评论,请登录注册
发表 您的文章,全世界数以千计的人们都将阅读它!
liuxiaodong
282
liuxiaodong 2008.08.25 14:44 

this ea based on Instantaneous Trendline Filter from Rosh !

for too lang name,I change the name to aaa02.

//+------------------------------------------------------------------+
//| Designed by AAA, China |
//| Copyright 2007, OKwh & Dxdcn & AAA |
//| THIS EA IS reworded by rosh'indicator |
//+------------------------------------------------------------------+
#property copyright "Copyright 2007,AAA, China."
#property link "http"
#define MAGICMA 200810011231
//+------------------------------------------------------------------+
//| 注意没有指标文件那些property |
//+------------------------------------------------------------------+
//
extern double TakeProfit = 100; //止赢点数
extern double StopLoss = 60; //止损点数
extern double TrailingStop =40; //跟踪止赢点数设置
extern int maxOpen = 4; //最多开仓次数限制
extern int bb = 0; //非零就允许跟踪止赢
//
extern double lots=0.1; //一次下单手数

int i, p2, xxx,p1, res1,res2,res3,res4; //时间控制, 仅当一个时间周期完成才检查条件
int init() //初始化
{

return(0);
}
int deinit() { return(0); } //反初始化
//主程序
int start()
{
CheckForOpen(); //开仓 平仓 条件检查 和操作
if (bb>0) CTP(); //跟踪止赢
return(0);
}
//+------下面是各子程序--------------------------------------------+


//平仓持有的买单、、先结束买肥美
void CloseBuy()
{
if (OrdersTotal( ) > 0 )
{
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()==MAGICMA+1)
{
OrderClose(OrderTicket(),OrderLots(),Bid,4,White);
}
if(OrderMagicNumber()==MAGICMA+2)
{
OrderClose(OrderTicket(),OrderLots(),Bid,4,White);
}
if(OrderMagicNumber()==MAGICMA+3)
{
OrderClose(OrderTicket(),OrderLots(),Ask,4,White);
}
if(OrderMagicNumber()==MAGICMA+4)
{
OrderClose(OrderTicket(),OrderLots(),Ask,4,White);
}
}
}
}
//平仓持有的卖单、、先结束卖肥美
void CloseSell()
{
if (OrdersTotal( ) > 0 )
{
for(i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()==MAGICMA+5)
{
OrderClose(OrderTicket(),OrderLots(),Ask,4,White);
}
if(OrderMagicNumber()==MAGICMA+6)
{
OrderClose(OrderTicket(),OrderLots(),Ask,4,White);
}
if(OrderMagicNumber()==MAGICMA+7)
{
OrderClose(OrderTicket(),OrderLots(),Bid,4,White);
}
if(OrderMagicNumber()==MAGICMA+8)
{
OrderClose(OrderTicket(),OrderLots(),Bid,4,White);
}
}
}
}
//判断是否买或卖或平仓
int buyorsell() //在这个函数计算设置你的交易信号
{
double easyeu11,easyeu21,easygu11,easygu21,easyuc11,easyuc21,easyuj11,easyuj21;
//
easyeu11=iCustom("UERUSD",PERIOD_M30,"aaa02",0.05,2000,false,0,0);
easyeu21=iCustom("UERUSD",PERIOD_M30,"aaa02",0.05,2000,false,1,0);
easygu11=iCustom("GBPUSD",PERIOD_M30,"aaa02",0.05,2000,false,0,0);
easygu21=iCustom("GBPUSD",PERIOD_M30,"aaa02",0.05,2000,false,1,0);
easyuc11=iCustom("USDCHF",PERIOD_M30,"aaa02",0.05,2000,false,0,0);
easyuc21=iCustom("USDCHF",PERIOD_M30,"aaa02",0.05,2000,false,1,0);
easyuj11=iCustom("USDJPY",PERIOD_M30,"aaa02",0.05,2000,false,0,0);
easyuj21=iCustom("USDJPY",PERIOD_M30,"aaa02",0.05,2000,false,1,0);
if(easyeu21>easyeu11 && easygu21>easygu11 && easyuc11>easyuc21 && easyuj11>easyuj21 )
return (1); // 买肥美SELL USD
if( easyeu21<easyeu11 && easygu21<easygu11 && easyuc11<easyuc21 && easyuj11<easyuj21 )
return (-1); // 卖肥美 BUY USD
//
return (0); //不交易 NO ANY OPENNING
}
int nowbuyorsell = 0;
void CheckForOpen()
{
//if (Time[0] == lasttime ) return; //每时间周期检查一次 时间控制
//lasttime = Time[0];
nowbuyorsell = buyorsell(); //获取买卖信号

if (nowbuyorsell == 1) //买 先结束卖肥美 CLOSE BUY USD
CloseSell();
if (nowbuyorsell == -1) //卖 先结束买肥美 CLOSE SELL USD
CloseBuy();


if (OrdersTotal( ) >= maxOpen) return ;
//如果已持有开仓次数达到最大,不做
if (nowbuyorsell==0) return; //不交易
TradeOK(); //去下单交易
}
void TradeOK() //去下单交易
{
//int error ;
if (nowbuyorsell == 1) //买肥美 SELL USD
{
res1=OrderSend("EURUSD",OP_BUY,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+1,0,Blue);
res2=OrderSend("GBPUSD",OP_BUY,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+2,0,Blue);
res3=OrderSend("USDCHF",OP_SELL,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+3,0,Blue);
res4=OrderSend("USDJPY",OP_SELL,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+4,0,Blue);

Sleep(5000);
return ;
}
if (nowbuyorsell == -1) //卖肥美 BUY USD
{
res1=OrderSend("EURUSD",OP_SELL,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+5,0,Blue);
res2=OrderSend("GBPUSD",OP_SELL,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+6,0,Blue);
res3=OrderSend("USDCHF",OP_BUY,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+7,0,Blue);
res4=OrderSend("USDJPY",OP_BUY,lots,Ask,4,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",MAGICMA+8,0,Blue);
Sleep(5000);
return ;
}
}
void CTP() //跟踪止赢
{
bool bs = false;
for (int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if (OrderType() == OP_BUY)
{
if ((Bid - OrderOpenPrice()) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置
{
if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Green);
}
}
}
else if (OrderType() == OP_SELL)
{
if ((OrderOpenPrice() - Ask) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置

{
if ((OrderStopLoss()) > (Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Tan);
}
}
}
}
}

Rashid Umarov
管理员
6600
Rashid Umarov 2008.08.25 16:21  
The "https://forum.mql4.com/ru/14937" indicator is no my own and I don't know about one, sorry.
okwh
1629
okwh 2008.08.26 12:15  
Print(easyeu11,easyeu12,......) ; check waht are them in log window !
liuxiaodong
282
liuxiaodong 2008.08.27 04:25  
DxdCn >>
Print(easyeu11,easyeu12,......) ; check waht are them in log window !

谢谢 就是用这个办法解决的 是自己粗心把eurusd 写成了 uerusd 呵呵

/
要添加评论,请登录注册