Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 511

 
woin2110:

if ((hi-low)<=max_koridor_v_punktah)
{
int buy = OrderSend(Symbol(), OP_BUYSTOP, LotBuy, OpenBuy, 0, StopLossBuy, 0);//open Buy order.

if (buy>0)
{
Alert ("The BuyStop order has been set ",buy);
}
int sell= OrderSend(Symbol(), OP_SELLSTOP, LotSell, OpenSell, 0, StopLossSell, 0);//open Sell order.
if (sell>0)
{
Alert ("SellStop order set ",sell);
}
if (DayOfWeek()==5 && Hour()==22) //delete pending and open orders on Friday, 23:00 server time
{
if (OrderSelect(sell,SELECT_BY_TICKET)==true)
{
OrderClose(sell,OrderLots(),Bid,3,Green);//(Ticket,lot,Close price, slippage in points, colour of the close arrow on the chart)

Close market order to sell.
OrderDelete(sell);//closing the Sell Limit.
}
if (OrderSelect(buy,SELECT_BY_TICKET)==true)
{
OrderClose(buy,OrderLots(),Ask,3,Red);//(Ticket, lot, close price, slippage in points, colour of the close arrow on the chart)

Close market order to buy.
OrderDelete(buy);//closing the buy limit.
return(0);
}
}
}

Who can tell me why it does not close orders and does not delete limits?

at least

like this:

if ((hi-low)<=max_koridor_v_punktah)
{
buy = OrderSend(Symbol(), OP_BUYSTOP, LotBuy, OpenBuy, 0, StopLossBuy, 0);//открытие ордера на покупку.

if (buy>0) 
{
Alert ("Установлен ордер BuyStop ",buy);
}
 sell= OrderSend(Symbol(), OP_SELLSTOP, LotSell, OpenSell, 0, StopLossSell, 0);//открытие ордера на продажу.
if (sell>0) 
{
Alert ("Установлен ордер SellStop ",sell);
}
if (DayOfWeek()==5 && Hour()==22) //удаляем отложенные и открытые ордера в пятницу, в 23:00 по серверному времени 
{
if (OrderSelect(sell,SELECT_BY_TICKET)==true)
{
OrderClose(sell,OrderLots(),Bid,3,Green);//(тикет,лот,цена закрытия,проскальзывание в пунктах,цвет 
стрелки закрытия на графике)зыкрытие рыночного ордера на продажу.
OrderDelete(sell);//закрытие лимиток на продажу.
}
if (OrderSelect(buy,SELECT_BY_TICKET)==true)
{
OrderClose(buy,OrderLots(),Ask,3,Red);//(тикет,лот,цена закрытия,проскальзывание в пунктах,цвет стрелки 
закрытия на графике)зыкрытие рыночного ордера на покупку.
OrderDelete(buy);//закрытие лимиток на покупку.
return(0); 
}
} 
}
далее int buy,sell; должно быть за пределами старта
Да и лимиток тут нет, поэтому закрыть он их и не должен. 
 
Vladon:

at least

like this:

Thank you
 
Is there a resource/platform that allows for multi-currency testing of EAs?
 
evillive:
The robot is unloaded from memory when removed from the chart and when the terminal is closed. At least look through the manual for a while, it's very useful and takes a lot of questions off your mind.

they won't read. they won't even watch the video. you have to hypnotise them somehow.....
 
Trader7777:
Is there a resource/platform that allows for multi-currency testing of EAs?


yes.

MT5

 
Vladon:


Yes.

MT5


Will an EA written in MLQ4 work?
 
isn-88:

Hello. I am trying to figure out how the events work. I have NOT worked the event of deleting an object from the chart (CHARTEVENT_OBJECT_DELETE). Removed both with the mouse and through the Object List. Build 600.

Please tell me what is wrong?

I use code from help

