invalid lots amount for OrderSend function
Hello
I am getting invalid lots amount for OrderSend function.
on a Demo account but not on a back test.
Could someone please have a look at the code and point me in the right direction as to where I might have gone wrong.
What is the meaning of this comment ? or is this simply DECOMPILED (stolen) CODE ?
// E37F0136AA3FFAF149B351F6A4C948E9
hi
it can be compile. But still getting invalid lots amount for OrderSend function when running the EA.
hi
it can be compile. But still getting invalid lots amount for OrderSend function when running the EA.
What is the meaning of this comment ? or is this simply DECOMPILED (stolen) CODE ?
Hello
I am getting invalid lots amount for OrderSend function.
on a Demo account but not on a back test.
Could someone please have a look at the code and point me in the right direction as to where I might have gone wrong.
extern double TakeProfit = 40.0;
extern double Lots = 0.3;
extern double InitialStop = 0.0;
extern double TrailingStop = 20.0;
extern int MaxTrades = 10;
extern int Pips = 15;
extern int SecureProfit = 10;
extern int AccountProtection = 1;
extern int OrderstoProtect = 3;
extern int ReverseCondition = 0;
extern double SlowEMA = 5.0;
extern double PastEMA = 11.0;
extern double SMA = 22.0;
extern double CCI = 13.0;
extern int bOOLINGERBAND = 7;
extern int MACDdivergent1 = 3;
extern int MACDdivergent2 = 8;
extern int FISHER_m11 = 10;
extern int AccountLockNumber = 94321;
extern string BrokerName = "Fxpro";
extern int mm = 0;
extern int risk = 12;
extern int Accountactivationcode = 24792;
int globi_204 = 0;
int globi_208 = 0;
int globi_212 = 5;
double globd_216 = 0.0;
double globd_224 = 0.0;
double globd_232 = 0.0;
double globd_240 = 0.0;
double globd_248 = 0.0;
double globd_256 = 0.0;
int globi_264 = OP_BUY;
int globi_268 = 0;
bool globi_272 = TRUE;
double globd_276 = 0.0;
int globi_284 = 0;
double globd_288 = 0.0;
int globi_296 = 0;
bool globi_300 = FALSE;
double globd_304 = 0.0;
double globd_312 = 0.0;
double globd_320 = 0.0;
double globd_328 = 0.0;
string globs_336 = "";
string globs_344 = "";
// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
Print(MarketInfo(Symbol(), MODE_LOTSIZE));
Print(MarketInfo(Symbol(), MODE_MINLOT));
Print(MarketInfo(Symbol(), MODE_LOTSTEP));
Print(MarketInfo(Symbol(), MODE_MAXLOT));
return (0);
}
// 52D46093050F38C27267BCE42543EF60
int deinit() {
return (0);
}
// EA2B2676C28C0DB26D39331A336C6B92
int start() {
if (globd_248 > 100.0) globd_248 = 100;
globi_204 = 0;
for (globi_208 = 0; globi_208 < OrdersTotal(); globi_208++) {
OrderSelect(globi_208, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) globi_204++;
}
if (globi_284 > globi_204) {
for (globi_208 = OrdersTotal(); globi_208 >= 0; globi_208--) {
OrderSelect(globi_208, SELECT_BY_POS, MODE_TRADES);
globi_264 = OrderType();
if (OrderSymbol() == Symbol()) {
if (globi_264 == OP_BUY) OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), globi_212, Blue);
if (globi_264 != OP_SELL) return (0);
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), globi_212, Red);
return (0);
}
}
}
globi_284 = globi_204;
if (globi_204 >= MaxTrades) globi_272 = FALSE;
else globi_272 = TRUE;
if (globd_276 == 0.0) {
for (globi_208 = 0; globi_208 < OrdersTotal(); globi_208++) {
OrderSelect(globi_208, SELECT_BY_POS, MODE_TRADES);
globi_264 = OrderType();
if (OrderSymbol() == Symbol()) {
globd_276 = OrderOpenPrice();
if (globi_264 == OP_BUY) globi_268 = 2;
if (globi_264 == OP_SELL) globi_268 = 1;
}
}
}
if (globi_204 < 1) {
globi_268 = 3;
if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) > iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) globi_268 = 2;
if (iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 0) < iMACD(NULL, 0, 14, 26, 9, PRICE_CLOSE, MODE_MAIN, 1)) globi_268 = 1;
if (ReverseCondition == 1) {
if (globi_268 == 1) globi_268 = 2;
else
if (globi_268 == 2) globi_268 = 1;
}
}
for (globi_208 = OrdersTotal(); globi_208 >= 0; globi_208--) {
OrderSelect(globi_208, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderType() == OP_SELL) {
if (TrailingStop > 0.0) {
if (OrderOpenPrice() - Ask >= (TrailingStop + Pips) * Point) {
if (OrderStopLoss() > Ask + Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderClosePrice() - TakeProfit * Point - TrailingStop * Point, 800, Purple);
return (0);
}
}
}
}
if (OrderType() == OP_BUY) {
if (TrailingStop > 0.0) {
if (Bid - OrderOpenPrice() >= (TrailingStop + Pips) * Point) {
if (OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderClosePrice() + TakeProfit * Point + TrailingStop * Point, 800, Yellow);
return (0);
}
}
}
}
}
}
globd_288 = 0;
globi_296 = 0;
globi_300 = FALSE;
globd_304 = 0;
globd_312 = 0;
for (globi_208 = 0; globi_208 < OrdersTotal(); globi_208++) {
OrderSelect(globi_208, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
globi_296 = OrderTicket();
if (OrderType() == OP_BUY) globi_300 = FALSE;
if (OrderType() == OP_SELL) globi_300 = TRUE;
globd_304 = OrderClosePrice();
globd_312 = OrderLots();
if (globi_300 == FALSE) {
if (OrderClosePrice() < OrderOpenPrice()) globd_288 -= (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point;
if (OrderClosePrice() > OrderOpenPrice()) globd_288 += (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point;
}
if (globi_300 == TRUE) {
if (OrderClosePrice() > OrderOpenPrice()) globd_288 -= (OrderClosePrice() - OrderOpenPrice()) * OrderLots() / Point;
if (OrderClosePrice() < OrderOpenPrice()) globd_288 += (OrderOpenPrice() - OrderClosePrice()) * OrderLots() / Point;
}
}
}
globd_288 *= globd_328;
globs_344 = "Profit: $" + DoubleToStr(globd_288, 2) + " +/-";
if (globi_204 >= MaxTrades - OrderstoProtect && AccountProtection == 1) {
if (globd_288 >= SecureProfit) {
OrderClose(globi_296, globd_312, globd_304, globi_212, Yellow);
globi_272 = FALSE;
return (0);
}
}
if (!IsTesting()) {
if (globi_268 == 3) globs_336 = "No conditions to open trades";
else globs_336 = " ";
Comment("LastPrice=", globd_276, " Previous open orders=", globi_284,
"\nContinue opening=", globi_272, " OrderType=", globi_268,
"\n", globs_344,
"\nLots=", globd_248,
"\n", globs_336);
Print(globs_336);
Print("globs_336");
}
if (globi_268 == 1 && globi_272) {
if (Bid - globd_276 >= Pips * Point || globi_204 < 1) {
globd_240 = Bid;
globd_276 = 0;
if (TakeProfit == 0.0) globd_224 = 0;
else globd_224 = globd_240 - TakeProfit * Point;
if (InitialStop == 0.0) globd_216 = 0;
else globd_216 = globd_240 + InitialStop * Point;
if (globi_204 != 0) {
globd_256 = globd_248;
for (globi_208 = 1; globi_208 <= globi_204; globi_208++) {
if (MaxTrades > 12) globd_256 = NormalizeDouble(1.5 * globd_256, 1);
else globd_256 = NormalizeDouble(2.0 * globd_256, 1);
Print(globd_256);
Print("globd_256");
}
} else globd_256 = globd_248;
if (globd_256 > 100.0) globd_256 = 100;
Print(globd_256);
Print(globd_240);
Print(globi_212);
Print(globd_216);
Print(globd_224);
Print("sell");
OrderSend(Symbol(), OP_SELL, globd_256, globd_240, globi_212, globd_216, globd_224, 0, 0, 0, Red);
return (0);
}
}
if (globi_268 == 2 && globi_272) {
if (globd_276 - Ask >= Pips * Point || globi_204 < 1) {
globd_232 = Ask;
globd_276 = 0;
if (TakeProfit == 0.0) globd_224 = 0;
else globd_224 = globd_232 + TakeProfit * Point;
if (InitialStop == 0.0) globd_216 = 0;
else globd_216 = globd_232 - InitialStop * Point;
if (globi_204 != 0) {
Print(globd_248);
Print("globd_248");
globd_256 = globd_248;
for (globi_208 = 1; globi_208 <= globi_204; globi_208++) {
if (MaxTrades > 12) globd_256 = NormalizeDouble(1.5 * globd_256, 1);
else globd_256 = NormalizeDouble(2.0 * globd_256, 1);
}
} else globd_256 = globd_248;
if (globd_256 > 100.0) globd_256 = 100;
Print(globd_256);
Print(globd_232);
Print(globi_212);
Print(globd_216);
Print(globd_224);
Print("BUY");
OrderSend(Symbol(), OP_BUY, globd_256, globd_232, globi_212, globd_216, globd_224, 0, 0, 0, Blue);
return (0);
}
}
return (0);
}