11评论

4收藏

剥头皮1点差

avatar 333666 | 2956 人阅读 | 11 人评论 | 2017-03-19

extern int    MinPrfofit   = 1;
extern int    MaxLoss      = 10;
extern int    Delta        = 3;
extern int    BB_Period    = 1;
extern int    BB_Deviation = 2;
extern bool   FixLotMM     = FALSE;
extern double FixLotSize   = 0.1;
extern double RiskPercent  = 10.0;
extern int    Slippage     = 2;
extern string Comm         = "Mathematical_Analysis";

int    MagicNum;
double StopPoint, Spread, LotStep, Lots, Lots1, MaxLot, MinLot;

double SetPoint()
{
  double PricePoint;

  if (Digits == 3)
    PricePoint = 0.01;
  else
  {
    if (Digits == 5)
      PricePoint = 0.0001;
    else
      PricePoint = Point;
  }
  return(PricePoint);
}

int init()
{
   MagicNum  = StringGetChar(Symbol(), 0) + 77704 + StringGetChar(Symbol(), 1) * 2 + 3 * StringGetChar(Symbol(), 3) + StringGetChar(Symbol(), 4) << 2 + 10000 * Period();
   StopPoint = MarketInfo(Symbol(), MODE_STOPLEVEL);
   Spread = MarketInfo(Symbol(), MODE_SPREAD);
   MaxLot = MarketInfo(Symbol(), MODE_MAXLOT);
   MinLot = MarketInfo(Symbol(), MODE_MINLOT);
   LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
//   HideTestIndicators(TRUE);
   ObjectCreate("comment_label", OBJ_LABEL, 0, 0, 0);
   ObjectSet("comment_label", OBJPROP_XDISTANCE, 50);
   ObjectSet("comment_label", OBJPROP_YDISTANCE, 20);
   ObjectSetText("comment_label", "紅之匯【大雨狂暴系統】", 40, "Arial", Blue);
   return (0);
}

int deinit() {
   ObjectDelete("comment_label");
   return (0);
}




int start()
{
  int    i;
  double SLPrice, TPPrice, DiffPrice;
  bool   LongSignal, ShortSignal;
  double UpperBoll, LowerBoll;

  if (FixLotMM)
    Lots = FixLotSize;
  else
    Lots = AccountFreeMargin() / 1000.0 * (RiskPercent / 100.0);
  if
    (Lots < MinLot) Lots = MinLot;
  else
  {
    if (Lots > MaxLot)
      Lots = MaxLot;
    else
    {
      for (Lots1 = MinLot; Lots1 <= Lots; Lots1 += LotStep) {}
      Lots = Lots1 - LotStep;
    }
  }
  if (Lots > 2300.0) Lots = NormalizeDouble(Lots, 0);
  for (i = OrdersTotal() - 1; i >= 0; i--)
  {
    OrderSelect(i, SELECT_BY_POS);
    if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNum)
      continue;
    if (OrderType() == OP_BUY)
    {
      DiffPrice = Bid - OrderOpenPrice();
      if ((MinPrfofit > 0 && DiffPrice >= MinPrfofit * SetPoint()) || (MaxLoss > 0 && DiffPrice <= (-1 * MaxLoss) * SetPoint()))
      {
        OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Purple);
        return(0);
      }
    }
    if (OrderType() == OP_SELL)
    {
      DiffPrice = OrderOpenPrice() - Ask;
      if ((MinPrfofit > 0 && DiffPrice >= MinPrfofit * SetPoint()) || (MaxLoss > 0 && DiffPrice <= (-1 * MaxLoss) * SetPoint()))
      {
        OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red);
        return(0);
      }
    }
    return(0);
  }

  UpperBoll = iBands(Symbol(), 0, BB_Period, BB_Deviation, 0, PRICE_OPEN, MODE_UPPER, 0);
  LowerBoll = iBands(Symbol(), 0, BB_Period, BB_Deviation, 0, PRICE_OPEN, MODE_LOWER, 0);
  if (Close[0] > UpperBoll + Delta * SetPoint())
    ShortSignal = TRUE;
  else
    ShortSignal = FALSE;
  if (Close[0] < LowerBoll - Delta * SetPoint())
    LongSignal = TRUE;
  else
    LongSignal = FALSE;
  if (LongSignal)
  {
    if (MaxLoss == 0)
      SLPrice = 0;
    else
      SLPrice = Ask - (MaxLoss + StopPoint) * SetPoint();
    if (MinPrfofit == 0)
      TPPrice = 0;
    else
      TPPrice = Ask + (MinPrfofit + StopPoint + Spread) * SetPoint();
    OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, SLPrice, TPPrice, Comm, MagicNum, 0xFF0000);
  }
  if (ShortSignal)
  {
    if (MaxLoss == 0)
      SLPrice = 0;
    else
      SLPrice = Bid + (MaxLoss + StopPoint) * SetPoint();
    if (MinPrfofit == 0)
      TPPrice = 0;
    else
      TPPrice = Bid - (MinPrfofit + StopPoint + Spread) * SetPoint();
    OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, SLPrice, TPPrice, Comm, MagicNum, 0x0000FF);
  }

  return(0);
}

""
还没有人打赏,支持一下

评论|共 11 个

zgicp

发表于 2020-6-18 10:00:44 | 显示全部楼层

路过,学习下

1162660566

发表于 2020-9-1 13:06:08 | 显示全部楼层

谢谢楼主分享

上海外滩

发表于 2021-7-12 13:20:18 | 显示全部楼层

犯咕很过分

发表于 2021-7-16 19:02:55 | 显示全部楼层

daaaaaaji

发表于 2021-7-18 20:40:08 | 显示全部楼层

顶下

manger

发表于 2021-7-24 17:40:18 | 显示全部楼层

谢谢

科林

发表于 2021-8-4 10:41:50 | 显示全部楼层

支持下

小虫一

发表于 2024-4-4 12:50:34 | 显示全部楼层

王景

发表于 2024-7-2 20:12:02 | 显示全部楼层

支持下

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则