last works on XOBS ...

This commit is contained in:
2025-02-07 02:22:19 +03:30
parent 114f327efe
commit 58c59f5514
11 changed files with 6802 additions and 1396 deletions
+546
View File
@@ -28,6 +28,7 @@
#include <ChartObjects/ChartObjectsArrows.mqh> #include <ChartObjects/ChartObjectsArrows.mqh>
#include <ChartObjects/ChartObjectsLines.mqh> #include <ChartObjects/ChartObjectsLines.mqh>
#include <ChartObjects/ChartObjectsShapes.mqh> #include <ChartObjects/ChartObjectsShapes.mqh>
#include <ChartObjects\ChartObjectsFibo.mqh>
#include <ChartObjects\ChartObjectsTxtControls.mqh> #include <ChartObjects\ChartObjectsTxtControls.mqh>
// //
@@ -45,6 +46,7 @@ enum ENUM_XCHARTOBJECTS
X_TREND_OBJ = 8861, X_TREND_OBJ = 8861,
X_XPVPIVOT_OBJ = 8862, X_XPVPIVOT_OBJ = 8862,
X_OHCL_OBJ = 8863, X_OHCL_OBJ = 8863,
X_RR_OBJ = 8864,
// //
// Structured ... // Structured ...
X_TRADE_DAY_OBJ = 9860, X_TRADE_DAY_OBJ = 9860,
@@ -2511,6 +2513,550 @@ class XCBoxObject : public XCBaseObject
CChartObjectRectangle mRect; CChartObjectRectangle mRect;
}; };
class XCRRObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param rr: XRR instance Reference ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XRR &rr,
string prefix = NULL //
)
{
//
bool result = false;
//
result = rr.IsValid();
if (!result)
{
return result;
}
//
string name = rr.GetTag();
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
string nameMD5 = ToMD5(name);
//
bool isLong = IsLong(rr.type);
//
double price1 = rr.entry;
double price2 = rr.sl;
//
datetime time1 = rr.time;
datetime time2 = (datetime)((int)rr.time + 2 * PeriodSeconds(rr.period));
//
result = mFibo.Create(
chart_id,
name,
window,
time1,
price1,
time2,
price2 //
);
if (!result)
{
return result;
}
//
mRR = rr;
ObjName(name);
//
int tpsCount = ArraySize(rr.tps);
int levels = tpsCount + 2;
result = mFibo.LevelsCount(levels);
if (!result)
{
return result;
}
//
// Set Fibo Levels ...
//
result = mFibo.LevelValue(0, 0);
if (!result)
{
return result;
}
result = mFibo.LevelDescription(0, "SL");
if (!result)
{
return result;
}
//
result = mFibo.LevelValue(1, 1.0);
if (!result)
{
return result;
}
result = mFibo.LevelDescription(1, "Entry");
if (!result)
{
return result;
}
//
for (int i = 0; i < tpsCount; i++)
{
//
int idx = i + 2;
double level = 1.0 + rr.tps[i];
string description = "TP " + ToString(rr.tps[i]);
//
result = mFibo.LevelValue(
idx,
level //
);
if (!result)
{
break;
}
//
result = mFibo.LevelDescription(
idx,
description //
);
if (!result)
{
break;
}
}
if (!result)
{
return result;
}
//
return result;
}
//
// Getter(s) / Setter(s) ...
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_RR_OBJ;
}
//
private:
//
//
// Props ...
XRR mRR;
CChartObjectFibo mFibo;
//
bool SetSLProps(
int width = 1,
color clr = clrRed,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
result = SetLevelProps(
0,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetEntryProps(
int width = 1,
color clr = clrOrange,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
result = SetLevelProps(
0,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetTPProps(
double tpValue,
int width = 1,
color clr = clrLime,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
int tpIDX = FindIndex(
tpValue,
mRR.tps //
);
result = IsValidIndex(tpIDX);
if (!result)
{
return result;
}
//
tpIDX += 2;
//
result = SetLevelProps(
tpIDX,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetLevelProps(
int id,
int width = 1,
color clr = clrYellow,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
// Color ...
result = mFibo.LevelColor(
id,
clr //
);
if (!result)
{
return result;
}
//
// Style ...
result = mFibo.LevelStyle(
id,
style //
);
if (!result)
{
return result;
}
//
// Width ...
if (width > 0)
{
//
result = mFibo.LevelWidth(
id,
width //
);
if (!result)
{
return result;
}
}
//
// Description ...
if (IsValid(description))
{
//
result = mFibo.LevelDescription(
id,
description //
);
if (!result)
{
return result;
}
}
//
return result;
}
};
class XCTrendObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param rr: XRR instance Reference ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XSwingPoint &swings[],
string prefix = NULL //
)
{
//
bool result = false;
//
int count = ArraySize(swings);
result =
count >= 2 &&
IsValidSize(count);
if (!result)
{
return result;
}
//
ENUM_X_SWING_TYPE type = swings[0].type;
bool isSwingLows = type == X_SWING_LOW;
//
double values[];
int valuesCount = ExtractSwings(
swings,
values //
);
result = valuesCount == count;
if (!result)
{
return result;
}
//
int firstIDX = -1;
double first = 0;
datetime firstTime = NULL;
//
int secondIDX = -1;
double second = 0;
datetime secondTime = NULL;
//
if (isSwingLows)
{
//
first = GetMin(
values,
firstIDX,
0,
0 //
);
if (IsValidIndex(firstIDX))
{
//
firstTime = swings[firstIDX].time;
//
second = FindBiggerThan(
first,
values,
true //
);
secondIDX = FindIndex(
second,
values //
);
if (IsValidIndex(secondIDX))
{
secondTime = swings[secondIDX].time;
}
}
}
else
{
//
first = GetMax(
values,
firstIDX,
0,
0 //
);
if (IsValidIndex(firstIDX))
{
//
firstTime = swings[firstIDX].time;
//
second = FindLesserThan(
first,
values,
true //
);
secondIDX = FindIndex(
second,
values //
);
if (IsValidIndex(secondIDX))
{
secondTime = swings[secondIDX].time;
}
}
}
//
// Validate Points ...
result =
//
IsValidIndex(firstIDX) &&
IsValidIndex(secondIDX) &&
//
IsSpecifiedValid(firstTime) &&
IsSpecifiedValid(secondTime) &&
//
(isSwingLows
? first < second
: first > second)
//
;
if (!result)
{
return result;
}
//
string name = ToString(type) + "_" + ToString(first) + "_" + ToString(second);
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
string nameMD5 = ToMD5(name);
//
result = mTrend.Create(
chart_id,
name,
window,
firstTime,
first,
secondTime,
second //
);
if (!result)
{
return result;
}
//
ObjName(name);
//
return result;
}
//
// Getter(s) / Setter(s) ...
/**
* Set Trend Color ...
*
* @param value: Color ...
*/
void TrendColor(color value)
{
mTrend.Color(value);
}
void TrendRayLeft(bool value)
{
mTrend.RayLeft(value);
}
void TrendRayRight(bool value)
{
mTrend.RayRight(value);
}
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_TREND_OBJ;
}
//
private:
//
//
// Props ...
CChartObjectTrend mTrend;
};
// //
// Zone Ticks ... // Zone Ticks ...
+107
View File
@@ -2780,6 +2780,9 @@ class XCPOIDrawer : public XCBase
// //
bool result = false; bool result = false;
//
object = NULL;
// //
result = zone.IsValid(); result = zone.IsValid();
if (!result) if (!result)
@@ -2812,6 +2815,63 @@ class XCPOIDrawer : public XCBase
return result; return result;
} }
/**
* Create Trend Line Object ...
*
* @param swings: XSwingPoint instance Collection ...
*
* @return ( bool )
*/
bool CreateTrend(
XSwingPoint &swings[],
XCTrendObject *&object //
)
{
//
bool result = false;
//
object = NULL;
//
result = ArraySize(swings) >= 2 &&
IsValidSize(ArraySize(swings));
if (!result)
{
return result;
}
//
string prefix = Prefix();
long chartID = ChartIdentification();
int window = SubWindowIdentification();
//
object = new XCTrendObject();
result = object.Create(
chartID,
window,
swings,
prefix //
);
//
if (!result)
{
return result;
}
//
color clrTrend = swings[0].type == X_SWING_LOW
? SwingLowColor()
: SwingHighColor();
object.TrendColor(clrTrend);
object.TrendRayRight(true);
//
return result;
}
/** /**
* Create Consolidation Zone Object ... * Create Consolidation Zone Object ...
* *
@@ -3100,6 +3160,53 @@ class XCPOIDrawer : public XCBase
return result; return result;
} }
/**
* Create Specific Risk Reward (RR) on Chart ...
*
* @param rr: XRR instance Reference ...
*
* @return ( bool )
*/
bool CreateRR(
XRR &rr,
XCRRObject *&object //
)
{
//
bool result = false;
//
object = NULL;
//
result = rr.IsValid();
if (!result)
{
return result;
}
//
string prefix = Prefix();
long chartID = ChartIdentification();
int window = SubWindowIdentification();
//
object = new XCRRObject();
result = object.Create(
chartID,
window,
rr,
prefix //
);
if (!result)
{
return result;
}
//
return result;
}
/** /**
* Draw Specified Signal ... * Draw Specified Signal ...
* *
File diff suppressed because it is too large Load Diff
+199
View File
@@ -0,0 +1,199 @@
//
// DRAW ...
//
//
XCBaseObject *drawnObjects[];
// //
// if (hasYoungestBullOB)
// {
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = drawer
// .CreateBullishOrderBlock(
// youngestBullOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// Add(
// (XCBaseObject *)iObj,
// drawnObjects //
// );
// }
// }
// //
// if (hasYoungestBearOB)
// {
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = drawer
// .CreateBearishOrderBlock(
// youngestBearOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// Add(
// (XCBaseObject *)iObj,
// drawnObjects //
// );
// }
// }
// //
// // Draw Breaked Bullish OrderBlocks ...
// if (hasBreakedBullOBs)
// {
// //
// for (int i = 0; i < breakedBullOBsCount; i++)
// {
// //
// XCOrderBlock *iOB = breakedBullOBs[i];
// // iOB.To(cTime);
// //
// XCBullishOrderBlockObject *iObj;
// bool isCreated = drawer
// .CreateBullishOrderBlock(
// iOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// Add(
// (XCBaseObject *)iObj,
// drawnObjects //
// );
// }
// }
// }
// //
// // Draw Breaked Bearish OrderBlocks ...
// if (hasBreakedBearOBs)
// {
// //
// for (int i = 0; i < breakedBearOBsCount; i++)
// {
// //
// XCOrderBlock *iOB = breakedBearOBs[i];
// // iOB.To(cTime);
// //
// XCBearishOrderBlockObject *iObj;
// bool isCreated = drawer
// .CreateBearishOrderBlock(
// iOB,
// iObj //
// );
// //
// if (isCreated)
// {
// //
// Add(
// (XCBaseObject *)iObj,
// drawnObjects //
// );
// }
// }
// }
//
// Draw Tests ...
if (hasTests)
{
//
for (int i = 0; i < testsCount; i++)
{
//
XOBTest iTest = tests[i];
//
bool hasOB = iTest.HasOB();
if (hasOB)
{
//
bool isBullish = iTest.ob.IsBullish();
//
XCBaseObject *obObj;
bool isCreated = drawer
.CreateOrderBlock(
iTest.ob,
obObj //
);
if (isCreated)
{
//
Add(
obObj,
drawnObjects //
);
}
}
//
// bool hasFVGs = iTest.HasFVGs();
// int fvgsCount = iTest.CountFVGs();
// for (int j = 0; j < fvgsCount; j++)
// {
// //
// XCFVG *jFVG = iTest.fvgs[j];
// // jFVG.To(iTest.ob.To());
// //
// XCBaseObject *fvgObj;
// bool isCreated = drawer
// .CreateFairValueGap(
// jFVG,
// fvgObj //
// );
// if (isCreated)
// {
// //
// Add(
// fvgObj,
// drawnObjects //
// );
// }
// }
//
bool hasFVG = iTest.fvg != NULL &&
iTest.fvg.IsValid();
if (hasFVG)
{
//
XCBaseObject *fvgObj;
bool isCreate = drawer.CreateFairValueGap(
iTest.fvg,
fvgObj //
);
if (isCreate)
{
//
Add(
fvgObj,
drawnObjects //
);
}
}
}
}
//
// END DRAW ...
//
File diff suppressed because it is too large Load Diff
+458 -4
View File
@@ -135,6 +135,35 @@ enum ENUM_X_SWING_TYPE
X_SWING_LOW = -1, X_SWING_LOW = -1,
}; };
//
string ToString(ENUM_X_SWING_TYPE value)
{
//
string result = NULL;
//
switch (value)
{
//
case X_NO_SWING:
result = "NO_SWING";
break;
//
case X_SWING_LOW:
result = "SWING_LOW";
break;
//
case X_SWING_HIGH:
result = "SWING_HIGH";
break;
}
//
return result;
}
// //
ENUM_SERIESMODE ToSeriesMode(ENUM_X_SWING_TYPE value) ENUM_SERIESMODE ToSeriesMode(ENUM_X_SWING_TYPE value)
{ {
@@ -1163,6 +1192,34 @@ struct XOHCL
return result; return result;
} }
//
// Retrieve Required Price for Zone Checking ...
// For Bullish Zones => low;
// For Bearish Zones => high;
double GetZoneCheckValue(ENUM_X_DIRECTION forDir)
{
//
double result = 0;
//
if (!IsValid() ||
!HasDirection(forDir))
{
return result;
}
//
bool isBullish = IsBullish(forDir);
//
result =
isBullish
? low
: high;
return result;
}
// //
// Calculate Bar Body ... // Calculate Bar Body ...
double GetBody() double GetBody()
@@ -3522,6 +3579,133 @@ struct XMarketParser
// //
}; };
//
// Specified Swing Point ...
struct XSwingPoint
{
//
// Props ...
string symbol;
ENUM_TIMEFRAMES period;
//
double swing;
datetime time;
ENUM_X_SWING_TYPE type;
//
// Constructor ...
XSwingPoint()
{
Clean();
}
//
// Tools ...
/**
* Cleanup Model ...
*/
void Clean()
{
//
swing = 0;
time = NULL;
//
symbol = NULL;
period = NULL;
//
type = X_NO_SWING;
}
/**
* Validate Model ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
swing > 0 &&
IsValid(time) &&
IsValid(symbol) &&
IsValid(period) &&
type != X_NO_SWING;
//
return result;
}
/**
* Check Swing is Low or not ...
*
* @return ( bool )
*/
bool IsSwingLow()
{
return type == X_SWING_LOW;
}
/**
* Check Swing is High or not ...
*
* @return ( bool )
*/
bool IsSwingHigh()
{
return type == X_SWING_HIGH;
}
};
/**
* Extract values of swings from specified Collection ...
*
* @param swings: XSwingPoint instance Collection ...
* @param values: double Collection ...
*
* @return ( int )
*/
int ExtractSwings(
XSwingPoint &swings[],
double &values[] //
)
{
//
int result = 0;
//
Clean(values);
//
int count = ArraySize(swings);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
Add(
swings[i].swing,
values //
);
}
//
result = ArraySize(values);
//
return result;
}
// //
// Functions ... // Functions ...
@@ -7544,6 +7728,61 @@ T GetMax(
return result; return result;
} }
template <typename T> template <typename T>
T GetMax(
T &buffer[], // the Buffer which required to search
int &index, // Item Index ...
int start = 0, // Start Index
int count = 0 // Count for Search
)
{
//
T result = 0;
index = -1;
//
if (count <= 0)
{
count = ArraySize(buffer);
}
//
T tmp[];
int tmpCount = Copy(
start,
count,
buffer,
tmp
//
);
if (tmpCount <= 0)
{
return result;
}
//
// Loop Through LoopBack ...
for (int i = 0; i < tmpCount; i++)
{
//
T iValue = tmp[i];
//
bool isNew = result == 0;
bool canSet = isNew ||
(!isNew &&
result < iValue);
if (canSet)
{
//
index = i;
result = iValue;
}
}
//
return result;
}
template <typename T>
T GetSpecifiedMax( T GetSpecifiedMax(
T &buffer[], // the Buffer which required to search T &buffer[], // the Buffer which required to search
int start = 0, // Start Index int start = 0, // Start Index
@@ -7556,6 +7795,21 @@ T GetSpecifiedMax(
count // count //
); );
} }
template <typename T>
T GetSpecifiedMax(
T &buffer[], // the Buffer which required to search
int &index, // Item Index ...
int start = 0, // Start Index
int count = 0 // Count for Search
)
{
return GetMax(
buffer,
index,
start,
count //
);
}
// //
// Get Min of Specific Loopback of a Buffer ... // Get Min of Specific Loopback of a Buffer ...
@@ -7612,6 +7866,61 @@ T GetMin(
return result; return result;
} }
template <typename T> template <typename T>
T GetMin(
T &buffer[], // the Buffer which required to search
int &index, // Item Index ...
int start = 0, // Start Index
int count = 0 // Count for Search
)
{
//
T result = 0;
index = -1;
//
if (count <= 0)
{
count = ArraySize(buffer);
}
//
T tmp[];
int tmpCount = Copy(
start,
count,
buffer,
tmp
//
);
if (tmpCount <= 0)
{
return result;
}
//
// Loop Through LoopBack ...
for (int i = 0; i < tmpCount; i++)
{
//
T iValue = tmp[i];
//
bool isNew = result == 0;
bool canSet = isNew ||
(!isNew &&
result > iValue);
if (canSet)
{
//
index = i;
result = iValue;
}
}
//
return result;
}
template <typename T>
T GetSpecifiedMin( T GetSpecifiedMin(
T &buffer[], // the Buffer which required to search T &buffer[], // the Buffer which required to search
int start = 0, // Start Index int start = 0, // Start Index
@@ -7624,6 +7933,21 @@ T GetSpecifiedMin(
count // count //
); );
} }
template <typename T>
T GetSpecifiedMin(
T &buffer[], // the Buffer which required to search
int &index, // Item Index ...
int start = 0, // Start Index
int count = 0 // Count for Search
)
{
return GetMin(
buffer,
index,
start,
count //
);
}
// //
// Find a Value less than Specified ... // Find a Value less than Specified ...
@@ -7651,12 +7975,14 @@ T FindLesserThan(
// //
ArrayResize( ArrayResize(
tmp, tmp,
ArraySize(source)); ArraySize(source) //
);
// //
ArrayCopy( ArrayCopy(
tmp, tmp,
source); source //
);
// //
// Sort Temp Buffer ... // Sort Temp Buffer ...
@@ -7685,6 +8011,69 @@ T FindLesserThan(
// //
return result; return result;
} }
template <typename T>
T FindLesserThan(
T value, // Specified Value ...
int &index, // Item Index ...
const T &source[], // Source ...
bool isDescend = false // Find Biggest Lesser Value ...
)
{
//
T result = -1;
index = -1;
//
int itemsCount = ArraySize(source);
if (itemsCount <= 0)
{
return result;
}
//
// Make a Copy of source ...
T tmp[];
//
ArrayResize(
tmp,
ArraySize(source) //
);
//
ArrayCopy(
tmp,
source //
);
//
// Sort Temp Buffer ...
ArraySort(tmp);
if (isDescend)
{
ArrayReverse(tmp);
}
//
int tmpCount = ArraySize(tmp);
for (int i = 0; i < tmpCount; i++)
{
//
T iValue = tmp[i];
//
if (iValue < value)
{
//
index = i;
result = iValue;
break;
}
}
//
return result;
}
// //
// Find a Value less than Specified ... // Find a Value less than Specified ...
@@ -7712,12 +8101,14 @@ T FindBiggerThan(
// //
ArrayResize( ArrayResize(
tmp, tmp,
ArraySize(source)); ArraySize(source) //
);
// //
ArrayCopy( ArrayCopy(
tmp, tmp,
source); source //
);
// //
// Sort Temp Buffer ... // Sort Temp Buffer ...
@@ -7746,6 +8137,69 @@ T FindBiggerThan(
// //
return result; return result;
} }
template <typename T>
T FindBiggerThan(
T value, // Specified Value ...
int &index, // Item Index ...
const T &source[], // Source ...
bool isDescend = false // Find Smallest Bigger Value ...
)
{
//
T result = -1;
index = -1;
//
int itemsCount = ArraySize(source);
if (itemsCount <= 0)
{
return result;
}
//
// Make a Copy of source ...
T tmp[];
//
ArrayResize(
tmp,
ArraySize(source) //
);
//
ArrayCopy(
tmp,
source //
);
//
// Sort Temp Buffer ...
ArraySort(tmp);
if (!isDescend)
{
ArrayReverse(tmp);
}
//
int tmpCount = ArraySize(tmp);
for (int i = 0; i < tmpCount; i++)
{
//
T iValue = tmp[i];
//
if (iValue > value)
{
//
index = i;
result = iValue;
break;
}
}
//
return result;
}
// //
// Find Same Values in Array ... // Find Same Values in Array ...
File diff suppressed because it is too large Load Diff
+183
View File
@@ -300,6 +300,189 @@ ENUM_X_DIRECTION ToDirection(ENUM_X_POSITION_TYPES value)
// //
// Structs ... // Structs ...
//
struct XRR
{
//
double tps[];
//
double sl;
double entry;
//
string prefix;
string symbol;
datetime time;
ENUM_TIMEFRAMES period;
//
ENUM_X_POSITION_TYPES type;
//
// Constructor ...
XRR()
{
Clean();
}
//
// Tools ...
//
void Clean()
{
//
sl = 0;
entry = 0;
//
time = NULL;
prefix = NULL;
period = NULL;
symbol = NULL;
//
type = X_POSITION_TYPE_NONE;
//
Clean(tps);
}
//
bool Init(
string _symbol,
ENUM_TIMEFRAMES _period,
double _sl,
double _entry,
ENUM_X_POSITION_TYPES _type,
string _prefix = NULL //
)
{
//
bool result = false;
//
result =
_sl > 0 &&
_entry > 0 &&
IsValid(_symbol) &&
IsValid(_period) &&
_type != X_POSITION_TYPE_ALL &&
_type != X_POSITION_TYPE_NONE &&
(_type == X_POSITION_TYPE_LONG
? _entry > _sl
: _entry < _sl);
if (!result)
{
return result;
}
//
Default();
//
sl = _sl;
type = _type;
entry = _entry;
symbol = _symbol;
period = _period;
prefix = _prefix;
//
time = TimeCurrent();
//
result = IsValid();
//
return result;
}
//
void Default()
{
//
Add(
1.0,
tps //
);
Add(
1.5,
tps //
);
Add(
2.0,
tps //
);
Add(
3.0,
tps //
);
Add(
4.0,
tps //
);
Add(
5.0,
tps //
);
Add(
6.0,
tps //
);
}
//
bool IsValid()
{
//
bool result = false;
//
result =
sl > 0 &&
entry > 0 &&
IsValid(time) &&
IsValid(symbol) &&
IsValid(period) &&
IsValidSize(ArraySize(tps)) &&
type != X_POSITION_TYPE_ALL &&
type != X_POSITION_TYPE_NONE &&
(type == X_POSITION_TYPE_LONG
? entry > 0
: entry < sl);
//
return result;
}
//
string GetTag()
{
//
string result = NULL;
//
if (!IsValid())
{
//
result = GetTypeName(this);
return result;
}
//
string sep = "_";
//
result =
GetTypeName(this) + sep + (IsValid(prefix) ? prefix + sep : "") + symbol + sep + ToString(period) + sep + ToFormatString(time) + sep + ToString(type);
//
return result;
}
};
// //
// Model an Open Position ... // Model an Open Position ...
struct XPosition struct XPosition
File diff suppressed because it is too large Load Diff
+14 -14
View File
@@ -105,7 +105,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{ {
// //
Clean(mXConditionsCollection); Clean(mXConditionsCollection);
Clean(mXOBSConditionsCollection); Clean(mX121SMCXOBSConditionsCollection);
// //
ZeroMemory(mTriggerCycleHelper); ZeroMemory(mTriggerCycleHelper);
@@ -755,9 +755,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// Detect Setup Conditions ... // Detect Setup Conditions ...
datetime setupTime = mXOBSConditions.setupTime; datetime setupTime = mX121SMCXOBSConditions.setupTime;
bool isSetuped = mXOBSConditions.IsSetuped(); bool isSetuped = mX121SMCXOBSConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOBSConditions.dir; ENUM_X_DIRECTION setupDir = mX121SMCXOBSConditions.dir;
if (!isSetuped) if (!isSetuped)
{ {
// //
@@ -765,7 +765,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
isSetuped = DetectX121SMCXOBSSignalSetup( isSetuped = DetectX121SMCXOBSSignalSetup(
symbol, symbol,
period, period,
mXOBSConditions, mX121SMCXOBSConditions,
mTriggerCycleHelper, mTriggerCycleHelper,
mDecisionCycleHelper, mDecisionCycleHelper,
mAnalyseCycleHelper, mAnalyseCycleHelper,
@@ -775,25 +775,25 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
); );
// //
setupDir = mXOBSConditions.dir; setupDir = mX121SMCXOBSConditions.dir;
setupTime = mXOBSConditions.setupTime; setupTime = mX121SMCXOBSConditions.setupTime;
// //
if (isSetuped) if (isSetuped)
{ {
// //
int items = AddX121SMCXOBSConditionsIfNotExists( int items = AddX121SMCXOBSConditionsIfNotExists(
mXOBSConditions, mX121SMCXOBSConditions,
mXOBSConditionsCollection // mX121SMCXOBSConditionsCollection //
); );
// //
mXOBSConditions.Clean(); mX121SMCXOBSConditions.Clean();
} }
} }
// //
int conditionsCount = ArraySize(mXOBSConditionsCollection); int conditionsCount = ArraySize(mX121SMCXOBSConditionsCollection);
result = IsValidSize(conditionsCount); result = IsValidSize(conditionsCount);
if (!result) if (!result)
{ {
@@ -805,7 +805,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
int selectedIndex = 0; int selectedIndex = 0;
X121SMCStrategyXOBSSignalConditions mTmpConditions[]; X121SMCStrategyXOBSSignalConditions mTmpConditions[];
Copy( Copy(
mXOBSConditionsCollection, mX121SMCXOBSConditionsCollection,
mTmpConditions // mTmpConditions //
); );
X121SMCStrategyXOBSSignalConditions mConditions; X121SMCStrategyXOBSSignalConditions mConditions;
@@ -841,7 +841,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{ {
// //
ArrayRemove( ArrayRemove(
mXOBSConditionsCollection, mX121SMCXOBSConditionsCollection,
i, i,
1 // 1 //
); );
@@ -874,7 +874,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// Remove Selected Index from Main Collection ... // Remove Selected Index from Main Collection ...
ArrayRemove( ArrayRemove(
mXOBSConditionsCollection, mX121SMCXOBSConditionsCollection,
selectedIndex, selectedIndex,
1 // 1 //
); );