last works on strategies ...
This commit is contained in:
@@ -44,7 +44,7 @@ XSCXCTHelper *mCTHelper;
|
||||
XSCXCCHelper *mCCHelper;
|
||||
|
||||
//
|
||||
XSCXSRBRStrategy *strategy;
|
||||
XSCBaseStrategy *strategies[];
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
@@ -66,7 +66,8 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
EventSetTimer(1);
|
||||
// EventSetTimer(1);
|
||||
// EventSetMillisecondTimer(100);
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
@@ -95,14 +96,17 @@ void OnDeinit(const int reason)
|
||||
delete mCCHelper;
|
||||
|
||||
//
|
||||
EventKillTimer();
|
||||
// EventKillTimer();
|
||||
|
||||
//
|
||||
Clean(strategies);
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
HandleStrategiesOnTick();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -110,13 +114,14 @@ void OnTick()
|
||||
void OnTimer()
|
||||
{
|
||||
//
|
||||
strategy.HandleTick();
|
||||
// HandleStrategiesOnTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
@@ -130,6 +135,7 @@ bool ValidateInputs()
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize all Requirements ...
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
@@ -166,26 +172,215 @@ bool InitialEA()
|
||||
}
|
||||
|
||||
//
|
||||
strategy = new XSCXSRBRStrategy(
|
||||
_Symbol,
|
||||
_Period,
|
||||
eaVolume,
|
||||
1.5, // R2R ...
|
||||
mSlippage,
|
||||
mMagicNumber + 1,
|
||||
eaAllowLong,
|
||||
eaAllowShort,
|
||||
0, // Max Longs
|
||||
0 // Max Shorts
|
||||
);
|
||||
strategy.SetAlertLogAlerts(true);
|
||||
strategy.SetAlertEnableAlerts(true);
|
||||
strategy.DarwSupportAndResistances(true);
|
||||
XSymbolParser symbolParser;
|
||||
|
||||
//
|
||||
bool drawAreas = false;
|
||||
|
||||
//
|
||||
// EURUSD ...
|
||||
string eurusdSymbol = "EURUSDb"; // symbolParser.GetEURUSDSymbol();
|
||||
if (IsValid(eurusdSymbol))
|
||||
{
|
||||
//
|
||||
// MAGIC NUMBER ...
|
||||
long magicNumber = mMagicNumber + 1;
|
||||
|
||||
// //
|
||||
// // Register XSRBR on EURUSD in M5 ...
|
||||
// XSCXSRBRStrategy *eurusdM5SRBRStrategy;
|
||||
// eurusdM5SRBRStrategy = new XSCXSRBRStrategy(
|
||||
// eurusdSymbol,
|
||||
// PERIOD_M5,
|
||||
// eaVolume,
|
||||
// 1.5, // R2R ...
|
||||
// mSlippage,
|
||||
// magicNumber,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// 0, // Max Longs
|
||||
// 0 // Max Shorts
|
||||
// );
|
||||
// eurusdM5SRBRStrategy.SetAlertLogAlerts(true);
|
||||
// eurusdM5SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
// eurusdM5SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
// RegisterStrategy(eurusdM5SRBRStrategy);
|
||||
|
||||
// //
|
||||
// // Register XSRBR on EURUSD in M10 ...
|
||||
// XSCXSRBRStrategy *eurusdM10SRBRStrategy;
|
||||
// eurusdM10SRBRStrategy = new XSCXSRBRStrategy(
|
||||
// eurusdSymbol,
|
||||
// PERIOD_M10,
|
||||
// eaVolume,
|
||||
// 1.5, // R2R ...
|
||||
// mSlippage,
|
||||
// magicNumber,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// 0, // Max Longs
|
||||
// 0 // Max Shorts
|
||||
// );
|
||||
// eurusdM10SRBRStrategy.SetAlertLogAlerts(true);
|
||||
// eurusdM10SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
// eurusdM10SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
// RegisterStrategy(eurusdM10SRBRStrategy);
|
||||
}
|
||||
|
||||
// //
|
||||
// // XAUUSD ...
|
||||
// string xauusdSymbol = "XAUUSDb";
|
||||
// if (IsValid(xauusdSymbol))
|
||||
// {
|
||||
// //
|
||||
// // MAGIC NUMBER ...
|
||||
// long magicNumber = mMagicNumber + 2;
|
||||
|
||||
// //
|
||||
// // Register XSRBR on XAUUSD in M5 ...
|
||||
// XSCXSRBRStrategy *xauusdM5SRBRStrategy;
|
||||
// xauusdM5SRBRStrategy = new XSCXSRBRStrategy(
|
||||
// xauusdSymbol,
|
||||
// PERIOD_M15,
|
||||
// eaVolume,
|
||||
// 1.5, // R2R ...
|
||||
// mSlippage,
|
||||
// magicNumber,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// 0, // Max Longs
|
||||
// 0 // Max Shorts
|
||||
// );
|
||||
// xauusdM5SRBRStrategy.SetAlertLogAlerts(true);
|
||||
// xauusdM5SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
// xauusdM5SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
// RegisterStrategy(xauusdM5SRBRStrategy);
|
||||
// }
|
||||
|
||||
//
|
||||
// GBPUSD ...
|
||||
string gbpusdSymbol = "GBPUSDb";
|
||||
if (IsValid(gbpusdSymbol))
|
||||
{
|
||||
//
|
||||
// MAGIC NUMBER ...
|
||||
long magicNumber = mMagicNumber + 3;
|
||||
|
||||
// //
|
||||
// // Register XSRBR on XAUUSD in M5 ...
|
||||
// XSCXSRBRStrategy *gbpusdM15SRBRStrategy;
|
||||
// gbpusdM15SRBRStrategy = new XSCXSRBRStrategy(
|
||||
// gbpusdSymbol,
|
||||
// PERIOD_M15,
|
||||
// eaVolume,
|
||||
// 1.5, // R2R ...
|
||||
// mSlippage,
|
||||
// magicNumber,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// 0, // Max Longs
|
||||
// 0 // Max Shorts
|
||||
// );
|
||||
// gbpusdM15SRBRStrategy.SetAlertLogAlerts(true);
|
||||
// gbpusdM15SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
// gbpusdM15SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
// RegisterStrategy(gbpusdM15SRBRStrategy);
|
||||
|
||||
//
|
||||
// Register XSRBR on XAUUSD in M5 ...
|
||||
// XSCXSRBRStrategy *gbpusdM30SRBRStrategy;
|
||||
// gbpusdM30SRBRStrategy = new XSCXSRBRStrategy(
|
||||
// gbpusdSymbol,
|
||||
// PERIOD_M30,
|
||||
// eaVolume,
|
||||
// 1.5, // R2R ...
|
||||
// mSlippage,
|
||||
// magicNumber,
|
||||
// eaAllowLong,
|
||||
// eaAllowShort,
|
||||
// 0, // Max Longs
|
||||
// 0 // Max Shorts
|
||||
// );
|
||||
// gbpusdM30SRBRStrategy.SetAlertLogAlerts(true);
|
||||
// gbpusdM30SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
// gbpusdM30SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
// RegisterStrategy(gbpusdM30SRBRStrategy);
|
||||
}
|
||||
|
||||
//
|
||||
// USDJPY ...
|
||||
string usdjpySymbol = "USDJPYb";
|
||||
if (IsValid(usdjpySymbol))
|
||||
{
|
||||
//
|
||||
// MAGIC NUMBER ...
|
||||
long magicNumber = mMagicNumber + 3;
|
||||
|
||||
//
|
||||
// Register XSRBR on XAUUSD in M5 ...
|
||||
XSCXSRBRStrategy *usdjpyM5SRBRStrategy;
|
||||
usdjpyM5SRBRStrategy = new XSCXSRBRStrategy(
|
||||
usdjpySymbol,
|
||||
PERIOD_M5,
|
||||
eaVolume,
|
||||
1.5, // R2R ...
|
||||
mSlippage,
|
||||
magicNumber,
|
||||
eaAllowLong,
|
||||
eaAllowShort,
|
||||
0, // Max Longs
|
||||
0 // Max Shorts
|
||||
);
|
||||
usdjpyM5SRBRStrategy.SetAlertLogAlerts(true);
|
||||
usdjpyM5SRBRStrategy.SetAlertEnableAlerts(true);
|
||||
usdjpyM5SRBRStrategy.DarwSupportAndResistances(drawAreas);
|
||||
RegisterStrategy(usdjpyM5SRBRStrategy);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Register Strategy ...
|
||||
void RegisterStrategy(XSCBaseStrategy *strategy)
|
||||
{
|
||||
//
|
||||
if (strategy == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
ArrayResize(
|
||||
strategies,
|
||||
ArraySize(strategies) + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
strategies[ArraySize(strategies) - 1] = strategy;
|
||||
}
|
||||
|
||||
//
|
||||
// Call All Registered Strategis Tick Handler Functions ...
|
||||
void HandleStrategiesOnTick()
|
||||
{
|
||||
//
|
||||
int count = ArraySize(strategies);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Call Tick Handler Function ...
|
||||
strategies[i].HandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Testing Functions ...
|
||||
|
||||
|
||||
@@ -2075,7 +2075,7 @@ struct XBarTracker
|
||||
int CountBars()
|
||||
{
|
||||
//
|
||||
return Bars(
|
||||
return iBars(
|
||||
symbol,
|
||||
period
|
||||
//
|
||||
@@ -2958,6 +2958,9 @@ struct XSymbolParser
|
||||
//
|
||||
// Forext ...
|
||||
|
||||
//
|
||||
// Symbol Parsing ...
|
||||
|
||||
//
|
||||
bool IsEURUSD(string symbol)
|
||||
{
|
||||
@@ -3245,6 +3248,37 @@ struct XSymbolParser
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Symbol Finder ...
|
||||
string GetEURUSDSymbol() {
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string symbols[];
|
||||
int symbolsCount = GetAllSymbols(
|
||||
symbols //
|
||||
);
|
||||
if (!IsValidSize(symbolsCount)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < symbolsCount; i++) {
|
||||
//
|
||||
string iSymbol = symbols[i];
|
||||
if (IsEURUSD(iSymbol)) {
|
||||
//
|
||||
result = iSymbol;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -503,10 +503,12 @@ struct XPivot
|
||||
|
||||
//
|
||||
bool isSupport;
|
||||
int supportLength;
|
||||
datetime supportTime;
|
||||
|
||||
//
|
||||
bool isResistance;
|
||||
int resistanceLength;
|
||||
datetime resistanceTime;
|
||||
|
||||
//
|
||||
@@ -598,7 +600,7 @@ struct XPivot
|
||||
_symbol,
|
||||
_period //
|
||||
);
|
||||
int maxAllowedBars = bars - 500;
|
||||
int maxAllowedBars = bars / 10;
|
||||
int currentLength = _supResVerificationsStep;
|
||||
|
||||
//
|
||||
@@ -659,6 +661,7 @@ struct XPivot
|
||||
{
|
||||
//
|
||||
supportTime = llBar.time;
|
||||
supportLength = currentLength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -751,7 +754,7 @@ struct XPivot
|
||||
_symbol,
|
||||
_period //
|
||||
);
|
||||
int maxAllowedBars = bars - 500;
|
||||
int maxAllowedBars = bars / 10;
|
||||
int currentLength = _supResVerificationsStep;
|
||||
|
||||
//
|
||||
@@ -812,6 +815,7 @@ struct XPivot
|
||||
{
|
||||
//
|
||||
resistanceTime = hhBar.time;
|
||||
resistanceLength = currentLength;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1294,6 +1298,8 @@ struct XPivot
|
||||
price = 0;
|
||||
|
||||
//
|
||||
supportLength = 0;
|
||||
resistanceLength = 0;
|
||||
breakedAsSupport = 0;
|
||||
rejectedAsSupport = 0;
|
||||
breakedAsResistance = 0;
|
||||
|
||||
@@ -180,7 +180,8 @@ public:
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
if (!result ||
|
||||
(!trendDetector.isUpTrend && !trendDetector.isDownTrend))
|
||||
{
|
||||
//
|
||||
trendDetector.Clean();
|
||||
|
||||
Reference in New Issue
Block a user