[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 74

 
Mathemat:

An array of 8 points is M[8][2] rather than M[8][8].

Are "any three" the pre-selected ones, or what?


Well, yes, the array is of course M[8][2]. Any three are any from the array that have to be defined in the calculation process. We can formulate it slightly differently: We need to find the coordinates of the centre of a circle and the coordinates of three points as close as possible to that circle.
 
 
atztek:


And then OrderOpenPrice() .


so it will define it by itself ?
 
Myth63:

so he'll identify it himself?
What do you mean by "it will find it"?
You look through the open orders, and for each order, the OrderOpenPrice() command gives the value of the price at which the order was opened.
Assign its value to some variable and use it.
 
Elenn: Well, yes, the array is of course M[8][2]. Any three are any of the array, which should be defined in the process of calculation.

In short, the problem boils down to this: there are three points. You have to draw a circle of radius r such that the sum of the squares of the distances from them to the circle is minimal.

Actually, it's a big task, not one that can be solved in a hurry. A circle is not a straight line. Which of the two distances to take is not at all obvious.

Well, here's a concrete example:

Show the correct arrangement.

 
atztek:
What do you mean "it will detect it"?
You look through the open orders, and for each order, the OrderOpenPrice() command gives the value of the price at which the order was opened.
Assign its value to some variable and use it.


I understood it that way. it will just automatically set it and use it for checking. ?

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()== OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNum2)
{
if ( Ask>(OrderOpenPrice()+(AD1*Point) )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black);
return(0);

}

Seems to be right ?

 
Myth63:


I understood it that way. it will just automatically set it and use it to check. ?

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()== OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNum2)
{
if ( Ask>(OrderOpenPrice()+(AD1*Point) )
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Black);
return(0);

}

Seems to be right ?

Not quite. And if no order is selected? Where is the price normalization when sending a trade order?

Orders are closed in a loop, which means that the search should be done not from zero, but from OrdersTotal()-1 to >=0

 
Mathemat:

In short, the problem boils down to this: There are three points. You have to draw a circle of radius r such that the sum of the squares of the distances from them to the circle is minimal.

It's actually a big task, not something you can do in a blink of an eye. A circle is not a straight line. Which of the two distances to take is not at all obvious.

Well, a concrete example:

Show the correct arrangement.


I think so:
 

Elenn: Думаю, что так:

No, I won't take on such a task. In the process of the calculation itself, you will have to decide which distances to take (there are two distances from any point to the circle). Nothing pretty.

Maybe GA can help to find the local minimum here. But I'm not good at that.

P.S. You didn't specify the target function - sum of squares of distances or sum of distances themselves.

 
Mathemat:

It's actually a big task, not something you can do in a blink of an eye. A circle is not a straight line.

I understand that the task is not an easy one. I don't want to reduce the problem to a stupid search of all the possible variants of "threes". As far as I understand, the variant with a straight line will also "participate" all the points, but not three of them. What do you think the variant for a line could look like, so that the sum of distances from the three "best" points to this line is minimal?
Reason: