Help! If I have 2 pendants set and one of them closed by Take Profit, I need the 2nd one to be deleted. How do I write it? Where is the error in the code?
int pos;
for (pos=0; pos<OrdersTotal(); pos++)
{
if (OrderSelect(pos, SELECT_BY_POS))
{
if (OrderClosePrice() >= OrderTakeProfit())
{
int i;
for (i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS))
{
if (OrderDelete(OrderTicket()))
{
Print("Ордер удален");
}
}
}
}
break;
}
}
}
return(0);
}
Good evening (I forgot to say hello in previous posts). Can you advise which function to use to do the following. In the Expert Advisor is opening an order by the indicator on the current candle (let it be number = 9). If after the opening order, it (the indicator) re-draw (and after closing candle 9 did not appear), then I need to AFTER the closing candle 9 order closed.
bool Mart - if true, it means there was a closed order on a stop, hence doing a doubling.
TradeInf - trade permission, if true, it means that there are no traded orders and we may trade)
There is the following code: if (Mart == true && TradeInf==true) { Alert("double the lot"); LotS=NormalizeDouble(LotS*martin,2); Alert("lot size",LotS); } if (Mart == false && TradeInf==true) { Alert("Reset lot"); LotS=lot; }
Then in OpenOrder commands, lot size = LotS.
So if it finds a lot closed by lot, the lot size becomes -9315605757223323600 why? What's the reason?
Sys15975382: It's against the rules of rounding, let's wait for what the older comrades have to say.
Uh... Gentlemen. You can't normalise lots like that... :) Here's a little help:
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 16.05.2008 |//| Описание : Возвращает нормализованное значение торгуемого лота. |//+----------------------------------------------------------------------------+//| Параметры: |//| lo - нормализуемое значение лота. |//| ro - способ округления ( False - в меньшую, |//| True - в большую сторону) |//| sy - наименование инструмента ("" или NULL - текущий символ) |//+----------------------------------------------------------------------------+double NormalizeLot(double lo, bool ro=False, string sy="") {
double l, k;
if (sy=="" || sy=="0") sy=Symbol();
double ls=MarketInfo(sy, MODE_LOTSTEP);
double ml=MarketInfo(sy, MODE_MINLOT);
double mx=MarketInfo(sy, MODE_MAXLOT);
if (ml==0) ml=0.1;
if (mx==0) mx=100;
if (ls>0) k=1/ls; else k=1/ml;
if (ro) l=MathCeil(lo*k)/k; else l=MathFloor(lo*k)/k;
if (l<ml) l=ml;
if (l>mx) l=mx;
return(l);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thank you.
warnings
My mother tongue is Ukrainian. But thank you for your attention.
Help! If I have 2 pendants set and one of them closed by Take Profit, I need the 2nd one to be deleted. How do I write it? Where is the error in the code?
Good evening (I forgot to say hello in previous posts). Can you advise which function to use to do the following. In the Expert Advisor is opening an order by the indicator on the current candle (let it be number = 9). If after the opening order, it (the indicator) re-draw (and after closing candle 9 did not appear), then I need to AFTER the closing candle 9 order closed.
There are input parameters:
bool Mart - if true, it means there was a closed order on a stop, hence doing a doubling.
TradeInf - trade permission, if true, it means that there are no traded orders and we may trade)
There is the following code:
if (Mart == true && TradeInf==true)
{
Alert("double the lot");
LotS=NormalizeDouble(LotS*martin,2);
Alert("lot size",LotS);
}
if (Mart == false && TradeInf==true)
{
Alert("Reset lot");
LotS=lot;
}
Then in OpenOrder commands, lot size = LotS.
So if it finds a lot closed by lot, the lot size becomes -9315605757223323600
why? What's the reason?
Hello, I'm calculating a lot from a balance value according to a different principle...
I end up with a number like 0.2345, how do I cut double without rounding it, I mean:
to one digit - 0.2
to two digits - 0.23
to three - 0.234 and so on...
Hello, I'm calculating a lot from a balance value according to a different principle...
I end up with a number like 0.2345, how do I cut double without rounding it, I mean:
to one digit - 0.2
to two digits - 0.23
to three - 0.234 etc...
double lot = NormalizeDouble(LOT,2)
lot - for placing orders
LOT - formula for order calculation
"2" - rounding to 2 decimal places.
It's against the rules of rounding, let's wait for what the older comrades have to say.
Uh... Gentlemen. You can't normalise lots like that... :) Here's a little help: