[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 409

 
The request from the chart is similar to CopyRates ArrayCopySeries, not RefreshRates. CopyRates is the only non-trading function that moves the server.
 
Zhunko:
When you open and update the chart, a request for new data goes to the server. Some greedy brokerage companies prefer to spend their money on their own pockets rather than on more powerful servers and a wider channel. They have to limit the number of requests from the terminal so that a weak server doesn't get "hung up". MRC has only 2000 requests per day. It's 10 times less than the number of their instruments multiplied by the number of TFs, not counting trade requests.
So, we have to avoid such kitchens. This is the first time I've heard negative things about MRC. It remains to be seen whether the terminal is the only one or whether the functions (except trading) also refer to the server. I asked this question to support (I wrote about it above, no answer yet). If not only, then all falls into place, and if only the terminal, then all goes out absurd that type of terminal is running and it will contact the server to update quotes, exceed the limit without trading. I think it is inadequate, and yet the functions, as Viktor said, except trading, don't access the server.

Zhunko:

Inludes in MQL4 help to streamline code. For example, this is how an indicator for 3000 lines looks like in my code.

The thing is, I've seen libraries, and it is mentioned in documentation, that inludes are usually placed at the very top of code, where global variables are declared. If there are functions in inludes, it seems strange to think that in a place where global variables are declared there will in fact be a function in that place, and alternatively, some kind of variables. That's not how the code is written. If variables used in the Expert Advisor and external custom variables are declared at the top, no one puts functions next to them! But they place inludes with functions, and it's considered normal, as I understand it. This is what confuses me the most here.

It just doesn't seem logical...

On the other hand, if an inline is placed, somewhere. instead of several functions, which are responsible for getting, say, a trade signal for some attribute, it would be a logical and readable thing.

Zhunko:

Unfortunately, the compiler does not allow one inclusion to be used more than once in one module. This is usually a way to save on repetitive code.

This is a small thing. After all, the main thing is to put main cumbersome functions and code fragments outside the main code, and call them via the inline. And then you can call the function, which you have inlined, by function name... And you won't have to worry about this restriction.
 

Good afternoon, all.

Studying MarketInfo ( ) and Print( ) functions

Here is a simple code using these functions

Tester, TF 60 min.

double T ;
int start()
{
 T = MarketInfo("EURUSD",MODE_HIGH); // в глобальную переменную Т запоминаем максимум дневной свечи,который должна возвращать  MarketInfo ( )
Print (" corresponds to ", T );           //
if ( T > iHigh( Symbol (), 0,10))  // если максимум текущей дневной свечи > High свечи N10(ТФ60 мин)
OrderSend(Symbol(),OP_SELL,0.1,Bid,1,0,0,"jfh",123 ); открыть ордер
}                                                                                                                       
return;

ПРОБЛЕМА 1.Ордер не открывается 2.Print() постоянно возвращает 0 ПРИМЕЧАНИЕ. Для открытия ордера - мне нужной сравнивать параметры свечей разных ТФ(60 мин и 1440 мин.) Подскажите пожалуйста как это можно сделать. Спасибо.

 
Integer:
The request from the chart looks like the CopyRates ArrayCopySeries request and not the RefreshRates one. CopyRates is the only non-trading function that moves the server.

Checked RefreshRates(). If this Expert Advisor is run, for example, on EURUSD, and another tool whose window has not been open for a long time is inserted in the settings (so that the history is not there), the history appears.

extern string Tool           = "AUDNZD"; // Имя инструмента.
extern bool   IsRefreshRates = true;     // Флаг включения обновления таймсерий.
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start()
 {
  string sTool = Tool; // Имя инструмента.
  if (Tool == "") sTool = Symbol();
  while (!IsStopped())
   {
    if (IsRefreshRates) RefreshRates();
    string sComment = StringConcatenate("MarketInfo()\n",
                                        TimeToStr(MarketInfo(sTool, MODE_TIME), TIME_DATE|TIME_MINUTES|TIME_SECONDS), "\n",
                                        DoubleToStr(MarketInfo(sTool, MODE_BID), Digits), "  ", DoubleToStr(MarketInfo(sTool, MODE_ASK), Digits),
                                        "\n\nПредопределенные переменные\n",
                                        TimeToStr(Time[0], TIME_DATE|TIME_MINUTES|TIME_SECONDS), "\n",
                                        DoubleToStr(Bid, Digits), "  ", DoubleToStr(Ask, Digits),
                                        "\n\nМассивы-таймсерии\n");
    for (int i = 0; i < 10; i++)
     {
      sComment = sComment + StringConcatenate(TimeToStr(iTime(sTool, 0, i), TIME_DATE|TIME_MINUTES|TIME_SECONDS), "  ",
                                              DoubleToStr(iOpen(sTool, 0, i), Digits), "  ",
                                              DoubleToStr(iLow(sTool, 0, i), Digits), "  ",
                                              DoubleToStr(iHigh(sTool, 0, i), Digits), "  ",
                                              DoubleToStr(iClose(sTool, 0, i), Digits), "  ",
                                              DoubleToStr(iVolume(sTool, 0, i), 0), "\n");
     }
    Comment(sComment);
    Sleep(300);
   }
 }

So, still RefreshRates() refers to the server and fills the history. As a consequence, controlling the arrival of history is necessary.

Support says that none of the functions directly refers to the server. Everything is performed through the terminal :-).

 
TarasBY:
If you use GetProfitFromDateInCurrency() (original - this is IMPORTANT: I do not know what you might have got there in your version), then the function should be called like this:

and the function will return profits on orders closed since the beginning of the current day.

And you can catch all stupid things in the code using Print().


it doesn't work. It shows all available profit on trades for the entire history.

Here's the original function and I didn't change anything in it, of course

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает суммарный профит в валюте депозита                  |
//|             закрытых с определённой даты позиций                           |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента             (""   - любой символ,         |
//|                                               NULL - текущий символ)       |
//|    op - операция                             (-1   - любая позиция)        |
//|    mn - MagicNumber                          (-1   - любой магик)          |
//|    dt - Дата и время в секундах с 1970 года  ( 0   - с начала истории)     |
//+----------------------------------------------------------------------------+
double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dt=0)
{
  double p=0;
  int    i, k=OrdersHistoryTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (mn<0 || OrderMagicNumber()==mn) {
            if (dt<OrderCloseTime()) {
              p+=OrderProfit()+OrderCommission()+OrderSwap();
            }
          }
        }
      }
    }
  }
  return(p);
}

here is its call and print

GetProfitFromDateInCurrency (Symbol(), -1, -1, iTime (NULL, PERIOD_D1, 0));  
Print(   GetProfitFromDateInCurrency () );
 
Zhunko:

Checked RefreshRates(). If this Expert Advisor is run, for example, on EURUSD, and another tool whose window has not been opened for a long time is inserted in the settings (so that the history is not there), the history appears.

So, still RefreshRates() refers to the server and fills the history. As a consequence, controlling the arrival of history is necessary.

Support says that none of the functions directly refers to the server. So, everything is done through the terminal :-)


Vadim, I ran your script on a terminal on which I have never opened any instruments apart from majors and crosses with yen. Anyway, here's a screenshot:

Nothing is pumped because the market data array is empty, judging by the comments...

 
hoz:


Vadim, I ran your script on a terminal on which I have never opened any instruments apart from majors and crosses with yen. Anyway, here's a screenshot:

Nothing is being pumped up as the market data array is empty, judging by the comments...


Yeah. He also didn't notice that he has MarketInfo() in his Expert Advisor, not just RefreshRates().
 
Zhunko:

Checked RefreshRates(). If this Expert Advisor is run, for example, on EURUSD, and another tool whose window has not been opened for a long time is inserted in the settings (so that the history is not there), the history appears.

So, still RefreshRates() refers to the server and fills the history. As a consequence, controlling the arrival of history is necessary.

Support says that none of the functions directly refers to the server. So, everything is done through the terminal :-)


The level of imagination is impressive. Why did the data appear only for some symbols (which were not opened), and not for all of them in the market review? How did the RefreshRates() function know that some symbols should be updated and some should not?

Junko, stop rambling.

 
lottamer:


does not work. Outputs all available profits on trades in the entire history.

Here is the original function and I didn't change anything in it, of course

here's its call and print

GetProfitFromDateInCurrency (Symbol(), -1, -1, iTime (NULL, PERIOD_D1, 0));  
Print(   GetProfitFromDateInCurrency () );

So everything is correct. You "read" the function line by line and understand how it works, if you're too bored to write it yourself, and everything will fall into place...

You have a function parameter:

iTime (NULL, PERIOD_D1, 0)

is thetime of the last day baropening, i.e. all positions that are closed before the current day bar is opened will be calculated and summed up! Does that make sense? So set another bar, which is required or whatever it is. But it's up to you to see.

 
Integer:

Yeah. He also didn't notice that he has MarketInfo() in his Expert Advisor, not only RefreshRates().


All other functions:


DoubleToStr(iOpen(sTool, 0, i), Digits), ",
DoubleToStr(iLow(sTool, 0, i), Digits), ",
DoubleToStr(iHigh(sTool, 0, i), Digits), " ",
DoubleToStr(iClose(sTool, 0, i), Digits), ",
DoubleToStr(iVolume(sTool, 0, i), 0), "\n");

Naturally, the data will be updated.

Reason: