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

 
leonid553:


Put this address on your browser "button". There you will find answers to all such questions:

https://www.mql5.com/ru/forum/131859

E.g. Page 4
GetTypeLastClosePos - Return type of last closed position or -1
GetTypeLastOpenPos - Return type of last open position or -1
isCloseLastPosByStop - Returns the flag of the last position closed by Stop
isCloseLastPosByTake - Returns the flag to close the last position by Take.
isLossLastPos - Returns the flag of loss of the last position.
isTradeToDay - Returns the flag of trading today
NumberOfBarCloseLastPos - Returns the close number of the last position or -1.
NumberOfBarOpenLastPos - Returns the bar number of the last position opened or -1.
NumberOfLossPosToday - Returns the number of losing positions closed today.
PriceCloseLastPos - Returns the closing price of the last closed position.

Thank you for your reply. I have seen these functions, but they have 1 big disadvantage. They use more functions in the function body and more functions in the functions ... Imho, these are just examples, not guides. + The author doesn't give any reason for using particular functions and operators. Not good for a beginner in general.
 
Question: how do I sort two (or more) arrays by one of them (just like in Excel, select two or more columns and sort the data "Sort by..."? If anyone has worked with this, please advise
 

Hello, Could you please tell me how to spell the condition to enter into the trade the following way: IF PRICE IS TRANSFERED (UNDER or over) MA-34 TO ENTER THE TRADE.

I want to change the conditions of entry into the trade in my Expert Advisor. My current condition is IF PRICE IS BETWEEN OR ALSO MA-34. HOW TO CHANGE IT FROM ABOVE OR EQUAL TO CROSSED.

if(GO && SignalType_2 && Bid >= MA2
 
tofmillion- Wrong! Great functions and working and with justification - for beginners it's perfect ( rough nesting not detected)
 

Please advise where the mistake is. I'm getting the exact value, but I can't make the "Obem_Pozic" value to be 1.00, so I can calculate the lot for displaying, I don't want to normalize values, it just gives out 4 decimal places.

I am writing in MQL4.

//Представление переменных
double Stoimost_Lot;
double Obem_Pozic;

int start()
{
//Рассчитываем стоимость одного лота
Stoimost_Lot=(AccountBalance()/2)/82-2;
NormalizeDouble(Stoimost_Lot,2);

//Рассчитываем объем лота (Кредитное плечо 1:200), 1 лот (1.00) = 100.000 базовой валют (USD)
Obem_Pozic=Stoimost_Lot*0.1;
NormalizeDouble(Obem_Pozic,2);

//Выводим сообщение
Alert("# 1 лот = ",Stoimost_Lot," USD #"," Выставляем объем = ",Obem_Pozic," #");
}
 
merkulov.artem:

Please advise where the mistake is. I'm getting the exact value, but I can't make the "Obem_Pozic" value to be 1.00, so I can calculate the lot for displaying, I don't want to normalize it, it just gives out 4 decimal places.

I wrote it in MQL4.

//Variable representation
double Stoimost_Lot;
double Obem_Pozic;

int start()
{
//Calculate the value of one lot
Stoimost_Lot=(AccountBalance()/2)/82-2;
NormalizeDouble(Stoimost_Lot,2);

//Calculate the volume of the lot (leverage 1:200), 1 lot (1.00) = 100,000 base currency (USD)
Obem_Pozic=Stoimost_Lot*0.1;
NormalizeDouble(Obem_Pozic,2);

//write a message
Alert("# 1 lot = ",Stoimost_Lot," USD #"," Volume = ",Obem_Pozic," #");
}

prints 4 decimal places in Alert. use DoubleToStr() in order to display the message accurately
 
ilunga:
The Alert function should be used with DoubleToStr() to display more accurately

You're here too :) I need value to store type double, for further assignment to the lot. And using DoubleToStr(), I will format it as string, that's exactly the problem. Is it possible to leave two decimal places, but retain the double type.
 
ilunga:


I solved the problem, in case you're wondering, converted to a string, then back to a double. :) Thanks for the tip, I'm a bit confused :)

//Представление переменных
double Stoimost_Lot;
double Obem_Pozic;

int start()
{
//Рассчитываем стоимость одного лота
Stoimost_Lot=StrToDouble(DoubleToStr(NormalizeDouble((AccountBalance()/2)/82-2,2),2));
//Рассчитываем объем лота (Кредитное плечо 1:200), 1 лот (1.00) = 100.000 базовой валюты (USD)
Obem_Pozic=StrToDouble(DoubleToStr(NormalizeDouble(Stoimost_Lot*0.1,2),2));
//Выводим сообщение
Alert("# 1 лот = ",Stoimost_Lot," USD #"," Выставляем объем = ",Obem_Pozic," #");
}
 
merkulov.artem:


I solved the problem, in case you're wondering, converted to a string, then back to a double. :) Thanks for the tip, I'm a bit slow on the uptake :)

You didn't quite get it right.

DoubleToStr should be used exactly in Alert- for displaying it on the screen. Internally, the number is stored as you need it to be

 
Can you please tell me if there is a code that defines the maximum number of orders that can be placed in a DC?
Reason: