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

 
I.e. your choice is working levels. If you set a prohibition/allowance in the external variables to form objects (used for indication), you can run optimisation.
 

Hello again. Thank you for the previous reply - very helpful. Please help again. I've got the function I need from one Expert Advisor that counts account profit (loss) for today (if f0_5(0)), yesterday (if f0_5(1)), etc:

double f0_5(int ai_0) {
   double ld_ret_4 = 0;
   for (int pos_12 = 0; pos_12 < OrdersHistoryTotal(); pos_12++) {
      if (!(OrderSelect(pos_12, SELECT_BY_POS, MODE_HISTORY))) break;
               if (OrderCloseTime() >= iTime(OrderSymbol(), PERIOD_D1, ai_0) && OrderCloseTime() < iTime(OrderSymbol(), PERIOD_D1, ai_0) + 86400) ld_ret_4 = ld_ret_4 + OrderProfit() + OrderCommission() + OrderSwap();
   }
   return (ld_ret_4);
}

The result should be a decimal fraction (supposedly), but the function returns an integer for some reason. In general, please help me to change the function so that it was a fraction with two decimal places.

Although I may have screwed up here: checked using Print(), but the function actually counts normally? In general, please help me to understand.

 
MaxZ:

Here's the famous idnikator.

Can you get a picture like this!? :))))))



Here it is.

 
It says that:
ArrayCopy(array2,array1,0,Bars*6-60,60);
// теперь array2 содержит 10 последних баров из истории (имеется в виду, что последний бар - это текущий бар, бар с индексом [0])

Why would array2 contain the last 10 bars?
Because Bars*6 - 60 will not return the value 10. I don't notice any logic at all.
For example, there are 1000 bars in the history. Then Bars*6 - 60 = 1000*6 - 60 = 6000 - 60 = 5940. Where are the last 10 bars?
 
hoz:
It says that:

Why would array2 contain the last 10 bars?
Because Bars*6 - 60 will not return the value 10. I don't notice any logic at all.
For example, there are 1000 bars in the history. Then Bars*6 - 60 = 1000*6 - 60 = 6000 - 60 = 5940. Where are the last 10 bars?

You surprise me again! The so-called last 10, from 0 to the 10th bar we have on the chart in contact with the price! Forget about the thirtieth and five thousandth bars in the history! We have already gone through them, and we need them only for the tester. And we need the latest ones, starting from zero, and of course, the new ones in the future - that's where we are going! ;))
 
borilunad:

You surprise me again! The so-called last 10, from 0 to the 10th bar we have on the chart in contact with the price! Forget about the thirtieth and five thousandth bars in the history! We have already gone through them, and we need them only for the tester. And we need the latest ones, starting from zero, and of course, the new ones in the future - that's where we are going! ;))

That last i.e. closer to current price I have already understood. But this piece of codeBars*6 - 60 I do not understand. What it will return? I want to understand how it may be calculated logically. May I ask you to explain? Maybe it's easy for someone, but I'm not a programmer by education, so I'm having a hard time understanding this flow of information. I am reading the tutorial, and am gradually asking the questions that I come across. I very much hope that the questions will soon be more relevant than they are now.
 
hoz:
It says that:
Why would array2 contain the last 10 bars?
Because Bars*6 - 60 will not return the value 10. I don't notice any logic at all.
For example, there are 1000 bars in the history. Then Bars*6 - 60 = 1000*6 - 60 = 6000 - 60 = 5940. Where are the last 10 bars?
5940 -Initial index of the original array to copy the last 10 bars (bar - 6 indices).
 

Roll:
5940 -The starting index of the initial array to copy the last 10 bars (bar is 6 indexes).

Dear experts, isn't there an error in the textbook?

Here is my reasoning:

At the beginning of the code,int ArrayCopyRates function is called which copies the data of the bars of the current chart into a two-dimensional array of RateInfo[][6] type and returns the number of copied bars or -1 in case of failure according to the example of this function:

double array1[][6];
ArrayCopyRates(array1,"EURUSD", PERIOD_H1);
Print("Текущий бар ",TimeToStr(array1[0][0]),"цена открытия ", array1[0][1]);

the current bar is the bar with index 0-0 , thus, returning to the original code, we copy the element with index 0-0 (the current bar) of array1 , to array2 with index 0-0, we get the last 10 bars (where the last bar is the current bar, the one with index [0]), which is contrary to what we wrote in the tutorial... so by copying element with index Bars*6-60,60 of array1 into array2 with index 0 we get information about bars from history.

 

Hello.

I have a custom indicator.

I'm writing an EA...and I have a question...how to access my indicator? Specifically, take the data from the specified bar (in my case, I need to take the 2nd bar). I have windowsPriceMax, but as far as I understood it, it displays only the last value of subwindow chart and it's not clear, if for example I have 3 lines on the indicator, what will it display?

 
Tragedy:

Hello.

I have a custom indicator.

I'm writing an EA...and I have a question...how to access my indicator? Specifically, take the data from the specified bar (in my case, I need to take the 2nd bar). I received windowsPriceMax, but as far as I understand it, it outputs only the last value of the chart and I don't understand if I have 3 lines on the indicator, what will it output?



double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

Calculation of the specified custom indicator. The custom indicator must be compiled (a file with EX4 extension) and located in terminal_directory\experts\indicators.
Parameters:

symbol - symbol name of the instrument, on the data of which the indicator will be calculated. NULL means the current symbol.
timeframe - Period. Can be one of the chart periods. 0 means period of the current chart.
name - Custom indicator name.
... - Parameter list (if needed). Passed parameters should correspond with the order of declaration and type of external (extern) variables of the custom indicator.
mode - Index of the indicator line. Can be from 0 to 7 and must correspond to the index, used by one of the SetIndexBuffer functions.
shift - Index of the value received from the indicator buffer (shift relative to the current bar by the specified number of periods back).

Reason: