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

 
r772ra:


x=10*1.03



ok! but I won't recalculate them every time, I need a function that calculates the percentages by itself

y=3; // number keeps changing with every tick

x=10+yP; // instead of P you need a percentage. i can't write it in mql

 
if(Line_7 > Lines_1 && Lines_1 > Line_6)
{
OrderSend(Symbol(),OP_BUY,Lots_Typ,Ask,5,0,0);
}
if(AccountProfit() > 50)
{ 
OrderClose(Symbol(),5,Ask,0);
}
Logical code chain:

1 If line 7 is above line 1, with line 1 above line 6,
2 then
3 a buy order is opened with Lots_Typ volume, possible slippage of 5 pips, no SL and TP, at closing price.

1 If the potential profit of this account is higher than $50,
2 then
3 all orders are closed, regardless of their properties (volume, buy/sell, ...).

The logic chain is lined up correctly, but the code on the logic chain is not.

OrderClose(Symbol(),5,Ask,0);
The mistake lies here.
If we build a logical chain, relative to the above code, we get:
Closing 5 lots of an order with a closing price and a possible slippage of 0 pips.

How to correct it? Please advise.
 
clubsmi:



ok! I can't recalculate them every time, I need a function which calculates percent by itself

y=3; // the number constantly changes with every tick

x=10+yP; // we need percentage instead of P. I can't write it in mql.

in relation to what?
 
clubsmi:



ok! I can't recalculate them every time, I need a function which calculates percent by itself

y=3; // the number constantly changes with every tick

x=10+yP; // instead of P we need percentage.

//+----------------------------------------------------------------------------+
double Percent(double x, double y) {return(x*0.01*y);}
//+----------------------------------------------------------------------------+

x - number, y - needed percentage

pass number x and the desired percentage of it to y, the output is percentage y of number x

 
Link_x:
Logic code chain:

1 If line 7 is above line 1, with line 1 above line 6,
2 then
3 a buy order is opened with volume Lots_Typ, possible slippage of 5 points, without SL and TP, at close price.

1 If potential profit of this account is higher than $50,
2 then
3 all orders will be closed, no matter what their properties are (volume, buy/sell, ...).

The logic chain is correct, but the code by logic chain is not.

The mistake lies here.
If we build a logical chain, relative to the above code, we get:
Closing 5 lots of an order with a closing price and a possible slippage of 0 pips.

How to correct it? Please advise.

Dear Sir, read the Documentation carefully,

Specifically

The bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE)
Closing of position. Returns TRUE if the function completed successfully. Returns FALSE if the function fails. To get information about the error, call the function GetLastError().
Parameters:
ticket - Unique serial number of the order.
lots - Number of lots to close.
price - The closing price.
slippage - The value of the maximum slippage in pips.
Color - Colour of the closing arrow on the chart. If the parameter is missing or its value is CLR_NONE, the arrow is not shown on the chart.
Example:
 if(iRSI(NULL,0,14,PRICE_CLOSE,0)>75) { OrderClose(order_id,1,Ask,3,Red); return(0); }

 
r772ra:

Dear Sir, read the Documentation carefully,

specifically

The bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE)
Closing of position. Returns TRUE if the function completed successfully. Returns FALSE if the function fails. To get information about the error, call the function GetLastError().
Parameters:
ticket - Unique serial number of the order.
lots - Number of lots to close.
price - The closing price.
slippage - The value of the maximum slippage in pips.
Color - Colour of the closing arrow on the chart. If the parameter is missing or its value is CLR_NONE, the arrow is not shown on the chart.
Example:

I know all this.
How can I make it so that all orders are closed, regardless of their characteristics?
 
Link_x:
I know all that.
How do I make it so that all orders are closed, regardless of their characteristics?

You know, good for you,

OrderClose(Symbol(),5,Ask,0) //зто твое

OrderClose(order_id,1,Ask,3,Red); // А зто пример из документации

// Найди отличие
 
artmedia70:

x - number, y - required percentage

pass the number x and the desired percentage y, the output is the percentage y of the number x



Just what I needed, thank you very much... It's so easy, I've been thinking for half a day! Thank you again!

 
r772ra:

You know, good for you,


In my example: random order number, volume 5, at closing price, with slippage 0, no arrow.
In the document example: order number calculation by order_id, volume is 1, by closing price, with slippage 3, arrow is red.

1 there is order_id calculation - no order_number calculation
2 volume (1) - volume (5)
3 slippage (3) - slippage (0)
4 arrow red - no arrow

Differences found.
Now let's go back to the task.

Task 1
Write code that will close all open orders without exceptions.

My reasoning.
It is possible to write this code, but the question arises: "How?
1 - create a code that keeps track of all open orders (total volume, order cluster number, buy/sell, allowable slippage).
2 - Create code that opens orders and sends data to the code that monitors all of these orders (a kind of database is created).
3 - The code is created that closes all orders under certain conditions and takes only unused data from the "peculiar database".
The data is not reused.

We could do it this way, but I think there is another, less cumbersome variant.
That's why I ask "how?".
 
Fuk! Sorry!
How do you keep track of the unique order number if the t.p. sets it? How do you change it?