查看: 1109|回复: 5

请老大帮忙!!给这EA加个止损!!

[复制链接]

8

主题

66

回帖

501

积分

积分
501
发表于 2007-10-3 08:50:13 | 显示全部楼层 |阅读模式
请老大帮忙!!给这EA加个止损!!
就是每次下单的时候,加上48点的止损!!别的不要变!
最好能做在EA里自己可以调的止损!!(想要多少就调为多少那种)
在线等!!!谢谢











//+------------------------------------------------------------------+
//|                                               10 pips a day.mq4 |
//|                      Copyright ?2005, MetaQuotes Software Corp. |
//|                                        http://www.me1taquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, MetaQuotes Software Corp."
#property link      "http://www.me1tquotes.net"

extern double lTakeProfit = 31;
extern double sTakeProfit = 35;
extern double lTrailingStop = 22;
extern double sTrailingStop = 19;
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "Generate from Gordago";
extern int Slippage = 2;
extern bool UseSound = False;
extern string NameFileSound = "alert.wav";
extern double Lots = 1;


void deinit() {
   Comment("");
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start(){
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
   if(sTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }

   double diClose0=iClose(NULL,5,0);
   double diMA1=iMA(NULL,5,7,0,MODE_SMA,PRICE_OPEN,0);
   double diClose2=iClose(NULL,5,0);
   double diMA3=iMA(NULL,5,6,0,MODE_SMA,PRICE_OPEN,0);

   if(AccountFreeMargin()<(100*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   if (!ExistPositions()){

      if ((diClose0<diMA1)){
         OpenBuy();
         return(0);
      }

      if ((diClose2>diMA3)){
         OpenSell();
         return(0);
      }
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
}

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
return(True);
}
}
}
return(false);
}
void TrailingPositionsBuy(int trailingStop) {
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol()) {
            if (OrderType()==OP_BUY) {
               if (Bid-OrderOpenPrice()>trailingStop*Point) {
                  if (OrderStopLoss()<Bid-trailingStop*Point)
                     ModifyStopLoss(Bid-trailingStop*Point);
               }
            }
         }
      }
   }
}
void TrailingPositionsSell(int trailingStop) {
   for (int i=0; i<OrdersTotal(); i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol()) {
            if (OrderType()==OP_SELL) {
               if (OrderOpenPrice()-Ask>trailingStop*Point) {
                  if (OrderStopLoss()>Ask+trailingStop*Point ||
OrderStopLoss()==0)  
                     ModifyStopLoss(Ask+trailingStop*Point);
               }
            }
         }
      }
   }
}
void ModifyStopLoss(double ldStopLoss) {
   bool fm;
   fm = OrderModify(OrderTicket(),OrderOpenPrice
(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
   if (fm && UseSound) PlaySound(NameFileSound);
}

void OpenBuy() {
   double ldLot, ldStop, ldTake;
   string lsComm;
   ldLot = GetSizeLot();
   ldStop = 0;
   ldTake = GetTakeProfitBuy();
   lsComm = GetCommentForOrder();
   OrderSend(Symbol
(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy);
   if (UseSound) PlaySound(NameFileSound);
}
void OpenSell() {
   double ldLot, ldStop, ldTake;
   string lsComm;

   ldLot = GetSizeLot();
   ldStop = 0;
   ldTake = GetTakeProfitSell();
   lsComm = GetCommentForOrder();
   OrderSend(Symbol
(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,0,0,clOpenSell);
   if (UseSound) PlaySound(NameFileSound);
}
string GetCommentForOrder() { return(Name_Expert); }
double GetSizeLot() { return(Lots); }
double GetTakeProfitBuy() { return(Ask+lTakeProfit*Point); }
double GetTakeProfitSell() { return(Bid-sTakeProfit*Point); }

7

主题

73

回帖

208

积分

积分
208
发表于 2007-10-3 10:14:15 | 显示全部楼层

回复 #1 xiaomin1681 的帖子

你这是著名的10点交易系统,特点是死抗到底,这才是开发者不设止损的原因。
你设了止损就明白了, 会一直亏损都爆!!

8

主题

66

回帖

501

积分

积分
501
 楼主| 发表于 2007-10-3 10:29:35 | 显示全部楼层
他死抗1000点!!郁闷呢!搞个止损看看!!

650

主题

5508

回帖

1万

积分

火星人返乡团团长

积分
13939

520FX神龟周年纪念水鬼混世魔王暴发户

QQ
发表于 2007-10-4 00:30:20 | 显示全部楼层
他有移动止损,没法改,要改成你说的手工止损那整个程序都要变了


如果从回帖中问题得到解决,请将帖子改为“已解决”

0

主题

8628

回帖

1万

积分

积分
17272
发表于 2016-9-29 08:59:20 | 显示全部楼层
原来...都是这种 学习了
回复 支持 反对

使用道具 举报

37

主题

4802

回帖

1万

积分

积分
10143
发表于 2023-12-10 20:58:28 | 显示全部楼层
5555555555
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

风险提示:本站内容仅供学习交流,不构成投资建议;禁止开户导流、喊单与代客理财。系统已启用敏感词自动进审/禁发。 · 客服/举报
小黑屋|手机版|Archiver|联系我们|法律声明|智慧网

Powered by Discuz! X5.0 Licensed © 2001-2026 Discuz! Team.|京ICP备15025159号-2

QQ客服返回顶部