汇神天下汇

#import "hs.dll"

   int fun1(double a0, double a1, double a2, double a3, double a4, double a5, double a6);

   int fun2(double a0, double a1, double a2, double a3, double a4, double a5, double a6);

#import


//string Gs_unused_76 = "ooooooooooooo";

int Gi_84 = 1000;

extern double Lots = 0.01;

bool 复利 = FALSE;

double RISK = 10.0;

int 十万 = 100000;

int 目标 = 50;

int slippage = 3;

int MagicNumber = 10533;

string comm = "Huishen Kitgain";

//bool Gi_unused_132 = TRUE;

//bool Gi_unused_136 = TRUE;

string Gs_unused_140 = "======t w参数=======";

double Gd_148 = 0.004;

double Gd_156 = -0.004;

string Gs_unused_164 = "====时间参数====";

bool Gi_172 = FALSE;

int Gi_176 = 0;

int Gi_180 = 1;

int Gi_184 = 23;

int Gi_188 = 59;

//int Gi_unused_192 = 0;

int xp = 1;

int 开单时刻 = 0;

int G_pos_204;

double dataDOWN;

double dataUP;

int buys;

int sells;

double 多单只赢之和 = 0.0;

double 空单只赢之和 = 0.0;

double 多单浮赢最小值 = 0.0;

double 空单浮赢最小值 = 0.0;

int 多单最惨 = 0;

int 空单最惨 = 0;

double 订单浮赢;

bool 最惨订单号 = FALSE;

int LotDigit;

int StartTime;


int init() 

{

   StartTime = TimeCurrent();

   if (Digits == 5 || Digits == 3 || ((StringFind(Symbol(), "XAU", 0)>= 0 || StringFind(Symbol(), "GOLD", 0)>= 0) && Digits == 2)) xp = 10;

   if ((StringFind(Symbol(), "XAU", 0) >= 0 || StringFind(Symbol(), "GOLD", 0) >= 0) && Digits == 3) xp = 100;

   LotDigit = MathCeil(MathAbs(MathLog(MarketInfo(Symbol(), MODE_LOTSTEP)) / MathLog(10)));

   return (0);

}


void deinit() {}


int start() 

{

   double 净值手数;

   Display();

   dataDOWN = NormalizeDouble(iCustom(NULL, 0, "tianxiahui-2", 4, 0), 8);//down

   dataUP = NormalizeDouble(iCustom(NULL, 0, "tianxiahui-2", 5, 0), 8);//up

   if (复利) 

   {

      净值手数 = AccountEquity() * RISK / 100000.0 * MathPow(10, LotDigit);

      Lots = NormalizeDouble(净值手数 / MathPow(10, LotDigit), 8);

      Lots = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), MathMax(Lots, MarketInfo(Symbol(), MODE_MINLOT)));

   }

   买卖单数();

   if (fun1(非零点(), Time[0], 开单时刻, buys, Gi_84, dataDOWN, Gd_156) == 1) 

   {

      if(!OrderSend(Symbol(), OP_BUY, Lots, Ask, slippage * xp, 0, 0, comm, MagicNumber, 0, Blue))return(0);

      开单时刻 = Time[0];

   }

   if (fun2(非零点(), Time[0], 开单时刻, sells, Gi_84, dataUP, Gd_148) == 1) 

   {

      if(!OrderSend(Symbol(), OP_SELL, Lots, Bid, slippage * xp, 0, 0, comm, MagicNumber, 0, Red))return(0);

      开单时刻 = Time[0];

   }

   谁最惨();

   if (订单浮赢 < 0.0 && MathAbs(订单浮赢) / (10.0 * Lots) > 十万) 

   {

      closeOD(OP_BUY);

      closeOD(OP_SELL);

   }

   if (buys == 1 && 多单只赢之和 / (10.0 * Lots) > 目标) closeOD(OP_BUY);

   if (sells == 1 && 空单只赢之和 / (10.0 * Lots) > 目标) closeOD(OP_SELL);

   if ((buys > 1 || sells > 1) && (多单只赢之和 + 空单只赢之和 + MathMin(多单浮赢最小值, 空单浮赢最小值)) / 10.0 / Lots >= 目标) 

      指定平仓(最惨订单号);

   return(0);

}


void closeOD(int A_cmd_0) 

{

   for (int order_total_4 = OrdersTotal(); order_total_4 >= 0; order_total_4--) 

   {

      if(!OrderSelect(order_total_4, SELECT_BY_POS, MODE_TRADES))continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)

         if (OrderType() == A_cmd_0) 

            if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage * xp, Yellow))continue;

   }

}


void 指定平仓(int Ai_0) 

{

   for (int order_total_4 = OrdersTotal(); order_total_4 >= 0; order_total_4--) {

      if(!OrderSelect(order_total_4, SELECT_BY_POS, MODE_TRADES))continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)

         if (OrderProfit()-MathAbs(OrderCommission())-MathAbs(OrderSwap()) > 0.0 || Ai_0 == OrderTicket()) 

            if(!OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), slippage * xp, Yellow))continue;

   }

}


int 非零点() 

{

   if (Gi_172 == FALSE) return (1);

   int datetime_0 = TimeCurrent();

   int str2time_4 = StrToTime(TimeToStr(datetime_0, TIME_DATE) + " " + Gi_176 + ":" + Gi_180);

   int str2time_8 = StrToTime(TimeToStr(datetime_0, TIME_DATE) + " " + Gi_184 + ":" + Gi_188);

   if (datetime_0 >= str2time_4 && datetime_0 <= str2time_8) return (1);

   return (0);

}


void 谁最惨() 

{

   buys = 0;

   sells = 0;

   多单只赢之和 = 0;

   空单只赢之和 = 0;

   多单浮赢最小值 = 0;

   空单浮赢最小值 = 0;

   多单最惨 = 0;

   空单最惨 = 0;

   订单浮赢 = 0;

   最惨订单号 = FALSE;

   for (G_pos_204 = 0; G_pos_204 < OrdersTotal(); G_pos_204++) 

   {

      if(!OrderSelect(G_pos_204, SELECT_BY_POS, MODE_TRADES))continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) 

      {

         if (OrderType() == OP_BUY) 

         {

            buys++;

            订单浮赢 += NormalizeDouble(OrderProfit(), 8);

            if (OrderProfit() > 0.0) 多单只赢之和 += NormalizeDouble(OrderProfit(), 8);

            if (OrderProfit() < 多单浮赢最小值) 

            {

               多单浮赢最小值 = NormalizeDouble(OrderProfit(), 8);

               多单最惨 = OrderTicket();

            }

         }

         if (OrderType() == OP_SELL) 

         {

            sells++;

            订单浮赢 += NormalizeDouble(OrderProfit(), 8);

            if (OrderProfit() > 0.0) 空单只赢之和 += NormalizeDouble(OrderProfit(), 8);

            if (OrderProfit() < 空单浮赢最小值) 

            {

               空单浮赢最小值 = NormalizeDouble(OrderProfit(), 8);

               空单最惨 = OrderTicket();

            }

         }

      }

   }

   if (多单浮赢最小值 < 空单浮赢最小值) 最惨订单号 = 多单最惨;

   if (多单浮赢最小值 > 空单浮赢最小值) 最惨订单号 = 空单最惨;

}


void 买卖单数() 

{

   buys = 0;

   sells = 0;

   for (G_pos_204 = 0; G_pos_204 < OrdersTotal(); G_pos_204++) {

      if(!OrderSelect(G_pos_204, SELECT_BY_POS, MODE_TRADES))continue;

      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {

         if (OrderType() == OP_BUY) buys++;

         if (OrderType() == OP_SELL) sells++;

      }

   }

}


