简体   繁体   English

收集价格值 High[0] 到 High[50] mql4

[英]Collect Price values High[0] to High[50] mql4

I was creating a for loop that looks for mean of price within a set array of 50. the difficulty I am having is with the collection and storage of High[0] to High[50] (Low[0] to Low[50]) data for the mean equation M= (Total Value/nbars)我正在创建一个 for 循环,在一组 50 的数组中查找价格的平均值。我遇到的困难是收集和存储 High[0] 到 High[50](Low[0] 到 Low[50] ) 平均方程的数据 M= (总值/nbars)

I was trying to follow C++:我试图关注 C++:

float arithmeticMean(float [], int);
int main()
{
    int n, i;
    float arr[50], armean;
    cout<<"Enter the Size (maz. 50): ";
    cin>>n;
    cout<<"\nEnter "<<n<<" Numbers: ";
    for(i=0; i<n; i++)
        cin>>arr[i];
    armean = arithmeticMean(arr, n);
    cout<<"\nArithmetic Mean = "<<armean;
    cout<<endl;
    return 0;
}
float arithmeticMean(float arr[], int n)
{
    int i;
    float sum=0, am;
    for(i=0; i<n; i++)
        sum = sum+arr[i];
    am = sum/n;
    return am;
}

And I attempted to resize the buffer and store price values, but this isn't correct, ideas?:我试图调整缓冲区大小并存储价格值,但这不正确,想法?:

{
int d = High[50]+Low[50];
double rb[],armean;
for(int s=-1; Close[s]<d; Close[s++]) //Array Iteration Loop Forward BarsToCheck
{
double Meansize = ArrayResize(rb,s);
double sum = Meansize+rb[s];
}
armean = sum/d;
}

You are really getting things confused, just keep it simple.你真的把事情弄糊涂了,保持简单。 Also remember that arrays are 0 based, therefore, if you want to count 50 items you will run from 0 to 49.还要记住 arrays 是基于 0 的,因此,如果要计算 50 个项目,您将从 0 运行到 49。

double total=0.0;
int count=50;
for(int i=count-1; i>=0; i--)
{
   total+=High[i];
}
double mean=total/50;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM