[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 888

 
Multy:

I see.

By the way, is there a timer in MQL4 or only in MQL5?

Probably just these functions:

https://www.mql5.com/ru/search?utm_campaign=MQL4.community

https://www.mql5.com/ru/search?utm_campaign=MQL4.community
 
kwadrad:

Question for the aksakals

The tester has suddenly stopped working, scratching out no historical data.

What should I do with it?

for your information: the archive of quotes was downloaded


It helped me to restart the terminal and delete the downloaded quotes beforehand in the folder: C:\Program Files\MetaTrader - Alpari\history\Alpari-Micro2

then re-downloaded the quote archive

 
Noterday:
Can you please tell me the function that calculates the maximum possible order opening volume?
Let me give you a rod... :)
The function below has all the data you need to calculate the parameters you need. I'm so lazy, I can't even bang on the keys...

You can find what you need and modify it yourself... The code itself is so simple and accessible that no one will have any trouble redoing it...

// ==========================================================================
// ------------ Функция рассчёта величины лота для открытия позиции ---------
// Если лот превышает возможный для открытия позы, то он корректируется 
// ==========================================================================

double CorrectLots(double lt, double divider=4.0)        // lt = проверяемый лот, divider = на сколько разделить
{                                                        //                                 свободные средства
   double ltcorr;
   double pnt =      MarketInfo(Symbol(),MODE_POINT);
   double mspr =     MarketInfo(Symbol(),MODE_SPREAD);
   double dig =      MarketInfo(Symbol(),MODE_DIGITS);
   double MaxLot =   MarketInfo(Symbol(),MODE_MAXLOT);
   double MinLot =   MarketInfo(Symbol(),MODE_MINLOT);
   double StpLot =   MarketInfo(Symbol(),MODE_LOTSTEP);
   double OneLot =   MarketInfo(Symbol(),MODE_MARGINREQUIRED);
   double TradeMrg = NormalizeDouble(AccountFreeMargin()/divider,dig);  // Свободные средства, разрешенные к торговле
   
   lt=MathAbs(lt);
   ltcorr=lt;                       // Зададим начальное значением ltcorr равным значению lt
   
   if (lt>=MaxLot) ltcorr=MaxLot;   // Проверим превышение допустимых ...
   if (lt<=MinLot) ltcorr=MinLot;   // ... значений лота
   
   double Money=lt*OneLot+mspr*pnt; // Вычисляем стоимость открываемой позы

   if (Money<TradeMrg)              // Если свободных средств больше, чем цена позиции - 
      {
         return(ltcorr);                                                         // ... возвращаем неизменённый лот
      }
   else if (Money>=TradeMrg)        // Если цена позиции равна или больше, чем есть свободных средств, то ...
      {
         ltcorr=MathAbs(MathFloor(TradeMrg/OneLot/StpLot)*StpLot);               // ... рассчитаем допустимый лот
         double MoneyCorr=ltcorr*OneLot+mspr*pnt;                      
         Print("Func CorrectLots: лот ",lt," скорректирован до ",ltcorr,
               " Стоимость позы до корректировки = ",Money,
               " Стоимость позы после корректировки = ",MoneyCorr
               ); 
         return(ltcorr);                                                         // ... и вернём его значение
      }
   Print("Func CorrectLots: лот вернули без изменений");
   return(ltcorr);                 // Возврат изначального лота в непредусмотренных случаях с сообщением
}

One question...

Why do you need a trade like Hitler's at the end of the war... He recruited kids into the Hitler Youth, so to speak, the meat for one shot of the Faust cartridge...

Doesn't ring any bells?????

IMHO, of course...

 
artmedia70:
Let me give you a rod... :)
The function below has all the data to calculate the parameters you need. I'm so lazy, I'm too lazy to even bang on the keys...

You can find what you need and modify it yourself... The code itself is so simple and accessible that no one will have any trouble redoing it...

One question...

Why do you need a trade like Hitler's at the end of the war... He recruited children into the Hitler Youth, so to speak, the meat for one shot of the Faust cartridge...

Doesn't ring any bells?????

IMHO, of course...


Thanks!

Not going to open with maximum volume, just need to calculate it based on Depot size, for further mathematical operations =))

 
Noterday:

