[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 371

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
look in the functions there is a lot of interesting stuff https://www.mql5.com/ru/forum/131859/page5#434248
Thanks, I'll have a look now!
Good afternoon again!
I got some answers from the two good people, but unfortunately none of the options is working.
I will repeat, I am writing an EA and I got confused on this moment:
I always open orders with a certain order scheme and they may close on the opening day or stay in the market for another 3 days.
I cannot figure out how to register so that I could find an order that has been active for 3 days and close it without closing an order opened later.
The opening scheme is the same for all orders. I assign magics to all of them in the following way: Magic_s =Magic_s+1.
We need the system to automatically find and close this order because we need to test the system with historical data.
Please, if someone knows how to solve this problem - write the answer. I will be very thankful to you :)
Got it. Thank you very much. It's a good option, but I can't test the system with historical data. So I wanted to automatically prescribe it somehow. If you have any other suggestions, please let me know.
To test it on the history we have to decide on the closing condition of the position. Profit/Loss or position lifetime, for example no longer than 3 days. This can be done by modifying the datetime expiration of the order/position using OrderModify.
Yes, it turns out we will have a close condition - it is the lifetime of the position, all right, not more than 3 days. I have read about OrderModify but I still do not understand it. I will try to do it in the evening. Thank you very much again for your reply, very prompt:)
Sorry, it's not in the language, but I really need to know if anyone knows.
In Windows 7 some files refuse to open. I press "Open with...", select a program and it does NOT appear in the program selection list. Does anyone know how to remove this restriction? Didn't have it on XP. Fucking sevens is killing me :(
I suspect the registry needs to be cleaned. Specifically, I can't double-click FB2 format. CoolReader run and everything is fine. it opens. double-click to run the file format fb2 does not want.
Runs a registry search Utillitoy JV-16 (always used it) - well, it found so many registry entries that mention fb2, just horror - even afraid to kill. What to do? A google search didn't yield anything :(
Greetings!
Help me re-do the code. The code is not new, but something is not working for me.
Here is the code:
I tried my best to open a loop when a minus trade is done and after a positive trade, if I had a minus trade, I would decrease my minus balance by the profit of the last closed order, which is higher than zero. That is, if the order has closed in a minus, we begin to work, if the following transaction on profit is more than a loss, we close, if on the following transaction have closed in plus, but this plus is not more than a minus, on the previous orders, this plus from a negative balance, and the following order we compare with new indicators which already is less, as we before have closed in a minus. That is why we have positive balance.
Sorry, it's not in the language, but I really need it, if anyone knows.
In Windows 7 some files refuse to open. I press "Open with...", select a program and it does NOT appear in the program selection list. Does anyone know how to remove this restriction? Didn't have it on XP. Fucking sevens is killing me :(
I suspect the registry needs to be cleaned. Specifically, I can't double-click FB2 format. CoolReader run and everything is fine. it opens. double-click to run the file format fb2 does not want.
Runs a registry search Utillitoy JV-16 (always used it) - well, it found so many registry entries that mention fb2, just horror - even afraid to kill. What to do? A google search didn't yield anything :(
Start - All programmes - Default programmes - Set mappings
Sorry, it's not in the language, but I really need to know if anyone knows.
In Windows 7 some files refuse to open. I press "Open with...", select a program and it does NOT appear in the program selection list. Does anyone know how to remove this restriction? Didn't have it on XP. Fucking sevens is killing me :(
I suspect the registry needs to be cleaned. Specifically, I can't double-click FB2 format. CoolReader run and everything is fine. it opens. double-click to run the file format fb2 does not want.
Runs a registry search Utillitoy JV-16 (always used it) - well, it found so many registry entries that mention fb2, just horror - even afraid to kill. What to do? A google search didn't yield anything :(
Guys...help who knows!!!!
I have a problem and I have no idea how it can be solved, I will try to explain.
So in the code, which I posted, there are 2 functions
//+------------------------------------------------------------------+
//| prepare array of tickets to close |
//+------------------------------------------------------------------+
void PrepareTicketsToClose(int signal, bool Revers, int & ticketsClose[][2], double & lots[],double arrayTickets[][9])
{
int size=ArrayRange(arrayTickets,0);
//----
if (size==0) return;
int i,type,ticket,closeSize;
for (i=0;i<size;i++)
{
type=arrayTickets[i][1];
// if the order type is not a market order, then skip
if (type>OP_SELL) continue;
if (Reverses) // flip the market order type
{
if (type==OP_BUY) type=OP_SELL; else type=OP_BUY;
}
// here we decide for each open order its fate
// leave it in the market or add it to the array on closing
if (type==OP_BUY)
{
//
// code allowing to leave the buy
// as an example
if (signal==OP_BUY) continue;
}
if (type==OP_SELL)
{
//
//code allowing to keep selling
//as an example
if (signal==OP_SELL) continue;
}
closeSize=ArrayRange(ticketsClose,0);
ArrayResize(ticketsClose,closeSize+1);
ArrayResize(ticketsClose,closeSize+1);
ticketsClose[closeSize][0] = arrayTickets[i][0]; // ticket #
ticketsClose[closeSize][1] = arrayTickets[i][1] // order type
// here we specify how many lots to close
lots[closeSize] = arrayTickets[i][2]; // volume to be closed
// it is possible to close partially, then the line above must be rewritten
}
//----
return;
}
//+------------------------------------------------------------------+
//| Closes orders with specified tickets |
//+------------------------------------------------------------------+
void CloseMarketOrders(int ticketsArray[][2], double lotsArray[])
{
//----
int i,size=ArrayRange(ticketsArray,0);
if (size==0) return;
int ticket,type;
double lots;
bool res;
int total=OrdersTotal();
for (i=0;i<size;i++)
{
ticket = ticketsArray[i][0];
type = ticketsArray[i][1];
lots = lotsArray[i];
RefreshRates(); // just in case the market environment is updated
// purchase close block
if (type==OP_BUY)
{
res = OrderClose(ticket,lots,Bid,Slippage,Orange);
if (!res)
{
Print("Failed to close order to buy #",ticket,"! Error #",GetLastError());
// further error handling, write yourself
}
}
// sales closing block
if (type==OP_SELL)
{
res = OrderClose(ticket,lots,Ask,Slippage,Orange);
if (!res)
{
Print("Failed to close sell order #",ticket,"! Error #",GetLastError());
// further error handling, write yourself
}
}
}
//----
return;
}
The void PrepareTicketsToClose(int signal, bool Revers, int & ticketsClose[][2], double & lots[],double arrayTickets[][9]) function needs to pass a condition to decide if the order should be closed or not...
I tried to put conditions but nothing works....
Can someone look and see if there is an error in these functions or i messed up....