CleanUp Workspace after Backup all Contents Even X121 Setup ...
This commit is contained in:
@@ -1,796 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center X121EA MQL5 Expert Advisor
|
||||
// -------------------------------------------------
|
||||
// Name: X121EA
|
||||
// Description: an Exper Advisor which used RSI and MA
|
||||
// to Analyse Market ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////x
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm X121EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
#include "../Classes/x-saherelm.x121.setup.xea.mq5"
|
||||
|
||||
//
|
||||
#define ShortName "X121EA"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
// Common ...
|
||||
input group "Common";
|
||||
input long x121EAMagicNumber = 78692110; // Magic Number
|
||||
input int x121EASlippage = 10; // Slippgae
|
||||
|
||||
//
|
||||
// Symbols ...
|
||||
input group "Symbol(s)";
|
||||
input string x121EASymbols = "EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,EURGBPb,XAUUSDb,XAGUSDb,AUDUSDb,EURAUDb,USDCADb,EURCADb,NZDUSDb,EURNZDb"; // Symbols
|
||||
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
||||
input bool x121EAUseAllWatchListSymbols = false; // Use All Watch List Symbols
|
||||
|
||||
//
|
||||
// Signals ...
|
||||
input group "Signals";
|
||||
input bool x121EAAllowLong = true; // Allow Long Trades
|
||||
input bool x121EAAllowShort = true; // Allow Short Trades
|
||||
input int x121EAStartSignallingHoure = 3; // Start Signalling at Specific Time
|
||||
input int x121EAEndSignallingHoure = 22; // End Signalling at Specific Time
|
||||
input int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time
|
||||
input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals
|
||||
input int x121EAReuiredSignalVerifications = 3; // Required Verifications for Signals
|
||||
input bool x121EAExecuteSignalsOnBreakout = false; // Execute Signals On Breakouts
|
||||
input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
|
||||
|
||||
//
|
||||
// Risk Management ...
|
||||
input group "Risk Management";
|
||||
input double x121EAVolume = 0.01; // Static Volume
|
||||
input double x121EATPPoint = 1000; // TP Point
|
||||
input double x121EASLPoint = 500; // SL Point
|
||||
input bool x121EAIgnoreSL = false; // Ignore Calculated SL
|
||||
input bool x121EAIgnoreTP = false; // Ignore Calculated TP
|
||||
input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
|
||||
input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol
|
||||
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
||||
input int x121EAMaxAllowedDrawdownPercent = 5; // Max Allowed Drawdown for Open Trades
|
||||
input bool x121EAIncreaseNextSignalsVolume = true; // Increase Next Signals Volume
|
||||
input double x121EAIncreaseNextSignalsVolumeMultiplier = 1; // Increase Next Signals Volume Multiplier
|
||||
input bool x121EAAcceptNextDirectionalSignalsWhenFirstInProfit = true; // Accept Same Symbol/Type Signal when Last in Profit
|
||||
|
||||
//
|
||||
input group "Trailling";
|
||||
input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses
|
||||
input bool x121EADisableTrailingWhenOpposit = true; // Disable Trailling When has Opposite In Drawdown
|
||||
input double x121EAFirstTrailDistance = 100; // Start Trailling Distance
|
||||
input double x121EAFirstTrailPoint = 60; // First Stop Trail
|
||||
input double x121EANextTrailDistance = 50; // Next Trailling Distance
|
||||
input double x121EANextTrailPoint = 30; // Next Trailling Step
|
||||
|
||||
//
|
||||
// input group "Supporting";
|
||||
// input bool x121EAAllowSupport = false; // Allow Support Signals
|
||||
// input bool x121EASupportOnlyForces = false; // Support Only Force Signals
|
||||
// double x121EASupportDistance = 0; // Supporting Distance
|
||||
// input int x121EAMaxNumberOfSupports = 0; // Max Number of Support Signals
|
||||
// input double x121EASupportVolumeMultiplier = 0; // Support Signals Volume Multiplier
|
||||
// input double x121EAMaxAllowedSupportVolume = 0; // Max Allowed Support Signals Volume
|
||||
|
||||
//
|
||||
input group "Grid";
|
||||
input bool x121EAAllowGrid = false; // Allow Grid Signals
|
||||
input bool x121EAGridOnlyForces = false; // Grid Only Force Signals
|
||||
input int x121EAMaxNumberOfGrids = 0; // Max Number of Grid Signals
|
||||
input double x121EAGridDistance = 0; // Grid Distance
|
||||
input double x121EAGridVolumeMultiplier = 0; // Grid Volume Multiplier
|
||||
input double x121EAMaxAllowedGridVolume = 0; // Max Allowed Grid Signals Volume
|
||||
|
||||
//
|
||||
input group "Recovery";
|
||||
input bool x121EAAllowRecovery = false; // Allow Recovery Signals
|
||||
input bool x121EARecoverOnlyForces = false; // Recover Only Force Signals
|
||||
input int x121EAMaxNumberOfRecoveries = 0; // Max Number of Recovery Signals
|
||||
input double x121EARecoveryDistance = 0; // Recovery Distance
|
||||
input double x121EARecoveryVolumeMultiplier = 0; // Recovery Volume Multiplier
|
||||
input double x121EAMaxAllowedRecoveryVolume = 0; // Max Allowed Recovery Signals Volume
|
||||
|
||||
//
|
||||
input group "Hedging";
|
||||
input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge
|
||||
input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging
|
||||
input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
input group "Alerts";
|
||||
input bool x121EAEnableAlerts = true; // Enable Alerts
|
||||
input bool x121EALogAlerts = true; // Log Alerts
|
||||
input bool x121EAMailAlerts = false; // Mail Alerts
|
||||
input bool x121EAPushAlerts = false; // Push Alerts
|
||||
input bool x121EATerminalAlerts = false; // Terminal Alerts
|
||||
|
||||
//
|
||||
// Time Tracking ...
|
||||
input group "Time Tracking";
|
||||
input bool x121EAAlertNewMonth = false; // Alert New Month
|
||||
input bool x121EAAlertNewWeek = false; // Alert New Week
|
||||
input bool x121EAAlertNewDay = false; // Alert New Day
|
||||
input bool x121EAAlertNewHour = false; // Alert New Hour
|
||||
input bool x121EAAlertNewMinute = false; // Alert New Minute
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Local Variables ...
|
||||
|
||||
//
|
||||
const bool is121EAInTestMode = IsRunningOnTestMode();
|
||||
XTimeTracker x121EATimeTracker;
|
||||
|
||||
//
|
||||
string x121EAUsedSymbols[];
|
||||
XSCX121SetupEA *x121EA;
|
||||
|
||||
//
|
||||
XSCAlert *x121EAAlert;
|
||||
XSCXCTHelper *x121EACTHelper;
|
||||
XSCXCCHelper *x121EACCHelper;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initializitation Succeed Message ...
|
||||
x121EAAlert.Alert("Initialized Successfully ...");
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// De Initialization Succeed ...
|
||||
x121EAAlert.Alert("De Initialized Successfully ...");
|
||||
|
||||
//
|
||||
// Clean Array ...
|
||||
Clean(x121EAUsedSymbols);
|
||||
|
||||
//
|
||||
// De Initialize XSampleEA Providers ...
|
||||
delete x121EA;
|
||||
|
||||
//
|
||||
delete x121EACTHelper;
|
||||
delete x121EACCHelper;
|
||||
|
||||
//
|
||||
delete x121EAAlert;
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
X121EAHandleTimeReports();
|
||||
|
||||
//
|
||||
x121EA.OnTick();
|
||||
|
||||
//
|
||||
X121ReportState();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Bar Timer ...
|
||||
XCTInputs ctInputs;
|
||||
ctInputs.Default();
|
||||
x121EACTHelper = new XSCXCTHelper();
|
||||
result = x121EACTHelper.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
ctInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bar Styles ...
|
||||
XCCInputs ccInputs;
|
||||
ccInputs.Default();
|
||||
x121EACCHelper = new XSCXCCHelper();
|
||||
result = x121EACCHelper.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
ccInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial Alert Class ...
|
||||
x121EATimeTracker.Clean();
|
||||
x121EAAlert = new XSCAlert();
|
||||
x121EAAlert.SetPrefix(ShortName);
|
||||
x121EAAlert.SetEnableAlerts(x121EAEnableAlerts);
|
||||
x121EAAlert.SetLogAlerts(x121EALogAlerts);
|
||||
x121EAAlert.SetMailAlerts(x121EAMailAlerts);
|
||||
x121EAAlert.SetPushAlerts(x121EAPushAlerts);
|
||||
x121EAAlert.SetTerminalAlerts(x121EATerminalAlerts);
|
||||
|
||||
//
|
||||
// TesterHideIndicators(true);
|
||||
|
||||
//
|
||||
string inputSymbols[];
|
||||
int inputSymbolsCount = SplitContent(
|
||||
inputSymbols,
|
||||
x121EASymbols //
|
||||
);
|
||||
|
||||
//
|
||||
string allSymbols[];
|
||||
int allSymbolsCount = GetAllSymbols(
|
||||
allSymbols //
|
||||
);
|
||||
|
||||
//
|
||||
string watchListSymbols[];
|
||||
int watchListSymbolsCount = GetAllSymbols(
|
||||
watchListSymbols,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
Clean(x121EAUsedSymbols);
|
||||
if (x121EAUseAllSymbols)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
allSymbols,
|
||||
x121EAUsedSymbols //
|
||||
);
|
||||
}
|
||||
else if (x121EAUseAllWatchListSymbols)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
watchListSymbols,
|
||||
x121EAUsedSymbols //
|
||||
);
|
||||
}
|
||||
else if (IsValidSize(inputSymbolsCount))
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
inputSymbols,
|
||||
x121EAUsedSymbols //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
Add(
|
||||
_Symbol,
|
||||
x121EAUsedSymbols //
|
||||
);
|
||||
}
|
||||
int symbolsCount = ArraySize(x121EAUsedSymbols);
|
||||
result = IsValidSize(symbolsCount);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(inputSymbols);
|
||||
Clean(allSymbols);
|
||||
Clean(watchListSymbols);
|
||||
Clean(x121EAUsedSymbols);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
x121EA = new XSCX121SetupEA(
|
||||
x121EASlippage,
|
||||
x121EAMagicNumber //
|
||||
);
|
||||
|
||||
//
|
||||
// Configure EA Class Instance ...
|
||||
|
||||
//
|
||||
// Signals ...
|
||||
x121EA.AllowLong(x121EAAllowLong);
|
||||
x121EA.AllowShort(x121EAAllowShort);
|
||||
x121EA.DelayBetweenTwoSignal(x121EADelayBetweenTwoSignal);
|
||||
x121EA.ExecuteSignalsOnBreakout(x121EAExecuteSignalsOnBreakout);
|
||||
x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications);
|
||||
x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames);
|
||||
|
||||
//
|
||||
// Risk Management ...
|
||||
x121EA.Volume(x121EAVolume);
|
||||
x121EA.TPPoint(x121EATPPoint);
|
||||
x121EA.SLPoint(x121EASLPoint);
|
||||
x121EA.IgnoreSL(x121EAIgnoreSL);
|
||||
x121EA.IgnoreTP(x121EAIgnoreTP);
|
||||
x121EA.MaxAllowedTrades(x121EAMaxAllowedTrades);
|
||||
x121EA.IncreaseNextSignalsVolume(x121EAIncreaseNextSignalsVolume);
|
||||
x121EA.UseMaxAllowedPerDirection(x121EAUseMaxAllowedPerDirection);
|
||||
x121EA.MaxAllowedDrawdownPercent(x121EAMaxAllowedDrawdownPercent);
|
||||
x121EA.IncreaseNextSignalsVolumeMultiplier(x121EAIncreaseNextSignalsVolumeMultiplier);
|
||||
x121EA.AcceptNextDirectionalSignalsWhenFirstInProfit(x121EAAcceptNextDirectionalSignalsWhenFirstInProfit);
|
||||
|
||||
//
|
||||
// Protection ...
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
x121EA.CloseOnOpposit(x121EACloseOnOpposit);
|
||||
x121EA.EndSignallingHoure(x121EAEndSignallingHoure);
|
||||
x121EA.CloseOnSpecificTime(x121EACloseOnSpecificTime);
|
||||
x121EA.StartSignallingHoure(x121EAStartSignallingHoure);
|
||||
|
||||
//
|
||||
// Trailling ...
|
||||
x121EA.AllowTrailStop(x121EAAllowTrailStop);
|
||||
x121EA.NextTrailPoint(x121EANextTrailPoint);
|
||||
x121EA.FirstTrailPoint(x121EAFirstTrailPoint);
|
||||
x121EA.NextTrailDistance(x121EANextTrailDistance);
|
||||
x121EA.FirstTrailDistance(x121EAFirstTrailDistance);
|
||||
x121EA.DisableTrailingWhenOpposit(x121EADisableTrailingWhenOpposit);
|
||||
|
||||
// //
|
||||
// // Supporting ...
|
||||
// x121EA.AllowSupport(x121EAAllowSupport);
|
||||
// x121EA.SupportOnlyForces(x121EASupportOnlyForces);
|
||||
// x121EA.SupportDistance(x121EASupportDistance);
|
||||
// x121EA.MaxNumberOfSupports(x121EAMaxNumberOfSupports);
|
||||
// x121EA.SupportVolumeMultiplier(x121EASupportVolumeMultiplier);
|
||||
// x121EA.MaxAllowedSupportVolume(x121EAMaxAllowedSupportVolume);
|
||||
|
||||
//
|
||||
// Grid ...
|
||||
x121EA.AllowGrid(x121EAAllowGrid);
|
||||
x121EA.GridOnlyForces(x121EAGridOnlyForces);
|
||||
x121EA.GridDistance(x121EAGridDistance);
|
||||
x121EA.MaxNumberOfGrids(x121EAMaxNumberOfGrids);
|
||||
x121EA.GridVolumeMultiplier(x121EAGridVolumeMultiplier);
|
||||
x121EA.MaxAllowedGridVolume(x121EAMaxAllowedGridVolume);
|
||||
|
||||
//
|
||||
// Recovery ...
|
||||
x121EA.AllowRecovery(x121EAAllowRecovery);
|
||||
x121EA.RecoverOnlyForces(x121EARecoverOnlyForces);
|
||||
x121EA.RecoveryDistance(x121EARecoveryDistance);
|
||||
x121EA.MaxNumberOfRecoveries(x121EAMaxNumberOfRecoveries);
|
||||
x121EA.RecoveryVolumeMultiplier(x121EARecoveryVolumeMultiplier);
|
||||
x121EA.MaxAllowedRecoveryVolume(x121EAMaxAllowedRecoveryVolume);
|
||||
|
||||
//
|
||||
// Hedging ...
|
||||
x121EA.RestingAfterHedge(x121EARestingAfterHedge);
|
||||
x121EA.MinProfitPerTrade(x121EAMinRequiredProfitPerTrade);
|
||||
x121EA.MinProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor);
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
x121EA.SetAlertPrefix(ShortName);
|
||||
x121EA.SetAlertEnableAlerts(x121EAEnableAlerts);
|
||||
x121EA.SetAlertLogAlerts(x121EALogAlerts);
|
||||
x121EA.SetAlertMailAlerts(x121EAMailAlerts);
|
||||
x121EA.SetAlertPushAlerts(x121EAPushAlerts);
|
||||
x121EA.SetAlertTerminalAlerts(x121EATerminalAlerts);
|
||||
|
||||
//
|
||||
// Configure Indicators ...
|
||||
X121SetupInputs setupInputsDefault;
|
||||
setupInputsDefault.Default();
|
||||
X121PreConfigureStyles(setupInputsDefault);
|
||||
|
||||
//
|
||||
// Prepare Providers and Add them into mX121EA class ...
|
||||
ENUM_TIMEFRAMES iHostPeriod = _Period;
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
string iSymbol = x121EAUsedSymbols[i];
|
||||
|
||||
//
|
||||
// Instancing Setup Cycle ...
|
||||
XSCX121SetupCycles *iSetupCycle;
|
||||
iSetupCycle = new XSCX121SetupCycles();
|
||||
result = iSetupCycle.Init(
|
||||
setupInputsDefault,
|
||||
iSymbol,
|
||||
iHostPeriod //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Adding Instance Pointer Class to EA Class Instance ...
|
||||
result = x121EA.AddSetup(iSetupCycle);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleaning Unused Arrays ...
|
||||
Clean(inputSymbols);
|
||||
Clean(allSymbols);
|
||||
Clean(watchListSymbols);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void X121PreConfigureStyles(X121SetupInputs &inputs)
|
||||
{
|
||||
//
|
||||
// XRL ...
|
||||
inputs.rlInputs.showFast = false;
|
||||
inputs.rlInputs.showSlow = false;
|
||||
inputs.rlInputs.showVerifier = false;
|
||||
|
||||
//
|
||||
// XHTD ...
|
||||
inputs.htdInputs.show = false;
|
||||
|
||||
//
|
||||
// XATSL ...
|
||||
inputs.atslInputs.show = false;
|
||||
|
||||
//
|
||||
// XSLN ...
|
||||
inputs.slnInputs.show = false;
|
||||
|
||||
//
|
||||
// XDMNT ...
|
||||
inputs.dmntInputs.showBull = false;
|
||||
inputs.dmntInputs.showBear = false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
inputs.strInputs.showTrends = false;
|
||||
inputs.strInputs.fillTrends = false;
|
||||
|
||||
//
|
||||
// XCHMA ...
|
||||
inputs.chmaInputs.showFast = false;
|
||||
inputs.chmaInputs.showSlow = false;
|
||||
inputs.chmaInputs.showCCFast = false;
|
||||
inputs.chmaInputs.showCCSlow = false;
|
||||
inputs.chmaInputs.showSCFast = false;
|
||||
inputs.chmaInputs.showSCSlow = false;
|
||||
inputs.chmaInputs.showMCFast = false;
|
||||
inputs.chmaInputs.showMCSlow = false;
|
||||
inputs.chmaInputs.showLCFast = false;
|
||||
inputs.chmaInputs.showLCSlow = false;
|
||||
inputs.chmaInputs.showHCFast = false;
|
||||
inputs.chmaInputs.showHCSlow = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
inputs.pvInputs.showPeaksAndVales = false;
|
||||
inputs.pvInputs.showLevels = false;
|
||||
inputs.pvInputs.showConsolidations = false;
|
||||
inputs.pvInputs.showFibo1Levels = false;
|
||||
inputs.pvInputs.showFibo2Levels = false;
|
||||
inputs.pvInputs.showFibo3Levels = false;
|
||||
inputs.pvInputs.showFibo4Levels = false;
|
||||
inputs.pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
// XMC ...
|
||||
inputs.mcInputs.showSar = false;
|
||||
inputs.mcInputs.showFastMa = false;
|
||||
inputs.mcInputs.showSlowMa = false;
|
||||
inputs.mcInputs.showVerifierMa = false;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
inputs.hkInputs.drawHikenAshi = false;
|
||||
inputs.hkInputs.drawSmoothedHikenAshi = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
inputs.cheInputs.showLongExit1Line = false;
|
||||
inputs.cheInputs.showShortExit1Line = false;
|
||||
inputs.cheInputs.showLongExit2Line = false;
|
||||
inputs.cheInputs.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
inputs.ichInputs.showTenkanSen = false;
|
||||
inputs.ichInputs.showKijunSen = false;
|
||||
inputs.ichInputs.showKijunSenPlus = false;
|
||||
inputs.ichInputs.showKijunSenNegative = false;
|
||||
inputs.ichInputs.showChikouSpan = false;
|
||||
inputs.ichInputs.showSenkouSpanA = false;
|
||||
inputs.ichInputs.showSenkouSpanB = false;
|
||||
inputs.ichInputs.showKumo = false;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
inputs.mrbInputs.showFastMa = false;
|
||||
inputs.mrbInputs.showSlowMa = false;
|
||||
inputs.mrbInputs.showRibbon = false;
|
||||
|
||||
//
|
||||
// XASCT ...
|
||||
inputs.asctInputs.showLongs = false;
|
||||
inputs.asctInputs.showShorts = false;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
inputs.sslcInputs.showUp = false;
|
||||
inputs.sslcInputs.showDown = false;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
inputs.hullInputs.showUpZone = false;
|
||||
inputs.hullInputs.showDownZone = false;
|
||||
}
|
||||
|
||||
//
|
||||
void X121ReportState()
|
||||
{
|
||||
//
|
||||
string comment = NULL;
|
||||
|
||||
//
|
||||
comment =
|
||||
ShortName + "\n" +
|
||||
"------------" + "\n" +
|
||||
"Trading Symbols: " + ToString(ArraySize(x121EAUsedSymbols)) + "\n" + "\n";
|
||||
|
||||
//
|
||||
// Detect What we Want to Show as Comment ...
|
||||
// bool isInForceState = x121EA.ForceState();
|
||||
double bullishScore = 0; // x121EA.GetBullishScore();
|
||||
double bearishScore = 0; // x121EA.GetBearishScore();
|
||||
double drawDownPercent = x121EA.GetDrawdownPercent();
|
||||
|
||||
//
|
||||
comment +=
|
||||
//
|
||||
(bullishScore > 0 || bearishScore > 0
|
||||
? "Scores:" + "\n" +
|
||||
"------------" + "\n" +
|
||||
"Bullish: " + ToString(bullishScore) + "\n" +
|
||||
"Bearish: " + ToString(bearishScore) + "\n" +
|
||||
"------------" + "\n"
|
||||
: "") +
|
||||
"Drawdown: " + ToString(drawDownPercent) + "%" + "\n" +
|
||||
// "------------" + "\n" +
|
||||
// "Force State: " + ToString(isInForceState) + "\n" +
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
XPosition positions[];
|
||||
int positionsCount = x121EA.mTrader.GetPositions(
|
||||
positions //
|
||||
);
|
||||
if (IsValidSize(positionsCount))
|
||||
{
|
||||
//
|
||||
int longs = 0;
|
||||
double longVolumes = 0;
|
||||
double longProfits = 0;
|
||||
|
||||
//
|
||||
int shorts = 0;
|
||||
double shortVolumes = 0;
|
||||
double shortProfits = 0;
|
||||
|
||||
//
|
||||
// Retrieve Required Informations of Positions ...
|
||||
CountPositions(
|
||||
positions,
|
||||
longs,
|
||||
longProfits,
|
||||
longVolumes,
|
||||
shorts,
|
||||
shortProfits,
|
||||
shortVolumes //
|
||||
);
|
||||
|
||||
//
|
||||
comment +=
|
||||
//
|
||||
"------------" + "\n" +
|
||||
"Positions: " + "\n" +
|
||||
"------------" + "\n" +
|
||||
(longs <= 0
|
||||
? ""
|
||||
: "\n" + "Longs:" + "\n" +
|
||||
"------------" + "\n" +
|
||||
"Count: " + ToString(longs) + "\n" +
|
||||
"Profits: " + ToString(longProfits) + "\n" +
|
||||
""
|
||||
//
|
||||
) +
|
||||
//
|
||||
(shorts <= 0
|
||||
? ""
|
||||
: "\n" + "Shorts:" + "\n" +
|
||||
"------------" + "\n" +
|
||||
"Count: " + ToString(shorts) + "\n" +
|
||||
"Profits: " + ToString(shortProfits) + "\n" +
|
||||
""
|
||||
//
|
||||
) +
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
if (positionsCount > 1 && x121EAMinRequiredProfitPerTrade > 0 && x121EAMinRequiredProfitPerVolumeFactor > 0)
|
||||
{
|
||||
//
|
||||
double profit = SpecifiedCalculatePositionsProfit(
|
||||
positions //
|
||||
);
|
||||
double requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
|
||||
positions,
|
||||
x121EAMinRequiredProfitPerTrade,
|
||||
x121EAMinRequiredProfitPerVolumeFactor //
|
||||
);
|
||||
|
||||
//
|
||||
comment +=
|
||||
//
|
||||
"\n" + "Hedging: " + "\n" +
|
||||
"------------" + "\n" +
|
||||
"Profits: " + ToString(profit) + "\n" +
|
||||
"RequiredProft: " + ToString(requiredProfitForHedge) + "\n" +
|
||||
//
|
||||
""
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValid(comment))
|
||||
{
|
||||
Comment(comment);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void X121EAHandleTimeReports()
|
||||
{
|
||||
//
|
||||
// Time Tracking ...
|
||||
|
||||
//
|
||||
// Alert Month ...
|
||||
if (x121EAAlertNewMonth)
|
||||
{
|
||||
//
|
||||
bool isNewMonth = x121EATimeTracker.IsNewMonth();
|
||||
if (isNewMonth)
|
||||
{
|
||||
x121EAAlert.Alert("New Mount ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Alert Week ...
|
||||
if (x121EAAlertNewWeek)
|
||||
{
|
||||
//
|
||||
bool isNewWeek = x121EATimeTracker.IsNewWeek();
|
||||
if (isNewWeek)
|
||||
{
|
||||
x121EAAlert.Alert("New Week ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Alert New Day ...
|
||||
if (x121EAAlertNewDay)
|
||||
{
|
||||
//
|
||||
bool isNewDay = x121EATimeTracker.IsNewDay();
|
||||
if (isNewDay)
|
||||
{
|
||||
x121EAAlert.Alert("New Day ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Alert New Hour ...
|
||||
if (x121EAAlertNewHour)
|
||||
{
|
||||
//
|
||||
bool isNewHour = x121EATimeTracker.IsNewHour();
|
||||
if (isNewHour)
|
||||
{
|
||||
x121EAAlert.Alert("New Hour ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Alert New Minute ...
|
||||
if (x121EAAlertNewMinute)
|
||||
{
|
||||
//
|
||||
bool isNewMinute = x121EATimeTracker.IsNewMinute();
|
||||
if (isNewMinute)
|
||||
{
|
||||
x121EAAlert.Alert("New Minute ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,9 +28,7 @@
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
|
||||
//
|
||||
#include "../Strategies/x-saherelm.xdtd.strategy.mq5"
|
||||
#include "../Strategies/x-saherelm.xchkm.strategy.mq5"
|
||||
#include "../Strategies/x-saherelm.xtest.strategy.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
@@ -61,8 +59,9 @@ bool eaIgnoreSL = false; // Ignore SL
|
||||
double eaR2R = 1.5; // Risk to Reward Ratio
|
||||
|
||||
//
|
||||
bool eaMultiSymbol = true; // Use Multi Symbol
|
||||
string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb";
|
||||
bool eaMultiSymbol = false; // Use Multi Symbol
|
||||
bool eaUseMaxAllowedTradesPerSymbol = true; // Use Max Allowed Trades Per Symbol
|
||||
string eaSymbols = "EURUSDb,USDJPYb,USDCHFb,GBPUSDb,XAUUSDb,XAGUSDb"; // Trading Symbols
|
||||
|
||||
//
|
||||
// Variables ...
|
||||
@@ -319,6 +318,10 @@ bool InitialEA()
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
xchmStrategy.EnableXCHM(false);
|
||||
xchmStrategy.EnableXCHHK(false);
|
||||
xchmStrategy.EnableXCHSTR(false);
|
||||
xchmStrategy.EnableXCHCHE(true);
|
||||
xchmStrategy.SetAlertLogAlerts(true);
|
||||
xchmStrategy.SetAlertEnableAlerts(true);
|
||||
xchmStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
@@ -369,6 +372,10 @@ bool InitialEA()
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
iStrategy.EnableXCHM(true);
|
||||
iStrategy.EnableXCHHK(true);
|
||||
iStrategy.EnableXCHSTR(true);
|
||||
iStrategy.EnableXCHCHE(true);
|
||||
iStrategy.SetAlertLogAlerts(true);
|
||||
iStrategy.SetAlertEnableAlerts(true);
|
||||
iStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
@@ -447,11 +454,26 @@ void OnSignalRecieved(XSignal &signal)
|
||||
//
|
||||
XPosition longs[];
|
||||
XPosition shorts[];
|
||||
eaTrader.GetPositions(
|
||||
longs,
|
||||
shorts,
|
||||
signal.symbol //
|
||||
);
|
||||
|
||||
//
|
||||
if (eaUseMaxAllowedTradesPerSymbol)
|
||||
{
|
||||
//
|
||||
eaTrader.GetPositions(
|
||||
longs,
|
||||
shorts,
|
||||
signal.symbol //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
eaTrader.GetPositions(
|
||||
longs,
|
||||
shorts,
|
||||
NULL // All Symbols ...
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
int longsCount = ArraySize(longs);
|
||||
@@ -480,11 +502,11 @@ void OnSignalRecieved(XSignal &signal)
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
if (signal.pushers < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// //
|
||||
// if (signal.pushers < 2)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT state;
|
||||
|
||||
@@ -1,746 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center XTest MQL5 Expert Advisor
|
||||
// -------------------------------------------------
|
||||
// Name: XTestEA
|
||||
// Description: an Exper Advisor which used XTestSetup
|
||||
// to Analyse Market ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////x
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XTestEA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "XTestEA"
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Test/x-saherelm.test.xea.mq5"
|
||||
#include "../Libraries/x-saherelm.tools.mq5"
|
||||
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long mMagicNumber = 78692110; // Magic Number
|
||||
int mSlippage = 10; // Slippgae
|
||||
|
||||
//
|
||||
double eaVolume = 0.01;
|
||||
double eaAllowLong = true;
|
||||
double eaAllowShort = true;
|
||||
|
||||
//
|
||||
// Variables ...
|
||||
XBarTracker eaBarTracker;
|
||||
|
||||
//
|
||||
XSCXTestSetupEA *mSetupEA;
|
||||
XSCXTestSetup *iSetup;
|
||||
XSCXCTHelper *mCTHelper;
|
||||
XSCXCCHelper *mCCHelper;
|
||||
|
||||
//
|
||||
XSCAlert *eaAlert;
|
||||
XTimeTracker eaTimeTracker;
|
||||
|
||||
//
|
||||
// For Pivot Checking ...
|
||||
XPivot lastSupportPivot;
|
||||
XPivot lastResistancePivot;
|
||||
|
||||
//
|
||||
// For Zone Checking ...
|
||||
// XZone lastSupportZone;
|
||||
// XZone lastResistanceZone;
|
||||
|
||||
//
|
||||
XTrendDetector trendDetector;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial Bar Tracker ...
|
||||
bool isInited = eaBarTracker.Init(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial Alert Class ...
|
||||
eaAlert = new XSCAlert(
|
||||
ShortName,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true //
|
||||
);
|
||||
eaTimeTracker.Clean();
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// De Initialize XSampleEA Providers ...
|
||||
delete mSetupEA;
|
||||
delete mCTHelper;
|
||||
delete mCCHelper;
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// mSetupEA.OnTick();
|
||||
|
||||
//
|
||||
if (!eaBarTracker.CanProcessBar())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Pivots ...
|
||||
HandleCheckPivots();
|
||||
|
||||
//
|
||||
// Check Zones ...
|
||||
// HandleCheckZones();
|
||||
|
||||
//
|
||||
// Check Time Tracker ...
|
||||
// HandleCheckTimeTracker();
|
||||
|
||||
//
|
||||
// Check Trend State ...
|
||||
// HandleCheckTrend();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Bar Timer ...
|
||||
XCTInputs ctInputs;
|
||||
ctInputs.Default();
|
||||
mCTHelper = new XSCXCTHelper();
|
||||
result = mCTHelper.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
ctInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bar Styles ...
|
||||
XCCInputs ccInputs;
|
||||
ccInputs.Default();
|
||||
mCCHelper = new XSCXCCHelper();
|
||||
result = mCCHelper.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
ccInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Preparing EA Class ...
|
||||
mSetupEA = new XSCXTestSetupEA(
|
||||
mSlippage,
|
||||
mMagicNumber //
|
||||
);
|
||||
|
||||
//
|
||||
// Configuring EA Class ...
|
||||
mSetupEA.Volume(eaVolume);
|
||||
mSetupEA.AllowLong(eaAllowLong);
|
||||
mSetupEA.AllowShort(eaAllowShort);
|
||||
|
||||
//
|
||||
// Configure Indicators ...
|
||||
XTestInputs setupInputsDefault;
|
||||
setupInputsDefault.Default();
|
||||
PreConfigureStyles(setupInputsDefault);
|
||||
|
||||
//
|
||||
// Instantiate Per Symbol ...
|
||||
|
||||
//
|
||||
string iSymbol = _Symbol;
|
||||
ENUM_TIMEFRAMES iPeriod = _Period;
|
||||
|
||||
//
|
||||
XTestInputs iInputs;
|
||||
iInputs = setupInputsDefault;
|
||||
iInputs.tpPoint = 60;
|
||||
iInputs.slPoint = 60;
|
||||
iInputs.symbol = iSymbol;
|
||||
iInputs.period = iPeriod;
|
||||
iInputs.volume = eaVolume;
|
||||
result = iInputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
iSetup = new XSCXTestSetup();
|
||||
result = iSetup.Init(iInputs);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mSetupEA.AddSetup(iSetup);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void PreConfigureStyles(XTestInputs &inputs)
|
||||
{
|
||||
//
|
||||
// XRL ...
|
||||
inputs.rlInputs.showFast = false;
|
||||
inputs.rlInputs.showSlow = false;
|
||||
inputs.rlInputs.showVerifier = false;
|
||||
|
||||
//
|
||||
// XHTD ...
|
||||
inputs.htdInputs.show = false;
|
||||
|
||||
//
|
||||
// XATSL ...
|
||||
inputs.atslInputs.show = false;
|
||||
|
||||
//
|
||||
// XSLN ...
|
||||
inputs.slnInputs.show = false;
|
||||
|
||||
//
|
||||
// XDMNT ...
|
||||
inputs.dmntInputs.showBull = false;
|
||||
inputs.dmntInputs.showBear = false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
inputs.strInputs.showTrends = false;
|
||||
inputs.strInputs.fillTrends = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
inputs.pvInputs.showPeaksAndVales = false;
|
||||
inputs.pvInputs.showLevels = false;
|
||||
inputs.pvInputs.showConsolidations = false;
|
||||
inputs.pvInputs.showFibo1Levels = false;
|
||||
inputs.pvInputs.showFibo2Levels = false;
|
||||
inputs.pvInputs.showFibo3Levels = false;
|
||||
inputs.pvInputs.showFibo4Levels = false;
|
||||
inputs.pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
// XMC ...
|
||||
inputs.mcInputs.showSar = false;
|
||||
inputs.mcInputs.showFastMa = false;
|
||||
inputs.mcInputs.showSlowMa = false;
|
||||
inputs.mcInputs.showVerifierMa = false;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
inputs.hkInputs.drawHikenAshi = false;
|
||||
inputs.hkInputs.drawSmoothedHikenAshi = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
inputs.cheInputs.showLongExit1Line = false;
|
||||
inputs.cheInputs.showShortExit1Line = false;
|
||||
inputs.cheInputs.showLongExit2Line = false;
|
||||
inputs.cheInputs.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
inputs.ichInputs.showTenkanSen = false;
|
||||
inputs.ichInputs.showKijunSen = false;
|
||||
inputs.ichInputs.showKijunSenPlus = false;
|
||||
inputs.ichInputs.showKijunSenNegative = false;
|
||||
inputs.ichInputs.showChikouSpan = false;
|
||||
inputs.ichInputs.showSenkouSpanA = false;
|
||||
inputs.ichInputs.showSenkouSpanB = false;
|
||||
inputs.ichInputs.showKumo = false;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
inputs.mrbInputs.showFastMa = false;
|
||||
inputs.mrbInputs.showSlowMa = false;
|
||||
inputs.mrbInputs.showRibbon = false;
|
||||
|
||||
//
|
||||
// XASCT ...
|
||||
inputs.asctInputs.showLongs = false;
|
||||
inputs.asctInputs.showShorts = false;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
inputs.sslcInputs.showUp = false;
|
||||
inputs.sslcInputs.showDown = false;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
inputs.hullInputs.showUpZone = false;
|
||||
inputs.hullInputs.showDownZone = false;
|
||||
|
||||
//
|
||||
// XCHMA ...
|
||||
inputs.chmaInputs.showFast = false;
|
||||
inputs.chmaInputs.showSlow = false;
|
||||
inputs.chmaInputs.showCCFast = false;
|
||||
inputs.chmaInputs.showCCSlow = false;
|
||||
inputs.chmaInputs.showSCFast = false;
|
||||
inputs.chmaInputs.showSCSlow = false;
|
||||
inputs.chmaInputs.showMCFast = false;
|
||||
inputs.chmaInputs.showMCSlow = false;
|
||||
inputs.chmaInputs.showLCFast = false;
|
||||
inputs.chmaInputs.showLCSlow = false;
|
||||
inputs.chmaInputs.showHCFast = false;
|
||||
inputs.chmaInputs.showHCSlow = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Testing Functions ...
|
||||
|
||||
//
|
||||
void HandleCheckPivots()
|
||||
{
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance ...
|
||||
if (!lastResistancePivot.isResistance)
|
||||
{
|
||||
//
|
||||
isInited = lastResistancePivot.FindLastResistance(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isDrawn = lastResistancePivot.Draw(ChartID());
|
||||
if (isDrawn)
|
||||
{
|
||||
Print("Valid Resistance ...");
|
||||
}
|
||||
} else {
|
||||
//
|
||||
bool isBreaked = lastResistancePivot.IsBreaked();
|
||||
bool isRejected = lastResistancePivot.IsRejected();
|
||||
|
||||
//
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
// lastResistancePivot.Clean();
|
||||
Print("Resistance Breaked ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (isRejected)
|
||||
{
|
||||
//
|
||||
// lastResistancePivot.Clean();
|
||||
Print("Resistance Rejected ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Support ...
|
||||
if (!lastSupportPivot.isSupport)
|
||||
{
|
||||
//
|
||||
isInited = lastSupportPivot.FindLastSupport(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isDrawn = lastSupportPivot.Draw(ChartID());
|
||||
if (isDrawn)
|
||||
{
|
||||
Print("Valid Support ...");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bool isBreaked = lastSupportPivot.IsBreaked();
|
||||
bool isRejected = lastSupportPivot.IsRejected();
|
||||
|
||||
//
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
// lastSupportPivot.Clean();
|
||||
Print("Support Breaked ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (isRejected)
|
||||
{
|
||||
//
|
||||
// lastSupportPivot.Clean();
|
||||
Print("Support Rejected ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void HandleCheckZones()
|
||||
{
|
||||
// //
|
||||
// bool result = false;
|
||||
|
||||
// //
|
||||
// // Find Last Support Zone ...
|
||||
// if (!lastSupportZone.IsValid())
|
||||
// {
|
||||
// //
|
||||
// result = lastSupportZone.FindLastSupportZone(
|
||||
// _Symbol,
|
||||
// _Period //
|
||||
// );
|
||||
// if (!result)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// result = lastSupportZone.Draw(ChartID());
|
||||
// if (result)
|
||||
// {
|
||||
// Print("Valid Support Zone ...");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Find Last Resistance Zone ...
|
||||
// if (!lastResistanceZone.IsValid())
|
||||
// {
|
||||
// //
|
||||
// result = lastResistanceZone.FindLastResistanceZone(
|
||||
// _Symbol,
|
||||
// _Period //
|
||||
// );
|
||||
// if (!result)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// result = lastResistanceZone.Draw(ChartID());
|
||||
// if (result)
|
||||
// {
|
||||
// Print("Valid Resistance Zone ...");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
void HandleCheckTimeTracker()
|
||||
{
|
||||
//
|
||||
// Month ...
|
||||
if (eaTimeTracker.IsNewMonth())
|
||||
{
|
||||
eaAlert.Alert("New Month ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Week ...
|
||||
if (eaTimeTracker.IsNewWeek())
|
||||
{
|
||||
eaAlert.Alert("New Week ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Day ...
|
||||
if (eaTimeTracker.IsNewDay())
|
||||
{
|
||||
eaAlert.Alert("New Day ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Hour ...
|
||||
if (eaTimeTracker.IsNewHour())
|
||||
{
|
||||
eaAlert.Alert("New Hour ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Minute ...
|
||||
if (eaTimeTracker.IsNewMinute())
|
||||
{
|
||||
eaAlert.Alert("New Minute ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void HandleCheckTrend()
|
||||
{
|
||||
//
|
||||
bool hasTrend = trendDetector.HasTrend();
|
||||
if (!hasTrend)
|
||||
{
|
||||
//
|
||||
bool trendFound = trendDetector.FindTrend(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
Print("Has Trend: " + (trendDetector.isUpTrend ? "Bullish" : "Bearish"));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void OldTests()
|
||||
{
|
||||
// //
|
||||
// XTestConditions conditions;
|
||||
// bool hasConditions = iSetup.GetConditions(
|
||||
// conditions,
|
||||
// 0,
|
||||
// 5 //
|
||||
// );
|
||||
// if (hasConditions)
|
||||
// {
|
||||
// //
|
||||
// bool isCHMAOverUnder1 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isFastOverMin &&
|
||||
// conditions.chmaConditions.isFastUnderMin)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder2 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isSlowOverMin &&
|
||||
// conditions.chmaConditions.isSlowUnderMin)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder3 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isFastOverMax &&
|
||||
// conditions.chmaConditions.isFastUnderMax)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder4 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isSlowOverMax &&
|
||||
// conditions.chmaConditions.isSlowUnderMax)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// if (isCHMAOverUnder1 || isCHMAOverUnder2 || isCHMAOverUnder3 || isCHMAOverUnder4)
|
||||
// {
|
||||
// Print("isCHMAOverUnder");
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// XOHCL cBar;
|
||||
// bool isInit = cBar.Init(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 1 //
|
||||
// );
|
||||
// if (!isInit)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// datetime time1 = iTime(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 2 //
|
||||
// );
|
||||
|
||||
// //
|
||||
// double fib382 = 0;
|
||||
|
||||
// //
|
||||
// bool isHammer = cBar.IsHammer();
|
||||
// if (isHammer)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// -1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("Hammer ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isShootingStar = cBar.IsShootingStar();
|
||||
// if (isShootingStar)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// 1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("ShootingStar ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBullishEngulf = cBar.IsBullishEngulf();
|
||||
// if (isBullishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bullish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBearishEngulf = cBar.IsBearishEngulf();
|
||||
// if (isBearishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bearish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user