Good afternoon Connoisseurs! Have you exhausted the hardest day of the year? Can we get down to business? ;=).
I drew an EA, everything is good, but MQL as I understand it works in MT4 environment. I want it to work with software that works directly with the exchange. Are there any other MQL compilers? If not, what language should I use to rewrite MQL?
Anatoliy Ryzhakov: I don't have a break. What is the reason why the EA cannot "see" its orders? My server time and my computer time are different.
Everyone's time is different. Start without rushing from afar. 1. Check what the OrdersTotal function gives you. Its value depends on history settings: Today, last 3 days, last week, ... Adjust it as you prefer. 2. Then create a cycle and output all orders with Alert. This is called debugging - it is a very important part of a programmer's work. More important than writing code.
Please advise how to fix invalid lots amount error for FreeMarginCheck function in EA, when accidentally setting negative volume (lot) value. To have a message about wrong lot, without error message, in the tester .
Everyone's time is different. Start without rushing from afar. 1. Check what the OrdersTotal function gives you. Its value depends on the history settings: Today, last 3 days, last week, ... Adjust it as you want. 2. Then create a cycle and output all orders using Alert. This is called debugging - it is a very important part of a programmer's work. More important than writing code.
It compiles well, no errors, but it is not appropriate for my case.
I found the following code
#property copyright"Влад Сергеев для mmgp"#property version"1.00"#property strict#property script_show_inputsinputint orders = 4; //всего ордеров в серии inputbool buy = true; //флаг разрешающий/запрещающий покупки inputbool sell = false; //флаг разрешающий/запрещающий продажи inputint magic = 100500; //уникальный номер для ордеров, открываемых этим скриптом inputdouble lot = 0.01; //объем каждого ордера серии inputint tp = 100; //тейк профит, в пунктах inputint sl = 100; //стоп лосс, в пунктах inputint slip = 2; //допустимое проскальзывание на открытии, в пунктах (для ECN, где открытие по рынку - игнор) //+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnStart()
{
int i=0; // для чего эта переменная
int ticket=0;
if(buy)
{
while(i<orders) // здесь эта переменная используется чтобы сравнивать ордера или для чего
{
RefreshRates(); // если убрать эту функцию коду хуже не становится
ticket=OrderSend(Symbol(),OP_BUY,lot,NormalizeDouble(Ask,Digits),slip,0,0,"",magic,0,clrBlue); //здесь понятно
if(ticket!=-1) // эта строчка тоже не понятна
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) // функция для выбора ордера это логично но тоже не понятно как ей пользоваться
{
OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-sl*Point,Digits),NormalizeDouble(OrderOpenPrice()+tp*Point,Digits),0,clrBlue);
// эту строчку тоже хотел бы чтобы объяснили
}
}
i++; // что увеличивается на оду единицу это относится к магическому номеру ордера чтобы программа понимала что у неё есть ордера
}
}
i=0;
if(sell) // прошлая запись была для покупак эта для продаж
{
while(i<orders)
{
RefreshRates();
ticket=OrderSend(Symbol(),OP_SELL,lot,NormalizeDouble(Bid,Digits),slip,0,0,"",magic,0,clrRed);
if(ticket!=-1)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+sl*Point,Digits),NormalizeDouble(OrderOpenPrice()-tp*Point,Digits),0,clrRed);
}
}
i++;
}
}
}
//+------------------------------------------------------------------+
Maybe it can be used, but I don't understand the meaning of strings. May this code be used when rewritten to fit my condition?
Sell order closes at Ask price
I'm a little confused! Point the finger where the bug is in the code!!!(log says ORDER CLOSE ERROR 4108) Thanks in advance!
Good afternoon Connoisseurs! Have you exhausted the hardest day of the year? Can we get down to business? ;=).
I drew an EA, everything is good, but MQL as I understand it works in MT4 environment. I want it to work with software that works directly with the exchange. Are there any other MQL compilers? If not, what language should I use to rewrite MQL?
You have a break and you need to continue.
I do not have a break. What is the reason why the EA may not "see" its orders? I have different server and computer times, maybe because of this?
Everyone's time is different. Start without rushing from afar. 1. Check what the OrdersTotal function gives you. Its value depends on history settings: Today, last 3 days, last week, ... Adjust it as you prefer. 2. Then create a cycle and output all orders with Alert. This is called debugging - it is a very important part of a programmer's work. More important than writing code.
Everyone's time is different. Start without rushing from afar. 1. Check what the OrdersTotal function gives you. Its value depends on the history settings: Today, last 3 days, last week, ... Adjust it as you want. 2. Then create a cycle and output all orders using Alert. This is called debugging - it is a very important part of a programmer's work. More important than writing code.
Thank you !
Can you guys tell me how to write in the code of the Expert Advisor to open 3 trades at once with the ability to set SL?
Here is my condition
I was advised to use (OrdersTotal()) function, but it does not fit in my case. I have it like this
It compiles well, no errors, but it is not appropriate for my case.
I found the following code
Maybe it can be used, but I don't understand the meaning of strings. May this code be used when rewritten to fit my condition?
Can you guys tell me how to write in the code of the Expert Advisor to open 3 trades at once with the ability to set SL?
Here is my condition
I was advised to use (OrdersTotal()) function, but it does not fit in my case. I have it like this
It compiles well, no errors, but it is not appropriate for my case.
I found the following code
Maybe it can be used, but I don't understand the meaning of strings. Can I use this code if I rewrite it to fit my condition?
Try it this way
pos=0; //order counter
for(int i=OrdersTotal()-1;i>=0;i--) //read market orders
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))continue;//select from the market orders
{
if (OrderSymbol()!=Symbol()&&OrderMagicNumber()!=Magic) continue;//select only EA orders (if there is Magic and it trades on any currency pair)
pos++; //if we have selected, then increase pos by one
}
}
Can you guys tell me how to write in the code of the EA to open 3 trades at once with the ability to set SL?