/*
Generated by EX4-TO-MQ4 decompiler V4.0.220.2c []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright "Copyright ?2007, 520FX Corp."
#property link "http://www.520fx.com"
extern double 获利美元平仓数 = 50.0;
extern int SlipPoint = 3;
int gi_88 = 0;
int gi_unused_92 = 0;
int init() {
writetext("Logo", "Powered by www.520fx.com", 10, 10, Yellow, 14);
return (0);
}
int start() {
double ld_0;
if (gi_88 == TRUE) {
CloseAllOrder();
if (gi_88 == TRUE) return;
} else {
ld_0 = GetProfitsHolding();
writetext("Profit", "持仓总盈利:" + DoubleToStr(ld_0, 2), 10, 30, White, 16);
if (ld_0 > 获利美元平仓数) {
CloseAllOrder();
return (0);
}
}
return (0);
}
void writetext(string a_name_0, string a_text_8, int a_x_16, int a_y_20, color a_color_24, int a_fontsize_28) {
ObjectDelete(a_name_0);
ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
ObjectSetText(a_name_0, a_text_8, a_fontsize_28, "Arial", a_color_24);
ObjectSet(a_name_0, OBJPROP_CORNER, 0);
ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_16);
ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_20);
}
double GetProfitsHolding() {
double ld_ret_4 = 0;
for (int l_pos_0 = 0; l_pos_0 < OrdersTotal(); l_pos_0++) {
OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES);
ld_ret_4 += OrderProfit();
}
return (ld_ret_4);
}
void CloseAllOrder() {
int lia_0[200];
gi_88 = FALSE;
int l_index_4 = 0;
for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
l_index_4++;
lia_0[l_index_4] = OrderTicket();
Print("全部平仓! :", lia_0[l_index_4]);
}
if (l_index_4 != 0) {
for (l_pos_8 = 1; l_pos_8 <= l_index_4; l_pos_8++) {
OrderSelect(lia_0[l_pos_8], SELECT_BY_TICKET);
if (OrderType() == OP_BUY) {
if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), SlipPoint) == 0) {
gi_88 = TRUE;
Print("多头平仓失败" + GetLastError());
}
}
if (OrderType() == OP_SELL) {
if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), SlipPoint) == 0) {
gi_88 = TRUE;
Print("空头平仓失败" + GetLastError());
}
}
}
}
}
|