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
+183
View File
@@ -300,6 +300,189 @@ ENUM_X_DIRECTION ToDirection(ENUM_X_POSITION_TYPES value)
//
// 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 ...
struct XPosition