[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 302

 
hoz:

Hmm. I guess you can't use a constant for case as a variable, according to the documentation. It says some kind of target constant, character constant or character expression.

It only works if you set a string-type letter, i.e. 1 character (if more than 1 character, the compiler swears) or a number.

Nothing else.
It says some target constants, character expressions and character constants.

Only integer constants.
 
Help me advice, there is a signal to open a buy position, after a while there is another signal or several buy positions, each of which lasts for 1 candle how to make at the time of each signal to open a new order and only one, and not packs without closing previous orders?
 
tommy27:
Please advise, there is a signal to open a buy position, some time later there is another signal or several signals to buy, each of which lasts for 1 candle how to make a new order open during each such signal and only one, and not packs without closing previous orders?
Check how many bars ago the last position was opened. If it is more than the specified value, a new position can be opened.
 
artmedia70:
Check how many bars ago the last position was opened. If it is more than this, a new position can be opened.


Thank you
 

I'm learning to work with libraries. I'm writing an Expert Advisor, there's a function like this:

//+-------------------------------------------------------------------------------------+
//| Получаем машку с заданными параметрами                                              |
//+-------------------------------------------------------------------------------------+
double GetMA(int typeOfMA)
{
   switch (typeOfMA)
   {
      case 1:      return (iMA(NULL, i_fastMATF, i_fastMAPeriod, i_fastMAShift, i_fastMAMethod, i_fastMAApplied, i_fastMAIndex));
      case 2:      return (iMA(NULL, i_slowMATF, i_slowMAPeriod, i_slowMAShift, i_slowMAMethod, i_slowMAApplied, i_slowMAIndex));
      case 3:      return (iMA(NULL, i_filtrMATF, i_filtrMAPeriod, i_filtrMAShift, i_filtrMAMethod, i_filtrMAApplied, i_filtrMAIndex));
   }
}

I put it in the inclusion, everything works as it should. But if you connect it to the library, there is an error when compiling the Expert Advisor:

'GetMA' - function is not defined       E:\Insall'd soft' s\Forex\MetaTraderForProgramming\experts\Scalper_M1.mq4 (127, 8)
'GetMA' - function is not defined       E:\Insall'd soft' s\Forex\MetaTraderForProgramming\experts\Scalper_M1.mq4 (127, 19)
'GetMA' - function is not defined       E:\Insall'd soft' s\Forex\MetaTraderForProgramming\experts\Scalper_M1.mq4 (129, 8)
'GetMA' - function is not defined       E:\Insall'd soft' s\Forex\MetaTraderForProgramming\experts\Scalper_M1.mq4 (129, 19)
4 ошибок, 0 предупреждений.

Why is this function not visible in the library?

The library has this content and compiles perfectly:

//+-------------------------------------------------------------------------------------+
//|                                                                  Scalper_M1_lbr.mq4 |
//|                                                                                 hoz |
//|                                                                                     |
//+-------------------------------------------------------------------------------------+
#property copyright "hoz"
#property link      ""
#property library

int i_fastMATF,
    i_fastMAPeriod,
    i_fastMAShift,
    i_fastMAMethod,
    i_fastMAApplied,
    i_fastMAIndex,
    i_slowMATF,
    i_slowMAPeriod,
    i_slowMAShift,
    i_slowMAMethod,
    i_slowMAApplied,
    i_slowMAIndex,
    i_filtrMATF,
    i_filtrMAPeriod,
    i_filtrMAShift,
    i_filtrMAMethod,
    i_filtrMAApplied,
    i_filtrMAIndex;
//+-------------------------------------------------------------------------------------+
//| Получаем машку с заданными параметрами                                              |
//+-------------------------------------------------------------------------------------+
double GetMA(int typeOfMA)
{
   switch (typeOfMA)
   {
      case 1:      return (iMA(NULL, i_fastMATF, i_fastMAPeriod, i_fastMAShift, i_fastMAMethod, i_fastMAApplied, i_fastMAIndex));
      case 2:      return (iMA(NULL, i_slowMATF, i_slowMAPeriod, i_slowMAShift, i_slowMAMethod, i_slowMAApplied, i_slowMAIndex));
      case 3:      return (iMA(NULL, i_filtrMATF, i_filtrMAPeriod, i_filtrMAShift, i_filtrMAMethod, i_filtrMAApplied, i_filtrMAIndex));
   }
}
 
Hi all. I really need some lectures on programming. Can you tell me where I can download them without any extra hassle? I've only found these: http://sdb.su/programmirovanie/page,17,782-mozzhechkov-a-a-upravlenie-robotami-i-robototexnicheskimi-sistemami.html But they don't suit me, as they are too complicated.
 
popovagalina:
Hi all. I really need some lectures on programming. Can you tell me where I can download them without any extra hassle? I found only these: http://sdb.su/programmirovanie/page,17,782-mozzhechkov-a-a-upravlenie-robotami-i-robototexnicheskimi-sistemami.html But they don't suit me, as they are too complicated.
Why is S. Kovalyov's textbook not good for you? See above and Documentation and TA to help! Good luck!
 

Hello.

Could you please tell me if the operator OrdersTotal() actually counts all open orders or those belonging to the symbol assigned to the Expert Advisor?

If it is general, how can we calculate only EURUSD if there are open orders for USDCHF etc.?

Thanks.

 
ed3sss:

Hello.

Could you please tell me if the operator OrdersTotal() actually counts all open orders or those belonging to the symbol assigned to the Expert Advisor?

If it is general, how can we calculate only EURUSD if there are open orders for USDCHF etc.?

Thanks.


It will calculate all of them. If you want to be specific to a symbol or something else, you can use this function:

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 28.11.2006                                                     |
//|  Описание : Возвращает количество ордеров.                                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любой ордер)                    |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
int NumberOfOrders(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), ko=0, ot;

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ot=OrderType();
      if (ot>1 && ot<6) {
        if ((OrderSymbol()==sy || sy=="") && (op<0 || ot==op)) {
          if (mn<0 || OrderMagicNumber()==mn) ko++;
        }
      }
    }
  }
  return(ko);
}
 
Now I have a question: the signals to the owl come from 2 indicators, the first signal lasts for 1 bar and then disappears, and the second appears either on the same bar or after a few bars. How to make the owl remember the 1st signal and wait for the second one to appear no matter how many bars later.