Thank you!

I'm not going to open with maximum volume, I just need to calculate it based on the Depo's size for further mathematical operations =))



for BUY:

NormalizeDouble(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_BUY,lot),2)

For SELL:

NormalizeDouble(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_SELL,lot),2);

lot - the variable holding the order volume

calculation result should be checked for >0

https://www.mql5.com/ru/search

 
IgorM:


for BUY:

NormalizeDouble(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_BUY,lot),2);

For SELL:

NormalizeDouble(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_SELL,lot),2);

lot - variable with the order volume

https://www.mql5.com/ru/search

... Well, Igor, you're in a hurry... :)

Before I had time to put my fingers to the keyboard, you'd already written back... :)

 
Thank you all!
 

Hi!

Can you suggest a code or a branch on how to memorise indicator line crossings with the price. i've seen it somewhere, but can't find it. I saw it somewhere but i can't find it.

I don't know if i'm interested, but i'm more interested in something like this:

int start()

  { 

 double LineX = iCustom ("EURUSD", Period_H1, "Indicator",0,0);

 double lineY = iCustom ("EURUSD", Period_H1, "Indicator",1,0);

double priceA = Ask;

double priceB = Bid;

double intersectionX = (LineX == priceA) ;

double intersectionY = (LineY == priceB) ;

// а так же еще определить, какое пересечение последнее, а какое предпоследние 

// intersectionX = последнее пересечение и на оборот
// intersectionY = предпоследние пересечение и на оборот

// то есть я понимаю логику, а  вот связать в коде не могу.
 
//произошло intersectionX,   то intersectionFirst = intersectionX; intersectionSecond = intersectionY;

// произошло intersectionY, то intersectionFirst = intersectionY; intersectionSecond = intersectionX;


 }
 
belck:

Hi!

Can you suggest a code or a branch on how to memorise indicator line crossings with the price. i've seen it somewhere, but can't find it. I saw it somewhere but i can't find it.

i want to know if the indicator line has crossed the price, but i'm more interested in this:


any crossover is best considered as a difference between the price (Ask/Bid) and the indicator line, i.e.

if (Ask-iCustom ("EURUSD", Period_H1, "Indicator",0,0) > 0) Comment("Price above the indicator"); else Comment("Price below the indicator");

If you compare the difference of these values, you don't need to normalize them for a proper comparison

particularly to your question - a crossing of the indicator line by the price is that moment when the Ask- -iCustom() difference was below zero during the previous calculation and then got higher, or vice versa

how you calculate this moment is your own business - maybe on the previous bar, or every tick, but such combinations:

double intersectionX = (LineX == priceA) ;

double intersectionY = (LineY == priceB) ;
You will be led into the maze of discrete mathematics faster than you can get the result you want - the bracketed expression will be either 0 or 1, which corresponds to the numerical representation of false and true
 
IgorM:


any crossing is optimally considered as the difference of price (Ask/Bid) and the indicator line, i.e.

if (Ask-iCustom ("EURUSD", Period_H1, "Indicator",0,0) > 0) Comment("Price above indicator"); else Comment("Price below indicator");

If you compare the difference of these values, you don't need to normalize them for a proper comparison

particularly to your question - a crossing of the indicator line by the price is that moment when the Ask- -iCustom() difference was below zero during the previous calculation and then got higher, or vice versa

How you calculate this moment is your own business - may it be on the previous bar, or every tick, but such combinations:

You will be led into the maze of discrete mathematics faster than you can get the result you want - the bracketed expression will be either 0 or 1, which corresponds to the numerical representation of false and true

That is, if I understand correctly, I can do this:

bool intersectionX = FALSE,
     intersectionY = FALSE;
int start()

  { 
if  (Ask-iCustom ("EURUSD", Period_H1, "Indicator",0,0) == 0)  {
intersectionX = TRUE;
intersectionY = FALSE;
}
if  (iCustom ("EURUSD", Period_H1, "Indicator",1,0)-Bid == 0) {
intersectionY = TRUE;
intersectionX = FALSE;
}
}
и я потом смогу intersectionY использовать только тогда когда оно TRUE, если FALSE, то такой код (intersectionY > Ask) не сработает, правильно я понимаю!?
Reason: