Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1205

 

why does the compiler give a warning on this line?

datetime time_setup=OrderGetInteger(ORDER_TIME_SETUP);
possible loss of data due to type conversion    
 
Can you give me a hint? When I subtract a number, I get 3e-5. How do I make it look like 0.00003? Thank you.
 
awsomdino:

Why does the compiler give a warning on this line?

Because XxxxGetInteger returns long (integer with sign), while datetime is an unsigned integer and a separate type. We should specify

datetime timeProperty = (datetime)XxxGetInteger(...)

 
prom18:
Tell me. When I subtract, I get a number 3e-5. How do I make it look like 0.00003? Thank you.

Where do you get it?

 

Hello!

The OnCalculate function periodically returns 0

prev_calculated = 0

I think it's because the chart is being populated with quotes from a third party resource. It doesn't look like the chart is being overwritten though.

How can I overwrite the new data without rewriting the old ones?

I just create an indicator with some calculations, I'm not trying to load quotes.

void filter(const int rates_total,const int prev_calculated)
  {
 
   int start=prev_calculated;
//--- если значения индикатора уже были рассчитаны на предыдущем тике, то работаем на последнем баре
   if(prev_calculated>0)
      start--;
//---
   for(int p=2; p<Pmax; p++) // отбор по периодам
      for(int b=start>rates_total-Pmax?start:rates_total-Pmax; b<rates_total; b++)
        {
 
Good time to you all. Question: in MT4, when working in the tester with crosses (pairs without quid), how does the tester calculate the results of closed positions, if the account, on which testing is conducted, is a dollar account? For the recalculation of position totals in dollars, does the tester take the exchange rate of the base currency of the cross to the dollar at the current moment or at the moment of the tested interval? I strongly suspect that it is at the current time. If so, is it not possible to make it count at the time of the interval?
Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
Mihail Matkovskij:

In MQL4 only in this way:

Result:


Thank you very much for your help.

 
Mihail Matkovskij:

Where do you get it?

Right here.

double price1=1.23450;
double price2=1.23447;
double delta=price1-price2;
Alert("Разбег ",delta);
 
prom18:

Right here.

Alert("Разбег "+DoubleToString(delta,_Digits));

or Alert(StringFormat("Spread %.5f",delta));

In general, get used to it, these are just different representations of the same number. Think back to your wonderful school days - that's where it comes from

 
Top2n:

Hello!

The OnCalculate function periodically returns 0

I think it's because the chart is being populated with quotes from a third party resource. It doesn't look like the chart is being overwritten though.

How can I overwrite the new data in these conditions without rewriting the old data?

I just create indicator with some calculations, I'm not trying to load quotes.

Declare a global variable (do not confuse with the global variables of the terminal)

 bool firstRun = false;

and make full recalculation only on the first tick

// простейшее условие пересчёта
if(!firstRun) {
  // пересчёт ...
  firstRun = true;
}

If firstRun will also reset along with OnCalculate parameters, the indicator will restart.

Reason: