last ...
This commit is contained in:
@@ -28,22 +28,40 @@
|
|||||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
#include "../Parsers/x-saherelm.xch.parser.mq5"
|
||||||
#include "../Strategies/x-saherelm.xch.strategy.mq5"
|
#include "../Strategies/x-saherelm.xch.strategy.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inputs ...
|
// Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Common ...
|
||||||
long eaMagicNumber = 78692110; // Magic Number
|
long eaMagicNumber = 78692110; // Magic Number
|
||||||
int eaSlippage = 10; // Slippgae
|
int eaSlippage = 10; // Slippgae
|
||||||
|
string eaLogSuffix = ""; // Log Suffix
|
||||||
|
|
||||||
//
|
//
|
||||||
double eaVolume = 0.01; // Static Volume
|
// Symbols ...
|
||||||
bool eaIgnoreTP = false; // Ignore TP
|
bool eaMultiSymbol = false; // Use Multi Symbol
|
||||||
bool eaIgnoreSL = false; // Ignore SL
|
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
|
||||||
double eaTPPoint = 150; // Static TP Point
|
string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
|
||||||
double eaSLPoint = 500; // Static SL Point
|
// string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
|
||||||
|
|
||||||
//
|
//
|
||||||
double eaR2R = 1.5; // Risk to Reward Ratio
|
// Trades ...
|
||||||
|
double eaVolume = 0.01; // Static Volume
|
||||||
|
double eaR2R = 1.5; // Risk to Reward Ratio for Dynamic TP SL
|
||||||
|
bool eaUseFixedTPSLPoints = true; // Use Fixed TP SL in Points
|
||||||
|
bool eaIgnoreTP = false; // Ignore TP
|
||||||
|
bool eaIgnoreSL = false; // Ignore SL
|
||||||
|
double eaTPPoint = 150; // Static TP Point
|
||||||
|
double eaSLPoint = 500; // Static SL Point
|
||||||
|
|
||||||
|
//
|
||||||
|
// Risk Management ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Risk Management > Trade Management ...
|
||||||
double eaAllowLong = true; // Allow Long Positions
|
double eaAllowLong = true; // Allow Long Positions
|
||||||
double eaAllowShort = true; // Allow Short Positions
|
double eaAllowShort = true; // Allow Short Positions
|
||||||
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
|
int eaMaxAllowedLongs = 1; // Max Allowed Long Positions
|
||||||
@@ -51,10 +69,41 @@ int eaMaxAllowedShorts = 1; // Max Allowed Short Positions
|
|||||||
double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades
|
double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades
|
||||||
|
|
||||||
//
|
//
|
||||||
bool eaMultiSymbol = false; // Use Multi Symbol
|
// Risk Management > Hedging ...
|
||||||
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
|
bool eaAllowHedging = true; // Allow Hedging Trades
|
||||||
string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
|
int eaMinTradesForHedge = 2; // Minimum Open Trades for Hedging
|
||||||
// string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
|
double eaMinimumProfitPerVolumeForHedging = 0.3; // Minimum Required Profit per Volume for Hedging
|
||||||
|
|
||||||
|
//
|
||||||
|
// Risk Management > Trailling Stop ...
|
||||||
|
bool eaAllowTrailStop = false; // Allow Trail Stop
|
||||||
|
double eaStartTrailInPoint = 100; // Trail Start After Profit (Point)
|
||||||
|
double eaTrailStepInPoint = 30; // Trail Size in each Step (Point)
|
||||||
|
bool eaIgnoreTPAfterTrail = true; // Ignore TP after Trail
|
||||||
|
|
||||||
|
//
|
||||||
|
// Risk Management > Trades Recovery ...
|
||||||
|
bool eaAllowRecovery = false; // Allow Recover Trades
|
||||||
|
double eaRecoveryTPPoint = 150; // Recovery TP (Point)
|
||||||
|
double eaRecoverySLPoint = 200; // Recovery SL (Point)
|
||||||
|
int eaMaxAllowedRecoveryTrades = 0; // Max Allowed Recovery Trades
|
||||||
|
double eaRecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier
|
||||||
|
double eaMaxAllowedRecoveryTradesVolume = 0.1; // Max Allowed Recovery Volume
|
||||||
|
|
||||||
|
//
|
||||||
|
// Alert ...
|
||||||
|
bool eAEnableAlerts = true; // Enable Alerts
|
||||||
|
bool eALogAlerts = true; // Log Alerts
|
||||||
|
bool eAMailAlerts = false; // Mail Alerts
|
||||||
|
bool eAPushAlerts = false; // Push Alerts
|
||||||
|
bool eATerminalAlerts = false; // Terminal Alerts
|
||||||
|
|
||||||
|
//
|
||||||
|
// Time Report ...
|
||||||
|
bool eaAlertNewMonths = false; // Alert New Month
|
||||||
|
bool eaAlertNewWeeks = false; // Alert New Weeks
|
||||||
|
bool eaAlertNewDays = false; // Alert New Days
|
||||||
|
bool eaAlertNewHours = false; // Alert New Hours
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variables ...
|
// Variables ...
|
||||||
@@ -87,6 +136,12 @@ XTimeTracker eaTimeTracker;
|
|||||||
// Trade Handler Instance Class ...
|
// Trade Handler Instance Class ...
|
||||||
XSCXTradeHandler *eaTradeHandler;
|
XSCXTradeHandler *eaTradeHandler;
|
||||||
|
|
||||||
|
//
|
||||||
|
string mTag =
|
||||||
|
!IsValid(eaLogSuffix)
|
||||||
|
? ShortName
|
||||||
|
: ShortName + "_" + eaLogSuffix;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Event Handlers ...
|
// Event Handlers ...
|
||||||
|
|
||||||
@@ -107,7 +162,7 @@ int OnInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
drawPrefix = ShortName;
|
drawPrefix = mTag;
|
||||||
|
|
||||||
//
|
//
|
||||||
// EventSetTimer(1);
|
// EventSetTimer(1);
|
||||||
@@ -245,7 +300,12 @@ bool InitialEA()
|
|||||||
//
|
//
|
||||||
// Create Instance of Alert Class ...
|
// Create Instance of Alert Class ...
|
||||||
eaAlert = new XSCAlert();
|
eaAlert = new XSCAlert();
|
||||||
eaAlert.SetPrefix(ShortName);
|
eaAlert.SetPrefix(mTag);
|
||||||
|
eaAlert.SetLogAlerts(eALogAlerts);
|
||||||
|
eaAlert.SetMailAlerts(eAMailAlerts);
|
||||||
|
eaAlert.SetPushAlerts(eAPushAlerts);
|
||||||
|
eaAlert.SetEnableAlerts(eAEnableAlerts);
|
||||||
|
eaAlert.SetTerminalAlerts(eATerminalAlerts);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create Trader Instance ...
|
// Create Trader Instance ...
|
||||||
@@ -260,11 +320,20 @@ bool InitialEA()
|
|||||||
//
|
//
|
||||||
// Initialize Trade Handler ...
|
// Initialize Trade Handler ...
|
||||||
eaTradeHandler = new XSCXTradeHandler(eaTrader);
|
eaTradeHandler = new XSCXTradeHandler(eaTrader);
|
||||||
eaTradeHandler.SetAlertPrefix(ShortName + "> TradeHandler");
|
|
||||||
eaTradeHandler.SaveTrades(true);
|
eaTradeHandler.SaveTrades(true);
|
||||||
eaTradeHandler.SaveSignals(true);
|
eaTradeHandler.SaveSignals(true);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Configure Alerts ...
|
||||||
|
eaTradeHandler.SetAlertPrefix(mTag);
|
||||||
|
eaTradeHandler.SetAlertEnableAlerts(eAEnableAlerts);
|
||||||
|
eaTradeHandler.SetAlertLogAlerts(eALogAlerts);
|
||||||
|
eaTradeHandler.SetAlertMailAlerts(eAMailAlerts);
|
||||||
|
eaTradeHandler.SetAlertPushAlerts(eAPushAlerts);
|
||||||
|
eaTradeHandler.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure Trade Management ...
|
||||||
eaTradeHandler.AllowLong(eaAllowLong);
|
eaTradeHandler.AllowLong(eaAllowLong);
|
||||||
eaTradeHandler.AllowShort(eaAllowShort);
|
eaTradeHandler.AllowShort(eaAllowShort);
|
||||||
eaTradeHandler.MaxAllowedLongs(eaMaxAllowedLongs);
|
eaTradeHandler.MaxAllowedLongs(eaMaxAllowedLongs);
|
||||||
@@ -274,34 +343,35 @@ bool InitialEA()
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Configure Hedging ...
|
// Configure Hedging ...
|
||||||
eaTradeHandler.AllowHedging(true);
|
eaTradeHandler.AllowHedging(eaAllowHedging);
|
||||||
eaTradeHandler.MinTradesForHedge(2);
|
|
||||||
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
||||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.3);
|
eaTradeHandler.MinTradesForHedge(eaMinTradesForHedge);
|
||||||
|
eaTradeHandler.HedgeMinProfitPerVolumeFactor(eaMinimumProfitPerVolumeForHedging);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Trailing ...
|
// Configure Trailing ...
|
||||||
eaTradeHandler.AllowTrailStops(false);
|
eaTradeHandler.AllowTrailStops(eaAllowTrailStop);
|
||||||
eaTradeHandler.TrailStepInPoint(30);
|
|
||||||
eaTradeHandler.TrailStartInPoint(100);
|
|
||||||
eaTradeHandler.IgnoreTPOnTrail(true);
|
|
||||||
eaTradeHandler.TrailBasedOnProfit(true);
|
eaTradeHandler.TrailBasedOnProfit(true);
|
||||||
|
eaTradeHandler.TrailStartInPoint(eaStartTrailInPoint);
|
||||||
|
eaTradeHandler.TrailStepInPoint(eaTrailStepInPoint);
|
||||||
|
eaTradeHandler.IgnoreTPOnTrail(eaIgnoreTPAfterTrail);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Recovery ...
|
// Configure Recovery ...
|
||||||
eaTradeHandler.AllowRecover(false);
|
eaTradeHandler.AllowRecover(eaAllowRecovery);
|
||||||
eaTradeHandler.RecoveryTPPoint(150);
|
|
||||||
eaTradeHandler.MaxAllowedRecover(0);
|
|
||||||
eaTradeHandler.MaxAllowedRecoveryVolume(0.1);
|
|
||||||
eaTradeHandler.RecoverySLPoint(200);
|
|
||||||
eaTradeHandler.RecoveryVolumeMultiplier(2);
|
|
||||||
eaTradeHandler.ForcePressuresInRecovery(false);
|
eaTradeHandler.ForcePressuresInRecovery(false);
|
||||||
|
eaTradeHandler.RecoveryTPPoint(eaRecoveryTPPoint);
|
||||||
|
eaTradeHandler.RecoverySLPoint(eaRecoverySLPoint);
|
||||||
|
eaTradeHandler.MaxAllowedRecover(eaMaxAllowedRecoveryTrades);
|
||||||
|
eaTradeHandler.RecoveryVolumeMultiplier(eaRecoveryVolumeMultiplier);
|
||||||
|
eaTradeHandler.MaxAllowedRecoveryVolume(eaMaxAllowedRecoveryTradesVolume);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Single Symbol ...
|
// Single Symbol ...
|
||||||
if (!eaMultiSymbol)
|
if (!eaMultiSymbol)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Create Class Instance ...
|
||||||
XSCXCHStrategy *xchStrategy;
|
XSCXCHStrategy *xchStrategy;
|
||||||
xchStrategy = new XSCXCHStrategy(
|
xchStrategy = new XSCXCHStrategy(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
@@ -311,11 +381,11 @@ bool InitialEA()
|
|||||||
eaR2R, // R2R ...
|
eaR2R, // R2R ...
|
||||||
eaSlippage,
|
eaSlippage,
|
||||||
eaMagicNumber,
|
eaMagicNumber,
|
||||||
true, // Ignore Signal Execution
|
true, // Ignore Signal Execution
|
||||||
true, // Use TP SL Point
|
eaUseFixedTPSLPoints, // Use TP SL Point
|
||||||
false, // Use Max
|
false, // Use Max
|
||||||
eaTPPoint, // TP
|
eaTPPoint, // TP
|
||||||
eaSLPoint, // SL
|
eaSLPoint, // SL
|
||||||
eaIgnoreTP,
|
eaIgnoreTP,
|
||||||
eaIgnoreSL,
|
eaIgnoreSL,
|
||||||
eaAllowLong,
|
eaAllowLong,
|
||||||
@@ -323,14 +393,27 @@ bool InitialEA()
|
|||||||
eaMaxAllowedLongs, // Max Longs
|
eaMaxAllowedLongs, // Max Longs
|
||||||
eaMaxAllowedShorts // Max Shorts
|
eaMaxAllowedShorts // Max Shorts
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configuere Strategy ...
|
||||||
xchStrategy.EnableXCHM(true);
|
xchStrategy.EnableXCHM(true);
|
||||||
xchStrategy.EnableXCHHK(true);
|
xchStrategy.EnableXCHHK(true);
|
||||||
xchStrategy.EnableXCHSTR(true);
|
xchStrategy.EnableXCHSTR(true);
|
||||||
xchStrategy.EnableXCHCHE(true);
|
xchStrategy.EnableXCHCHE(true);
|
||||||
xchStrategy.SetAlertLogAlerts(true);
|
|
||||||
xchStrategy.DrawImportantAreas(false);
|
xchStrategy.DrawImportantAreas(false);
|
||||||
xchStrategy.SetAlertEnableAlerts(true);
|
|
||||||
xchStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
|
xchStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure Alerts ...
|
||||||
|
xchStrategy.SetAlertPrefix(mTag);
|
||||||
|
xchStrategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||||
|
xchStrategy.SetAlertLogAlerts(eALogAlerts);
|
||||||
|
xchStrategy.SetAlertMailAlerts(eAMailAlerts);
|
||||||
|
xchStrategy.SetAlertPushAlerts(eAPushAlerts);
|
||||||
|
xchStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Strategy ...
|
||||||
RegisterStrategy(xchStrategy);
|
RegisterStrategy(xchStrategy);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -354,9 +437,11 @@ bool InitialEA()
|
|||||||
for (int i = 0; i < symbolsCount; i++)
|
for (int i = 0; i < symbolsCount; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
// Select Symbol ...
|
||||||
string iSymbol = symbols[i];
|
string iSymbol = symbols[i];
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Create Class Instance ...
|
||||||
XSCXCHStrategy *iStrategy;
|
XSCXCHStrategy *iStrategy;
|
||||||
iStrategy = new XSCXCHStrategy(
|
iStrategy = new XSCXCHStrategy(
|
||||||
iSymbol,
|
iSymbol,
|
||||||
@@ -378,16 +463,27 @@ bool InitialEA()
|
|||||||
eaMaxAllowedLongs, // Max Longs
|
eaMaxAllowedLongs, // Max Longs
|
||||||
eaMaxAllowedShorts // Max Shorts
|
eaMaxAllowedShorts // Max Shorts
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configuere Strategy ...
|
||||||
iStrategy.EnableXCHM(true);
|
iStrategy.EnableXCHM(true);
|
||||||
iStrategy.EnableXCHHK(true);
|
iStrategy.EnableXCHHK(true);
|
||||||
iStrategy.EnableXCHSTR(true);
|
iStrategy.EnableXCHSTR(true);
|
||||||
iStrategy.EnableXCHCHE(true);
|
iStrategy.EnableXCHCHE(true);
|
||||||
iStrategy.SetAlertLogAlerts(true);
|
|
||||||
iStrategy.DrawImportantAreas(false);
|
iStrategy.DrawImportantAreas(false);
|
||||||
iStrategy.SetAlertEnableAlerts(true);
|
|
||||||
iStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
|
iStrategy.AddXCHSignalEventHandler(OnSignalRecieved);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Configure Alerts ...
|
||||||
|
iStrategy.SetAlertPrefix(mTag);
|
||||||
|
iStrategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||||
|
iStrategy.SetAlertLogAlerts(eALogAlerts);
|
||||||
|
iStrategy.SetAlertMailAlerts(eAMailAlerts);
|
||||||
|
iStrategy.SetAlertPushAlerts(eAPushAlerts);
|
||||||
|
iStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register Strategy ...
|
||||||
RegisterStrategy(iStrategy);
|
RegisterStrategy(iStrategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,7 +550,33 @@ void HandleTradeState()
|
|||||||
void HandleTimeReport()
|
void HandleTimeReport()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (eaTimeTracker.IsNewDay())
|
// Monthly Report ....
|
||||||
|
if (eaAlertNewMonths &&
|
||||||
|
eaTimeTracker.IsNewMonth())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Month ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Weekly Report ....
|
||||||
|
if (eaAlertNewWeeks &&
|
||||||
|
eaTimeTracker.IsNewWeek())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Week ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Daily Report ....
|
||||||
|
if (eaAlertNewDays &&
|
||||||
|
eaTimeTracker.IsNewDay())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
string msg = "New Day ...";
|
string msg = "New Day ...";
|
||||||
@@ -462,6 +584,18 @@ void HandleTimeReport()
|
|||||||
//
|
//
|
||||||
eaAlert.Alert(msg);
|
eaAlert.Alert(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Hourly Report ....
|
||||||
|
if (eaAlertNewHours &&
|
||||||
|
eaTimeTracker.IsNewHour())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string msg = "New Hour ...";
|
||||||
|
|
||||||
|
//
|
||||||
|
eaAlert.Alert(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user