void Display() {

   Comment("平台商: " + AccountCompany() + "杠杆: " + AccountLeverage() 

      + "\n" 

      + "EA独立代码 magic: " + MagicNumber

      + "\n" 

      + "启动时间: " + ((TimeCurrent() - StartTime) / 60 / 60) + "小时" 

      + "\n" 

      + "------------------------------------" 

      + "\n" 

      + "多单个数:" + 订单个数(0, MagicNumber) 

      + "\n" 

      + "多单获利: " + NormalizeDouble(当前浮亏(OP_BUY, MagicNumber), 8) 

      + "\n" 

      + "多单手数: " + NormalizeDouble(手数之和(OP_BUY, MagicNumber), 8) 

      + "\n" 

      + "------------------------------------" 

      + "\n" 

      + "空单个数:" + 订单个数(1, MagicNumber) + "空单获利:" + NormalizeDouble(当前浮亏(OP_SELL, MagicNumber), 8) 

      + "\n" 

      + "空单手数:" + NormalizeDouble(手数之和(OP_SELL, MagicNumber), 8) 

      + "\n" 

      + "------------------------------------" 

      + "\n" 

      + "浮动盈亏:" + NormalizeDouble(当前浮亏(OP_BUY, MagicNumber) + 当前浮亏(OP_SELL, MagicNumber), 8) 

      + "\n" 

      + "------------------------------------" 

   + "\n");

}


int 订单个数(int Ai_0, int A_magic_4) 

{

   int count_8 = 0;

   int count_12 = 0;

   int count_16 = 0;

   int count_20 = 0;

   int count_24 = 0;

   int count_28 = 0;

   for (int pos_32 = 0; pos_32 < OrdersTotal(); pos_32++) {

      if (OrderSelect(pos_32, SELECT_BY_POS) == TRUE) {

         if (OrderSymbol() == Symbol()) {

            if (OrderMagicNumber() == A_magic_4) {

               switch (OrderType()) {

               case OP_BUY:

                  count_8++;

                  break;

               case OP_SELL:

                  count_12++;

                  break;

               case OP_BUYLIMIT:

                  count_16++;

                  break;

               case OP_BUYSTOP:

                  count_24++;

                  break;

               case OP_SELLSTOP:

                  count_28++;

                  break;

               case OP_SELLLIMIT:

                  count_20++;

               }

            }

         }

      }

   }

   switch (Ai_0) {

   case 0:

      return (count_8);

   case 1:

      return (count_12);

   case 2:

      return (count_16);

   case 4:

      return (count_24);

   case 3:

      return (count_20);

   case 5:

      return (count_28);

   }

   return (0);

}


double 当前浮亏(int A_cmd_0, int A_magic_4) {

   double Ld_8 = 0;

   for (int pos_16 = 0; pos_16 < OrdersTotal(); pos_16++) {

      if (OrderSelect(pos_16, SELECT_BY_POS) == TRUE) {

         if (OrderSymbol() == Symbol()) {

            if (OrderMagicNumber() == A_magic_4)

               if (OrderType() == A_cmd_0) Ld_8 += NormalizeDouble(OrderProfit() -MathAbs(OrderSwap())-MathAbs(OrderCommission()), 8);

         }

      }

   }

   return (NormalizeDouble(Ld_8, 8));

}


double 手数之和(int A_cmd_0, int A_magic_4) {

   double Ld_8 = 0;

   for (int pos_16 = 0; pos_16 < OrdersTotal(); pos_16++) {

      if (OrderSelect(pos_16, SELECT_BY_POS) == TRUE) {

         if (OrderSymbol() == Symbol()) {

            if (OrderMagicNumber() == A_magic_4)

               if (OrderType() == A_cmd_0) Ld_8 += OrderLots();

         }

      }

   }

   return (NormalizeDouble(Ld_8, 8));

}

8.jpg


微信公众号:天泓评测


本博客所有文章如无特别注明均为原创。作者:天泓评测
分享到:更多

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)