Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 801
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
I am solving the task of closing all open charts using MQL4 tools. There are 3 open charts with different currency pairs and this is the script code:
When I run the script, only one of three charts is closed and here are the prints from the log:
It means that after closing of one chart the current chart should be the other one, but:
1. After the first chart is closed, theChartID functionreturns the identifier of the closed chart instead of the current one
2. ChartClose()function in 2 and 3 iterations returns true, which means it closes successfully the already closed window...
Who knows where the bug is and how to solve this problem?
I don't understand what the problem is?
A close message should appear. The order opens, gets to the stop, closes and that's it! Where is the error?
I think OrderSelect() should be inside a while loop, and besides, the position number will be incorrect, because after closing it will become different - in this case it's better to select from the ticket
I am solving the task of closing all open charts using MQL4 tools. There are 3 open charts with different currency pairs and this is the script code:
When I run the script, only one of three charts is closed and here are the prints from the log:
It means that after closing of one chart the current chart should be the other one, but:
1. After the first chart is closed,ChartID functionreturns the identifier of the closed chart instead of the current one
2. ChartClose()function in 2 and 3 iterations returns true, which means it closes successfully the already closed window...
Who knows where the bug is and how to solve this problem?
pako, sometimes it works, sometimes it doesn't, I don't know why... I get an error:
2014.12.11 17:52:12.456 Access violation read to 0x09295000 in 'C:\.....................ex4'
Could it be because it's trying to close the chart the script is thrown on?
PS works correctly if the script is attached to the first chart from the left. But if I place it on any other chart, I get an error
pako, sometimes it works, sometimes it doesn't, I don't know why... I get an error:
2014.12.11 17:52:12.456 Access violation read to 0x09295000 in 'C:\.....................ex4'
Could it be because it's trying to close the chart the script is thrown on?
PS works correctly if the script is attached to the first chart from the left. But if I place it on any other chart, I get an error
Guys, help me out here
The problem is the following function to translate the order into non-loss, it starts working incorrectly if I set it on the Yen pairs and allow all open orders into non-loss
i leave them all ok, but on five digits it returns to zero even if i set it to five digits only but the best thing is that if i set it to five it works ok
What is the reason for such work? What should be taken into account in these functions, so that the correct execution was carried out and did not depend on the EA operation in what window I threw it three or five digits?
Thank you very much.
}
//==================================================================================================
// функция перевода ордеров стоп лоса в без убыток по всем открытым ордерам
//==================================================================================================
if(_Simbol==false)//если false то по всем ордерам открытым
{
for(int i=0;i<OrdersTotal();i++)//цикл перебора ордеров
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))//будем искать следующие
{
if(OrderType()==OP_BUY) //если тип бай
{
double bid=MarketInfo(OrderSymbol(),MODE_BID);//последний известный бид инструмента
double point=MarketInfo(OrderSymbol(),MODE_POINT);//чему равен пункт инструмента
if(OrderStopLoss()<OrderOpenPrice())//если стоп лос меньше цены открытия
{
if(bid-Dist_Perivoda*point>OrderOpenPrice())//бид-профит*пункт больше цены открытия
{//модифицируем стоп лос
bool ord_modifik=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+NormalizeDouble(Level_Zahiti*point,Digits),OrderTakeProfit(),0,clrNONE);
if(!ord_modifik)//если не получилось
Comment(GetLastError());//номер ошибки в угол
}
}
}
if(OrderType()==OP_SELL)//если тип селл
{
double ask=MarketInfo(OrderSymbol(),MODE_ASK);//последний известный аск инструмента
double point=MarketInfo(OrderSymbol(),MODE_POINT);//чему равен пункт инструмента
if(OrderStopLoss()==0||OrderStopLoss()>OrderOpenPrice())//если стоп лос больше цены открытия или равен нолю
{
if(ask+Dist_Perivoda*point<OrderOpenPrice())//аск +профит*пункт меньше цены открытия
{//модифицируем стоп лос
bool ord_modifik=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-NormalizeDouble(Level_Zahiti*point,Digits),OrderTakeProfit(),0,clrNONE);
if(!ord_modifik)//если не получилось
Comment(GetLastError());//номер ошибки в угол
}
}
}
}
}
}
Thanks for the code, I understand the gist, although I still get an error sometimes.
Experimented with functions that show chart IDs. What is ChartFirst() from documentation is absolutely unclear, one can interpret it any way - may it mean the first chart opened in order from the left, or the first chart opened from all the open ones (in time), or the first ever opened in the terminal (the possibility that it is open now is almost zero, so it makes no sense to close it). I am more inclined to the latter version, because I have never seen this function return the ID of the chart, which is open at the moment.
Thanks for the code, I understand the gist, although I still get an error sometimes.
Experimented with functions that show chart IDs. What is ChartFirst() from documentation is absolutely unclear, one can interpret it any way - may it mean the first chart opened in order from the left, or the first chart opened from all the open ones (in time), or the first ever opened in the terminal (the possibility that it is open now is almost zero, so it makes no sense to close it). I am more inclined to the latter version, because I have never seen this function returning the ID of chart which is open at the moment.
ChartFirst
Returns chart ID of the first chart of the client terminal.
I understand that this is the leftmost chart
ChartFirst
Returns the identifier of the first chart of the client terminal.
I understand that this is the leftmost chart
Unfortunately it is not, it is easy to check it:
1. open 2-3 currency pairs in the terminal
2. run the code to check it: