When implementing different "grids" I came up with the following structure:
The structure is filled in on every new tick, based on the Magic Number value (it stores all the information needed to identify the order: order number, which grid it belongs to, etc.).
This is the code I came up with
class Info
{
private:
struct str
{
string Sym; // Символ ордераstring Com; // Коммент ордераint Tic; // Тиккет ордераint Typ; // Тип ордераint Mag; // Меджик номер ордераdouble Lot; // Лот ордераdouble Pri; // Цена открытия ордераdouble SL_; // Стоп лосс ордераdouble TP_; // Тейк профит ордераdatetime Tim; // Время открытия ордераdouble Pro; // Профит ордера
};
int m_tick_upper; // Тиккет максимального по цене ордераint m_tick_upper_; // Тиккет предпоследнего максимального по цене ордераint m_tick_lower; // Тиккет минимального по цене ордераint m_tick_lower_; // Тиккет предпоследнего минимального по цене оредраint m_tick_start; // Тиккет первого по времени ордераint m_tick_start_; // Тиккет вторго по времени ордераint m_tick_end; // Тиккет последнего по времени ордераint m_tick_end_; // Тиккет предпоследнего по времени ордераint m_magic; // Меджик номерstring m_symbol; // Символ ордераvoid SearchTicketPriceType(constint type); // Поиск по ценеvoid SearchTicketTimeType(constint type); // Поиск по времениpublic:
str Price_Max; // Структура запроса максимальных ценн
str Price_Min; // Структура запроса минимальных ценн
str Time_End; // Структура последних ордеров
str Time_Start; // Структура начальных ордеров
str Price_Max2; // Структура запроса максимальных ценн
str Price_Min2; // Структура запроса минимальных ценн
str Time_End2; // Структура последних ордеров
str Time_Start2; // Структура начальных ордеровvoid SetMagic (constint mag) { m_magic = mag; } // Принудительное указание меджик номераvoid SetSymbol(conststring sym) { m_symbol = sym; } // Принудительное указание символаvoid SearchTimeOrder(constint type); // Заполнение структуры по времени void SearchPriceOrder(constint type); // Заполнение структуры по ценам
Info(conststring sym,constint mag); // Параметрический конструктор
Info(){};
~Info(){};
};
Artyom Trishkin: No, you don't need a code. Algorithm in a nutshell, if you can... I really don't know how to run an EA in a terminal running in a crashed OS
It's easier for me to lay out the code than to explain it:
//+------------------------------------------------------------------+//| Expert Remove orders function |//+------------------------------------------------------------------+void RemoveOrders()
{
int orders_total = OrdersTotal();
//--- if ( orders_total > 0 )
{
for ( int i = 0; i < orders_total; i++ )
{
ulong temp_order_ticket = OrderGetTicket( i );
if ( OrderSelect( temp_order_ticket ) )
{
string temp_symbol = OrderGetString( ORDER_SYMBOL );
if ( temp_symbol == _Symbol )
{
RemoveOldOrder( temp_symbol, temp_order_ticket );
}
}
}
}
}
//+------------------------------------------------------------------+//| Expert remove old order function |//+------------------------------------------------------------------+void RemoveOldOrder( conststring symbol, constulong ord_ticket )
{
MqlTradeRequest request = {0};
MqlTradeResult result = {0};
request.action = TRADE_ACTION_REMOVE;
request.order = ord_ticket;
if ( OrderSend( request, result ) )
{
if ( result.retcode == TRADE_RETCODE_PLACED )
{
// SetTransCount( true );
}
}
else
{
Print( "Удаление старого ордера не выполнено! Билет = ", ord_ticket);
}
}
Shit, man, *** don't bullshit. You yourself defined the right direction: state should be recovered from the current environment, what MT gives you is the most reliable option. Instead of it, you write a long and useless class Info, into which you have to somehow cram the values found by external functions. Yes, eventually it will contain the variables you need: maximum and minimum ticket in terms of price for the order, as well as other important for you stuff. But in reality the problem is solved by a specialized container of orders: Imagine you have a list of orders, where each order represents a table row with many columns (order id, open time, open price, profit, etc., etc.). You do sorting by one of the columns, and get exactly the sequence you need. So, all this can be done with help of classes, which you like to use (though clueless, sorry). I'll write how to do it tomorrow, if you're interested.
Vasiliy Sokolov: Shit, man, *** don't bullshit. You yourself have defined the right direction: state should be recovered from the current environment, what MT gives you is the most reliable option. Instead of it, you write a long and useless class Info, into which you have to somehow cram the values found by external functions. Yes, eventually it will contain the variables you need: maximum and minimum ticket in terms of price for the order, as well as other important for you stuff. But in reality the problem is solved by a specialized container of orders: Imagine you have a list of orders, where each order represents a table row with many columns (order id, open time, open price, profit, etc., etc.). You do sorting by one of the columns, and get exactly the sequence you need. So, all this can be done with help of classes, which you like to use (though clueless, sorry). How to do it - I'll write tomorrow, if you're interested.
Very eager to see....
I need information not for the sake of information, but for further processing and calculation ...
It's easier for me to post the code than to explain it:
How will it work on a broken computer? (no surprise at all with the functions).
That's why I said - I don't need code. I need an algorithm that works on a computer that doesn't work (the axis is broken, if you remember a quote: "I really don't know how to run the Expert Advisor in the terminal, which is running on the crashed OS", and I don't need VPS and other stuff - think, that the OS on the computer, server, etc., where the terminal with the Expert Advisor is running, is crashed - your code is a poultice for it there and ... ).
How will it work on a broken computer??? (no surprise at all with the functions).
That's why I said - I don't need code. I need an algorithm that works on a computer that's not working (because the OS is down, if you remember - and I quote: "I really don't know how to run the Expert Advisor in the terminal, which is running on the crashed OS", and I don't need VPS and other stuff - think, that the OS on the computer, server, etc., where the terminal with the Expert Advisor is running, is crashed - your code is a poultice for it there and ... With your code and ... ).
Artyom Trishkin: No problem. I'm sick of trying to get my point across...
The bottom line is that even if the operating system on the server is down, you can run a home PC that will restore control of the account at the time that is required to restart the servo.
In my practice of working with the VDS / VPS servers OS has never flipped, but restarts are unforeseen and scheduled happens.
The essence of my question is to competently write code which collects information about current situation...
The point of my question is to correctly write code that collects information about the current situation...
You wrote here that you have already written in procedural style. So, all you have to do is to collect it all into a class. You can also remove some parameters from function call, make methods for presetting parameters (magik, symbol), but it's better not to do.
Of course if there is nothing to do, you can go another way. Class. It has method Refresh() to get list of orders (the only one that can return false). The other methods use this list.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
When implementing different "grids" I came up with the following structure:
The structure is filled in on every new tick, based on the Magic Number value (it stores all the information needed to identify the order: order number, which grid it belongs to, etc.).
This is the code I came up with
...
"By the way - if the Windows is down, the EA cannot delete orders either - only manual here, so this example cannot fully apply to auto-trading."
POSSIBLE, you probably don't know how. If interested I can post the code.
No, you don't need a code. Algorithm in a nutshell, if you can... I really don't know how to run an EA in a terminal running in a crashed OS
It's easier for me to lay out the code than to explain it:
This is the code I came up with
Shit, man, *** don't bullshit. You yourself have defined the right direction: state should be recovered from the current environment, what MT gives you is the most reliable option. Instead of it, you write a long and useless class Info, into which you have to somehow cram the values found by external functions. Yes, eventually it will contain the variables you need: maximum and minimum ticket in terms of price for the order, as well as other important for you stuff. But in reality the problem is solved by a specialized container of orders: Imagine you have a list of orders, where each order represents a table row with many columns (order id, open time, open price, profit, etc., etc.). You do sorting by one of the columns, and get exactly the sequence you need. So, all this can be done with help of classes, which you like to use (though clueless, sorry). How to do it - I'll write tomorrow, if you're interested.
Very eager to see....
I need information not for the sake of information, but for further processing and calculation ...
It's easier for me to post the code than to explain it:
How will it work on a broken computer? (no surprise at all with the functions).
That's why I said - I don't need code. I need an algorithm that works on a computer that doesn't work (the axis is broken, if you remember a quote: "I really don't know how to run the Expert Advisor in the terminal, which is running on the crashed OS", and I don't need VPS and other stuff - think, that the OS on the computer, server, etc., where the terminal with the Expert Advisor is running, is crashed - your code is a poultice for it there and ...
).
How will it work on a broken computer??? (no surprise at all with the functions).
That's why I said - I don't need code. I need an algorithm that works on a computer that's not working (because the OS is down, if you remember - and I quote: "I really don't know how to run the Expert Advisor in the terminal, which is running on the crashed OS", and I don't need VPS and other stuff - think, that the OS on the computer, server, etc., where the terminal with the Expert Advisor is running, is crashed - your code is a poultice for it there and ... With your code and ... ).
Here we go, forger in the forest...
Let's finish our discussion here!
Here we go, for better or for worse...
Let's end our discussion here!
No problem. I'm sick of trying to get my point across...
The bottom line is that even if the operating system on the server is down, you can run a home PC that will restore control of the account at the time that is required to restart the servo.
In my practice of working with the VDS / VPS servers OS has never flipped, but restarts are unforeseen and scheduled happens.
The essence of my question is to competently write code which collects information about current situation...
...
The point of my question is to correctly write code that collects information about the current situation...
You wrote here that you have already written in procedural style. So, all you have to do is to collect it all into a class. You can also remove some parameters from function call, make methods for presetting parameters (magik, symbol), but it's better not to do.
Of course if there is nothing to do, you can go another way. Class. It has method Refresh() to get list of orders (the only one that can return false). The other methods use this list.