#define KEY_NUMPAD_5 12
#define KEY_LEFT 37
#define KEY_UP 38
#define KEY_RIGHT 39
#define KEY_DOWN 40
#define KEY_NUMLOCK_DOWN 98
#define KEY_NUMLOCK_LEFT 100
#define KEY_NUMLOCK_5 101
#define KEY_NUMLOCK_RIGHT 102
#define KEY_NUMLOCK_UP 104
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
Print("Запущен эксперт с именем ",MQLInfoString(MQL_PROGRAM_NAME));
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, // идентификатор события
const long& lparam, // параметр события типа long
const double& dparam, // параметр события типа double
const string& sparam) // параметр события типа string
{
//--- нажатие левой кнопкой мышки на графике
if(id==CHARTEVENT_CLICK)
{
Print("Координаты щелчка мышки на графике: x = ",lparam," y = ",dparam);
}
//--- нажатие мышкой на графическом объекте
if(id==CHARTEVENT_OBJECT_CLICK)
{
Print("Нажатие кнопки мышки на объекте с именем '"+sparam+"'");
}
//--- нажатие кнопки на клавиатуре
if(id==CHARTEVENT_KEYDOWN)
{
switch(int(lparam))
{
case KEY_NUMLOCK_LEFT: Print("Нажата KEY_NUMLOCK_LEFT"); break;
case KEY_LEFT: Print("Нажата KEY_LEFT"); break;
case KEY_NUMLOCK_UP: Print("Нажата KEY_NUMLOCK_UP"); break;
case KEY_UP: Print("Нажата KEY_UP"); break;
case KEY_NUMLOCK_RIGHT: Print("Нажата KEY_NUMLOCK_RIGHT"); break;
case KEY_RIGHT: Print("Нажата KEY_RIGHT"); break;
case KEY_NUMLOCK_DOWN: Print("Нажата KEY_NUMLOCK_DOWN"); break;
case KEY_DOWN: Print("Нажата KEY_DOWN"); break;
case KEY_NUMPAD_5: Print("Нажата KEY_NUMPAD_5"); break;
case KEY_NUMLOCK_5: Print("Нажата KEY_NUMLOCK_5"); break;
default: Print("Нажата какая-то неперечисленная клавиша");
}
ChartRedraw();
}
//--- удален объект
if(id==CHARTEVENT_OBJECT_DELETE)
{
Print("Удален объект с именем ",sparam);
}
//--- создан объект
if(id==CHARTEVENT_OBJECT_CREATE)
{
Print("Создан объект с именем ",sparam);
}
//--- перемещен объект или изменены координаты точек привязки
if(id==CHARTEVENT_OBJECT_DRAG)
{
Print("Изменение точек привязки объекта с именем ",sparam);
}
//--- изменен текст в поле ввода графического объекта Edit
if(id==CHARTEVENT_OBJECT_ENDEDIT)
{
Print("Изменен текст в объекте Edit ",sparam);
}
}


It's weird for me, too.
 
Trader7777:

Will an EA written in MLQ4 work?


If you translate the code to mt5 then yes.

there are no other remedies.

 
Zolotai:


Thank you. What do you need void init and deinit for? I understand deinit, it only executes code. When the robot starts, right? And init ?

How can you use a code. That is, you don't have to worry about the five digits. How do I know what my five digits are at the moment?

A simple condition in the init function
double point;
int OnInit()
{
point = Point;
if(Digits % 2 == 1)// значит пятизнак
point *= 10;
}
Metals, stocks and raw materials do not count.
 
woin2110:

if ((hi-low)<=max_koridor_v_punktah)
{
int buy = OrderSend(Symbol(), OP_BUYSTOP, LotBuy, OpenBuy, 0, StopLossBuy, 0);//open Buy order.

if (buy>0)
{
Alert ("The BuyStop order has been set ",buy);
}
int sell= OrderSend(Symbol(), OP_SELLSTOP, LotSell, OpenSell, 0, StopLossSell, 0);//open Sell order.
if (sell>0)
{
Alert ("SellStop order set ",sell);
}
if (DayOfWeek()==5 && Hour()==22) //delete pending and open orders on Friday, 23:00 server time
{
if (OrderSelect(sell,SELECT_BY_TICKET)==true)
{
OrderClose(sell,OrderLots(),Bid,3,Green);//(Ticket,lot,Close price, slippage in pips,colour of the close arrow on the chart){ Close market order to sell.
OrderDelete(sell);//closing the Sell Limit.
}
if (OrderSelect(buy,SELECT_BY_TICKET)==true)
{
OrderClose(buy,OrderLots(),Ask,3,Red);//(Ticket,lot,close price,slippage in points,colour of the close arrow on the chart)/close market order to buy.
OrderDelete(buy);//closing the buy limit.
return(0);
}
}
}

Who can tell me why it does not close orders and does not delete limits?


Close buy order at Bid price, sell at Ask price.
Reason: