Last Works ...
This commit is contained in:
@@ -36,6 +36,15 @@ enum ENUM_X_PRICE
|
||||
X_PRICE_LOW
|
||||
};
|
||||
|
||||
//
|
||||
enum ENUM_X_DIRECTION
|
||||
{
|
||||
X_DIRECTION_ALL,
|
||||
X_DIRECTION_NONE,
|
||||
X_DIRECTION_BULLISH,
|
||||
X_DIRECTION_BEARISH,
|
||||
};
|
||||
|
||||
//
|
||||
// Swing Types Enum ...
|
||||
enum ENUM_X_SWING_TYPE
|
||||
@@ -5038,6 +5047,219 @@ struct XOHCL
|
||||
}
|
||||
};
|
||||
|
||||
struct XTrend
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
datetime at;
|
||||
|
||||
//
|
||||
XOHCL swingHighs[];
|
||||
XOHCL swingLows[];
|
||||
|
||||
//
|
||||
bool isBullish;
|
||||
bool isBearish;
|
||||
|
||||
//
|
||||
void XTrend()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Initialize ...
|
||||
*
|
||||
* @param _symbol: String ...
|
||||
* @param _period: ENUM_TIMEFRAMES member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Init(
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
NormalizePeriod(_period);
|
||||
|
||||
//
|
||||
result = IsValid(_symbol) &&
|
||||
IsValid(_period);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
symbol = _symbol;
|
||||
period = _period;
|
||||
|
||||
//
|
||||
XOHCL bar;
|
||||
result = bar.Init(
|
||||
symbol,
|
||||
period,
|
||||
0 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpBULLSWH[];
|
||||
XOHCL tmpBULLSWL[];
|
||||
bool hasBullishTrend = bar.HasBullishTrend(
|
||||
tmpBULLSWH,
|
||||
tmpBULLSWL,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
XOHCL tmpBEARSWH[];
|
||||
XOHCL tmpBEARSWL[];
|
||||
bool hasBearishTrend = bar.HasBearishTrend(
|
||||
tmpBEARSWH,
|
||||
tmpBEARSWL,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasBullishTrend)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
tmpBULLSWH,
|
||||
swingHighs //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
tmpBULLSWL,
|
||||
swingLows //
|
||||
);
|
||||
}
|
||||
//
|
||||
else if (hasBearishTrend)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
tmpBEARSWH,
|
||||
swingHighs //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
tmpBEARSWL,
|
||||
swingLows //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBullishTrend ||
|
||||
hasBullishTrend)
|
||||
{
|
||||
at = TimeCurrent();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
at = NULL;
|
||||
|
||||
//
|
||||
isBullish = false;
|
||||
isBearish = false;
|
||||
|
||||
//
|
||||
Clean(swingLows);
|
||||
Clean(swingHighs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
IsValid(at) &&
|
||||
(isBullish ||
|
||||
isBearish) &&
|
||||
(ArraySize(swingHighs) > 0 ||
|
||||
ArraySize(swingLows) > 0);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Unique Identifier ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string hash = symbol + "," + ToString(period) + "," + ToFormatString(at);
|
||||
hash = ToMD5(hash);
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"XTrend_" +
|
||||
(isBullish ? "Bullish_" : "Bearish_") +
|
||||
symbol + "_" +
|
||||
ToString(period) + "_" +
|
||||
hash
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Tracking Times ...
|
||||
struct XTimeTracker
|
||||
@@ -8660,6 +8882,32 @@ MqlDateTime MilliSecondsToStruct(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Hours to Seconds ...
|
||||
int HoursToSeconds(int value)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (value == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = value * 60 * 60;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve DateTime Structure ...
|
||||
MqlDateTime GetCurrentTime()
|
||||
@@ -12971,4 +13219,33 @@ int GetCycleLengthOn(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Direction ...
|
||||
|
||||
//
|
||||
bool IsBullish(ENUM_X_DIRECTION value)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = value == X_DIRECTION_BULLISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBearish(ENUM_X_DIRECTION value)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = value == X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user