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

 
optionany:

Yes this function of course I know, I mean - a tab in the window of the terminal, (trade, assets, account history, news, alerts, mail, etc.) when the mail comes there (in the internal mail terminal) sent an SMS or e-mail (eg to receive messages about restarting the server, etc.)?

So phrase the question as you think about it.

If you are thinking clearly, you are thinking clearly...

 

Hello. I can't understand what my mistake is, or rather what is the flaw in this block in my program:

//---Separate accounting of open orders

for(int i=OrdersTotal()-1;i>=0;i--)//OrdersTotal()-1;i>=0;i-- //Loop of orders
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);// If an order is found, then:
{
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=Magic) continue;
}

{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
Total++;
}
return;
}
//---

for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=Magic) continue;
}

{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL)
Total++;
}
return;
}
//---

The EA stably works in the Strategy Tester and on a demo account, but when compiling it generates 2 warnings: return value of 'OrderSelect' shuld be checked, which I cannot get over. If it's possible, please tell me what I wrote wrong or incomplete.

 
YuryVL:

Hello. I can't understand what my mistake is, or rather what is the flaw in this block in my program:

//---Separate accounting of open orders

for(int i=OrdersTotal()-1;i>=0;i--)//OrdersTotal()-1;i>=0;i-- //Loop of orders
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);// If an order is found, then:
{
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=Magic) continue;
}

{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
Total++;
}
return;
}
//---

for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
{
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=Magic) continue;
}

{
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)
if(OrderType()==OP_SELL)
Total++;
}
return;
}
//---

The EA stably works in the Strategy Tester and on a demo account, but when compiling it displays a warning: return value of 'OrderSelect' shuld be checked, which I cannot overcome in any way. If it's possible, please tell me what I wrote wrong or incomplete.


SRS to insert code! And why 2 loops, after checking if no check if yes and Total should read both types and keep in memory for each separately? No one will understand that! You have to build logic to make it clear to everyone what you want, then the compiler will understand too!
 
YuryVL:

Hello. I can't understand what my mistake is, or rather the deficiency of this block in my program:

...

1) To paste the code correctly here, click on SRC and then copy your code in the box (picture below).


2) Try this code:

int Total_BUY=0, Total_SELL=0; // новые переменные как счетчики ордеров

//---Раздельный учёт открытых ордеров
for(int i=OrdersTotal()-1; i>=0; i--) // Цикл перебора ордеров
  {
   // OrderSelect() надо выбирать с помощью if
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)); // Если найден ордер, то:
     {
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue;
      else
        {
         if(OrderType()==OP_BUY)  Total_BUY++;  // считает открытые позиции на покупку
         if(OrderType()==OP_SELL) Total_SELL++; // считает открытые позиции на продажу
        }
     }
  }
 

How can I get alert

Alert(OrderOpenPrice());

displaythe opening price of the order with 5 decimal places? NormalizeDouble(OrderOpenPrice(),Digits) doesn't help.(The order is pre-selected).

 
JoinDoe:

How can I get alert

display the opening price of the order with 5 decimal places? NormalizeDouble(OrderOpenPrice(),Digits) doesn't help.(The order is pre-selected).

Alert(DoubleToString(OrderOpenPrice(),Digits));
 
Leo59:
Hello dear!

Please help translate the algorithm for finding the coordinates of the intersection point of two segments

From the article:

It's very simple!
x1,y1 and x2,y2 are coordinates of vertices of the first segment;
x3,y3 and x4,y4 are coordinates of the vertices of the second segment;

to find the intersection we make the equations of the lines:
first equation:
(x-x1)/(x2-x1)=(y-y1)/(y2-y1);
second equation
(x-x3)/(x4-x3)=(y-y3)/(y4-y3);
these equations define a line passing through two points, which is what we need.
From these equations we find x and y by the following formulas:
x:=((x1*y2-x2*y1)*(x4-x3)-(x3*y4-x4*y3)*(x2-x1))/((y1-y2)*(x4-x3)-(y3-y4)*(x2-x1));
y:=((y3-y4)*x-(x3*y4-x4*y3))/(x4-x3);
since our lines intersect, they have a common intersection point with the coordinates (x,y), which we need to find.
For the intersection to belong to our line segments, we need to constrain it, i.e. check the condition:
if
(((x1<=x)and(x2>=x)and(x3<=x)and(x4 >=x))or((y1<=y)and(y2>=y)and(y3<=y) and(y4>=y))
then there is an intersection point of these segments, and if there is not, there is no intersection point.
You should also check the parallelism of these segments using angle coefficients:
k1:=(x2-x1)/(y2-y1);
k2:=(x4-x3)/(y4-y3);
where k1 and k2 are tangents of the angle of slope of the segments to the positive direction of axis ОХ, if k1=k2, then the segments are parallel, so they don't have intersection points.

And maybe someone has a ready-made one in the archives?


maybe
 

Is there any possibility or function in MT4 to redirect messages to the internal terminal mail (about leverage change, server restart, etc.) by sms or e-mail

P.s a tab in terminal window, (trade, assets, account history, news, alerts, MESSAGE, etc.)?

 
Hello Dear forum users!

I have started studying MQL4 and when writing a simple indicator I faced a problem that I cannot solve. The essence of the problem:

1_How to find High[i - end of day], I have a simple loop Close[i]-Open[i+1], I need to find High[i - end of day]. For example, from[i],[1],[2] and to the end of the day (PERIOD_H1) . I'm not sure how to do it. There is the 'iHigh' function, but it's a bit different.

2_ is not all, sorry for impudence, there is the 'iBars' function ( Returns the number of bars in the history for a specified symbol and period). Can you please tell me, which combination of functions can calculate not only the number of bars with time, say, '12:00' or '15:00' in history(PERIOD_H1), but also how many bars with time.

I have looked through all the manual, maybe I have overlooked something, but I have not found anything suitable. Used search engine, the result is the same. Might know where these questions were discussed, please send me the link.

Thanks in advance!

 
Vadim_2015:


See the help for functions, and the forum for examples of their use:

1. iHighest/iLowest
- to avoid confusion, these functions return an index corresponding to the maximum/minimum price.
Then you should put their values into High[] / Low[]. You will find a lot of examples on the forum.

2. iBarShift
Reason: