333666 发表于 2017-3-19 14:51:43

剥头皮1点差

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 > UpperBoll + Delta * SetPoint())
    ShortSignal = TRUE;
else
    ShortSignal = FALSE;
if (Close < 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);
}

zgicp 发表于 2020-6-18 10:00:44

路过,学习下

1162660566 发表于 2020-9-1 13:06:08

谢谢楼主分享

上海外滩 发表于 2021-7-12 13:20:18

{:1_181:}

犯咕很过分 发表于 2021-7-16 19:02:55

{:1_186:}

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

{:1_189:}

王景 发表于 2024-7-2 20:12:02

支持下
页: [1] 2
查看完整版本: 剥头皮1点差