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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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:
далее int buy,sell; должно быть за пределами старта
at least
like this:
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.....
Is there a resource/platform that allows for multi-currency testing of EAs?
yes.
MT5
Yes.
MT5
Will an EA written in MLQ4 work?
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);
}
}
Will an EA written in MLQ4 work?
If you translate the code to mt5 then yes.
there are no other remedies.
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?
Metals, stocks and raw materials do not count.
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.