Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Wrong applied price for ValueStorage-based iPrice(). Also a fix for ArraySize() and const-ness #737

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
* - https://www.mql5.com/en/docs/array/arraysize
*/
template <typename X>
static int ArraySize(ARRAY_REF(X, array)) {
static int ArraySize(const ARRAY_REF(X, array)) {
return ::ArraySize(array);
}

Expand Down
8 changes: 7 additions & 1 deletion Storage/ValueStorage.price.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ class PriceValueStorage : public HistoryValueStorage<double> {
return _low.Fetch(_shift);
case PRICE_CLOSE:
return _close.Fetch(_shift);
case PRICE_MEDIAN:
return (_high.Fetch(_shift) + _low.Fetch(_shift)) / 2;
case PRICE_TYPICAL:
return (_high.Fetch(_shift) + _low.Fetch(_shift) + _close.Fetch(_shift)) / 3;
case PRICE_WEIGHTED:
return (_high.Fetch(_shift) + _low.Fetch(_shift) + (2 * _close.Fetch(_shift))) / 4;
}
Alert("Wrong applied price for ValueStorage-based iPrice()!");
Alert("Wrong applied price for ValueStorage-based iPrice()! Got ", EnumToString(_ap));
DebugBreak();
return 0;
}
Expand Down
Loading