last ...
This commit is contained in:
@@ -28,22 +28,40 @@
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
|
||||
//
|
||||
#include "../Parsers/x-saherelm.xch.parser.mq5"
|
||||
#include "../Strategies/x-saherelm.xch.strategy.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
// Common ...
|
||||
long eaMagicNumber = 78692110; // Magic Number
|
||||
int eaSlippage = 10; // Slippgae
|
||||
string eaLogSuffix = ""; // Log Suffix
|
||||
|
||||
//
|
||||
double eaVolume = 0.01; // Static Volume
|
||||
bool eaIgnoreTP = false; // Ignore TP
|
||||
bool eaIgnoreSL = false; // Ignore SL
|
||||
double eaTPPoint = 150; // Static TP Point
|
||||
double eaSLPoint = 500; // Static SL Point
|
||||
// Symbols ...
|
||||
bool eaMultiSymbol = false; // Use Multi Symbol
|
||||
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
|
||||
string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
|
||||
// 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 eaAllowShort = true; // Allow Short 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
|
||||
|
||||
//
|
||||
bool eaMultiSymbol = false; // Use Multi Symbol
|
||||
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
|
||||
string eaSymbols = "EURUSDb,USDJPYb"; // Trading Symbols
|
||||
// string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
|
||||
// Risk Management > Hedging ...
|
||||
bool eaAllowHedging = true; // Allow Hedging Trades
|
||||
int eaMinTradesForHedge = 2; // Minimum Open Trades for Hedging
|
||||
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 ...
|
||||
@@ -87,6 +136,12 @@ XTimeTracker eaTimeTracker;
|
||||
// Trade Handler Instance Class ...
|
||||
XSCXTradeHandler *eaTradeHandler;
|
||||
|
||||
//
|
||||
string mTag =
|
||||
!IsValid(eaLogSuffix)
|
||||
? ShortName
|
||||
: ShortName + "_" + eaLogSuffix;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -107,7 +162,7 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
drawPrefix = ShortName;
|
||||
drawPrefix = mTag;
|
||||
|
||||
//
|
||||
// EventSetTimer(1);
|
||||
@@ -245,7 +300,12 @@ bool InitialEA()
|
||||
//
|
||||
// Create Instance of Alert Class ...
|
||||
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 ...
|
||||
@@ -260,11 +320,20 @@ bool InitialEA()
|
||||
//
|
||||
// Initialize Trade Handler ...
|
||||
eaTradeHandler = new XSCXTradeHandler(eaTrader);
|
||||
eaTradeHandler.SetAlertPrefix(ShortName + "> TradeHandler");
|
||||
eaTradeHandler.SaveTrades(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.AllowShort(eaAllowShort);
|
||||
eaTradeHandler.MaxAllowedLongs(eaMaxAllowedLongs);
|
||||
@@ -274,34 +343,35 @@ bool InitialEA()
|
||||
|
||||
//
|
||||
// Configure Hedging ...
|
||||
eaTradeHandler.AllowHedging(true);
|
||||
eaTradeHandler.MinTradesForHedge(2);
|
||||
eaTradeHandler.AllowHedging(eaAllowHedging);
|
||||
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.3);
|
||||
eaTradeHandler.MinTradesForHedge(eaMinTradesForHedge);
|
||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(eaMinimumProfitPerVolumeForHedging);
|
||||
|
||||
//
|
||||
// Configure Trailing ...
|
||||
eaTradeHandler.AllowTrailStops(false);
|
||||
eaTradeHandler.TrailStepInPoint(30);
|
||||
eaTradeHandler.TrailStartInPoint(100);
|
||||
eaTradeHandler.IgnoreTPOnTrail(true);
|
||||
eaTradeHandler.AllowTrailStops(eaAllowTrailStop);
|
||||
eaTradeHandler.TrailBasedOnProfit(true);
|
||||
eaTradeHandler.TrailStartInPoint(eaStartTrailInPoint);
|
||||
eaTradeHandler.TrailStepInPoint(eaTrailStepInPoint);
|
||||
eaTradeHandler.IgnoreTPOnTrail(eaIgnoreTPAfterTrail);
|
||||
|
||||
//
|
||||
// Configure Recovery ...
|
||||
eaTradeHandler.AllowRecover(false);
|
||||
eaTradeHandler.RecoveryTPPoint(150);
|
||||
eaTradeHandler.MaxAllowedRecover(0);
|
||||
eaTradeHandler.MaxAllowedRecoveryVolume(0.1);
|
||||
eaTradeHandler.RecoverySLPoint(200);
|
||||
eaTradeHandler.RecoveryVolumeMultiplier(2);
|
||||
eaTradeHandler.AllowRecover(eaAllowRecovery);
|
||||
eaTradeHandler.ForcePressuresInRecovery(false);
|
||||
eaTradeHandler.RecoveryTPPoint(eaRecoveryTPPoint);
|
||||
eaTradeHandler.RecoverySLPoint(eaRecoverySLPoint);
|
||||
eaTradeHandler.MaxAllowedRecover(eaMaxAllowedRecoveryTrades);
|
||||
eaTradeHandler.RecoveryVolumeMultiplier(eaRecoveryVolumeMultiplier);
|
||||
eaTradeHandler.MaxAllowedRecoveryVolume(eaMaxAllowedRecoveryTradesVolume);
|
||||
|
||||
//
|
||||
// Single Symbol ...
|
||||
if (!eaMultiSymbol)
|
||||
{
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XSCXCHStrategy *xchStrategy;
|
||||
xchStrategy = new XSCXCHStrategy(
|
||||
_Symbol,
|
||||
@@ -311,11 +381,11 @@ bool InitialEA()
|
||||
eaR2R, // R2R ...
|
||||
eaSlippage,
|
||||
eaMagicNumber,
|
||||
true, // Ignore Signal Execution
|
||||
true, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
true, // Ignore Signal Execution
|
||||
eaUseFixedTPSLPoints, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
eaIgnoreTP,
|
||||
eaIgnoreSL,
|
||||
eaAllowLong,
|
||||
@@ -323,14 +393,27 @@ bool InitialEA()
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
|
||||
//
|
||||
// Configuere Strategy ...
|
||||
xchStrategy.EnableXCHM(true);
|
||||
xchStrategy.EnableXCHHK(true);
|
||||
xchStrategy.EnableXCHSTR(true);
|
||||
xchStrategy.EnableXCHCHE(true);
|
||||
xchStrategy.SetAlertLogAlerts(true);
|
||||
xchStrategy.DrawImportantAreas(false);
|
||||
xchStrategy.SetAlertEnableAlerts(true);
|
||||
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);
|
||||
}
|
||||
//
|
||||
@@ -354,9 +437,11 @@ bool InitialEA()
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Select Symbol ...
|
||||
string iSymbol = symbols[i];
|
||||
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XSCXCHStrategy *iStrategy;
|
||||
iStrategy = new XSCXCHStrategy(
|
||||
iSymbol,
|
||||
@@ -378,16 +463,27 @@ bool InitialEA()
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
|
||||
//
|
||||
// Configuere Strategy ...
|
||||
iStrategy.EnableXCHM(true);
|
||||
iStrategy.EnableXCHHK(true);
|
||||
iStrategy.EnableXCHSTR(true);
|
||||
iStrategy.EnableXCHCHE(true);
|
||||
iStrategy.SetAlertLogAlerts(true);
|
||||
iStrategy.DrawImportantAreas(false);
|
||||
iStrategy.SetAlertEnableAlerts(true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -454,7 +550,33 @@ void HandleTradeState()
|
||||
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 ...";
|
||||
@@ -462,6 +584,18 @@ void HandleTimeReport()
|
||||
//
|
||||
eaAlert.Alert(msg);
|
||||
}
|
||||
|
||||
//
|
||||
// Hourly Report ....
|
||||
if (eaAlertNewHours &&
|
||||
eaTimeTracker.IsNewHour())
|
||||
{
|
||||
//
|
||||
string msg = "New Hour ...";
|
||||
|
||||
//
|
||||
eaAlert.Alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user