This commit is contained in:
2025-03-26 05:25:00 +03:30
parent a5511f2f69
commit 8278d132dd
10 changed files with 3686 additions and 30 deletions
+134 -11
View File
@@ -306,6 +306,28 @@ ENUM_X_MARKET_CYCLES NormalizeCycle(ENUM_X_MARKET_CYCLES value)
return value;
}
/**
* Normalize Price Boundary ...
*
* @param value: ENUM_X_BOUNDARY_PRICE, Provided Boundary Mode ...
*
* @return ( ENUM_X_BOUNDARY_PRICE )
*/
ENUM_X_BOUNDARY_PRICE NormalizeBoundary(ENUM_X_BOUNDARY_PRICE value)
{
//
ENUM_X_BOUNDARY_PRICE result = value;
//
if (!IsValid(result))
{
result = X_BOUNDARY_PRICE_HIGH_LOW;
}
//
return result;
}
/**
* Normalize Integer Value ...
*
@@ -836,14 +858,14 @@ double GetPoints(
/**
* Converts Price to Point ...
*
*
* @param price: double, price ...
* @param mSymbol: string, Symbol ...
*
*
* @return ( double )
*/
double PriceToPoint(
double mPrice, // the price amount which required to calculate
double mPrice, // the price amount which required to calculate
string mSymbol = NULL // Trading Symbol
)
{
@@ -5929,12 +5951,12 @@ double GetPipPrice(
* @return ( double )
*/
double GetAppliedPrice(
ENUM_X_PRICE mType, // Type of Price Selection
const double &mOpen[], // Open Prices
const double &mHigh[], // High Preices
const double &mLow[], // Low Prices
const double &mClose[], // Close Prices
int barIndex // Bar Index
ENUM_X_PRICE mType, // Type of Price Selection
const double &mOpen[], // Open Prices
const double &mHigh[], // High Preices
const double &mLow[], // Low Prices
const double &mClose[], // Close Prices
int barIndex // Bar Index
)
{
//
@@ -6103,7 +6125,7 @@ double GetAppliedPrice(
string mSymbol = NULL, // Symbol
ENUM_TIMEFRAMES mPeriod = NULL, // Period
int barIndex = 0, // Bar Index
ENUM_X_PRICE mType = X_PRICE_CLOSE // Type of Price Selection,
ENUM_X_PRICE mType = X_PRICE_CLOSE // Type of Price Selection
)
{
//
@@ -6177,7 +6199,7 @@ double GetAppliedPrice(
string mSymbol = NULL, // Symbol
ENUM_TIMEFRAMES mPeriod = NULL, // Period
datetime mTime = NULL, // Bar Time
ENUM_X_PRICE mType = X_PRICE_CLOSE // Type of Price Selection,
ENUM_X_PRICE mType = X_PRICE_CLOSE // Type of Price Selection
)
{
//
@@ -6220,6 +6242,107 @@ double GetAppliedPrice(
return result;
}
/**
* Calculate Price Boundary ...
*
* @param upper: double collection reference, Upper Boundary ...
* @param lower: double collection reference, Lower Boundary ...
* @param mSymbol: string, Specified Symbol ...
* @param mPeriod: ENUM_TIMEFRAMES member, Specified PEriod ...
* @param mMode: ENUM_X_BOUNDARY_PRICE member, Specified Boundary Mode ...
* @param mLength: int, Loopback Length of Bondary ...
* @param barIndex: int, Specified Bar Index ...
* @return ( int )
*/
int GetPriceBoundary(
double &upper[], // Upper Boundary
double &lower[], // Lower Boundary
string mSymbol = NULL, // Symbol
ENUM_TIMEFRAMES mPeriod = NULL, // Period
ENUM_X_BOUNDARY_PRICE mMode = NULL, // Boundary Mode
int mLength = 1, // Length
int barIndex = 0 // Bar Index
)
{
//
int result = 0;
//
Clean(upper);
Clean(lower);
//
// Normalize Args ...
mMode = NormalizeBoundary(mMode);
mSymbol = NormalizeSymbol(mSymbol);
mPeriod = NormalizePeriod(mPeriod);
mLength = NormalizeInt(mLength, 1);
barIndex = NormalizeInt(barIndex, 0);
//
// Prepare Boundary Price Types ...
ENUM_X_PRICE upperType =
mMode == X_BOUNDARY_PRICE_UP_DOWN
? X_PRICE_UP
: mMode == X_BOUNDARY_PRICE_HIGH_LOW
? X_PRICE_HIGH
: X_PRICE_NONE;
ENUM_X_PRICE lowerType =
mMode == X_BOUNDARY_PRICE_UP_DOWN
? X_PRICE_DOWN
: mMode == X_BOUNDARY_PRICE_HIGH_LOW
? X_PRICE_LOW
: X_PRICE_NONE;
//
// Check Boundary Type Validation ...
bool isValid = IsValid(lowerType) &&
IsValid(upperType);
if (!isValid)
{
return result;
}
//
// Loop through Loopbacks ...
int start = barIndex + mLength;
int end = barIndex;
for (int i = start; i >= end; i--)
{
//
double iUpper = GetAppliedPrice(
mSymbol,
mPeriod,
i,
upperType //
);
double iLower = GetAppliedPrice(
mSymbol,
mPeriod,
i,
lowerType //
);
//
Add(
iUpper,
upper //
);
//
Add(
iLower,
lower //
);
}
//
result = ArraySize(upper);
//
return result;
}
//
// END Price ...
//
+63
View File
@@ -309,6 +309,69 @@ string ToString(ENUM_X_PRICE value)
// END Price Type ...
//
//
// START Boundary Price Type ...
//
//
// Available Boundary Price Types ...
enum ENUM_X_BOUNDARY_PRICE
{
X_BOUNDARY_PRICE_NONE, // None
X_BOUNDARY_PRICE_UP_DOWN, // Up/Down
X_BOUNDARY_PRICE_HIGH_LOW, // High/Low
};
/**
* Validate ...
*
* @param value: ENUM_X_BOUNDARY_PRICE member ...
*
* @return ( bool )
*/
bool IsValid(ENUM_X_BOUNDARY_PRICE value)
{
//
bool result = false;
//
result =
value != NULL &&
value != X_BOUNDARY_PRICE_NONE;
//
return result;
}
/**
* Converts To String ...
*
* @param value: ENUM_X_BOUNDARY_PRICE member ...
*
* @return ( string )
*/
string ToString(ENUM_X_BOUNDARY_PRICE value)
{
//
string result = NULL;
//
if (!IsValid(value))
{
value = X_BOUNDARY_PRICE_NONE;
}
//
result = EnumToString(value);
//
return result;
}
//
// END Boundary Price Type ...
//
//
// START Direction ...
//