我有一个EA是针对5位小数MT4平台的,我使用的是4位小数MT4平台.请教各位师傅给指点一下,怎样将5位小数EA更改为4位小数EA.谢谢了.
-------------------------------------------------------------------------------------------------------------------------
平台分五位数报价和六位数报价两种 ,小数点后4位还是五位这种说法不准确,看来楼主不是理科生。呵呵 简单改了下,没仔细看,五位数平台里面每点在在六位数平台里面是10点,明白意思剩下的自己搞定吧。
#property copyright "WWW.SCALPER.RU"
#property link "WWW.SCALPER.RU"
extern int Start1 = 10;
extern int Start2 = 14;
extern int EOD = 24;
extern int FridayClosing = 23;
extern bool FirstSessionOnly = FALSE;
extern int Length = 4;
extern int Pips = 5;//?
extern int StopLoss = 5;
extern int BreakEven = 3;
extern int TrailingStop = 0;
extern int LossPips = 0;
extern int TakeProfit = 8;
extern double Lots = 0.1;
extern bool MM = TRUE;
extern int LotsPercent = 10;
int gi_140;
int gi_unused_144;
bool gi_148 = TRUE;
double g_stoplevel_15.2;
double g_spread_16.0;
double g_maxlot_16.8;
double g_minlot_17.6;
double g_lotstep_18.4;
double setpoint() {
double l_point_0;
if (Digits == 3) l_point_0 = 0.01;
else {
if (Digits == 5) l_point_0 = 0.0001;
else l_point_0 = Point;
}
return (l_point_0);
}
int init() {
gi_unused_144 = 3;
gi_140 = StringGetChar(Symbol(), 0) + 77706 + StringGetChar(Symbol(), 1) * 2 + 3 * StringGetChar(Symbol(), 3) + StringGetChar(Symbol(), 4) << 2 + 10000 * Period();
g_stoplevel_152 = MarketInfo(Symbol(), MODE_STOPLEVEL);
g_spread_160 = MarketInfo(Symbol(), MODE_SPREAD);
g_maxlot_168 = MarketInfo(Symbol(), MODE_MAXLOT);
g_minlot_176 = MarketInfo(Symbol(), MODE_MINLOT);
g_lotstep_184 = MarketInfo(Symbol(), MODE_LOTSTEP);
HideTestIndicators(TRUE);
return (0);
}
int start() {
double ld_0;
string ls_8;
if (AccountFreeMargin() < 1500.0 * ld_0) return (0);
if (MM) {
if (LotsPercent > 0) Lots = NormalizeDouble(MathCeil(AccountFreeMargin() / 10000.0 * LotsPercent) / 10.0, 1);
else Lots = ld_0;
}
if (gi_148) {
ls_8 = "(c)2006 咽浪芟判.杏 HTTP://WWW.SCALPER.RU";
Comment(ls_8);
}
if (EOD >= 24) EOD = 0;
if (FridayClosing == 0) FridayClosing = 24;
string ls_16 = "IDS_" + Symbol();
if (Hour() == Start1 && Minute() < 10) SetOrders(ls_16, 1);
if (Hour() == Start2 && Minute() < 10 && !FirstSessionOnly) SetOrders(ls_16, 2);
for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) {
OrderSelect(l_pos_24, SELECT_BY_POS);
if (OrderComment() == ls_16) {
if (Hour() == EOD || (DayOfWeek() >= 5 && Hour() == FridayClosing - 1 && Minute() >= 50)) {
switch (OrderType()) {
case OP_BUY:
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
break;
case OP_SELL:
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
break;
default:
OrderDelete(OrderTicket());
}
} else {
if (LossPips > 0) {
if (OrderType() == OP_BUY)
if (OrderOpenPrice() - Bid >= LossPips * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice(), 0, Green);
if (OrderType() == OP_SELL)
if (Ask - OrderOpenPrice() >= LossPips * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice(), 0, Green);
}
if (TrailingStop == 0) {
if (OrderType() == OP_BUY)
if (High[0] - OrderOpenPrice() >= BreakEven * setpoint() && OrderStopLoss() < OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
if (OrderType() == OP_SELL)
if (OrderOpenPrice() - Low[0] >= BreakEven * setpoint() && OrderStopLoss() > OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
} else {
if (OrderType() == OP_BUY)
if (High[0] - OrderStopLoss() >= (StopLoss + TrailingStop) * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() + TrailingStop * setpoint(), OrderTakeProfit(), 0, Green);
if (OrderType() == OP_SELL)
if (OrderStopLoss() - Low[0] >= (StopLoss + TrailingStop) * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() - TrailingStop * setpoint(), OrderTakeProfit(), 0, Green);
}
}
}
}
return (0);
}
void SetOrders(string a_comment_0, int a_magic_8) {
int l_ticket_12;
int l_count_16 = 0;
int l_count_20 = 0;
double ld_24 = iHigh(NULL, PERIOD_H1, iHighest(NULL, PERIOD_H1, MODE_HIGH, Length, 1)) + Pips * setpoint();
double ld_32 = iLow(NULL, PERIOD_H1, iLowest(NULL, PERIOD_H1, MODE_LOW, Length, 1)) - Pips * setpoint();
double l_price_40 = MathMax(ld_24 - StopLoss * setpoint(), ld_32);
double l_price_48 = MathMin(ld_32 + StopLoss * setpoint(), ld_24);
double l_price_56 = ld_24 + TakeProfit * setpoint();
double l_price_64 = ld_32 - TakeProfit * setpoint();
for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++) {
OrderSelect(l_pos_72, SELECT_BY_POS, MODE_TRADES);
if (OrderComment() == a_comment_0 && OrderMagicNumber() == a_magic_8) {
if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUY) l_count_16++;
if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELL) l_count_20++;
}
}
if (l_count_16 == 0) {
l_ticket_12 = OrderSend(Symbol(), OP_BUYSTOP, Lots, ld_24, 3, l_price_40, l_price_56, a_comment_0, a_magic_8, 0, Green);
if (l_ticket_12 < 0 && GetLastError() == 130/* INVALID_STOPS */) l_ticket_12 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, l_price_40, l_price_56, a_comment_0, a_magic_8, 0, Green);
}
if (l_count_20 == 0) {
l_ticket_12 = OrderSend(Symbol(), OP_SELLSTOP, Lots, ld_32, 3, l_price_48, l_price_64, a_comment_0, a_magic_8, 0, Green);
if (l_ticket_12 < 0 && GetLastError() == 130/* INVALID_STOPS */) l_ticket_12 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, l_price_48, l_price_64, a_comment_0, a_magic_8, 0, Green);
}
}
谢谢了
我有一个EA是针对5位小数MT4平台的,我使用的是4位小数MT4平台.请教各位师傅给指点一下,怎样将5位小数EA更改为4位小数EA.谢谢了.
#property copyright "WWW.SCALPER.RU"
#property link "WWW.SCALPER.RU"
extern int Start1 = 10;
extern int Start2 = 14;
extern int EOD = 24;
extern int FridayClosing = 23;
extern bool FirstSessionOnly = FALSE;
extern int Length = 4;
extern int Pips = 5;
extern int StopLoss = 50;
extern int BreakEven = 30;
extern int TrailingStop = 0;
extern int LossPips = 0;
extern int TakeProfit = 80;
extern double Lots = 0.1;
extern bool MM = TRUE;
extern int LotsPercent = 10;
int gi_140;
int gi_unused_144;
bool gi_148 = TRUE;
double g_stoplevel_152;
double g_spread_160;
double g_maxlot_168;
double g_minlot_176;
double g_lotstep_184;
double setpoint() {
double l_point_0;
if (Digits == 3) l_point_0 = 0.01;
else {
if (Digits == 5) l_point_0 = 0.0001;
else l_point_0 = Point;
}
return (l_point_0);
}
int init() {
gi_unused_144 = 3;
gi_140 = StringGetChar(Symbol(), 0) + 77706 + StringGetChar(Symbol(), 1) * 2 + 3 * StringGetChar(Symbol(), 3) + StringGetChar(Symbol(), 4) << 2 + 10000 * Period();
g_stoplevel_152 = MarketInfo(Symbol(), MODE_STOPLEVEL);
g_spread_160 = MarketInfo(Symbol(), MODE_SPREAD);
g_maxlot_168 = MarketInfo(Symbol(), MODE_MAXLOT);
g_minlot_176 = MarketInfo(Symbol(), MODE_MINLOT);
g_lotstep_184 = MarketInfo(Symbol(), MODE_LOTSTEP);
HideTestIndicators(TRUE);
return (0);
}
int start() {
double ld_0;
string ls_8;
if (AccountFreeMargin() < 1500.0 * ld_0) return (0);
if (MM) {
if (LotsPercent > 0) Lots = NormalizeDouble(MathCeil(AccountFreeMargin() / 10000.0 * LotsPercent) / 10.0, 1);
else Lots = ld_0;
}
if (gi_148) {
ls_8 = "(c)2006 咽浪芟判.杏 HTTP://WWW.SCALPER.RU";
Comment(ls_8);
}
if (EOD >= 24) EOD = 0;
if (FridayClosing == 0) FridayClosing = 24;
string ls_16 = "IDS_" + Symbol();
if (Hour() == Start1 && Minute() < 10) SetOrders(ls_16, 1);
if (Hour() == Start2 && Minute() < 10 && !FirstSessionOnly) SetOrders(ls_16, 2);
for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) {
OrderSelect(l_pos_24, SELECT_BY_POS);
if (OrderComment() == ls_16) {
if (Hour() == EOD || (DayOfWeek() >= 5 && Hour() == FridayClosing - 1 && Minute() >= 50)) {
switch (OrderType()) {
case OP_BUY:
OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
break;
case OP_SELL:
OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
break;
default:
OrderDelete(OrderTicket());
}
} else {
if (LossPips > 0) {
if (OrderType() == OP_BUY)
if (OrderOpenPrice() - Bid >= LossPips * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice(), 0, Green);
if (OrderType() == OP_SELL)
if (Ask - OrderOpenPrice() >= LossPips * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice(), 0, Green);
}
if (TrailingStop == 0) {
if (OrderType() == OP_BUY)
if (High[0] - OrderOpenPrice() >= BreakEven * setpoint() && OrderStopLoss() < OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
if (OrderType() == OP_SELL)
if (OrderOpenPrice() - Low[0] >= BreakEven * setpoint() && OrderStopLoss() > OrderOpenPrice()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
} else {
if (OrderType() == OP_BUY)
if (High[0] - OrderStopLoss() >= (StopLoss + TrailingStop) * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() + TrailingStop * setpoint(), OrderTakeProfit(), 0, Green);
if (OrderType() == OP_SELL)
if (OrderStopLoss() - Low[0] >= (StopLoss + TrailingStop) * setpoint()) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() - TrailingStop * setpoint(), OrderTakeProfit(), 0, Green);
}
}
}
}
return (0);
}
void SetOrders(string a_comment_0, int a_magic_8) {
int l_ticket_12;
int l_count_16 = 0;
int l_count_20 = 0;
double ld_24 = iHigh(NULL, PERIOD_H1, iHighest(NULL, PERIOD_H1, MODE_HIGH, Length, 1)) + Pips * setpoint();
double ld_32 = iLow(NULL, PERIOD_H1, iLowest(NULL, PERIOD_H1, MODE_LOW, Length, 1)) - Pips * setpoint();
double l_price_40 = MathMax(ld_24 - StopLoss * setpoint(), ld_32);
double l_price_48 = MathMin(ld_32 + StopLoss * setpoint(), ld_24);
double l_price_56 = ld_24 + TakeProfit * setpoint();
double l_price_64 = ld_32 - TakeProfit * setpoint();
for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++) {
OrderSelect(l_pos_72, SELECT_BY_POS, MODE_TRADES);
if (OrderComment() == a_comment_0 && OrderMagicNumber() == a_magic_8) {
if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUY) l_count_16++;
if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELL) l_count_20++;
}
}
if (l_count_16 == 0) {
l_ticket_12 = OrderSend(Symbol(), OP_BUYSTOP, Lots, ld_24, 3, l_price_40, l_price_56, a_comment_0, a_magic_8, 0, Green);
if (l_ticket_12 < 0 && GetLastError() == 130/* INVALID_STOPS */) l_ticket_12 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, l_price_40, l_price_56, a_comment_0, a_magic_8, 0, Green);
}
if (l_count_20 == 0) {
l_ticket_12 = OrderSend(Symbol(), OP_SELLSTOP, Lots, ld_32, 3, l_price_48, l_price_64, a_comment_0, a_magic_8, 0, Green);
if (l_ticket_12 < 0 && GetLastError() == 130/* INVALID_STOPS */) l_ticket_12 = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, l_price_48, l_price_64, a_comment_0, a_magic_8, 0, Green);
}
}