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(); result = tsInputs.IsValid();
if (!result) { if (!result)
{
return result; return result;
} }
@@ -258,12 +259,108 @@ public:
// X5 Provider Market Conditions ... // X5 Provider Market Conditions ...
class X5MarketConditions : public XSCBaseProviderMarketConditions class X5MarketConditions : public XSCBaseProviderMarketConditions
{ {
//
// Public ...
public:
// //
// Buffers ... // 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 ... // 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 ... // Generate Score ...
@@ -335,6 +432,9 @@ public:
amaHelper = new XSCXAMAHelper(); amaHelper = new XSCXAMAHelper();
chmaHelper = new XSCXCHMAHelper(); chmaHelper = new XSCXCHMAHelper();
chlhHelper = new XSCXCHLHHelper(); chlhHelper = new XSCXCHLHHelper();
//
mNumberOfItems = 5;
} }
// //
@@ -544,29 +644,300 @@ public:
// Functions ... // Functions ...
// //
virtual bool GetMarketConditions( virtual string GetTag()
X5MarketConditions &conditions, // Market Conditions Result
int barIndex = 0 // Specified Bar Index
)
{ {
// //
bool result = false; string result = NULL;
//
result =
//
GetToken() +
"[" +
GetSymbol() +
"," +
ToString(GetPeriod()) +
"]"
//
;
// //
return result; 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 ... // Check Market For Signal ...
virtual bool HasSignal( virtual bool HasSignal(
int barIndex, int barIndex,
XSignal &signal, // Hold's Signal if Exists ... XSignal &mSignal, // Hold's Signal if Exists ...
X5MarketConditions &conditions // Hold's Market Conditions ... X5MarketConditions &mConditions // Hold's Market Conditions ...
) )
{ {
// //
bool result = false; bool result = false;
//
result = !CanIgnoreProcess();
if (!result)
{
return result;
}
//
GetMarketConditions(mConditions, barIndex);
//
if (result)
{
Print(GetToken() + ", " + GetTag() + ", Salam");
}
// //
return result; return result;
} }
@@ -582,6 +953,7 @@ protected:
private: private:
// //
// Props ... // Props ...
int mNumberOfItems; // Number of Buffer Ites Read in Conditions ...
// //
// Tools ... // Tools ...
+3 -3
View File
@@ -110,8 +110,8 @@ public:
mCycle.Init( mCycle.Init(
symbol, symbol,
period, period,
X_MARKET_CYCLE_UNKNOWN, X_MARKET_CYCLE_SHORT,
X_PERIOD_NOTHING, X_PERIOD_MANUALLY,
period, period,
"HOST Period" "HOST Period"
// //
@@ -148,7 +148,7 @@ public:
virtual void DeInit(); virtual void DeInit();
// //
virtual bool GetMarketConditions( virtual void GetMarketConditions(
XSCBaseProviderMarketConditions &conditions, // Market Conditions Result XSCBaseProviderMarketConditions &conditions, // Market Conditions Result
int barIndex = 0 // Specified Bar Index int barIndex = 0 // Specified Bar Index
); );
+54 -54
View File
@@ -968,7 +968,7 @@ public:
// //
// Check Spread is Ok for Executing Specific Signal ... // Check Spread is Ok for Executing Specific Signal ...
bool CheckSpreadForSignalExecution(XSignal &signal) bool CheckSpreadForSignalExecution(XSignal &mSignal)
{ {
// //
bool result = false; bool result = false;
@@ -983,7 +983,7 @@ public:
{ {
// //
// Retrieve Signal Spread ... // Retrieve Signal Spread ...
double spread = signal.GetSpread(); double spread = mSignal.GetSpread();
result = spread <= mMaxAllowedSpread; result = spread <= mMaxAllowedSpread;
} }
@@ -994,7 +994,7 @@ public:
// //
// Check Account Policy ... // Check Account Policy ...
bool CheckAccountPolicy( bool CheckAccountPolicy(
XSignal &signal, // For Executing Signal XSignal &mSignal, // For Executing Signal
ENUM_X_SIGNAL_EXECUTION_RESULT &state // State Holder ENUM_X_SIGNAL_EXECUTION_RESULT &state // State Holder
) )
{ {
@@ -1023,7 +1023,7 @@ public:
// //
// Check Spread for Trade ... // Check Spread for Trade ...
result = CheckSpreadForSignalExecution(signal); result = CheckSpreadForSignalExecution(mSignal);
if (!result) if (!result)
{ {
// //
@@ -1078,7 +1078,7 @@ public:
// //
// Execute a Signal ... // Execute a Signal ...
bool ExecuteSignal( bool ExecuteSignal(
XSignal &signal, // Signal XSignal &mSignal, // Signal
ENUM_X_SIGNAL_EXECUTION_RESULT &state, // Result ENUM_X_SIGNAL_EXECUTION_RESULT &state, // Result
ENUM_ORDER_TYPE_TIME lifetime = ORDER_TIME_GTC, // Order LifeTime ENUM_ORDER_TYPE_TIME lifetime = ORDER_TIME_GTC, // Order LifeTime
datetime expiration = NULL, // order expiration time datetime expiration = NULL, // order expiration time
@@ -1091,25 +1091,25 @@ public:
// //
double currentEntry = GetEntry( double currentEntry = GetEntry(
signal.symbol, mSignal.symbol,
signal.type mSignal.type
// //
); );
bool isLong = IsLong(signal.type); bool isLong = IsLong(mSignal.type);
// //
// Select SL and TP ... // Select SL and TP ...
// //
double selectedSL = 0; double selectedSL = 0;
signal.RegularSL(selectedSL); mSignal.RegularSL(selectedSL);
// //
double selectedTP = 0; double selectedTP = 0;
signal.RegularTP(selectedTP); mSignal.RegularTP(selectedTP);
// //
if (!signal.IsValid()) if (!mSignal.IsValid())
{ {
// //
state = X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS; state = X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS;
@@ -1118,13 +1118,13 @@ public:
// //
// Handle Market Execution ... // Handle Market Execution ...
if (signal.mode == X_ORDER_MODE_MARKET) if (mSignal.mode == X_ORDER_MODE_MARKET)
{ {
// //
// Do Apply Policies here ... // Do Apply Policies here ...
bool hasPolicy = !checkPolicies bool hasPolicy = !checkPolicies
? true ? true
: CheckAccountPolicy(signal, state); : CheckAccountPolicy(mSignal, state);
if (!hasPolicy) if (!hasPolicy)
{ {
result = false; result = false;
@@ -1136,13 +1136,13 @@ public:
{ {
// //
result = Buy( result = Buy(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
signal.comment mSignal.comment
// //
); );
} }
@@ -1150,13 +1150,13 @@ public:
{ {
// //
result = Sell( result = Sell(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
signal.comment mSignal.comment
// //
); );
} }
@@ -1164,7 +1164,7 @@ public:
} }
// //
// Handle Stop Execution ... // 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 ... // Check Price ...
result = isLong result = isLong
? signal.entry > currentEntry ? mSignal.entry > currentEntry
: signal.entry < currentEntry; : mSignal.entry < currentEntry;
if (!result) if (!result)
{ {
// //
@@ -1188,15 +1188,15 @@ public:
{ {
// //
result = BuyStop( result = BuyStop(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
lifetime, lifetime,
expiration, expiration,
signal.comment mSignal.comment
// //
); );
} }
@@ -1204,22 +1204,22 @@ public:
{ {
// //
result = SellStop( result = SellStop(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
lifetime, lifetime,
expiration, expiration,
signal.comment mSignal.comment
// //
); );
} }
} }
// //
// Handle Limit Execution ... // Handle Limit Execution ...
else if (signal.mode == X_ORDER_MODE_LIMIT) else if (mSignal.mode == X_ORDER_MODE_LIMIT)
{ {
// //
// Check Conditions ... // Check Conditions ...
@@ -1227,8 +1227,8 @@ public:
// //
// Check Price ... // Check Price ...
result = isLong result = isLong
? signal.entry < currentEntry ? mSignal.entry < currentEntry
: signal.entry > currentEntry; : mSignal.entry > currentEntry;
if (!result) if (!result)
{ {
// //
@@ -1242,15 +1242,15 @@ public:
{ {
// //
result = BuyLimit( result = BuyLimit(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
lifetime, lifetime,
expiration, expiration,
signal.comment mSignal.comment
// //
); );
} }
@@ -1258,15 +1258,15 @@ public:
{ {
// //
result = SellLimit( result = SellLimit(
signal.symbol, mSignal.symbol,
signal.period, mSignal.period,
signal.volume, mSignal.volume,
signal.entry, mSignal.entry,
selectedSL, selectedSL,
selectedTP, selectedTP,
lifetime, lifetime,
expiration, expiration,
signal.comment mSignal.comment
// //
); );
} }
@@ -1281,7 +1281,7 @@ public:
// //
ulong ticket; ulong ticket;
if (signal.mode == X_ORDER_MODE_MARKET) if (mSignal.mode == X_ORDER_MODE_MARKET)
{ {
ticket = GetLastOpenPositionTicket(); ticket = GetLastOpenPositionTicket();
} }
@@ -1291,11 +1291,11 @@ public:
} }
// //
signal.positionId = ticket; mSignal.positionId = ticket;
// //
// Handle Store XPositionInfo ... // Handle Store XPositionInfo ...
if (signal.mode == X_ORDER_MODE_MARKET) if (mSignal.mode == X_ORDER_MODE_MARKET)
{ {
// //
// TODO: Implement this ... // TODO: Implement this ...
@@ -1303,7 +1303,7 @@ public:
// //
// Handle Executing Support Signals ... // Handle Executing Support Signals ...
int supportsCount = ArraySize(signal.supports); int supportsCount = ArraySize(mSignal.supports);
if (supportsCount > 0) if (supportsCount > 0)
{ {
// //
@@ -1311,7 +1311,7 @@ public:
for (int i = 0; i < supportsCount; i++) for (int i = 0; i < supportsCount; i++)
{ {
// //
XSignal iSupport = signal.supports[i]; XSignal iSupport = mSignal.supports[i];
// //
int supIndex = i + 1; int supIndex = i + 1;
+7
View File
@@ -47,8 +47,10 @@ MqlTick x5EATick;
// //
// X5Provider ... // X5Provider ...
XSignal signal;
X5ProviderInputs x5Inputs; X5ProviderInputs x5Inputs;
XSCX5Provider *x5Provider; XSCX5Provider *x5Provider;
X5MarketConditions conditions;
// //
// Event Handlers ... // Event Handlers ...
@@ -134,6 +136,11 @@ void OnTick()
{ {
return; return;
} }
//
signal.Clean();
conditions.Clear();
x5Provider.HasSignal(0, signal, conditions);
} }
// //
+10 -10
View File
@@ -275,16 +275,16 @@ private:
// //
int totalBars = CountBars(); int totalBars = CountBars();
// // //
// // Short Exit 2 ... // Short Exit 2 ...
// CopyBuffer( CopyBuffer(
// mHandler, mHandler,
// X_CHE_SHORT_EXIT_2_LINE, XFI_MAIN_LINE,
// 0, 0,
// totalBars, totalBars,
// shortExit2Buffer mainBuffer
// // //
// ); );
} }
}; };
+8 -8
View File
@@ -2533,7 +2533,7 @@ struct XPositionInfo
// Fill from a Signal ... // Fill from a Signal ...
// The Signal must Executed ... // The Signal must Executed ...
bool BySignal( bool BySignal(
XSignal &signal // the Signal which need to use XSignal &mSignal // the Signal which need to use
) )
{ {
// //
@@ -2543,24 +2543,24 @@ struct XPositionInfo
Clean(); Clean();
// //
result = signal.IsValid() && signal.IsExecuted() && signal.mode == X_ORDER_MODE_MARKET; result = mSignal.IsValid() && mSignal.IsExecuted() && mSignal.mode == X_ORDER_MODE_MARKET;
if (!result) if (!result)
{ {
return result; return result;
} }
// //
ticket = signal.positionId; ticket = mSignal.positionId;
action = signal.action; action = mSignal.action;
// //
// Select TPS and SLS from signal ... // Select TPS and SLS from signal ...
// //
double sl = 0; double sl = 0;
bool hasRegularSL = signal.RegularSL(sl); bool hasRegularSL = mSignal.RegularSL(sl);
Copy( Copy(
signal.sls, mSignal.sls,
sls sls
// //
); );
@@ -2576,9 +2576,9 @@ struct XPositionInfo
// //
double tp = 0; double tp = 0;
bool hasRegularTP = signal.RegularTP(tp); bool hasRegularTP = mSignal.RegularTP(tp);
Copy( Copy(
signal.tps, mSignal.tps,
tps tps
// //
); );