Constants won't work either, there will be an error:
constint AA =11;
ArrWe m[AA];
Access specifiers
Access specifiers tell the compiler how to access variables, members of structures or classes.
Theconstspecifier declares a variable to be a constant and does not allow this variable's value to be changed in the process of program execution. It is allowed to initialize a variable once when declaring it.
papaklass: I don't get it. I put an EA on the chart and this message appears in the "Experts" tab. The Expert Advisor continues its work anyway. This is not an error, but a warning. A warning about what?
It is an error at runtime - it means a memory leak. Somewhere memory occupied by a string is not being freed. Most likely, it is a structure or class that is not deleted after new. You need to look through the code to be more specific.
constants won't work either, there will be an error:
Access specifiers
Access specifiers tell the compiler how to access variables, members of structures or classes.
Theconstspecifier declares a variable to be a constant, and does not allow this variable's value to be changed in the process of program execution. It is allowed to initialize a variable once when declaring it.
A constant variable is not a constant! It is allowed to be initialized once, i.e., it is a variable for which memory is allocated.
The task of the constants is to be calculated and inserted into the code without occupying the memory at runtime.
The constant will be const AA=11.
Therefore the compiler will get sworn. If const AA=11, it won't complain.
On the last interval in ChannelPeriod = 100; there is a sharp shift upwards in the indicator readings, going beyond the last 100 bars everything shows normally.
Does anyone know how to fix it?
//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime& time[],
constdouble& open[],
constdouble& high[],
constdouble& low[],
constdouble& close[],
constlong& tick_volume[],
constlong& volume[],
constint& spread[])
{
//--- variables of indicatorint i;
CopyClose(Symbol1_Name,PERIOD_M30,0,rates_total,close_1);
CopyClose(Symbol2_Name,PERIOD_M30,0,rates_total,close_2);
//--- main cyclefor(i=prev_calculated; i<rates_total; i++)
{
Last[i] = (Symbol1_Vol*Symbol1_K*close_1[i] - Symbol2_Vol*Symbol2_K*close_2[i]);
}
// Считаем положение эквити относительно канала удвоенного среднеквадратичного отклоненияdouble StdDev;
for(i=prev_calculated; i<rates_total; i++)
{
StdDev=MyStdDev(Last,ChannelPeriod,i);
if(StdDev>0.00001) // Защита от отсутствия данных
ExtStdDevBuffer[i]=(Last[i]+2*StdDev-iMAOnArrayMQL4(Last,0,ChannelPeriod,0,MODE_SMA,i))/(4*StdDev);
}
return(rates_total);
}
//-----------------------------------------------------------------------------------------//-----------------------------------------------------------------------------------------// Calculation StdDev -----------------------------------------------| // StdDev = SQRT (SUM [(S(i) - SMA(i))^2, N] / N) | double MyStdDev(double &array[], int BandsPeriod, int Index)
{
double ds, sum, center;
sum = 0;
center = iMAOnArrayMQL4(array,0,BandsPeriod,0,MODE_SMA,Index);
for(int i = 0; i < BandsPeriod; i++)
{
ds = array[Index+i] - center;
sum += ds * ds;
}
sum = MathSqrt (sum / BandsPeriod);
return (sum);
}
//-----------------------------------------------------------------------------------------//-----------------------------------------------------------------------------------------double iMAOnArrayMQL4(double &array[], int total, int period, int ma_shift, int ma_method, int shift)
{
double buf[],arr[];
if(total==0) total=ArraySize(array);
if(total>0 && total<=period) return(0);
if(shift>total-period-ma_shift) return(0);
switch(ma_method)
{
caseMODE_SMA :
{
total=ArrayCopy(arr,array,0,shift+ma_shift,period);
if(ArrayResize(buf,total)<0) return(0);
double sum=0;
int i,pos=total-1;
for(i=1;i<period;i++,pos--)
sum+=arr[pos];
while(pos>=0)
{
sum+=arr[pos];
buf[pos]=sum/period;
sum-=arr[pos+period-1];
pos--;
}
return(buf[0]);
}
caseMODE_EMA :
{
if(ArrayResize(buf,total)<0) return(0);
double pr=2.0/(period+1);
int pos=total-2;
while(pos>=0)
{
if(pos==total-2) buf[pos+1]=array[pos+1];
buf[pos]=array[pos]*pr+buf[pos+1]*(1-pr);
pos--;
}
return(buf[shift+ma_shift]);
}
caseMODE_SMMA :
{
if(ArrayResize(buf,total)<0) return(0);
double sum=0;
int i,k,pos;
pos=total-period;
while(pos>=0)
{
if(pos==total-period)
{
for(i=0,k=pos;i<period;i++,k++)
{
sum+=array[k];
buf[k]=0;
}
}
else sum=buf[pos+1]*(period-1)+array[pos];
buf[pos]=sum/period;
pos--;
}
return(buf[shift+ma_shift]);
}
caseMODE_LWMA :
{
if(ArrayResize(buf,total)<0) return(0);
double sum=0.0,lsum=0.0;
double price;
int i,weight=0,pos=total-1;
for(i=1;i<=period;i++,pos--)
{
price=array[pos];
sum+=price*i;
lsum+=price;
weight+=i;
}
pos++;
i=pos+period;
while(pos>=0)
{
buf[pos]=sum/weight;
if(pos==0) break;
pos--;
i--;
price=array[pos];
sum=sum-lsum+price*period;
lsum-=array[i];
lsum+=price;
}
return(buf[shift+ma_shift]);
}
default: return(0);
}
return(0);
}
//-----------------------------------------------------------------------------------------
Why, when I press the "Start" button, the tester does not test from the initial deposit level, but from the level where the last test ended. There is no such problem in 4. How to start testing from the initial deposit level?
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.
Found a "confusion".
Why doesn't the compiler like the define of the second b variable?
And in general, how do I handle this situation?
It doesn't like the define.
It just writes another error - wrong variable type for the array dimension
You can only specify constants in dimensions
it's not the define that he doesn't like.
It also writes another error - wrong variable type for the array dimension
Only constants may be specified in dimensions
Constants won't work either, there will be an error:
Access specifiers
Access specifiers tell the compiler how to access variables, members of structures or classes.
Theconstspecifier declares a variable to be a constant and does not allow this variable's value to be changed in the process of program execution. It is allowed to initialize a variable once when declaring it.
I meant only two options
int Arr[100]
or
#define r 100
int Arr[r]
For the rest ArrayResize
I don't get it. I put an EA on the chart and this message appears in the "Experts" tab. The Expert Advisor continues its work anyway. This is not an error, but a warning. A warning about what?
constants won't work either, there will be an error:
Access specifiers
Access specifiers tell the compiler how to access variables, members of structures or classes.
Theconstspecifier declares a variable to be a constant, and does not allow this variable's value to be changed in the process of program execution. It is allowed to initialize a variable once when declaring it.
A constant variable is not a constant! It is allowed to be initialized once, i.e., it is a variable for which memory is allocated.
The task of the constants is to be calculated and inserted into the code without occupying the memory at runtime.
The constant will be const AA=11.
Therefore the compiler will get sworn. If const AA=11, it won't complain.
Can you tell me what the problem is?
On the last interval in ChannelPeriod = 100; there is a sharp shift upwards in the indicator readings, going beyond the last 100 bars everything shows normally.
Does anyone know how to fix it?
Please give me a direct link where you can download textbooks in PDF format because my phone browser can't see everything on the website.