【宽客EA】趋势性剥头皮EA
EA根据以下形态的出现建仓,并以最近的高低点止盈。比如为下跌趋势出现两连阳就建仓空单,为上涨趋势出现两连阴开盘买入。它的不足是无法抓住大盈利,亏损总是盈利成正比,他也无法在震荡行情下很好的生存。//+------------------------------------------------------------------+
//| EA.mq4 |
//|
//| https://www.geekquant.com |
//+------------------------------------------------------------------+
#property copyright "jay"
#property link "https://www.geekquant.com"
#property version "1.00"
#property strict
extern double my_lots= 0.01; //Lots
extern int zhi_s=100; //StopLoss
extern string magic="aimoney6@126.com";
int dian_c=6,
wei_s =100;
double dian_z=0.1;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(Point < 0.001)
{
dian_z=0.0001;
wei_s=100000;
}
else if(Point == 0.001)
{
dian_z=0.01;
wei_s=1000;
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
static datetimetime=0;
static double zhi_y=0; //takepofit
int ab=0;
bool bo=false;
double close_1=Close,
close_2=Close,
open_1=Open,
open_2=Open;
double MA_5 =iMA(NULL, 0,14,0,MODE_SMMA,PRICE_MEDIAN,0);
dian_c=StrToInteger(DoubleToStr((Ask-Bid)*wei_s, 0));
for(int i=OrdersTotal()-1; i>=0; i--)
{
bo= OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
if(bo==false)break;
if(OrderSymbol()!=Symbol())continue;
if(OrderType() == OP_BUY && Bid >= zhi_y)
{
bo=OrderClose(OrderTicket(), OrderLots(), Bid, 5);
if(bo==true)
{
for(int L=OrdersTotal()-1; L>=0; L--)
{
bo=OrderSelect(L, SELECT_BY_POS, MODE_HISTORY);
if(bo==false)break;
if(OrderSymbol()!=Symbol())continue;
if(OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 5);
zhi_y=0;
}
RefreshRates();
}
}
}
else if(OrderType() == OP_SELL && Ask <= zhi_y)
{
bo=OrderClose(OrderTicket(), OrderLots(), Ask, 5);
if(bo==true)
{
for(int LI=OrdersTotal()-1; LI>=0; LI--)
{
bo=OrderSelect(LI, SELECT_BY_POS, MODE_HISTORY);
if(bo==false)break;
if(OrderSymbol()!=Symbol())continue;
if(OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 5);
zhi_y=0;
}
RefreshRates();
}
}
}
}
if(close_2 > MA_5 && close_1 > MA_5 && open_2 - close_2 >0 && open_1 - close_1 > 0 && time != Time)
{
if(!Check(Symbol(), my_lots, OP_SELL)) return;
if(my_lots<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
{
Comment("交易量过小无法交易");
return;
}
OrderSend(Symbol(), OP_BUY, my_lots, Bid, dian_c, 0, 0, magic, 00000000);
time=Time;
zhi_y=Low;
}
else if(close_2 < MA_5 && close_1 < MA_5 && close_2 - close_2 >0 && close_1 - open_1 > 0 && time != Time)
{
if(!Check(Symbol(), my_lots, OP_SELL)) return;
if(my_lots<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
{
Comment("交易量过小无法交易");
return;
}
OrderSend(Symbol(), OP_SELL, my_lots, Ask, dian_c, 0, 0, magic, 0000000);
time=Time;
zhi_y=High;
}
}
//+------------------------------------------------------------------+
bool Check(string symb, double lots,int type)
{
double free_margin=AccountFreeMarginCheck(symb,type, lots);
//-- 如果资金不够
if(free_margin<0)
{
string oper=(type==OP_BUY)?"买入":"卖出";
Print("资金不足以进行", oper," ",lots, " ", symb, " 错误编号",GetLastError());
return(false);
}
//--- 检验成功
return(true);
}
怎么不会自己止盈止损啊,多少才会止盈止损,能不能设定固定的止盈止损?
页:
[1]