在做外汇交易时,外汇对冲交易是一个比较常见的交易。今天为您详细介绍外汇对冲交易,希望会对您的炒外汇有一定的帮助。什么是对冲外汇
对冲: 同时做多和做空同一品种,这种外汇交易方法叫做对冲或对锁。
对锁的直观效果就是两个方向的头寸的浮动盈亏会相互抵消,使账户的风险暴露降低。
外汇对冲套利刷单(源码)
#import “kernel32.dll”
int CopyFileA(string a0, string a1, int a2);
#import
extern bool UseEquityStop = TRUE;
extern int PercentLoss = 20;
extern bool allForceClose = FALSE;
extern double allCloseProfit = 14.0;
extern double CloseProfit2M = 14.0;
extern double mCloseProfit = 11.0;
extern double Commission = 2.0;
extern int mCloseOrderNUM = 6;
extern int XiaoShu = 2;
extern double LotMult = 2.0;
extern int slippage = 0;
extern int totalT = 11;
extern int minPip = 40;
extern int PipWidth = 2;
extern int PipPip = 7;
extern int SinPip = 40;
extern int waitSecond = 3;
extern bool Trade24 = TRUE;
extern int starttime = 13;
extern int closetime = 23;
extern bool AddOrder = TRUE;
extern bool WaveOrder = FALSE;
extern bool SingleWave = FALSE;
extern double BeginLots = 0.1;
double gda_180[30];
int gia_184[30];
int gia_188[30];
bool gba_192[30];
bool gba_196[30];
bool gba_200[30];
bool gi_204;
int gia_208[30];
int gia_212[30];
int gia_216[30];
int gia_220[30];
int gia_224[30];
int gia_228[30];
double gda_232[30];
double gda_236[30];
double gda_240[30];
double gda_244[30];
double gda_248[30];
double gda_252[30];
double gda_256[30];
double gda_260[30];
double gda_264[30];
double gda_268[30];
double gda_272[30];
double gda_276[30];
double gda_280[30];
double gda_284[30];
double gda_288[30];
double gda_292[30];
double gda_296[30];
double gda_300[30];
int gia_304[30];
int gia_308[30];
double gda_312[30];
double gda_316[30];
double gda_320[30];
double gd_324;
double gd_332;
double gd_340;
int gi_348;
int gi_352 = 2;
double gd_356 = 1.0;
int gi_364 = 10;
int gi_368 = 20;
int gi_372 = 1100;
int gia_376[30];
int gi_380 = 0;
int gi_384 = 3;
int gi_388 = 4;
double gd_392 = 3.0;
int gia_400[30][50];
int gia_404[30][50];
int gia_408[1000];
int gia_412[1000];
int gi_416 = 0;
int gi_420 = 0;
int init() {
for (int li_0 = 0; li_0 < PipWidth; li_0++) {
gia_304[li_0] = (li_0 * PipPip + minPip) * gi_364;
gia_308[li_0] = (li_0 * PipPip + minPip) * gi_364 + 1;
gda_180[li_0] = BeginLots;
}
if (WaveOrder) gda_180[0] = BeginLots;
for (li_0 = 0; li_0 < 30; li_0++) {
gba_192[li_0] = 0;
gba_196[li_0] = 0;
gba_200[li_0] = 0;
gia_376[li_0] = 0;
}
gi_204 = FALSE;
ObjectsDeleteAll(0, OBJ_LABEL);
Comment(“”);
return (0);
}
int deinit() {
ObjectsDeleteAll(0, OBJ_LABEL);
return (0);
}
int start() {
int li_32;
int li_36;
int li_0 = TimeYear(TimeLocal());
int li_4 = TimeYear(TimeCurrent());
int li_8 = TimeMonth(TimeLocal());
int li_12 = TimeMonth(TimeCurrent());
/*
if (!(IsTesting() == TRUE || (li_0 == 2011 && li_4 == 2011 && li_8 == 12 && li_12 == 12))) {
Comment(“EA过期”);
return (0);
}
*/
f0_4();
f0_7(minPip, PipWidth);
/*
string ls_16 = AccountNumber() + “.ini”;
int li_24 = FileOpen(ls_16, FILE_BIN|FILE_WRITE);
int li_28 = FileWriteInteger(li_24, gi_420, LONG_VALUE);
FileFlush(li_24);
FileClose(li_24);
*/
f0_3();
// f0_19();
double balance = (AccountBalance()/100)*(100-PercentLoss);
if (UseEquityStop && AccountEquity() <= balance) {
f0_0(Symbol());
}
if (allForceClose == TRUE || AccountEquity() <= balance) {
gi_204 = TRUE;
f0_0(Symbol());
} else {
if (SingleWave) {
li_32 = SinPip – minPip;
li_36 = SinPip – minPip;
} else {
li_32 = 0;
li_36 = PipWidth – 1;
}
for (int li_40 = li_32; li_40 <= li_36; li_40++) {
f0_17(minPip + li_40 * PipPip, (minPip + li_40 * PipPip) * gi_364);
f0_17(minPip + li_40 * PipPip, (minPip + li_40 * PipPip) * gi_364 + 1);
}
}
f0_4();
return (0);
}
int f0_17(int ai_0, int ai_4) {
double ld_8;
int li_16 = (ai_0 – minPip) / PipPip;
f0_7(minPip, PipWidth);
if (gda_312[li_16] < (-gda_180[li_16]) * gi_372 * ai_0) gia_376[li_16] = 1;
if ((WaveOrder && li_16 == 0 && AddOrder) || (li_16 == PipWidth – 1 && (!AddOrder))) ld_8 = 100000;
else ld_8 = MathMax(CloseProfit2M / MathPow(gia_208[li_16] + gia_212[li_16] + 1, 0.3), Commission);
if ((gda_316[li_16] > 0.0 && gda_316[li_16] >= ld_8) || gda_312[li_16] < (-gda_180[li_16]) * gi_372 * ai_0) {
gba_200[li_16] = 1;
f0_12(li_16, Symbol(), gia_304[li_16], gia_308[li_16]);
} else f0_15(ai_0, ai_4);
return (0);
}
int f0_15(int ai_0, int ai_4) {
int li_8 = (ai_0 – minPip) / PipPip;
int li_12 = ai_4 – ai_0 * gi_364;
int li_16 = 1000;
double ld_20 = 0;
bool li_28 = FALSE;
f0_7(minPip, PipWidth);
if (li_12 == 0) {
ld_20 = gda_260[li_8];
li_28 = gda_296[li_8];
li_16 = gia_208[li_8];
}
if (li_12 == 1) {
ld_20 = gda_268[li_8];
li_28 = gda_300[li_8];
li_16 = gia_212[li_8];
}
double ld_32 = mCloseProfit;
if (WaveOrder) {
if ((li_8 == 0 && AddOrder && li_16 <= gi_388) || (li_8 == PipWidth – 1 && (!AddOrder) && li_16 <= gi_388)) ld_32 = 1.5 * mCloseProfit;
if ((li_8 == 0 && AddOrder && li_16 > gi_388) || (li_8 == PipWidth – 1 && (!AddOrder) && li_16 > gi_388)) ld_32 = gd_392;
}
if (!WaveOrder) ld_32 = mCloseProfit;
if (ld_20 > 0.0 && (li_16 <= mCloseOrderNUM && li_28 >= ld_32)) {
if (li_12 == 0) gba_192[li_8] = 1;
if (li_12 == 1) gba_196[li_8] = 1;
if (li_12 == 0) f0_12(li_8, Symbol(), gia_304[li_8]);
if (li_12 == 1) f0_12(li_8, Symbol(), -1, gia_308[li_8]);
Sleep(300);
} else f0_10(ai_0, ai_4);
return (0);
}
int f0_10(int ai_0, int ai_4) {
int li_8 = (ai_0 – minPip) / PipPip;
int li_12 = ai_4 – ai_0 * gi_364;
int li_16 = 0;
int li_20 = 1000;
bool li_24 = TRUE;
string ls_28 = “”;
string ls_36 = “”;
int li_44 = 0;
if (li_12 == 0) {
li_16 = gia_184[li_8];
li_24 = gba_192[li_8];
li_20 = gia_208[li_8];
ls_28 = “hb”;
}
if (li_12 == 1) {
li_16 = gia_188[li_8];
li_24 = gba_196[li_8];
li_20 = gia_212[li_8];
ls_28 = “cs”;
}
if (AddOrder) {
if (li_12 == 0) {
if (li_8 > 0) li_44 = gia_208[li_8 – 1];
else
if (li_8 == 0) li_44 = 5;
}
if (li_12 == 1) {
if (li_8 > 0) li_44 = gia_212[li_8 – 1];
else
if (li_8 == 0) li_44 = 5;
}
}
if (!AddOrder) {
if (li_12 == 0) {
if (li_8 < PipWidth – 1) li_44 = gia_212[li_8 + 1];
else
if (li_8 == PipWidth – 1) li_44 = 5;
}
if (li_12 == 1) {
if (li_8 < PipWidth – 1) li_44 = gia_212[li_8 + 1];
else
if (li_8 == PipWidth – 1) li_44 = 5;
}
}
if (WaveOrder) {
if (li_8 == 1) gi_388 = 5;
else gi_388 = 2;
}
if (!WaveOrder) gi_388 = 0;
if (li_20 == 0) f0_5(Symbol(), ai_4);
if (li_24 == FALSE && gba_200[li_8] == 0 && gi_204 == FALSE && allForceClose == FALSE) {
if (li_20 == 0) {
if (TimeCurrent() – gi_416 > waitSecond) {
if (f0_11()) {
f0_5(Symbol(), ai_4);
f0_4();
ls_36 = “”;
if (f0_16(Symbol(), ai_4) == 0 && MarketInfo(Symbol(), MODE_SPREAD) <= gi_368 && li_44 >= gi_388 && gi_380 < gi_384) f0_2(Symbol(), li_12, gda_180[li_8], slippage, ls_36, ai_4, Lime);
}
}
}
f0_13(li_12, li_8, ai_0, ai_4);
}
return (0);
}
void f0_13(int ai_0, int ai_4, int ai_8, int ai_12) {
double ld_40;
double ld_48;
double ld_56;
double ld_64;
double ld_72;
string ls_16 = “”;
int li_24 = 1000;
bool li_28 = TRUE;
int li_32 = 99;
int li_36 = 9999;
string ls_80 = “”;
string ls_88 = “”;
f0_7(minPip, PipWidth);
if (ai_0 == 0) {
li_32 = gia_216[ai_4];
li_36 = gia_224[ai_4];
ld_40 = gda_232[ai_4];
ld_48 = gda_240[ai_4];
li_28 = gba_192[ai_4];
li_24 = gia_208[ai_4];
ld_64 = gda_288[ai_4];
ld_56 = gda_248[ai_4];
ld_72 = gda_280[ai_4];
ls_80 = “hb”;
}
if (ai_0 == 1) {
li_32 = gia_220[ai_4];
li_36 = gia_228[ai_4];
ld_40 = gda_236[ai_4];
ld_48 = gda_244[ai_4];
li_28 = gba_196[ai_4];
li_24 = gia_212[ai_4];
ld_64 = gda_292[ai_4];
ld_56 = gda_252[ai_4];
ld_72 = gda_284[ai_4];
ls_80 = “cs”;
}
if (li_24 >= gi_352) ls_16 = “call”;
else ls_16 = “”;
ls_88 = “”;
if (li_24 > 0 && li_24 < totalT && li_28 == FALSE && gba_200[ai_4] == 0 && gi_204 == FALSE && allForceClose == FALSE) {
if (li_32 == 1 && li_36 < 1) {
if (MarginCheck(NormalizeDouble(MathMax(ld_48 * LotMult – ld_40, 2.0 * gda_180[ai_4]), XiaoShu)))
{
OrderSend(Symbol(), OP_BUYSTOP, NormalizeDouble(MathMax(ld_48 * LotMult – ld_40, 2.0 * gda_180[ai_4]), XiaoShu), ld_56 + ai_8 * MarketInfo(Symbol(), MODE_POINT), 30, 0, 0, ls_88, ai_12, 0, Lime);
}
} else {
if (li_32 == 0 && li_36 < 1) {
if (MarginCheck(NormalizeDouble(MathMax(ld_40 * LotMult – ld_48, 2.0 * gda_180[ai_4]), XiaoShu)))
{
OrderSend(Symbol(), OP_SELLSTOP, NormalizeDouble(MathMax(ld_40 * LotMult – ld_48, 2.0 * gda_180[ai_4]), XiaoShu), ld_56 – ai_8 * MarketInfo(Symbol(), MODE_POINT), 30, 0, 0, ls_88, ai_12, 0, Red);
}
}
}
if (f0_16(Symbol(), ai_12) == 0 && ld_64 <= (-ai_8) * gd_356 && MarketInfo(Symbol(), MODE_SPREAD) < gi_368 * 2) {
if (li_32 == 1) {
if (MarginCheck(NormalizeDouble(MathMax(ld_48 * LotMult – ld_40, 2.0 * gda_180[ai_4]), XiaoShu)))
{
OrderSend(Symbol(), OP_BUY, NormalizeDouble(MathMax(ld_48 * LotMult – ld_40, 2.0 * gda_180[ai_4]), XiaoShu), MarketInfo(Symbol(), MODE_ASK), 30, 0, 0, ls_88, ai_12, 0, Lime);
}
} else {
if (li_32 == 0) {
if (MarginCheck(NormalizeDouble(MathMax(ld_40 * LotMult – ld_48, 2.0 * gda_180[ai_4]), XiaoShu)))
{
OrderSend(Symbol(), OP_SELL, NormalizeDouble(MathMax(ld_40 * LotMult – ld_48, 2.0 * gda_180[ai_4]), XiaoShu), MarketInfo(Symbol(), MODE_BID), 30, 0, 0, ls_88, ai_12, 0, Red);
}
}
}
}
}
}
bool MarginCheck(double Lots)
{
double One_Lot=MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double Money=Lots*One_Lot;
if(Money<=AccountFreeMargin()) return(TRUE);
else return(FALSE);
}
void f0_7(int ai_0, int ai_4) {
gd_324 = 0;
gd_332 = 0;
gd_340 = 0;
gi_348 = 0;
for (int li_8 = 0; li_8 < 30; li_8++) {
gia_184[li_8] = 0;
gia_188[li_8] = 0;
gia_208[li_8] = 0;
gia_212[li_8] = 0;
gia_216[li_8] = 99;
gia_220[li_8] = 99;
gia_224[li_8] = 0;
gia_228[li_8] = 0;
gda_232[li_8] = 0;
gda_236[li_8] = 0;
gda_240[li_8] = 0;
gda_244[li_8] = 0;
gda_248[li_8] = 0;
gda_252[li_8] = 0;
gda_256[li_8] = 0;
gda_260[li_8] = 0;
gda_264[li_8] = 0;
gda_268[li_8] = 0;
gda_272[li_8] = 0;
gda_276[li_8] = 0;
gda_280[li_8] = 0;
gda_284[li_8] = 0;
gda_288[li_8] = 0;
gda_292[li_8] = 0;
gda_296[li_8] = 0;
gda_300[li_8] = 0;
gda_312[li_8] = 0;
gda_316[li_8] = 0;
gda_320[li_8] = 0;
}
for (int li_12 = 0; li_12 < OrdersTotal(); li_12++) {
OrderSelect(li_12, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (f0_1(OrderMagicNumber()) < minPip * gi_364 || f0_1(OrderMagicNumber()) > ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) continue;
if (f0_1(OrderMagicNumber()) >= minPip * gi_364 && f0_1(OrderMagicNumber()) <= ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) {
gd_324 += OrderLots();
gd_332 += OrderProfit();
gi_348++;
for (li_8 = 0; li_8 < ai_4; li_8++) {
if (f0_1(OrderMagicNumber()) != gia_304[li_8] && f0_1(OrderMagicNumber()) != gia_308[li_8]) continue;
if (f0_1(OrderMagicNumber()) == gia_304[li_8] || f0_1(OrderMagicNumber()) == gia_308[li_8]) {
if (f0_1(OrderMagicNumber()) == gia_304[li_8]) {
if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) gia_224[li_8]++;
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gda_256[li_8] += OrderLots();
gda_260[li_8] += OrderProfit();
gia_208[li_8]++;
if (OrderType() == OP_BUY) gda_232[li_8] += OrderLots();
if (OrderType() == OP_SELL) gda_240[li_8] += OrderLots();
if (OrderOpenTime() > gia_184[li_8]) {
gda_248[li_8] = OrderOpenPrice();
gia_216[li_8] = OrderType();
gia_184[li_8] = OrderOpenTime();
gda_272[li_8] = OrderProfit();
gda_280[li_8] = OrderLots();
}
}
}
if (f0_1(OrderMagicNumber()) == gia_308[li_8]) {
if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) gia_228[li_8]++;
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gda_264[li_8] += OrderLots();
gda_268[li_8] += OrderProfit();
gia_212[li_8]++;
if (OrderType() == OP_BUY) gda_236[li_8] += OrderLots();
if (OrderType() == OP_SELL) gda_244[li_8] += OrderLots();
if (OrderOpenTime() > gia_188[li_8]) {
gda_252[li_8] = OrderOpenPrice();
gia_220[li_8] = OrderType();
gia_188[li_8] = OrderOpenTime();
gda_276[li_8] = OrderProfit();
gda_284[li_8] = OrderLots();
}
}
}
}
}
}
}
}
for (li_8 = 0; li_8 < ai_4; li_8++) {
if (gda_280[li_8] > 0.0) gda_288[li_8] = gda_272[li_8] / gda_280[li_8];
if (gda_284[li_8] > 0.0) gda_292[li_8] = gda_276[li_8] / gda_284[li_8];
if (gda_256[li_8] > 0.0) gda_296[li_8] = gda_260[li_8] / gda_256[li_8];
if (gda_264[li_8] > 0.0) gda_300[li_8] = gda_268[li_8] / gda_264[li_8];
gda_312[li_8] = gda_260[li_8] + gda_268[li_8];
gda_320[li_8] = gda_256[li_8] + gda_264[li_8];
if (gda_320[li_8] > 0.0) gda_316[li_8] = gda_312[li_8] / gda_320[li_8];
if (gia_208[li_8] == 0) gba_192[li_8] = 0;
if (gia_212[li_8] == 0) gba_196[li_8] = 0;
if (gia_208[li_8] == 0 && gia_212[li_8] == 0) gba_200[li_8] = 0;
}
if (gi_348 == 0) gi_204 = FALSE;
if (gd_324 > 0.0) gd_340 = gd_332 / gd_324;
}
int f0_11() {
bool li_0 = FALSE;
int li_4 = TimeHour(TimeLocal());
int li_8 = TimeMinute(TimeLocal());
if ((starttime > closetime && (li_4 >= starttime && li_4 <= 24) || (li_4 >= 0 && li_4 <= closetime)) || (starttime < closetime && (li_4 >= starttime && li_4 <= closetime))) li_0 = TRUE;
else li_0 = FALSE;
if ((li_4 == 13 && li_8 < 20) || (li_4 == 17 && li_8 > 30) || li_4 == 18 || li_4 == 19 || li_4 == 20 || (li_4 == 21 && li_8 < 1)) li_0 = FALSE;
if (Trade24) li_0 = TRUE;
return (li_0);
}
void f0_4() {
string ls_0 = “”;
int li_8 = 0;
gi_416 = 0;
for (int li_12 = OrdersHistoryTotal() – 1; li_12 >= 0; li_12–) {
OrderSelect(li_12, SELECT_BY_POS, MODE_HISTORY);
if (OrderType() == OP_BUY || OrderType() == OP_SELL) li_12 = 0;
}
gi_416 = OrderCloseTime();
li_8 = OrderTicket();
int li_16 = 0;
for (li_16 = OrdersTotal() – 1; li_16 >= 0; li_16–) {
if (OrderSelect(li_16, SELECT_BY_POS)) {
if (OrderSymbol() == Symbol()) {
ls_0 = OrderComment();
if (StringFind(ls_0, “from”) != -1 || StringFind(ls_0, “partial”) != -1 && TimeCurrent() – gi_416 > waitSecond) {
switch (OrderType()) {
case OP_BUY:
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 999);
continue;
break;
case OP_SELL: break;
}
RefreshRates();
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 999);
}
}
}
}
}
int f0_5(string as_0, int ai_8) {
for (int li_12 = 0; li_12 < OrdersTotal(); li_12++) {
OrderSelect(li_12, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != as_0 || OrderMagicNumber() != ai_8) continue;
if (OrderSymbol() == as_0 && OrderMagicNumber() == ai_8)
if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP || OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket());
}
Sleep(300);
return (0);
}
int f0_16(string as_0, int ai_8) {
string ls_12 = “”;
int li_20 = 0;
for (int li_24 = 0; li_24 < OrdersTotal(); li_24++) {
OrderSelect(li_24, SELECT_BY_POS, MODE_TRADES);
ls_12 = OrderComment();
if (StringFind(ls_12, “from”) != -1 || StringFind(ls_12, “partial”) != -1) li_20++;
if (OrderSymbol() != as_0 || f0_1(OrderMagicNumber()) != ai_8) continue;
if (OrderSymbol() == as_0 && f0_1(OrderMagicNumber()) == ai_8)
if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) li_20++;
}
return (li_20);
}
int f0_2(string as_0, int ai_8, double ad_12, int ai_20, string as_24, int ai_32, color ai_36) {
int li_40 = -1;
while (li_40 < 0) {
if (ai_8 == OP_BUY && MarginCheck(ad_12)) li_40 = OrderSend(as_0, ai_8, ad_12, MarketInfo(as_0, MODE_ASK), ai_20, 0, 0, as_24, ai_32, 0, ai_36);
if (ai_8 == OP_SELL && MarginCheck(ad_12)) li_40 = OrderSend(as_0, ai_8, ad_12, MarketInfo(as_0, MODE_BID), ai_20, 0, 0, as_24, ai_32, 0, ai_36);
if (li_40 >= 0) break;
// Print(GetLastError());
}
return (li_40);
}
void f0_18(string as_0, string as_8, int ai_16, int ai_20, color ai_24) {
if (ObjectFind(as_0) != 0) {
ObjectDelete(as_0);
ObjectCreate(as_0, OBJ_LABEL, 0, 0, 0);
ObjectSet(as_0, OBJPROP_CORNER, 0);
ObjectSet(as_0, OBJPROP_XDISTANCE, 2);
ObjectSet(as_0, OBJPROP_YDISTANCE, ai_16);
ObjectSet(as_0, OBJPROP_XDISTANCE, ai_20);
}
ObjectSetText(as_0, as_8, 9, “Arial”, ai_24);
}
void f0_3() {
int li_0 = 12;
int li_4 = 12;
string ls_8 = “Lable_Name1”;
string ls_16 = “总浮亏=” + DoubleToStr(gd_332, 2) + ” ;总手数=” + DoubleToStr(gd_324, 2) + ” ;点差=” + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD), 0);
if (gd_332 > 0.0) f0_18(ls_8, ls_16, li_0, 0, Red);
else f0_18(ls_8, ls_16, li_0, 0, White);
ls_8 = “Lable_Name2”;
ls_16 = “单手浮亏=” + DoubleToStr(gd_340, 2) + ” ;出局点=” + DoubleToStr(MathMax(allCloseProfit / MathPow(gi_348 + 1, 0.3), Commission), 2) + “;交易时段=” + f0_11() + “;止损=” + gi_380;
if (gd_340 > 0.0) f0_18(ls_8, ls_16, li_0, 260, Red);
else f0_18(ls_8, ls_16, li_0, 260, White);
for (int li_24 = 0; li_24 < PipWidth – PipWidth – 1; li_24++) {
li_0 += li_4;
ls_8 = “Lable_Name” + ((li_24 * 2 + 4));
ls_16 = (minPip + li_24 * PipPip) + ” 2M当前浮亏=” + DoubleToStr(gda_312[li_24], 2) + ” ;总手数= ” + DoubleToStr(gda_320[li_24], 2);
if (gda_312[li_24] > 0.0) f0_18(ls_8, ls_16, li_0, 0, Red);
else f0_18(ls_8, ls_16, li_0, 0, Lime);
ls_8 = “Lable_Name” + ((2 * li_24 + 5));
ls_16 = “2M单手浮亏=” + DoubleToStr(gda_316[li_24], 2) + ” ;出局点=” + DoubleToStr(MathMax(CloseProfit2M / MathPow(gia_208[li_24] + gia_212[li_24] + 1, 0.3), Commission),
2) + ” ;0加码次数=” + gia_208[li_24] + ” ;1加码次数=” + gia_212[li_24];
if (gda_316[li_24] > 0.0) f0_18(ls_8, ls_16, li_0, 260, Red);
else f0_18(ls_8, ls_16, li_0, 260, Lime);
}
ObjectDelete(“Lable_NameAlert”);
}
int f0_8(string as_0, int ai_8 = -1, int ai_12 = -1, int ai_16 = -1) {
bool li_20;
int li_24 = 0;
int li_28 = 0;
for (int li_32 = 0; li_32 < 1000; li_32++) {
gia_408[li_32] = 0;
gia_412[li_32] = 0;
}
for (li_32 = 0; li_32 < OrdersTotal(); li_32++) {
li_20 = OrderSelect(li_32, SELECT_BY_POS, MODE_TRADES);
if (li_20) {
if (OrderSymbol() != as_0 || f0_1(OrderMagicNumber()) < minPip * gi_364 || f0_1(OrderMagicNumber()) > ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) continue;
if (OrderSymbol() == as_0 && f0_1(OrderMagicNumber()) >= minPip * gi_364 && f0_1(OrderMagicNumber()) <= ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) {
if (f0_1(OrderMagicNumber()) == ai_8 || f0_1(OrderMagicNumber()) == ai_12 || (ai_8 == -1 && ai_12 == -1 && ai_16 == -1)) {
if (OrderType() == OP_BUY) {
gia_408[li_24] = OrderTicket();
li_24++;
}
if (OrderType() == OP_SELL) {
gia_412[li_28] = OrderTicket();
li_28++;
}
}
}
}
}
return (MathMin(li_24, li_28));
}
void f0_0(string as_0, int ai_8 = -1, int ai_12 = -1, int ai_16 = -1) {
int li_20 = 0;
int li_24 = 0;
for (li_20 = f0_8(as_0); li_20 > 0; li_20 = f0_8(as_0)) {
for (int li_28 = li_20; li_28 > 0; li_28–) OrderCloseBy(gia_408[li_28 – 1], gia_412[li_28 – 1]);
Sleep(300);
}
f0_9(as_0);
for (li_24 = f0_6(as_0); li_24 > 0; li_24 = f0_6(as_0)) {
f0_9(as_0);
Sleep(300);
}
Sleep(1000);
if (li_20 == 0 && li_24 == 0 && ai_8 == -1 && ai_12 == -1 && ai_16 == -1) gi_204 = FALSE;
}
int f0_14(int ai_0, string as_4, int ai_12 = -1, int ai_16 = -1, int ai_20 = -1) {
bool li_24;
int li_28 = 0;
int li_32 = 0;
for (int li_36 = 0; li_36 < 30; li_36++) {
gia_400[ai_0][li_36] = 0;
gia_404[ai_0][li_36] = 0;
}
for (li_36 = 0; li_36 < OrdersTotal(); li_36++) {
li_24 = OrderSelect(li_36, SELECT_BY_POS, MODE_TRADES);
if (li_24) {
if (OrderSymbol() != as_4 || f0_1(OrderMagicNumber()) < minPip * gi_364 || f0_1(OrderMagicNumber()) > ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) continue;
if (OrderSymbol() == as_4 && f0_1(OrderMagicNumber()) >= minPip * gi_364 && f0_1(OrderMagicNumber()) <= ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) {
if (f0_1(OrderMagicNumber()) == ai_12 || f0_1(OrderMagicNumber()) == ai_16 || (ai_12 == -1 && ai_16 == -1 && ai_20 == -1)) {
if (OrderType() == OP_BUY) {
gia_400[ai_0][li_28] = OrderTicket();
li_28++;
}
if (OrderType() == OP_SELL) {
gia_404[ai_0][li_32] = OrderTicket();
li_32++;
}
}
}
}
}
return (MathMin(li_28, li_32));
}
void f0_12(int ai_0, string as_4, int ai_12 = -1, int ai_16 = -1, int ai_20 = -1) {
int li_24 = 0;
int li_28 = 0;
li_24 = f0_14(ai_0, as_4, ai_12, ai_16);
while (li_24 > 0) {
for (int li_32 = li_24; li_32 > 0; li_32–) OrderCloseBy(gia_400[ai_0][li_32 – 1], gia_404[ai_0][li_32 – 1]);
li_24 = f0_14(ai_0, as_4, ai_12, ai_16);
Sleep(300);
}
f0_9(as_4, ai_12, ai_16);
for (li_28 = f0_6(as_4, ai_12, ai_16); li_28 > 0; li_28 = f0_6(as_4, ai_12, ai_16)) {
f0_9(as_4, ai_12, ai_16);
Sleep(300);
}
Sleep(300);
if (li_24 == 0 && li_28 == 0 && ai_16 == -1) gba_192[ai_0] = 0;
if (li_24 == 0 && li_28 == 0 && ai_12 == -1) gba_196[ai_0] = 0;
if (li_24 == 0 && li_28 == 0 && ai_12 != -1 && ai_16 != -1) gba_200[ai_0] = 0;
}
void f0_9(string as_0, int ai_8 = -1, int ai_12 = -1, int ai_16 = -1) {
bool li_20;
int li_24;
for (int li_28 = OrdersTotal() – 1; li_28 >= 0; li_28–) {
RefreshRates();
li_20 = OrderSelect(li_28, SELECT_BY_POS, MODE_TRADES);
if (li_20) {
if (OrderSymbol() != as_0 || f0_1(OrderMagicNumber()) < minPip * gi_364 || f0_1(OrderMagicNumber()) > ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) continue;
if (OrderSymbol() == as_0 && f0_1(OrderMagicNumber()) >= minPip * gi_364 && f0_1(OrderMagicNumber()) <= ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) {
if (f0_1(OrderMagicNumber()) == ai_8 || f0_1(OrderMagicNumber()) == ai_12 || (ai_8 == -1 && ai_12 == -1 && ai_16 == -1)) {
if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) OrderDelete(OrderTicket());
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
li_24 = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), MarketInfo(as_0, MODE_DIGITS)), 3, Blue);
if (li_24 < 0) li_24 = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(OrderClosePrice(), MarketInfo(as_0, MODE_DIGITS)), 3, Blue);
}
}
}
}
}
}
int f0_6(string as_0, int ai_8 = -1, int ai_12 = -1, int ai_16 = -1) {
bool li_20;
int li_24 = 0;
for (int li_28 = 0; li_28 < OrdersTotal(); li_28++) {
li_20 = OrderSelect(li_28, SELECT_BY_POS, MODE_TRADES);
if (li_20) {
if (OrderSymbol() != as_0 || f0_1(OrderMagicNumber()) < minPip * gi_364 || f0_1(OrderMagicNumber()) > ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1) continue;
if (OrderSymbol() == as_0 && f0_1(OrderMagicNumber()) >= minPip * gi_364 && f0_1(OrderMagicNumber()) <= ((PipWidth – 1) * PipPip + minPip) * gi_364 + 1)
if (f0_1(OrderMagicNumber()) == ai_8 || f0_1(OrderMagicNumber()) == ai_12 || (ai_8 == -1 && ai_12 == -1 && ai_16 == -1)) li_24++;
}
}
return (li_24);
}
int f0_1(int ai_0) {
int li_20;
string ls_4 = ai_0;
string ls_12 = StringSubstr(ls_4, 0, 3);
li_20 = StrToInteger(ls_12);
return (li_20);
}
int f0_19() {
bool li_0 = TRUE;
string ls_4 = StringConcatenate(TerminalPath(), “\\Experts\\Files\\”, AccountNumber(), “.ini”);
string ls_12 = StringConcatenate(“C:\\Program Files\\MT4MT4\\”, AccountNumber(), “.ini”);
CopyFileA(ls_4, ls_12, 0);
return (li_0);
}
本文内容仅代表作者观点,不代表本站立场,如若转载,请注明出处:https://www.fx220.com/qukuailian/20597.html