Cleanup Backups ...
This commit is contained in:
Binary file not shown.
@@ -1,346 +0,0 @@
|
|||||||
//
|
|
||||||
// Detect Inside Zones ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XCFVG *insideFVG;
|
|
||||||
bool hasInsideFVG = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
XCOrderBlock *insideOB;
|
|
||||||
bool hasInsideOB = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSupplyZone *insideSupply;
|
|
||||||
bool hasInsideSupply = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
XCDemandZone *insideDemand;
|
|
||||||
bool hasInsideDemand = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSupportZone *insideSupport;
|
|
||||||
bool hasInsideSupport = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
XCResistanceZone *insideResistnce;
|
|
||||||
bool hasInsideResistance = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect PullBack ...
|
|
||||||
|
|
||||||
//
|
|
||||||
ENUM_X_DIRECTION pullbackDir;
|
|
||||||
bool hasPullBack = mXWZBarAnalyser.HasPullBack(
|
|
||||||
pullbackDir,
|
|
||||||
iBar //
|
|
||||||
);
|
|
||||||
bool hasBullishPullBack =
|
|
||||||
hasPullBack &&
|
|
||||||
IsBullish(pullbackDir);
|
|
||||||
bool hasBearishPullBack =
|
|
||||||
hasPullBack &&
|
|
||||||
IsBearish(pullbackDir);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect PinBar ...
|
|
||||||
|
|
||||||
//
|
|
||||||
ENUM_X_DIRECTION pinBarDir;
|
|
||||||
bool hasPinBar = mXWZBarAnalyser.IsPinBar(
|
|
||||||
iBar,
|
|
||||||
pinBarDir,
|
|
||||||
0 //
|
|
||||||
);
|
|
||||||
bool hasBullishPinBar =
|
|
||||||
hasPinBar &&
|
|
||||||
IsBullish(pinBarDir);
|
|
||||||
bool hasBearishPinBar =
|
|
||||||
hasPinBar &&
|
|
||||||
IsBearish(pinBarDir);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Order Block ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL obBar;
|
|
||||||
XCOrderBlock *ob;
|
|
||||||
ENUM_X_DIRECTION obDir;
|
|
||||||
bool hasOB = mXWZBarAnalyser.HasOrderBlock(
|
|
||||||
iBar,
|
|
||||||
obBar,
|
|
||||||
obDir //
|
|
||||||
);
|
|
||||||
bool hasBullishOB =
|
|
||||||
hasOB &&
|
|
||||||
IsBullish(obDir);
|
|
||||||
bool hasBearishOB =
|
|
||||||
hasOB &&
|
|
||||||
IsBearish(obDir);
|
|
||||||
if (hasOB)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
ob = new XCOrderBlock();
|
|
||||||
bool isInited = ob.Init(obBar, obDir);
|
|
||||||
if (isInited)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
ENUM_X_DIRECTION forDir = ob.GetDirection();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check OB Not Activated ...
|
|
||||||
XOHCL activationBar;
|
|
||||||
bool isObActivationBarBodyIn = false;
|
|
||||||
bool isActivated = ob.IsActivated(
|
|
||||||
forDir,
|
|
||||||
activationBar,
|
|
||||||
isObActivationBarBodyIn,
|
|
||||||
false,
|
|
||||||
_Period //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isActivated)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
hasOB = false;
|
|
||||||
obBar.Clean();
|
|
||||||
ZeroMemory(ob);
|
|
||||||
hasBullishOB = false;
|
|
||||||
hasBearishOB = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasBullishPinBar)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCBarArrowObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateBarArrow(
|
|
||||||
iBar,
|
|
||||||
iObj,
|
|
||||||
X_PRICE_LOW,
|
|
||||||
159,
|
|
||||||
clrAqua,
|
|
||||||
3,
|
|
||||||
ANCHOR_BOTTOM,
|
|
||||||
"BULLPULL" //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasBearishPinBar)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCBarArrowObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateBarArrow(
|
|
||||||
iBar,
|
|
||||||
iObj,
|
|
||||||
X_PRICE_HIGH,
|
|
||||||
159,
|
|
||||||
clrMagenta,
|
|
||||||
3,
|
|
||||||
ANCHOR_TOP,
|
|
||||||
"BEARPULL" //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasOB)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCBaseObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer.CreateOrderBlock(
|
|
||||||
ob,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int idx = -1;
|
|
||||||
int count = 0;
|
|
||||||
bool has = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
ENUM_X_DIRECTION trend =
|
|
||||||
IsValid(lastBullishTrend) &&
|
|
||||||
lastBullishTrend > lastBearishTrend
|
|
||||||
? X_DIRECTION_BULLISH
|
|
||||||
: IsValid(lastBearishTrend) &&
|
|
||||||
lastBearishTrend > lastBullishTrend
|
|
||||||
? X_DIRECTION_BEARISH
|
|
||||||
: X_DIRECTION_NONE;
|
|
||||||
bool hasTrend = HasDirection(trend);
|
|
||||||
bool hasBullishTrend = hasTrend &&
|
|
||||||
IsBullish(trend);
|
|
||||||
bool hasBearishTrend = hasTrend &&
|
|
||||||
IsBearish(trend);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Order Block ...
|
|
||||||
has = hasBullishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
has = hasBearishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fair Value Gap ...
|
|
||||||
has = hasBullishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
has = hasBearishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Supply Zone ...
|
|
||||||
has = hasBearishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Resistance Zone ...
|
|
||||||
has = hasBearishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Demand Zone ...
|
|
||||||
has = hasBullishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Support Zone ...
|
|
||||||
has = hasBullishTrend;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw Inside Zones ...
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideOB)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCBaseObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateOrderBlock(
|
|
||||||
insideOB,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideFVG)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCBaseObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateFairValueGap(
|
|
||||||
insideFVG,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideSupply)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupplyZoneObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateSupplyZone(
|
|
||||||
insideSupply,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideDemand)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCDemandZoneObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateDemandZone(
|
|
||||||
insideDemand,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideSupport)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZoneObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateSupportZone(
|
|
||||||
insideSupport,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (hasInsideResistance)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZoneObject *iObj;
|
|
||||||
bool isCreated = mXWZPOIDrawer
|
|
||||||
.CreateResistanceZone(
|
|
||||||
insideResistnce,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
//
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
mXWZDrawnObjects.Add(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,464 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SaherElm IT Center XTest MQL5 Expert Advisor
|
|
||||||
// -------------------------------------------------
|
|
||||||
// Name: X121SMCEA
|
|
||||||
// Description: an Exper Advisor which used Panels
|
|
||||||
//
|
|
||||||
// Maintainer:
|
|
||||||
// ------------
|
|
||||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Global Properties ...
|
|
||||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
||||||
#property link "https://saherelm.ir"
|
|
||||||
#property version "1.00"
|
|
||||||
#property description "SaherElm X121SMCEA"
|
|
||||||
#property strict
|
|
||||||
|
|
||||||
//
|
|
||||||
#define ShortName "X121SMCEA"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Imports ...
|
|
||||||
#include "../X121SMCEA/Experts/x-121.smc.expert.alert.class.mq5"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Inputs ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Common ...
|
|
||||||
input group "Common";
|
|
||||||
input long eaMagicNumber = 78692110; // Magic Number
|
|
||||||
input int eaSlippage = 10; // Slippgae
|
|
||||||
input string eaLogSuffix = ""; // Log Suffix
|
|
||||||
|
|
||||||
//
|
|
||||||
// Symbols ...
|
|
||||||
input group "Symbols";
|
|
||||||
input bool eaMultiSymbol = false; // Use Multi Symbol
|
|
||||||
input string eaSymbols = "EURUSDb"; // Trading Symbols
|
|
||||||
|
|
||||||
//
|
|
||||||
// Signalling ...
|
|
||||||
input group "Signalling";
|
|
||||||
input bool eaAllowLong = true; // Allow Long Signals
|
|
||||||
input bool eaAllowShort = true; // Allow Short Signals
|
|
||||||
input int eaMaxAllowedLongs = 5; // Max Allowed Long Signals
|
|
||||||
input int eaMaxAllowedShorts = 5; // Max Allowed Short Signals
|
|
||||||
input bool eaUseMaxAllowedSignalsPerSymbol = true; // Use Max Allowed Signal Types Per Symbol
|
|
||||||
input double eaLastPositionProfitForAcceptNextInPoint = 0; // Last Position Profit In Points for Accept new Signal
|
|
||||||
input int eaDelaysBetweenTwoSignalsInBar = 0; // Delay between two Signals in Bars
|
|
||||||
input double eaMaxAllowedSpread = 25; // Max Allowed Spread for Signalling
|
|
||||||
input int eaMinRequiredVerificationForSpreadPass = 20; // Minimum Spread Verification for Signalling
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trade ...
|
|
||||||
input group "Trade";
|
|
||||||
input bool eaAllowTrade = false; // Allow Open Trade On Signals
|
|
||||||
input string eaStartTradeAt = ""; // Enable Trade on Signals on Time
|
|
||||||
input string eaStopTradeAt = ""; // Enable Trade on Signals on Time
|
|
||||||
input string eaCloseAllTradesAt = ""; // Enable Close All Trades on Signals on Time
|
|
||||||
|
|
||||||
//
|
|
||||||
// Risk Management ...
|
|
||||||
input group "Risk Management";
|
|
||||||
input double eaR2R = 4; // Signallers Risk to Reward Ratio
|
|
||||||
input double eaVolume = 0; // Static Volume
|
|
||||||
input double eaStaticBalance = 1000; // Static Balance
|
|
||||||
input double eaBalancePerTrade = 10; // Balance Used in Each Trade
|
|
||||||
input double eaRiskPercentPerBalance = 0; // Risk Percent Per Balance in Each Trade
|
|
||||||
input bool eaDynamicRiskManagement = false; // Dynamic Risk Management
|
|
||||||
input bool eaUseDynamicVolume = false; // Use Dynamic Volume
|
|
||||||
input double eaDynamicVolumeStep = 0.01; // Increase Volume Step
|
|
||||||
input double eaDynamicVolumeBalanceFactor = 200; // Balance Factor for Generate Dynamic Volume
|
|
||||||
input double eaMaxAllowedDrawdownToOpenTrades = 3; // Max Allowed Drawdown for Open Trades
|
|
||||||
input int eaMaxAllowedSLToPauseSignallingPerSymbol = 2; // Max Allowed SL for Pause Signalling Per Symbol
|
|
||||||
input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 7200; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds
|
|
||||||
|
|
||||||
//
|
|
||||||
// Protection ...
|
|
||||||
input group "Protection";
|
|
||||||
input bool eaAllowHedging = false; // Allow Hedge Positions
|
|
||||||
input int eaMinOpenTradesFroHedging = 4; // Minimum Open Positions for Hedging
|
|
||||||
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
|
|
||||||
input double eaHedgeingMinRequiredProfitPerVolumeStep = 2.0; // Minimum Required Profit Per Volume Step for Hedging
|
|
||||||
|
|
||||||
//
|
|
||||||
// Alert ...
|
|
||||||
// Here we Provider All Requirements for
|
|
||||||
// Configuring Alert Provider ...
|
|
||||||
input group "Alert";
|
|
||||||
input bool eaEnableAlerts = true; // Enable Alerts
|
|
||||||
input bool eaLogAlerts = true; // Log Alerts
|
|
||||||
input bool eaMailAlerts = false; // Mail Alerts
|
|
||||||
input bool eaPushAlerts = true; // Push Alerts
|
|
||||||
input bool eaTerminalAlerts = false; // Terminal Alerts
|
|
||||||
|
|
||||||
//
|
|
||||||
// Time Report ...
|
|
||||||
input group "Reports";
|
|
||||||
input bool eaReportNewMonths = false; // Report New Month
|
|
||||||
input bool eaReportNewWeeks = false; // Report New Weeks
|
|
||||||
input bool eaReportNewDays = true; // Report New Days
|
|
||||||
input bool eaReportNewHours = false; // Report New Hours
|
|
||||||
|
|
||||||
//
|
|
||||||
// Define Local Variables ...
|
|
||||||
|
|
||||||
XC121SMCExpert *eaExpert;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Event Handlers ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialization ...
|
|
||||||
int OnInit()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Validate Inputs and Required Parameters
|
|
||||||
// for EA to Works fine ...
|
|
||||||
if (!ValidateInputs())
|
|
||||||
{
|
|
||||||
return INIT_PARAMETERS_INCORRECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize Timer ...
|
|
||||||
if (!InitTimer())
|
|
||||||
{
|
|
||||||
return INIT_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Configure EA Expert Class ...
|
|
||||||
eaExpert = new XC121SMCExpert();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Event Handlers ...
|
|
||||||
eaExpert.OnSignalEventListener = OnSignalRecieved;
|
|
||||||
eaExpert.OnDealsChangedEventListener = OnDealsChanged;
|
|
||||||
eaExpert.OnOrdersChangedEventListener = OnOrdersChanged;
|
|
||||||
eaExpert.OnPositionSLEventListener = OnStopLossTriggered;
|
|
||||||
eaExpert.OnPositionTPEventListener = OnTakeProfitTriggered;
|
|
||||||
eaExpert.OnPositionsChangedEventListener = OnPositionsChanged;
|
|
||||||
eaExpert.OnPositionForceCloseEventListener = OnPositionForceClosed;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Common ...
|
|
||||||
eaExpert.MagicNumber(eaMagicNumber);
|
|
||||||
eaExpert.Slippage(eaSlippage);
|
|
||||||
eaExpert.TagPrefix(eaLogSuffix);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Symbol ...
|
|
||||||
eaExpert.SetSymbol(_Symbol);
|
|
||||||
eaExpert.SetPeriod(_Period);
|
|
||||||
eaExpert.Symbols(eaSymbols);
|
|
||||||
eaExpert.MultiSymbol(eaMultiSymbol);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Signalling ...
|
|
||||||
eaExpert.AllowLong(eaAllowLong);
|
|
||||||
eaExpert.AllowShort(eaAllowShort);
|
|
||||||
eaExpert.MaxAllowedLongs(eaMaxAllowedLongs);
|
|
||||||
eaExpert.MaxAllowedShorts(eaMaxAllowedShorts);
|
|
||||||
eaExpert.UseMaxAllowedSignalsPerSymbol(eaUseMaxAllowedSignalsPerSymbol);
|
|
||||||
eaExpert.LastPositionProfitForAcceptNextInPoint(eaLastPositionProfitForAcceptNextInPoint);
|
|
||||||
eaExpert.DelaysBetweenTwoSignalsInBar(eaDelaysBetweenTwoSignalsInBar);
|
|
||||||
eaExpert.MaxAllowedSpread(eaMaxAllowedSpread);
|
|
||||||
eaExpert.MinRequiredVerificationForSpreadPass(eaMinRequiredVerificationForSpreadPass);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trade ...
|
|
||||||
eaExpert.AllowTrade(eaAllowTrade);
|
|
||||||
eaExpert.StartTradeAt(eaStartTradeAt);
|
|
||||||
eaExpert.StopTradeAt(eaStopTradeAt);
|
|
||||||
eaExpert.CloseAllTradesAt(eaCloseAllTradesAt);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Risk Management ...
|
|
||||||
eaExpert.R2R(eaR2R);
|
|
||||||
eaExpert.Volume(eaVolume);
|
|
||||||
eaExpert.StaticBalance(eaStaticBalance);
|
|
||||||
eaExpert.BalancePerTrade(eaBalancePerTrade);
|
|
||||||
eaExpert.RiskPercentPerBalance(eaRiskPercentPerBalance);
|
|
||||||
eaExpert.DynamicRiskManagement(eaDynamicRiskManagement);
|
|
||||||
eaExpert.UseDynamicVolume(eaUseDynamicVolume);
|
|
||||||
eaExpert.DynamicVolumeStep(eaDynamicVolumeStep);
|
|
||||||
eaExpert.DynamicVolumeBalanceFactor(eaDynamicVolumeBalanceFactor);
|
|
||||||
eaExpert.MaxAllowedDrawdownToOpenTrades(eaMaxAllowedDrawdownToOpenTrades);
|
|
||||||
eaExpert.MaxAllowedSLToPauseSignallingPerSymbol(eaMaxAllowedSLToPauseSignallingPerSymbol);
|
|
||||||
eaExpert.PauseSignallingAfterReachesMaxAllowedSLInSecconds(eaPauseSignallingAfterReachesMaxAllowedSLInSecconds);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Protection ...
|
|
||||||
eaExpert.AllowHedging(eaAllowHedging);
|
|
||||||
eaExpert.MinOpenTradesFroHedging(eaMinOpenTradesFroHedging);
|
|
||||||
eaExpert.HedgingMinVolumeStep(eaHedgingMinVolumeStep);
|
|
||||||
eaExpert.HedgeingMinRequiredProfitPerVolumeStep(eaHedgeingMinRequiredProfitPerVolumeStep);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Alert ...
|
|
||||||
eaExpert.SetAlertEnableAlerts(eaEnableAlerts);
|
|
||||||
eaExpert.SetAlertLogAlerts(eaLogAlerts);
|
|
||||||
eaExpert.SetAlertMailAlerts(eaMailAlerts);
|
|
||||||
eaExpert.SetAlertPushAlerts(eaPushAlerts);
|
|
||||||
eaExpert.SetAlertTerminalAlerts(eaTerminalAlerts);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reports ...
|
|
||||||
eaExpert.ReportNewMonths(eaReportNewMonths);
|
|
||||||
eaExpert.ReportNewWeeks(eaReportNewWeeks);
|
|
||||||
eaExpert.ReportNewDays(eaReportNewDays);
|
|
||||||
eaExpert.ReportNewHours(eaReportNewHours);
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isInited = eaExpert.HandleOnInit();
|
|
||||||
if (!isInited)
|
|
||||||
{
|
|
||||||
return INIT_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Init Succeed ...
|
|
||||||
return INIT_SUCCEEDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// DeInitialization ...
|
|
||||||
void OnDeinit(const int reason)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
|
||||||
// REASON_REMOVE 1 Program removed from a chart
|
|
||||||
// REASON_RECOMPILE 2 Program recompiled
|
|
||||||
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
|
||||||
// REASON_CHARTCLOSE 4 Chart closed
|
|
||||||
// REASON_PARAMETERS 5 Inputs changed by a user
|
|
||||||
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
|
||||||
// REASON_TEMPLATE 7 Another chart template applied
|
|
||||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
|
||||||
// REASON_CLOSE 9 Terminal closed
|
|
||||||
|
|
||||||
//
|
|
||||||
// Destroy Timer ...
|
|
||||||
eaExpert.HandleOnDeInit();
|
|
||||||
|
|
||||||
//
|
|
||||||
delete eaExpert;
|
|
||||||
|
|
||||||
//
|
|
||||||
ZeroMemory(eaExpert);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// On Tick Handler ...
|
|
||||||
void OnTick()
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Handle On Trade Event ...
|
|
||||||
void OnTrade()
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnTrade();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// On Timer ...
|
|
||||||
void OnTimer()
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Chart Event Handler ...
|
|
||||||
void OnChartEvent(
|
|
||||||
const int id,
|
|
||||||
const long &lparam,
|
|
||||||
const double &dparam,
|
|
||||||
const string &sparam //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnChartEvent(id, lparam, dparam, sparam);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Event Listeners ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do What we Want by Specific Signal ...
|
|
||||||
*
|
|
||||||
* @param signal: XSignal instance ...
|
|
||||||
* @param conditions: XStrategyConditions instance ...
|
|
||||||
*/
|
|
||||||
void OnSignalRecieved(
|
|
||||||
XSignal &signal,
|
|
||||||
X121SMCStrategyConditions &conditions //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
eaExpert.HandleOnSignalRecieved(
|
|
||||||
signal,
|
|
||||||
conditions //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle StopLoss Triggered Positions ...
|
|
||||||
*
|
|
||||||
* @param deal: XDeal instance ...
|
|
||||||
*/
|
|
||||||
void OnStopLossTriggered(const XDeal &deal)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnStopLossTriggered(deal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Take Profit Triggered Positions ...
|
|
||||||
*
|
|
||||||
* @param deal: XDeal instance ...
|
|
||||||
*/
|
|
||||||
void OnTakeProfitTriggered(const XDeal &deal)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnTakeProfitTriggered(deal);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Force Close a Position ...
|
|
||||||
*
|
|
||||||
* @param ticket: ULONG ...
|
|
||||||
* @param position: XPosition instance ...
|
|
||||||
* @param comment: String ...
|
|
||||||
*/
|
|
||||||
void OnPositionForceClosed(
|
|
||||||
const ulong ticket,
|
|
||||||
const XPosition &position,
|
|
||||||
const string comment //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
eaExpert.HandleOnPositionForceClosed(
|
|
||||||
ticket,
|
|
||||||
position,
|
|
||||||
comment //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Deals Changes ...
|
|
||||||
*
|
|
||||||
* @param count: Integer, Number of Changes ...
|
|
||||||
*/
|
|
||||||
void OnDealsChanged(int count)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnDealsChanged(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Orders Changes ...
|
|
||||||
*
|
|
||||||
* @param count: Integer, Number of Changes ...
|
|
||||||
*/
|
|
||||||
void OnOrdersChanged(int count)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnOrdersChanged(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle Positions Changes ...
|
|
||||||
*
|
|
||||||
* @param count: Integer, Number of Changes ...
|
|
||||||
*/
|
|
||||||
void OnPositionsChanged(int count)
|
|
||||||
{
|
|
||||||
eaExpert.HandleOnPositionsChanged(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Custom Functions ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate all Inputs of Expert Adviser ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool ValidateInputs()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
string errMessage = "";
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isCommonValid = (
|
|
||||||
//
|
|
||||||
eaSlippage > 0 &&
|
|
||||||
eaMagicNumber > 0
|
|
||||||
//
|
|
||||||
);
|
|
||||||
if (!isCommonValid)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
errMessage += "common configurations error;" + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result =
|
|
||||||
//
|
|
||||||
// Common ...
|
|
||||||
isCommonValid &&
|
|
||||||
//
|
|
||||||
// Otere ...
|
|
||||||
true
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Since here Logger not Initiallized, we Use Raw Print Command ...
|
|
||||||
Print(ShortName + " Errors: \n", errMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Timer ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool InitTimer()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// TODO: Initialize Timer if necessary ...
|
|
||||||
// result = EventSetTimer(1);
|
|
||||||
// result = EventSetMillisecondTimer(100);
|
|
||||||
result = true;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy Timer ...
|
|
||||||
*/
|
|
||||||
void DestroyTimer()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// TODO: Use This ...
|
|
||||||
// EventKillTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
Reference in New Issue
Block a user