There is a problem with the Expert Advisor in the tester. I am testing on 1-minute data. I calculate the stochastic for the higher TF by myself using the minute data.
The history of minutes has been downloaded since 2001. In the "Charts" tab set the maximum number of bars in the history, and displayed.
The whole history on the chart is scrolled.
The problem is that, as it turned out with the debug print, no matter from what date I start the tester, the maximum number of bars
in the Bars variable on the first bar of the test (at the start) is always 1001 or 1002. The value of Bars increases by 1 with every next bar.
Therefore, it is impossible to count the higher TFs at the start.
There is one solution. We should add a ban on trading before Bars reaches the desired value.
Can we solve this problem in another way? Does this start value of Bars in the tester increase somehow?
There is a problem with the Expert Advisor in the tester. I am testing on 1-minute data. I calculate the stochastic for the higher TF by myself using the minute data.
The history of minutes has been downloaded since 2001. In the "Charts" tab set the maximum number of bars in the history, and displayed.
The whole history on the chart is scrolled.
The problem is that, as it turned out with the debug print, no matter from what date I start the tester, the maximum number of bars
in the Bars variable on the first bar of the test (at the start) is always 1001 or 1002. The value of Bars increases by 1 with every next bar.
Therefore, it is impossible to count the higher TFs at the start.
There is one solution. We should add a ban on trading before Bars reaches the desired value.
Can we solve this problem in another way? Does this start value of Bars in the tester increase somehow?
What could be the problem. When writing an EA, I have to test it many times to track changes. After a random number of tests, the strategy tester does not accept changes made to the code. It sometimes comes to the point of absurdity. You can simply delete a piece of code and the owl will work in the tester following the algorithm written earlier. The same happens with parsing calculations into CSV. After a certain number of tests some random crap is parsed into CSV.
Aleksey Maryaskin: Gentlemen Developers! Good day to all. I am interested in the question of creating a template for an Expert Advisor (script) when creating it. Can it be edited somewhere and how is it done?
A direct link here probably won't get through... You may google "I will post MQL4 course in this thread" (without the quotes). Search for "template" (I think it's on the 2nd page).
Vitaly Muzichenko: Look at the indicator itself, it will make more sense.
Looked at It's the same as the link I gave you.
double SMMA(int period) {
//fill array with closing prices int k=period; for(int i=1; i<=period; i++) { H1_Close[i]=Close[k]; // Print("H1_Close [",i,"] ",H1_Close[i]," Close [",k,"] ",Close[k]); k--; } //calculate the first element as the average closing price double Summ=0; for (int i=1; i<=period;i++) Summ=Summ+H1_Close[i]; //SUM1 = SUM(CLOSE, N) double TmpSMMA=Summ/period; //SMMA1 = SUM1/N //calculate the i-th element as SMMA (i) = (SMMA (i - 1) * (N - 1) + CLOSE (i)) / N for(int i=2;i<=period;i++) TmpSMMA=(TmpSMMA*(period-1)+H1_Close[i])/period; } The result is still much different from the indicator data in the terminal. WHY ?
Alexey Viktorov: There is a calculation algorithm in the inluder.
So I seem to do everything as in the calculations, but the result does not come out. Day 4 I can not figure it out. I wrote the code of the function in Vitaly Muzichenko's answer, but I can't figure out what the error is
zsu1970: So I seem to be doing everything as in the calculations, but the result does not come out. I'm sitting here for the 4th day and can't figure it out. I wrote the code of the function in Vitaly Muzichenko's answer, but I can't figure out what the error is
You put the prices right away, or get them and then paste them into the calculation?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
There is a problem with the Expert Advisor in the tester. I am testing on 1-minute data. I calculate the stochastic for the higher TF by myself using the minute data.
The history of minutes has been downloaded since 2001. In the "Charts" tab set the maximum number of bars in the history, and displayed.
The whole history on the chart is scrolled.
The problem is that, as it turned out with the debug print, no matter from what date I start the tester, the maximum number of bars
in the Bars variable on the first bar of the test (at the start) is always 1001 or 1002. The value of Bars increases by 1 with every next bar.
Therefore, it is impossible to count the higher TFs at the start.
There is one solution. We should add a ban on trading before Bars reaches the desired value.
Can we solve this problem in another way? Does this start value of Bars in the tester increase somehow?
There is a problem with the Expert Advisor in the tester. I am testing on 1-minute data. I calculate the stochastic for the higher TF by myself using the minute data.
The history of minutes has been downloaded since 2001. In the "Charts" tab set the maximum number of bars in the history, and displayed.
The whole history on the chart is scrolled.
The problem is that, as it turned out with the debug print, no matter from what date I start the tester, the maximum number of bars
in the Bars variable on the first bar of the test (at the start) is always 1001 or 1002. The value of Bars increases by 1 with every next bar.
Therefore, it is impossible to count the higher TFs at the start.
There is one solution. We should add a ban on trading before Bars reaches the desired value.
Can we solve this problem in another way? Does this start value of Bars in the tester increase somehow?
P.S. I pressed the compile button.
I really need to understand the algorithm for calculating the smoothed moving average. There are several reasons why the iMA function is not suitable.
As I understood the information from https://www.metatrader5.com/ru/terminal/help/indicators/trend_indicators/ma#smma
The first element is calculated as the sum of closing prices divided by the period.
The following ones are calculated according to the formula SMMA (i) = (SMMA (i - 1) * (N - 1) + CLOSE (i)) / N.
Let's take a period of 5 and the closing prices of EUR/USD H1 for the period from 24.02.2017 19:00 to 24.02.2017 23.00 (GMT+2) i.e. last 5 candles
The closing prices are 1.05681; 1.05702; 1.05639; 1.05612; 1.05592.
Correspondingly, 1st element - 1.056452; 2nd element - 1.056852 3rd element - 1.05676 4th element - 1.056632 5th element - 1.056489
But on the SMMA 5 chart, close is 1.05706, i.e. the difference is already in the 3rd digit
What am I counting wrong?
And how shall I calculate correctly in order to get 1.05706?
I really need to understand the algorithm for calculating the smoothed moving average. There are several reasons why the iMA function is not suitable.
As I understood the information from https://www.metatrader5.com/ru/terminal/help/indicators/trend_indicators/ma#smma
The first element is calculated as the sum of closing prices divided by the period.
The following ones are calculated according to the formula SMMA (i) = (SMMA (i - 1) * (N - 1) + CLOSE (i)) / N.
Let's take a period of 5 and the closing prices of EUR/USD H1 for the period from 24.02.2017 19:00 to 24.02.2017 23.00 (GMT+2) i.e. last 5 candles
The closing prices are 1.05681; 1.05702; 1.05639; 1.05612; 1.05592.
Correspondingly, 1st element - 1.056452; 2nd element - 1.056852 3rd element - 1.05676 4th element - 1.056632 5th element - 1.056489
But on the SMMA 5 chart, close is 1.05706, i.e. the difference is already in the 3rd digit
What am I counting wrong?
And how shall I calculate correctly in order to get 1.05706?
Gentlemen Developers! Good day to all. I am interested in the question of creating a template for an Expert Advisor (script) when creating it. Can it be edited somewhere and how is it done?
Look at the indicator itself, it will make more sense.
double SMMA(int period)
{
//fill array with closing prices
int k=period;
for(int i=1; i<=period; i++)
{
H1_Close[i]=Close[k];
// Print("H1_Close [",i,"] ",H1_Close[i]," Close [",k,"] ",Close[k]);
k--;
}
//calculate the first element as the average closing price
double Summ=0;
for (int i=1; i<=period;i++)
Summ=Summ+H1_Close[i]; //SUM1 = SUM(CLOSE, N)
double TmpSMMA=Summ/period; //SMMA1 = SUM1/N
//calculate the i-th element as SMMA (i) = (SMMA (i - 1) * (N - 1) + CLOSE (i)) / N
for(int i=2;i<=period;i++)
TmpSMMA=(TmpSMMA*(period-1)+H1_Close[i])/period;
}
The result is still much different from the indicator data in the terminal. WHY ?
I really need to understand the algorithm for calculating the smoothed moving average. There are several reasons why the iMA function is not suitable.
As I understood the information from https://www.metatrader5.com/ru/terminal/help/indicators/trend_indicators/ma#smma
The first element is calculated as the sum of closing prices divided by the period.
The following ones are calculated according to the formula SMMA (i) = (SMMA (i - 1) * (N - 1) + CLOSE (i)) / N.
Let's take a period of 5 and the closing prices of EUR/USD H1 for the period from 24.02.2017 19:00 to 24.02.2017 23.00 (GMT+2) i.e. last 5 candles
The closing prices are 1.05681; 1.05702; 1.05639; 1.05612; 1.05592.
Correspondingly, 1st element - 1.056452; 2nd element - 1.056852 3rd element - 1.05676 4th element - 1.056632 5th element - 1.056489
But on the SMMA 5 chart, close is 1.05706, i.e. the difference is already in the 3rd digit
What am I counting wrong?
And how shall I calculate correctly in order to get 1.05706?
There is a calculation algorithm in the inluder.
I wrote the code of the function in Vitaly Muzichenko's answer, but I can't figure out what the error is
So I seem to be doing everything as in the calculations, but the result does not come out. I'm sitting here for the 4th day and can't figure it out.
I wrote the code of the function in Vitaly Muzichenko's answer, but I can't figure out what the error is