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

 
Integer:


I'm impressed by the level of fantasy. Why data is shown only for some symbols (which were not opened) and not for all symbols in the market review? How did the RefreshRates() function know that some symbols should be updated and some should not?

Junko, stop raving.


Dmitry, let's not quarrel with each other. It is better to help each other, because you and Vadim have had so many disagreements lately. I was bored with my thoughts for a couple of days, didn't visit the thread, and then, as usual, I went and looked through everything. To be honest it was funny to read, really funny! There are such a skirmish, and such discussions and congresses that I just wonder :) Occasionally abstruse phrases and words, but in fact complete nonsense. I will judge no one, though I am far from advanced thinking, myself still to learn to learn (in some places to swim), and then understood and clearly see that the debate has reached complete absurdity.

It seems to be a gathering of pros, otherwise I won't say it. I can't say otherwise about you, because I can see that everyone understands what they are doing. But what is interesting is that pros can be prone to slip-ups when they do not want to admit their mistakes. But we learn from our mistakes! There is nothing to be ashamed of. So if someone made a mistake, you do not need to go off topic, but rather confess. For dozens of pages of programmer's rubbish turning to personalities, it is somehow not an option. The purpose of at least this branch or forum is not to shit each other from head to foot, but to get better in programming and share our thoughts on the subject. So let's live together. Enough of the bickering.

 
hoz:

Well, that's right. 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:

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


sorry, it still doesn't work.

I want the function to return the total profit for today, not for today.

and no matter how I tried ... it doesn't work. The result is just the whole story.

If you subtract today's BEFORE from the WHOLE history, you will get today's total.

double tm1=GetProfitFromDateInCurrency (Symbol(), -1, -1, iTime (NULL, PERIOD_D1, 0));  
double tm2=GetProfitFromDateInCurrency (Symbol(), -1, -1, TimeCurrent());  

Print(  m2-m1 );

prints nil .....

 
It is always easier for a fool to prove a fool to a clever man than vice versa, for it is inherently easier for a clever man to doubt.
 
lottamer:


In theory, if you subtract what happened BEFORE today from the WHOLE story, you get what happened today.

prints ZERO, for fuck's sake.....


The idea is to understand what this function does. And to understand it, you have to break it down line by line in its entirety. I have already told you this. It's all elementary. And there's no point in helping, because it's up to you whether or not you understand the code of one simple function.

I described it above.

 
hoz:


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

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

1. How did you run it? You have to run it without refresh first. I.e. IsRefreshRates = false. The data will not be updated.

2. Then you must run it with IsRefreshRates = true. The data will be updated.

Here's a screenshot 1: screenshot 2:

Note the bar times. You can also see that MarketInfo() takes data from the market overview.

Here is the Expert Advisor. I corrected it a little. I have corrected it a little.

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() (", sTool, ")\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Предопределенные переменные (", Symbol(), ")\n",
                                        TimeToStr(Time[0], TIME_DATE|TIME_MINUTES|TIME_SECONDS), "\n",
                                        DoubleToStr(Bid, Digits), "  ", DoubleToStr(Ask, Digits),
                                        "\n\nМассивы-таймсерии (", sTool, ")\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);
   }
 } 
hoz:


Dimitri, let's not quarrel. It is better to help each other, because you and Vadim have had so many disagreements lately. I once spent a couple of days in my head, did not go to the branch, and then, as usual, went and scoured everything. To be honest it was funny to read, really funny! There are such a skirmish, and such discussions and congresses that I just wonder :) Occasionally abstruse phrases and words, but in fact complete nonsense. I will judge no one, though I am far from advanced thinking, myself still to learn to learn (in some places to swim), and then understood and clearly see that the debate has reached complete absurdity.

I think we have gathered professionals. I won't say anything about you otherwise, because I see that everyone understands what he or she is doing. But what is interesting is that pros are sometimes prone to slip-ups when they do not want to admit their mistakes. But we learn from our mistakes! There is nothing to be ashamed of. So if someone made a mistake, you do not need to go off topic, but rather confess. For dozens of pages of programmer's rubbish turning to personalities, it is somehow not an option. The purpose of at least this branch or forum is not to shit each other from head to foot, but to get better in programming and share our thoughts on the subject. So let's live together. Enough of the bickering.

Victor, don't pay attention. There are people who cannot formulate a thought and do not know how to build a reasoned speech. For them the most compelling argument is profanity.

Also such people are not receptive to anything new. Dmitri still does not understand how you can work with streams without organizing your queue. He has not even given an example where this queue is necessary.

Now he is arguing again. Instead of checking and arguing his position.

 
Zhunko:

Victor, you are not paying attention. There are some people who cannot formulate a thought and do not know how to build a reasoned speech. For them, the most powerful argument is profanity.

Also such people are not receptive to anything new. Dmitri still does not understand how you can work with streams without organizing your queue. He has not even given an example where this queue is necessary.

Now he is arguing again. Instead of checking and arguing his position.


Junko, you're overreacting. Everything written here applies directly to you. You don't understand about streams, you don't understand why the data updated, etc., but you pretend to be an expert, and that's bullshit. And you pretend to be so righteous.
 
Integer:


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 raving.

RefreshRates() updates only those values the Expert Advisor operates with. That's how it finds out. From Expert Advisor. Long time ago someone from Metakvot wrote about it.
 
hoz:


The idea is to understand what this function does. And to understand it, you have to take it apart line by line. I've already told you that. It's all elementary. And there's no point in helping, because it's up to you if you understand the code of one simple function or not.

I described it above.


I figured it out.

in general, the function returns the total profit, but only of the period that you set in the History tab. and it changes it along the way immediately if you change the period in the HISTORY tab

I do not need it.

I need it to set the period by a given parameter.

I'm trying to change the function itself...

double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dt=iTime (NULL, PERIOD_D1, 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);
}

but the compiler complains that

'iTime' - initialization expected

What should I add?

 
Zhunko:
RefreshRates() only updates what the Expert Advisor is working with. That's how it finds out. From the Expert Advisor. Long time ago someone from Metakvot wrote about it.

Don't give programming language functions some mystical features and properties that they don't have.

 
On the previous page at the end I wrote about what updates the data.
Reason: