last works ...
This commit is contained in:
@@ -134,7 +134,19 @@ struct X121SetupCycleInputs
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool GetConsitions(
|
bool CanProcessBar()
|
||||||
|
{
|
||||||
|
return cycle.barTracker.CanProcessBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void WaitsUntilNextBar()
|
||||||
|
{
|
||||||
|
cycle.barTracker.Waits();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool GetConditions(
|
||||||
X121SetupConditions &conditions, //
|
X121SetupConditions &conditions, //
|
||||||
int barIndex = 0, //
|
int barIndex = 0, //
|
||||||
int loopback = 5 //
|
int loopback = 5 //
|
||||||
@@ -229,6 +241,16 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = cBarTracker.Init(
|
||||||
|
_inputs.symbol,
|
||||||
|
_hostPeriod //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Short ...
|
// Short ...
|
||||||
result = sCycle.Init(
|
result = sCycle.Init(
|
||||||
@@ -321,6 +343,176 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string GetSymbol()
|
||||||
|
{
|
||||||
|
return cCycle.GetSymbol();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_TIMEFRAMES GetPeriod()
|
||||||
|
{
|
||||||
|
return cCycle.GetPeriod();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool CanProcessBar(
|
||||||
|
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycle)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
result = sBarTracker.CanProcessBar();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
result = mBarTracker.CanProcessBar();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
result = lBarTracker.CanProcessBar();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
result = hBarTracker.CanProcessBar();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
default:
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
result = cBarTracker.CanProcessBar();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void WaitsUntilNextBar(
|
||||||
|
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
switch (cycle)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
sBarTracker.Waits();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
mBarTracker.Waits();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
lBarTracker.Waits();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
hBarTracker.Waits();
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
default:
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
cBarTracker.Waits();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool GetConditions(
|
||||||
|
X121SetupConditions &conditions, //
|
||||||
|
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN, //
|
||||||
|
int barIndex = 0, //
|
||||||
|
int loopback = 5 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
switch (cycle)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_SHORT:
|
||||||
|
//
|
||||||
|
result = sCycle.GetConditions(
|
||||||
|
conditions,
|
||||||
|
barIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_MEDIUM:
|
||||||
|
//
|
||||||
|
result = mCycle.GetConditions(
|
||||||
|
conditions,
|
||||||
|
barIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_LONG:
|
||||||
|
//
|
||||||
|
result = lCycle.GetConditions(
|
||||||
|
conditions,
|
||||||
|
barIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_MARKET_CYCLE_HIND:
|
||||||
|
//
|
||||||
|
result = hCycle.GetConditions(
|
||||||
|
conditions,
|
||||||
|
barIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
default:
|
||||||
|
case X_MARKET_CYCLE_UNKNOWN:
|
||||||
|
//
|
||||||
|
result = cCycle.GetConditions(
|
||||||
|
conditions,
|
||||||
|
barIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protected ...
|
// Protected ...
|
||||||
protected:
|
protected:
|
||||||
@@ -333,10 +525,20 @@ private:
|
|||||||
//
|
//
|
||||||
X121SetupInputs inputs; // Cycles Configurations
|
X121SetupInputs inputs; // Cycles Configurations
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bar Trackers ...
|
||||||
|
XBarTracker cBarTracker;
|
||||||
|
XBarTracker sBarTracker;
|
||||||
|
XBarTracker mBarTracker;
|
||||||
|
XBarTracker lBarTracker;
|
||||||
|
XBarTracker hBarTracker;
|
||||||
|
|
||||||
//
|
//
|
||||||
X121SetupCycleInputs cCycle; // Current (Host) Cycle
|
X121SetupCycleInputs cCycle; // Current (Host) Cycle
|
||||||
X121SetupCycleInputs sCycle; // Short Cycle
|
X121SetupCycleInputs sCycle; // Short Cycle
|
||||||
X121SetupCycleInputs mCycle; // Medium Cycle
|
X121SetupCycleInputs mCycle; // Medium Cycle
|
||||||
X121SetupCycleInputs lCycle; // Long Cycle
|
X121SetupCycleInputs lCycle; // Long Cycle
|
||||||
X121SetupCycleInputs hCycle; // Hind Cycle
|
X121SetupCycleInputs hCycle; // Hind Cycle
|
||||||
}
|
};
|
||||||
|
|
||||||
|
//
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2719,6 +2719,34 @@ public:
|
|||||||
.ByIndex(index);
|
.ByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool GetLastDeal(
|
||||||
|
XDeal &result // Hold's Result
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool mResult = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
mResult = HistorySelect(0, TimeCurrent());
|
||||||
|
if (!mResult)
|
||||||
|
{
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int lastDealIndex = HistoryDealsTotal() - 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
mResult = GetDeal(
|
||||||
|
lastDealIndex,
|
||||||
|
result //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Specified Deal's History ...
|
// Retrieve Specified Deal's History ...
|
||||||
int GetDealsHistory(
|
int GetDealsHistory(
|
||||||
|
|||||||
+58
-131
@@ -90,109 +90,14 @@ void OnDeinit(const int reason)
|
|||||||
|
|
||||||
//
|
//
|
||||||
// De Initialize XSampleEA Providers ...
|
// De Initialize XSampleEA Providers ...
|
||||||
|
delete mEA;
|
||||||
//
|
|
||||||
delete mSetup;
|
|
||||||
|
|
||||||
//
|
|
||||||
delete mAlert;
|
|
||||||
delete mTrader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// On Tick Handler ...
|
// On Tick Handler ...
|
||||||
void OnTick()
|
void OnTick()
|
||||||
{
|
{
|
||||||
//
|
mEA.OnTick();
|
||||||
if (!xBarTracker.CanProcessBar())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get Consitions and Validate it ...
|
|
||||||
X121SetupConditions conditions;
|
|
||||||
bool hasConditions = mSetup.GetConditions(
|
|
||||||
conditions //
|
|
||||||
);
|
|
||||||
if (!hasConditions)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
string separator = "\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve Scores ...
|
|
||||||
double bullishScore = 0;
|
|
||||||
double bearishScore = 0;
|
|
||||||
conditions.GenerateScore(
|
|
||||||
bullishScore,
|
|
||||||
bearishScore //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Create Score Summary for Commenting on Chart ...
|
|
||||||
string scoreSummary =
|
|
||||||
//
|
|
||||||
"Scores:" + separator +
|
|
||||||
"----------" + separator +
|
|
||||||
"Bullish: " + ToString(bullishScore) + separator +
|
|
||||||
"Bearish: " + ToString(bearishScore) + separator +
|
|
||||||
""
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
Comment(scoreSummary);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Conditions has Signal or not ...
|
|
||||||
int pusher = 0;
|
|
||||||
XSignal signal;
|
|
||||||
bool hasSignal = mSignalGenerator
|
|
||||||
.HasSignal(
|
|
||||||
conditions,
|
|
||||||
signal,
|
|
||||||
pusher,
|
|
||||||
eaAllowLong,
|
|
||||||
eaAllowShort,
|
|
||||||
eaVolume,
|
|
||||||
0, // SL Point ...
|
|
||||||
30 // TP Point ...
|
|
||||||
);
|
|
||||||
if (!hasSignal)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Since we have a Signal in current Bar, ignore other ticks and
|
|
||||||
// waits for Next Bar ...
|
|
||||||
xBarTracker.Waits();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Generate Condition Summary for Logging ...
|
|
||||||
string summary = conditions.GenerateSummary(false, true, false);
|
|
||||||
|
|
||||||
//
|
|
||||||
Print(summary);
|
|
||||||
|
|
||||||
//
|
|
||||||
ENUM_X_SIGNAL_EXECUTION_RESULT state;
|
|
||||||
int isExecuted = mTrader.ExecuteSignal(
|
|
||||||
signal,
|
|
||||||
state //
|
|
||||||
);
|
|
||||||
if (isExecuted)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
string message = "Signal Executed Successfully ...";
|
|
||||||
|
|
||||||
//
|
|
||||||
mAlert.Alert(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -207,49 +112,71 @@ bool InitialEA()
|
|||||||
//
|
//
|
||||||
TesterHideIndicators(true);
|
TesterHideIndicators(true);
|
||||||
|
|
||||||
//
|
//
|
||||||
SetLogAlerts(true);
|
result = IsValid(eaSymbols);
|
||||||
SetPrefix(ShortName);
|
if (!result)
|
||||||
SetEnableAlerts(true);
|
{
|
||||||
SetPushAlerts(false);
|
return result;
|
||||||
SetMailAlerts(false);
|
}
|
||||||
SetTerminalAlerts(false);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
mTrader = new XSCTrade(
|
string symbols[];
|
||||||
|
int symbolsCount = SplitContent(
|
||||||
|
symbols,
|
||||||
|
eaSymbols //
|
||||||
|
);
|
||||||
|
result = symbolsCount > 0;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mEA = new XSCX121SetupEA(
|
||||||
eaSlippage,
|
eaSlippage,
|
||||||
eaMagicNumber,
|
eaMagicNumber //
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0 //
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = xBarTracker.Init(
|
// Allow Signals ...
|
||||||
_Symbol,
|
mEA.AllowLong(true);
|
||||||
_Period //
|
mEA.AllowShort(true);
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
X121SetupInputs x121Inputs;
|
mEA.SetAlertPrefix(ShortName);
|
||||||
x121Inputs.symbol = _Symbol;
|
|
||||||
x121Inputs.period = _Period;
|
//
|
||||||
result = x121Inputs.Init();
|
X121SetupInputs setupInputsDefault;
|
||||||
if (!result)
|
setupInputsDefault.Default();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Providers and Add them into mX121EA class ...
|
||||||
|
for (int i = 0; i < symbolsCount; i++)
|
||||||
{
|
{
|
||||||
return result;
|
//
|
||||||
}
|
// Requirements ...
|
||||||
mSetup = new XSCX121Setup();
|
string iSymbol = symbols[i];
|
||||||
result = mSetup.Init(
|
ENUM_TIMEFRAMES iHostPeriod = _Period;
|
||||||
x121Inputs //
|
|
||||||
);
|
//
|
||||||
if (!result)
|
XSCX121SetupCycles *iSetupCycle;
|
||||||
{
|
iSetupCycle = new XSCX121SetupCycles();
|
||||||
return result;
|
result = iSetupCycle.Init(
|
||||||
|
setupInputsDefault,
|
||||||
|
iSymbol,
|
||||||
|
iHostPeriod //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = mEA.AddSetup(iSetupCycle);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -6973,6 +6973,28 @@ string ToString(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
template <typename T>
|
||||||
|
string ToString(
|
||||||
|
string prefix, // Title
|
||||||
|
T value, // Value
|
||||||
|
string lineSeparator = "\n", // Line Separator
|
||||||
|
string prefixSeparator = ":" // Title Separator
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = prefix +
|
||||||
|
prefixSeparator + " " +
|
||||||
|
ToString(value) +
|
||||||
|
lineSeparator;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
string SetLabel(
|
string SetLabel(
|
||||||
string mLabel, // Provided Label ...
|
string mLabel, // Provided Label ...
|
||||||
|
|||||||
Reference in New Issue
Block a user