Fix Market Sessions Timing Issues ...

This commit is contained in:
2024-10-21 16:58:12 +03:30
parent 9f43c4ab43
commit 4de2c7b31c
5 changed files with 365 additions and 103 deletions
@@ -96,6 +96,11 @@ class XCFromToObject : public CChartObject
// Deconstructors ...
void ~XCFromToObject()
{
//
mToVLine.Detach();
mFromVLine.Detach();
mToVLine.Delete();
mFromVLine.Delete();
}
/**
+34 -100
View File
@@ -337,90 +337,30 @@ class XCPOI : public XSCBaseAlert
}
/**
* Get Session Label Font Size ...
* Get Session Working Hors ...
*
* @return ( int )
*/
int SessionFontSize()
int SessionOpenHours()
{
return mSessionFontSize;
return mSessionOpenHours;
}
/**
* Set Session Label Font Size ...
* Set Session Working Hors ...
*
* @param value: Integer ...
*/
void SessionFontSize(int value)
void SessionOpenHours(int value)
{
//
if (value < 2)
if (value <= 0)
{
value = 2;
value = 9;
}
//
if (value > 30)
{
value = 30;
}
//
mSessionFontSize = value;
}
/**
* Get Session Label Font ...
*
* @return ( string )
*/
string SessionFont()
{
return mSessionFont;
}
/**
* Set Session Label Font ...
*
* @param value: String ...
*/
void SessionFont(string value)
{
//
if (!IsValid(value))
{
value = "Arial";
}
//
mSessionFont = value;
}
/**
* Get Session Label Angle ...
*
* @return ( double )
*/
double SessionAngle()
{
return mSessionAngle;
}
/**
* Set Session Label Angle ...
*
* @param value: Double ...
*/
void SessionAngle(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mSessionAngle = value;
mSessionOpenHours = value;
}
//
@@ -1208,13 +1148,11 @@ class XCPOI : public XSCBaseAlert
if (!IsValidIndex(marketSessionIDX))
{
//
int offset = TimeGMTOffset();
string zTimeString = GetTimeString(zBar.time);
datetime zTimeGMT = GetUTCTime(zBar.time);
string zTimeString = GetTimeString(zTimeGMT);
//
datetime iStartTime = (datetime)((int)StringToTime(iSession.start) + offset);
string iStartTimeString = GetTimeString(iStartTime);
bool isStarted = iStartTimeString == zTimeString;
bool isStarted = iSession.start == zTimeString;
//
if (isStarted)
@@ -1225,8 +1163,8 @@ class XCPOI : public XSCBaseAlert
iMarketSession.from = zBar.time;
//
int iSessionWorkingHoure = 8;
int iSessionWorkingSeconds = 8 * 60 * 60;
int iSessionWorkingHoure = SessionOpenHours();
int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60;
iMarketSession.to = (datetime)((int)zBar.time + iSessionWorkingSeconds);
//
@@ -1474,7 +1412,7 @@ class XCPOI : public XSCBaseAlert
XSession mSyndeySession;
mSyndeySession.Init(
X_SYDNEY,
"21:00", // Start ...
"20:00", // Start ...
"05:00" // End Next Day ...
);
mSyndeySession.startColor = clrFireBrick;
@@ -1489,8 +1427,8 @@ class XCPOI : public XSCBaseAlert
XSession mTokyoSession;
mTokyoSession.Init(
X_TOKYO,
"23:00", // Start ...
"07:00" // End Next Day ...
"00:00", // Start ...
"09:00" // End Next Day ...
);
mTokyoSession.startColor = clrBlueViolet;
mTokyoSession.endColor = clrBlueViolet;
@@ -1505,7 +1443,7 @@ class XCPOI : public XSCBaseAlert
mLondonSession.Init(
X_LONDON,
"07:00", // Start ...
"15:00" // End ...
"16:00" // End ...
);
mLondonSession.startColor = clrLime;
mLondonSession.endColor = clrLime;
@@ -1520,7 +1458,7 @@ class XCPOI : public XSCBaseAlert
mNewYorkSession.Init(
X_NEW_YORK,
"12:00", // Start ...
"20:00" // End ...
"21:00" // End ...
);
mNewYorkSession.startColor = clrAqua;
mNewYorkSession.endColor = clrAqua;
@@ -1528,9 +1466,7 @@ class XCPOI : public XSCBaseAlert
AddSession(mNewYorkSession);
//
SessionFont("Arial");
SessionFontSize(16);
SessionAngle(90);
SessionOpenHours(9);
//
MaxNumberOfPOIs(10);
@@ -1893,18 +1829,12 @@ class XCPOI : public XSCBaseAlert
}
//
int offset = TimeGMTOffset();
string zTimeString = GetTimeString(zBar.time);
datetime zTimeGMT = GetUTCTime(zBar.time);
string zTimeString = GetTimeString(zTimeGMT);
//
datetime iStartTime = (datetime)((int)StringToTime(iSession.start) + offset);
string iStartTimeString = GetTimeString(iStartTime);
bool isStarted = iStartTimeString == zTimeString;
//
datetime iEndTime = (datetime)((int)StringToTime(iSession.end) + offset);
string iEndTimeString = GetTimeString(iEndTime);
bool isEnded = iEndTimeString == zTimeString;
bool isStarted = iSession.start == zTimeString;
bool isEnded = iSession.end == zTimeString;
//
// Detect Sessions Based on Time ...
@@ -1926,8 +1856,8 @@ class XCPOI : public XSCBaseAlert
iMarketSession.to = zBar.time;
//
int iSessionWorkingHoure = 8;
int iSessionWorkingSeconds = 8 * 60 * 60;
int iSessionWorkingHoure = SessionOpenHours();
int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60;
iMarketSession.from = (datetime)((int)zBar.time - iSessionWorkingSeconds);
//
@@ -3092,16 +3022,12 @@ class XCPOI : public XSCBaseAlert
//
iObj.ToColor(TradingDaysEndColor());
iObj.ToStyle(TradingDaysEndStyle());
//
}
//
// Configure Sessions ...
bool mAllowDrawMarketSessions; // Draw Market Sessions ...
int mSessionFontSize; // Session Label Font Size ...
string mSessionFont; // Session Label Font ...
double mSessionAngle; // Session Label Angle ...
int mSessionOpenHours; // How many Hours a Session is Open
XSession mSessions[]; // Forex Sessions
XMarketSession mMarketSessions[]; // Founded Market Sessions ...
CArrayObj mMarketSessionObjects; // Founded Market Session Chart Ojects ...
@@ -3157,6 +3083,14 @@ class XCPOI : public XSCBaseAlert
iObj.ToStyle(mSessions[sessionIDX].endStyle);
//
string msg =
ToString(session.session) + "\n" +
"Offset: " + ToString(TimeGMTOffset()) + "\n" +
"LOffset: " + ToString(GetLocalOffset()) + "\n" +
"UTCROffset: " + ToString(GetUTCRequiredTimeOffset()) + "\n" +
"First Bar: " + ToString(session.from) + "\n" +
"Last Bar: " + ToString(session.to) + "\n";
LogAlert(msg);
}
//