test x5 provider reading Buffers correctly and also CanIgnoreProcess works properly ...

This commit is contained in:
2024-05-19 03:51:48 +03:30
parent 4c1b97e805
commit 4eba93231a
6 changed files with 463 additions and 84 deletions
+381 -9
View File
@@ -109,7 +109,8 @@ public:
//
result = tsInputs.IsValid();
if (!result) {
if (!result)
{
return result;
}
@@ -258,12 +259,108 @@ public:
// X5 Provider Market Conditions ...
class X5MarketConditions : public XSCBaseProviderMarketConditions
{
//
// Public ...
public:
//
// Buffers ...
//
// XTS ...
double tsCurrents[];
double tsNearests[];
double tsMediests[];
double tsFarests[];
//
// XFI ...
double fis[];
//
// XTD ...
double tdBullishs[];
double tdBearishs[];
double tdSignals[];
//
// XLH ...
double lhHhs[];
double lhLls[];
double lhSignals[];
//
// XTM ...
double tms[];
//
// XAMA ...
double amas[];
//
// XOBD ...
double obds[];
//
// XRSI ...
double rsis[];
//
// XCHMA ...
double chmaScFasts[];
double chmaScSlows[];
double chmaMcFasts[];
double chmaMcSlows[];
double chmaLcFasts[];
double chmaLcSlows[];
double chmaHotStates[];
//
// XCHLH ...
double chlhScHHs[];
double chlhScLLs[];
double chlhMcHHs[];
double chlhMcLLs[];
double chlhLcHHs[];
double chlhLcLLs[];
double chlhHotStates[];
//
//
// Conditions ...
void Clear()
{
//
Clean(tsCurrents);
Clean(tsNearests);
Clean(tsMediests);
Clean(tsFarests);
Clean(fis);
Clean(tdBullishs);
Clean(tdBearishs);
Clean(tdSignals);
Clean(lhHhs);
Clean(lhLls);
Clean(lhSignals);
Clean(tms);
Clean(amas);
Clean(obds);
Clean(rsis);
Clean(chmaScFasts);
Clean(chmaScSlows);
Clean(chmaMcFasts);
Clean(chmaMcSlows);
Clean(chmaLcFasts);
Clean(chmaLcSlows);
Clean(chmaHotStates);
Clean(chlhScHHs);
Clean(chlhScLLs);
Clean(chlhMcHHs);
Clean(chlhMcLLs);
Clean(chlhLcHHs);
Clean(chlhLcLLs);
Clean(chlhHotStates);
}
//
// Generate Score ...
@@ -335,6 +432,9 @@ public:
amaHelper = new XSCXAMAHelper();
chmaHelper = new XSCXCHMAHelper();
chlhHelper = new XSCXCHLHHelper();
//
mNumberOfItems = 5;
}
//
@@ -544,29 +644,300 @@ public:
// Functions ...
//
virtual bool GetMarketConditions(
X5MarketConditions &conditions, // Market Conditions Result
int barIndex = 0 // Specified Bar Index
)
virtual string GetTag()
{
//
bool result = false;
string result = NULL;
//
result =
//
GetToken() +
"[" +
GetSymbol() +
"," +
ToString(GetPeriod()) +
"]"
//
;
//
return result;
}
//
virtual void GetMarketConditions(
X5MarketConditions &mConditions, // Market Conditions Result
int barIndex = 0 // Specified Bar Index
)
{
//
mConditions.Clear();
//
// XTM ...
tmHelper.CopyMain(
barIndex,
mNumberOfItems,
mConditions.tms);
//
// XAMA ...
amaHelper.CopyMain(
barIndex,
mNumberOfItems,
mConditions.amas);
//
// XFI ...
fiHelper.CopyMain(
barIndex,
mNumberOfItems,
mConditions.fis);
//
// XOBD ...
obdHelper.CopyMain(
barIndex,
mNumberOfItems,
mConditions.obds);
//
// XRSI ...
rsiHelper.CopyMain(
barIndex,
mNumberOfItems,
mConditions.rsis);
//
// XLH ...
//
// HH ...
lhHelper.CopyHH(
barIndex,
mNumberOfItems,
mConditions.lhHhs);
//
// LL ...
lhHelper.CopyLL(
barIndex,
mNumberOfItems,
mConditions.lhLls);
//
// Signal ...
lhHelper.CopySignal(
barIndex,
mNumberOfItems,
mConditions.lhSignals);
//
// XTD ...
//
// Bullish ...
tdHelper.CopyBullish(
barIndex,
mNumberOfItems,
mConditions.tdBullishs);
//
// Bearish ...
tdHelper.CopyBearish(
barIndex,
mNumberOfItems,
mConditions.tdBearishs);
//
// Signal ...
tdHelper.CopySignal(
barIndex,
mNumberOfItems,
mConditions.tdSignals);
//
// XTS ...
//
// Current ...
tsHelper.CopyCurrent(
barIndex,
mNumberOfItems,
mConditions.tsCurrents);
//
// Nearest ...
tsHelper.CopyNearest(
barIndex,
mNumberOfItems,
mConditions.tsNearests);
//
// Mediest ...
tsHelper.CopyMediest(
barIndex,
mNumberOfItems,
mConditions.tsMediests);
//
// Farest ...
tsHelper.CopyFarest(
barIndex,
mNumberOfItems,
mConditions.tsFarests);
//
// XCHMA ...
//
// Short ...
//
// Fast ...
chmaHelper.CopySCFast(
barIndex,
mNumberOfItems,
mConditions.chmaScFasts);
//
// Slow ...
chmaHelper.CopySCSlow(
barIndex,
mNumberOfItems,
mConditions.chmaScSlows);
//
// Medium ...
//
// Fast ...
chmaHelper.CopyMCFast(
barIndex,
mNumberOfItems,
mConditions.chmaMcFasts);
//
// Slow ...
chmaHelper.CopyMCSlow(
barIndex,
mNumberOfItems,
mConditions.chmaMcSlows);
//
// Long ...
//
// Fast ...
chmaHelper.CopyLCFast(
barIndex,
mNumberOfItems,
mConditions.chmaLcFasts);
//
// Slow ...
chmaHelper.CopyLCSlow(
barIndex,
mNumberOfItems,
mConditions.chmaLcSlows);
//
// Hot States ...
chmaHelper.CopyHotState(
barIndex,
mNumberOfItems,
mConditions.chmaHotStates);
//
// XCHLH ...
//
// Short ...
//
// HH ...
chlhHelper.CopySCHH(
barIndex,
mNumberOfItems,
mConditions.chlhScHHs);
//
// LL ...
chlhHelper.CopySCLL(
barIndex,
mNumberOfItems,
mConditions.chlhScLLs);
//
// Medium ...
//
// HH ...
chlhHelper.CopyMCHH(
barIndex,
mNumberOfItems,
mConditions.chlhMcHHs);
//
// LL ...
chlhHelper.CopyMCLL(
barIndex,
mNumberOfItems,
mConditions.chlhMcLLs);
//
// Long ...
//
// HH ...
chlhHelper.CopyLCHH(
barIndex,
mNumberOfItems,
mConditions.chlhLcHHs);
//
// LL ...
chlhHelper.CopyLCLL(
barIndex,
mNumberOfItems,
mConditions.chlhLcLLs);
//
// Hot State ...
chlhHelper.CopyHotState(
barIndex,
mNumberOfItems,
mConditions.chlhHotStates);
}
//
// Check Market For Signal ...
virtual bool HasSignal(
int barIndex,
XSignal &signal, // Hold's Signal if Exists ...
X5MarketConditions &conditions // Hold's Market Conditions ...
XSignal &mSignal, // Hold's Signal if Exists ...
X5MarketConditions &mConditions // Hold's Market Conditions ...
)
{
//
bool result = false;
//
result = !CanIgnoreProcess();
if (!result)
{
return result;
}
//
GetMarketConditions(mConditions, barIndex);
//
if (result)
{
Print(GetToken() + ", " + GetTag() + ", Salam");
}
//
return result;
}
@@ -582,6 +953,7 @@ protected:
private:
//
// Props ...
int mNumberOfItems; // Number of Buffer Ites Read in Conditions ...
//
// Tools ...
+3 -3
View File
@@ -110,8 +110,8 @@ public:
mCycle.Init(
symbol,
period,
X_MARKET_CYCLE_UNKNOWN,
X_PERIOD_NOTHING,
X_MARKET_CYCLE_SHORT,
X_PERIOD_MANUALLY,
period,
"HOST Period"
//
@@ -148,7 +148,7 @@ public:
virtual void DeInit();
//
virtual bool GetMarketConditions(
virtual void GetMarketConditions(
XSCBaseProviderMarketConditions &conditions, // Market Conditions Result
int barIndex = 0 // Specified Bar Index
);
+54 -54
View File
@@ -968,7 +968,7 @@ public:
//
// Check Spread is Ok for Executing Specific Signal ...
bool CheckSpreadForSignalExecution(XSignal &signal)
bool CheckSpreadForSignalExecution(XSignal &mSignal)
{
//
bool result = false;
@@ -983,7 +983,7 @@ public:
{
//
// Retrieve Signal Spread ...
double spread = signal.GetSpread();
double spread = mSignal.GetSpread();
result = spread <= mMaxAllowedSpread;
}
@@ -994,7 +994,7 @@ public:
//
// Check Account Policy ...
bool CheckAccountPolicy(
XSignal &signal, // For Executing Signal
XSignal &mSignal, // For Executing Signal
ENUM_X_SIGNAL_EXECUTION_RESULT &state // State Holder
)
{
@@ -1023,7 +1023,7 @@ public:
//
// Check Spread for Trade ...
result = CheckSpreadForSignalExecution(signal);
result = CheckSpreadForSignalExecution(mSignal);
if (!result)
{
//
@@ -1078,7 +1078,7 @@ public:
//
// Execute a Signal ...
bool ExecuteSignal(
XSignal &signal, // Signal
XSignal &mSignal, // Signal
ENUM_X_SIGNAL_EXECUTION_RESULT &state, // Result
ENUM_ORDER_TYPE_TIME lifetime = ORDER_TIME_GTC, // Order LifeTime
datetime expiration = NULL, // order expiration time
@@ -1091,25 +1091,25 @@ public:
//
double currentEntry = GetEntry(
signal.symbol,
signal.type
mSignal.symbol,
mSignal.type
//
);
bool isLong = IsLong(signal.type);
bool isLong = IsLong(mSignal.type);
//
// Select SL and TP ...
//
double selectedSL = 0;
signal.RegularSL(selectedSL);
mSignal.RegularSL(selectedSL);
//
double selectedTP = 0;
signal.RegularTP(selectedTP);
mSignal.RegularTP(selectedTP);
//
if (!signal.IsValid())
if (!mSignal.IsValid())
{
//
state = X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS;
@@ -1118,13 +1118,13 @@ public:
//
// Handle Market Execution ...
if (signal.mode == X_ORDER_MODE_MARKET)
if (mSignal.mode == X_ORDER_MODE_MARKET)
{
//
// Do Apply Policies here ...
bool hasPolicy = !checkPolicies
? true
: CheckAccountPolicy(signal, state);
: CheckAccountPolicy(mSignal, state);
if (!hasPolicy)
{
result = false;
@@ -1136,13 +1136,13 @@ public:
{
//
result = Buy(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
signal.comment
mSignal.comment
//
);
}
@@ -1150,13 +1150,13 @@ public:
{
//
result = Sell(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
signal.comment
mSignal.comment
//
);
}
@@ -1164,7 +1164,7 @@ public:
}
//
// Handle Stop Execution ...
else if (signal.mode == X_ORDER_MODE_STOP)
else if (mSignal.mode == X_ORDER_MODE_STOP)
{
//
@@ -1173,8 +1173,8 @@ public:
//
// Check Price ...
result = isLong
? signal.entry > currentEntry
: signal.entry < currentEntry;
? mSignal.entry > currentEntry
: mSignal.entry < currentEntry;
if (!result)
{
//
@@ -1188,15 +1188,15 @@ public:
{
//
result = BuyStop(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
lifetime,
expiration,
signal.comment
mSignal.comment
//
);
}
@@ -1204,22 +1204,22 @@ public:
{
//
result = SellStop(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
lifetime,
expiration,
signal.comment
mSignal.comment
//
);
}
}
//
// Handle Limit Execution ...
else if (signal.mode == X_ORDER_MODE_LIMIT)
else if (mSignal.mode == X_ORDER_MODE_LIMIT)
{
//
// Check Conditions ...
@@ -1227,8 +1227,8 @@ public:
//
// Check Price ...
result = isLong
? signal.entry < currentEntry
: signal.entry > currentEntry;
? mSignal.entry < currentEntry
: mSignal.entry > currentEntry;
if (!result)
{
//
@@ -1242,15 +1242,15 @@ public:
{
//
result = BuyLimit(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
lifetime,
expiration,
signal.comment
mSignal.comment
//
);
}
@@ -1258,15 +1258,15 @@ public:
{
//
result = SellLimit(
signal.symbol,
signal.period,
signal.volume,
signal.entry,
mSignal.symbol,
mSignal.period,
mSignal.volume,
mSignal.entry,
selectedSL,
selectedTP,
lifetime,
expiration,
signal.comment
mSignal.comment
//
);
}
@@ -1281,7 +1281,7 @@ public:
//
ulong ticket;
if (signal.mode == X_ORDER_MODE_MARKET)
if (mSignal.mode == X_ORDER_MODE_MARKET)
{
ticket = GetLastOpenPositionTicket();
}
@@ -1291,11 +1291,11 @@ public:
}
//
signal.positionId = ticket;
mSignal.positionId = ticket;
//
// Handle Store XPositionInfo ...
if (signal.mode == X_ORDER_MODE_MARKET)
if (mSignal.mode == X_ORDER_MODE_MARKET)
{
//
// TODO: Implement this ...
@@ -1303,7 +1303,7 @@ public:
//
// Handle Executing Support Signals ...
int supportsCount = ArraySize(signal.supports);
int supportsCount = ArraySize(mSignal.supports);
if (supportsCount > 0)
{
//
@@ -1311,7 +1311,7 @@ public:
for (int i = 0; i < supportsCount; i++)
{
//
XSignal iSupport = signal.supports[i];
XSignal iSupport = mSignal.supports[i];
//
int supIndex = i + 1;