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

 
Vitaly Muzichenko:

Good "tone" programming is a programme without errors or warnings, everything else is amateurish.


Let's leave the tastefulness behind. I assume that such warnings are made for a reason. The question is why?

 
Artyom Trishkin:
You are not going to withdraw the money earned by the Expert Advisor from the journal. Accordingly, the program must process the errors in order to act accordingly.

So the software handles them anyway, if there are any, and displays messages about them. What am I missing here?

 
Andrey Sokolov:

So the software handles them anyway, if there are any, and displays messages about them. What am I missing here?

Not the program, but the terminal.
For the program to process them, they must first be fetched. To do this, trade functions return false on error. Further, if the result of the function is false, you must get the error code GetLastError() and handle it in your program.
 

hello! the terminal is not authorised! where to go, what to do?

 
kalmyk87 hello! the terminal is not authorising! where to go, what to do?
Authorization = connection to the broker's server, you need to turn on the internet. If demo - you forgot your password, open a new account. If real - call your broker.
 
STARIJ:
Authorisation = communication with broker's server, you need to turn on the internet. If demo - forget password, open a new account. If real - call the broker.

I authorised my account...but the mql5 profile is not authorised for some reason...

 

Good afternoon. Please help with this question...

The indicator draws a white level for the current day from the CSV. If the price does not reach this level, it (the level) continues to be displayed with a dotted line on the following days. When the price reaches this white dotted line in the future, it stops. However, after checking the unreached levels the next day the indicator considers the level as completed and stops drawing it.

I would like this dotted line to stay on the chart. Thank you.

//------------- читаю и разбираю строку из файла --

txt_data = FileReadString(file);   дата_уровней = StrToTime(txt_data+" 00:00");
if(FileIsEnding(file)==true)     break; // если конец  Выход из цикла
ArrayInitialize(d_input, 0);
for (int i=0; i<12; i++)  //== считываю уровни в массив
 {
 txt_data = FileReadString(file); 
 d_input[i] = replace_dot(txt_data);
 if ( FileIsLineEnding(file) ) break;
 }

if(уровни == Daily)
  {
   double white = d_input[4];
   t0 = дата_уровней + 1*PeriodSeconds(PERIOD_H1);
   t1 = дата_уровней + 23*PeriodSeconds(PERIOD_H1);
     Draw_Level("white", white, c_day_3, STYLE_SOLID, толщина); 
      if(показ_неотработок)
    if( !check_white_level(дата_уровней, white) )
     draw_line(t0, white, c_day_3) ;
  }
//   отображение  уровней 
void Draw_Level(string name, double _level, color _colr, int _style, int _width)
{
string o_name = i_name +"_"+ name +"_"+ TimeToStr(t0,TIME_DATE);
if (_level>0)
 {
  if (ObjectFind(o_name) != 0)
   ObjectCreate(o_name, OBJ_TREND, 0, t0, _level, t1, _level);
  ObjectSet(o_name, OBJPROP_TIME1, t0);
  ObjectSet(o_name, OBJPROP_PRICE1, _level);
  ObjectSet(o_name, OBJPROP_TIME2, t1);
  ObjectSet(o_name, OBJPROP_PRICE2, _level);
  ObjectSet(o_name, OBJPROP_COLOR, _colr);
  ObjectSet(o_name, OBJPROP_STYLE, _style);
  if(_style == STYLE_DOT)   ObjectSet(o_name, OBJPROP_WIDTH, 1);
    else     ObjectSet(o_name, OBJPROP_WIDTH, _width);
  ObjectSet(o_name, OBJPROP_RAY, false);  // луч
  ObjectSetText(o_name, DoubleToStr(_level, 4) );
  ObjectSetInteger(0, o_name, OBJPROP_SELECTABLE, False); 
   ObjectSetInteger(0, o_name, OBJPROP_HIDDEN, True);  
   ObjectSetString(0, o_name, OBJPROP_TOOLTIP, "\n"); // убираю всплывающую надпись
 }
}
// проверка_отработки уровня
bool check_white_level(datetime t_open, double _level)
{
if (_level <= 0) return(False);
int bar0 = iBarShift(NULL, 0, t_open);
double max = High[iHighest(NULL, 0, MODE_HIGH, bar0, 0)];
double min = Low[iLowest(NULL, 0, MODE_LOW, bar0, 0)];
if( _level <= max && _level >= min )
  return(TRUE);
return(False);
}
void draw_line(datetime begin, double _level, color _clr)
{
if (_level <= 0) return;
string o_name = i_name +"_wh1_"+ TimeToStr(begin,TIME_DATE);
datetime t_0 = begin ;
datetime t_1 = TimeCurrent() ;
  if (ObjectFind(o_name) != 0)
   ObjectCreate(o_name, OBJ_TREND, 0, t_0, _level, t_1, _level);
  ObjectSet(o_name, OBJPROP_TIME1, t_0);
  ObjectSet(o_name, OBJPROP_PRICE1, _level);
  ObjectSet(o_name, OBJPROP_TIME2, t_1);
  ObjectSet(o_name, OBJPROP_PRICE2, _level);
  ObjectSet(o_name, OBJPROP_COLOR, _clr);
  ObjectSet(o_name, OBJPROP_STYLE, STYLE_DOT);
   ObjectSet(o_name, OBJPROP_WIDTH, 1);
    ObjectSet(o_name, OBJPROP_RAY, false);  // луч
    ObjectSetInteger(0, o_name, OBJPROP_SELECTABLE, False); 
  ObjectSetInteger(0, o_name, OBJPROP_HIDDEN, True);  
  ObjectSetString(0, o_name, OBJPROP_TOOLTIP, "\n"); // убираю всплывающую надпись
}
 
HELP ME UNDERSTAND WHAT A BOND IS
1) How do I calculate my bail? How do I get this value in EA?
2) How do I calculate a margin for locking? How do I get this value in my EA?
3) How do I get the margin value from the ticket of an open order? I couldn't find functions like OrderMargin(), although I can see the margin on orders in the terminal (or is it lying?).
4) Is the deposit a parameter fixed once at the moment of order opening or recalculated (floating) at each new moment of order existence at the current rate?

Is the formula for manual calculation of the deposit correct?
(base_lot * trade_lot * current_rate%%%%%USD) / leverage = USD margin
 
smart_man:
HELP ME UNDERSTAND WHAT A DEPOSIT IS
1) How do I calculate the deposit? How do I get this value in my EA?
2) How do I calculate a margin for locking? How do I get this value in my EA?
3) How do I get the margin value from the ticket of an open order? I couldn't find functions like OrderMargin(), although I can see the margin on orders in the terminal (or is it lying?).
4) Is the deposit a parameter fixed once at the moment of order opening or recalculated (floating) at each new moment of order opening at the current rate?

Is the formula for manual calculation of the deposit correct?
(base_lot * trade_lot * current_rate%%%%%USD) / leverage = USD margin

1)

 margin =AccountInfoDouble(ACCOUNT_MARGIN);                        //-Размер зарезервированных залоговых средств на счете  в валюте депозита

2) do not use

3)formula is the same as yours, only instead of "current_%%%%%USD", it is position open price.

4) parameter is fixed


Correct

 
Alekseu Fedotov:

1)

2) do not use

3)formula is the same as yours, only instead of "current_%%%%%USD", it is position open price.

4) parameter is fixed


Correct

Thank you!

2) Found information that the formula is the same, only at the end still divide everything by 2, but do not know if this is actually true

3) Opening price of the position, which by OrderOpenPrice() ?

5) Another question, if any opening is planned, then before that all the future costs of the order have to be calculated (amount of margin, amount of profit and loss, but here we also need to calculate the point value, check availability of free funds, limit in percentage of free funds for risk at once, did I miss something else? Or is there some other way? Is there any drawdown, should it be calculated as well?

5.1) How do I calculate the pip value?

5.2) How do I check if I have any available funds?

I ask these questions, because it is difficult to understand on my own, as there are so many specifics, like accounting.

Reason: