Questions from Beginners MQL5 MT5 MetaTrader 5 - page 43

 
Dimka-novitsek: Still, it's still fighting... Let's say action=ORDER_TYPE_SELL, it says 'action' - undeclared identifier. OrENUM_ORDER_TYPE action=ORDER_TYPE_SELL, it says 'action' - unexpected token. And so on...

So "what is a function and what is a function call" is still unread? :)

OrderCalcMargin(ORDER_TYPE_SELL,_Symbol,i,last_tick.bid,margin); //параметры функции вставляются примерно так :)
 

I'll get that...

I don't make the function... I'll find out where it came from! I'm sorry if I misled you or if I misunderstood. I'll just...

Ah, here.

OrderCalcMargin

Calculates the amount of margin required for the specified order type in the current account and in the current market environment, without considering current pending orders and open positions. Allows you to estimate the amount of margin for the planned trade. The value is returned in the account currency.
bool OrderCalcMargin(
ENUM_ORDER_TYPE action, // order type
string symbol, // symbol name
double volume, // volume
double price, //open price
double& margin //variable for getting the margin value
);

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Dimka-novitsek:

But it still fouls up... Let's say action=ORDER_TYPE_SELL, it says 'action' - undeclared identifier. OrENUM_ORDER_TYPE action=ORDER_TYPE_SELL, it says 'action' - unexpected token.

It's everywhere... And in English...

Dimitri!

Once again I am pointing you to the function and function call sections!


Function definition:

int function (int a, int b)
{
   return (a+b);
}

first comes its header.

It has the return value type (int), function name and its input parameters with their types!


function call:

int c = 1;
int d = 5;
int summa;
summa = function(c, d);   // вызывается функция, фактические параметры переменные c и d
summa = function(1, 3);   // вызывается функция, фактические параметры числа 1 и 3
summa = function(1, d);   // вызывается функция, фактические параметры число 1 и переменная d

here first you have defined some variables (or not)

and then you call the function by writing in parentheses for which numbers or variables you call it.

 
Ah, I'll declare the variables above the function!
 
Ugh!!! 0 error(s), 0 warning(s) 1 1 , Thank you!!!
 
Please help me, I can not become a programmer, so just tell me what to do, I have an Expert Advisor mql5 how to modify it to mql4, if you can not tell me please tell me!!!! or in private
 
fokeevis:
Help please, I can't become a programmer, so please tell me what to do, i have an mql5 Expert Advisor, how can i modify it to mql4, if you are not hard to tell me about it!!!! or in person.
It is complicated and very difficult, especially for a non-programmer, so you are right to ask Jobs.
 
I developed a function at someone's request, it should look something like this.
double GetLot(  double Risk,  ENUM_ORDER_TYPE  action ,  string  symbol ,   double  price ,  double   Lot  ){ 
                     double  volume=1,margin=1; 
                       if(!use_percent_of_deposit) return  (Lot) ; MqlTick last_tick;SymbolInfoTick(Symbol(),last_tick);
                                           switch(action)
     {
      case ORDER_TYPE_BUY: price=last_tick.asc ;
      case ORDER_TYPE_SELL: price=last_tick.bid ;
      case ORDER_TYPE_BUY_LIMIT: price=price;
      case ORDER_TYPE_SELL_LIMIT:  price=price;
      case ORDER_TYPE_BUY_STOP:  price=price;
      case ORDER_TYPE_SELL_STOP:  price=price;
      case ORDER_TYPE_BUY_STOP_LIMIT:  price=price;
      case ORDER_TYPE_SELL_STOP_LIMIT:  price=price;}
                     OrderCalcMargin(
         action,           // тип ордера
                  symbol,           // имя символа
                  volume,           // объем
                  price,            // цена открытия
                 margin            // переменная для получения значения маржи
                   ); 
         
         double  Koeffitsyenta=AccountInfoDouble(ACCOUNT_BALANCE)/ margin ;
         Lot= (Koeffitsyenta*Risk)/100;
         double Pt=1/SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP); 
          Lot= Lot*Pt; Print( "Lot*Pt  " ,  Lot   );
         Lot=NormalizeDouble(Lot,0); 
          Lot= Lot/Pt;
         double MAX=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MAX);
           double MIN=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);
          if (Lot>MAX) Lot=MAX;if (Lot<MIN) Lot=MIN;
          return(Lot);
                 
                   }
I haven't compiled it yet, I haven't tested it, I wrote it in Notepad.
 
Dimka-novitsek:
I developed a function at someone's request, it should look something like this. I haven't compiled it yet, I haven't tested it in work, I wrote it in Notepad.
So what's the question?
 

Is it possible to make the spread on MetaQuotes-Demo server constant, because debugging, adjustment turns into a nightmare, you have to take into account the spread, which is constantly changing and distorts the picture????????

Floating spread is an unnecessary headache.

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
Reason: