Collect Price values High[0] to High[50] mql4
Collect Price values High[0] to High[50] mql4
Loading saved threads...
Qan N · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Qan N
Original post: https://stackoverflow.com/questions/73515729
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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)
I was trying to follow 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;
}
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/73517129
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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.
double total=0.0;
int count=50;
for(int i=count-1; i>=0; i--) total+=High[i];
double mean=total/count;
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Qan N Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/73515729 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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) I was trying to follow 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; }
Checking account access…