last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
|
||||
//
|
||||
#include "../Strategies/x-saherelm.xdtd.strategy.mq5"
|
||||
#include "../Strategies/x-saherelm.xtest.strategy.mq5"
|
||||
|
||||
//
|
||||
@@ -45,8 +46,8 @@ int eaMaxAllowedLongs = 0; // Max Allowed Long Positions
|
||||
int eaMaxAllowedShorts = 0; // Max Allowed Short Positions
|
||||
|
||||
//
|
||||
double eaTPPoint = 200; // Static TP Point
|
||||
double eaSLPoint = 100; // Static SL Point
|
||||
input double eaTPPoint = 200; // Static TP Point
|
||||
input double eaSLPoint = 100; // Static SL Point
|
||||
|
||||
//
|
||||
bool eaIgnoreTP = false; // Ignore TP
|
||||
@@ -246,7 +247,7 @@ bool InitialEA()
|
||||
|
||||
//
|
||||
// Configure Hedging ...
|
||||
eaTradeHandler.AllowHedging(true);
|
||||
eaTradeHandler.AllowHedging(false);
|
||||
eaTradeHandler.HedgeVolumeFactor(eaVolume);
|
||||
eaTradeHandler.HedgeMinProfitPerVolumeFactor(0.2);
|
||||
|
||||
@@ -272,11 +273,8 @@ bool InitialEA()
|
||||
bool useXAUUSD = false;
|
||||
|
||||
//
|
||||
bool useXSRBR = false;
|
||||
bool useXEMRNG = false;
|
||||
bool useXOBVG = false;
|
||||
bool useXPVFMC = false;
|
||||
bool useXTest = true;
|
||||
bool useXTest = false;
|
||||
bool useXDTD = false;
|
||||
|
||||
//
|
||||
// EURUSD ...
|
||||
@@ -287,6 +285,37 @@ bool InitialEA()
|
||||
// MAGIC NUMBER ...
|
||||
long magicNumber = eaMagicNumber + 1;
|
||||
|
||||
//
|
||||
// XDTD ...
|
||||
if (useXDTD)
|
||||
{
|
||||
//
|
||||
XSCXDTDStrategy *eurusdXTDTStrategy;
|
||||
eurusdXTDTStrategy = new XSCXDTDStrategy(
|
||||
eurusdSymbol,
|
||||
PERIOD_M15,
|
||||
eaVolume,
|
||||
eaR2R, // R2R ...
|
||||
eaSlippage,
|
||||
magicNumber,
|
||||
true, // Ignore Signal Execution
|
||||
true, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
eaIgnoreTP,
|
||||
eaIgnoreSL,
|
||||
eaAllowLong,
|
||||
eaAllowShort,
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
eurusdXTDTStrategy.SetAlertLogAlerts(true);
|
||||
eurusdXTDTStrategy.SetAlertEnableAlerts(true);
|
||||
eurusdXTDTStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
RegisterStrategy(eurusdXTDTStrategy);
|
||||
}
|
||||
|
||||
//
|
||||
// XTest ...
|
||||
if (useXTest)
|
||||
@@ -300,9 +329,9 @@ bool InitialEA()
|
||||
eaR2R, // R2R ...
|
||||
eaSlippage,
|
||||
magicNumber,
|
||||
true, // Ignore Signal Execution
|
||||
true, // Use TP SL Point
|
||||
false, // Use Max
|
||||
true, // Ignore Signal Execution
|
||||
true, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
eaIgnoreTP,
|
||||
@@ -319,6 +348,32 @@ bool InitialEA()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XSCXDTDStrategy *xTDTStrategy;
|
||||
xTDTStrategy = new XSCXDTDStrategy(
|
||||
_Symbol,
|
||||
_Period,
|
||||
eaVolume,
|
||||
eaR2R, // R2R ...
|
||||
eaSlippage,
|
||||
eaMagicNumber,
|
||||
true, // Ignore Signal Execution
|
||||
true, // Use TP SL Point
|
||||
false, // Use Max
|
||||
eaTPPoint, // TP
|
||||
eaSLPoint, // SL
|
||||
eaIgnoreTP,
|
||||
eaIgnoreSL,
|
||||
eaAllowLong,
|
||||
eaAllowShort,
|
||||
eaMaxAllowedLongs, // Max Longs
|
||||
eaMaxAllowedShorts // Max Shorts
|
||||
);
|
||||
xTDTStrategy.SetAlertLogAlerts(true);
|
||||
xTDTStrategy.SetAlertEnableAlerts(true);
|
||||
xTDTStrategy.AddSignalEventHandler(OnSignalRecieved);
|
||||
RegisterStrategy(xTDTStrategy);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,875 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XSCXDTDStrategy
|
||||
// Description: provides all based classes for use ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
|
||||
//
|
||||
// Import(s) Helper(s) ...
|
||||
#include "../Helpers/x-saherelm.xhk.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xpv.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xtd.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xdon.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xvlm.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xosc.helper.mq5"
|
||||
|
||||
//
|
||||
// Base Classes ...
|
||||
#include "../Classes/x-saherelm.xstrategy.class.mq5"
|
||||
|
||||
//
|
||||
// Specific Identifier(s) of XStrategy ...
|
||||
string XDTDStartegyToken = "XDTD";
|
||||
|
||||
//
|
||||
// XStrategy Class Implementation(s) ...
|
||||
class XSCXDTDStrategy : public XSCBaseStrategy
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XSCXDTDStrategy(
|
||||
//
|
||||
// Base ...
|
||||
string _symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES _period, // Trading TimeFrame
|
||||
double _volume, // Voluem
|
||||
double _r2r, // Risk/Reward Ratio
|
||||
int _slippage, // Trader Slippage
|
||||
long _magicNumber, // Trader Magic Number
|
||||
bool _ignoreSignalExecution = false, // Ignore Signal Execution
|
||||
bool _useTPSLAsPoint = false, // Converts TP and SL by Provided Points
|
||||
bool _forceMaxTPSLAsPoint = false, // Force Max TP and SL by Provided Points
|
||||
double _tpPoint = 0, // TP As Point
|
||||
double _slPoint = 0, // SL As Point
|
||||
bool _ignoreTP = false, // TP set to 0
|
||||
bool _ignoreSL = false, // SL set to 0
|
||||
bool _allowLong = true,
|
||||
bool _allowShort = true,
|
||||
int _maxAllowedLongs = 0,
|
||||
int _maxAllowedShorts = 0 //
|
||||
) : XSCBaseStrategy(_symbol,
|
||||
_period,
|
||||
_volume,
|
||||
_r2r,
|
||||
_slippage,
|
||||
_magicNumber,
|
||||
_ignoreSignalExecution,
|
||||
_useTPSLAsPoint,
|
||||
_forceMaxTPSLAsPoint,
|
||||
_tpPoint,
|
||||
_slPoint,
|
||||
_ignoreTP,
|
||||
_ignoreSL,
|
||||
_allowLong,
|
||||
_allowShort,
|
||||
_maxAllowedLongs,
|
||||
_maxAllowedShorts //
|
||||
)
|
||||
{
|
||||
//
|
||||
SetAlertPrefix(GetTag());
|
||||
|
||||
//
|
||||
PrepareRequirements();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCXDTDStrategy()
|
||||
{
|
||||
//
|
||||
delete pvHelper;
|
||||
delete tdHelper;
|
||||
delete hkHelper;
|
||||
delete oscHelper;
|
||||
delete vlmHelper;
|
||||
delete donHelper;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter / Setter (s) ...
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
//
|
||||
// Customize Strategy Identifier ...
|
||||
string GetTag() override
|
||||
{
|
||||
return XDTDStartegyToken;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Conditions For Signal ...
|
||||
bool HasSignal(
|
||||
XSignal &signal //
|
||||
) override
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
signal.Clean();
|
||||
|
||||
//
|
||||
double sl = 0;
|
||||
double tp = 0;
|
||||
double risk = 0;
|
||||
double entry = 0;
|
||||
double reward = 0;
|
||||
double r2r = R2R();
|
||||
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY;
|
||||
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
||||
|
||||
//
|
||||
bool hasLong = false;
|
||||
bool hasShort = false;
|
||||
|
||||
//
|
||||
// Retrieve Conditions ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVConditions pvConditions;
|
||||
result = pvHelper.GetConditions(pvConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTD ...
|
||||
XTDConditions tdConditions;
|
||||
result = tdHelper.GetConditions(tdConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XHKConditions hkConditions;
|
||||
result = hkHelper.GetConditions(hkConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XVLM ...
|
||||
XVLMConditions vlmConditions;
|
||||
result = vlmHelper.GetConditions(vlmConditions);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
|
||||
//
|
||||
// Open ...
|
||||
double upperOs[];
|
||||
double lowerOs[];
|
||||
ArraySetAsSeries(upperOs, true);
|
||||
ArraySetAsSeries(lowerOs, true);
|
||||
donHelper.CopyUpperO(
|
||||
0,
|
||||
5,
|
||||
upperOs //
|
||||
);
|
||||
donHelper.CopyLowerO(
|
||||
0,
|
||||
5,
|
||||
lowerOs //
|
||||
);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
double upperCs[];
|
||||
double lowerCs[];
|
||||
ArraySetAsSeries(upperCs, true);
|
||||
ArraySetAsSeries(lowerCs, true);
|
||||
donHelper.CopyUpperC(
|
||||
0,
|
||||
5,
|
||||
upperCs //
|
||||
);
|
||||
donHelper.CopyLowerC(
|
||||
0,
|
||||
5,
|
||||
lowerCs //
|
||||
);
|
||||
|
||||
//
|
||||
// High ...
|
||||
double upperHs[];
|
||||
double lowerHs[];
|
||||
ArraySetAsSeries(upperHs, true);
|
||||
ArraySetAsSeries(lowerHs, true);
|
||||
donHelper.CopyUpperH(
|
||||
0,
|
||||
5,
|
||||
upperHs //
|
||||
);
|
||||
donHelper.CopyLowerH(
|
||||
0,
|
||||
5,
|
||||
lowerHs //
|
||||
);
|
||||
|
||||
//
|
||||
// Low ...
|
||||
double upperLs[];
|
||||
double lowerLs[];
|
||||
ArraySetAsSeries(upperLs, true);
|
||||
ArraySetAsSeries(lowerLs, true);
|
||||
donHelper.CopyUpperL(
|
||||
0,
|
||||
5,
|
||||
upperLs //
|
||||
);
|
||||
donHelper.CopyLowerL(
|
||||
0,
|
||||
5,
|
||||
lowerLs //
|
||||
);
|
||||
|
||||
//
|
||||
double atr = oscHelper.GetATR(1);
|
||||
|
||||
//
|
||||
double rsis[];
|
||||
ArraySetAsSeries(rsis, true);
|
||||
oscHelper.CopyRSI(
|
||||
0,
|
||||
3,
|
||||
rsis //
|
||||
);
|
||||
|
||||
//
|
||||
// Start Calculations ...
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
// Retrieve Bars ...
|
||||
|
||||
//
|
||||
// Last Bar ...
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar of Last Bar ...
|
||||
XOHCL pBar;
|
||||
result = cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing Low Bar ...
|
||||
XOHCL lastSwingLow;
|
||||
result = cBar.FindLastSwingLow(lastSwingLow);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Last Swing High Bar ...
|
||||
XOHCL lastSwingHigh;
|
||||
result = cBar.FindLastSwingHigh(lastSwingHigh);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Highest High(s) and Lowest Low(s) ...
|
||||
|
||||
//
|
||||
// Highest High ...
|
||||
double hh3 = cBar.FindHighest(
|
||||
3,
|
||||
MODE_HIGH //
|
||||
);
|
||||
|
||||
//
|
||||
// Lowest Low ...
|
||||
double ll3 = cBar.FindLowest(
|
||||
3,
|
||||
MODE_LOW //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Support Exists or Find ...
|
||||
bool hasSupport = support.IsValid();
|
||||
if (!hasSupport)
|
||||
{
|
||||
//
|
||||
hasSupport =
|
||||
//
|
||||
cBar.HasSupport(support)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
DrawSupport(
|
||||
support,
|
||||
ChartID() //
|
||||
);
|
||||
|
||||
//
|
||||
supportTime = cBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance Exists or Find ...
|
||||
bool hasResistance = resistance.IsValid();
|
||||
if (!hasResistance)
|
||||
{
|
||||
//
|
||||
hasResistance =
|
||||
//
|
||||
cBar.HasResistance(resistance)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
DrawResistance(
|
||||
resistance,
|
||||
ChartID() //
|
||||
);
|
||||
|
||||
//
|
||||
resistanceTime = cBar.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// For Trend ...
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
// Detect Bullish/Bearish Patterns and Trends ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishPattern = HasBullishPattern(cBar);
|
||||
bool isBullishTrend = cBar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishPattern = HasBearishPattern(cBar);
|
||||
bool isBearishTrend = cBar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// Detect Conditions ...
|
||||
// Prepare Required Conditions ...
|
||||
|
||||
//
|
||||
// High Upper => tpp top
|
||||
// Low Upper => top bottom
|
||||
|
||||
//
|
||||
// High Lower => bottom top
|
||||
// Low Lower => bottom bottom
|
||||
|
||||
//
|
||||
bool isUpperBandToched = IsValid(upperTouchTime);
|
||||
if (!isUpperBandToched)
|
||||
{
|
||||
//
|
||||
isUpperBandToched =
|
||||
//
|
||||
(cBar.high > upperLs[cIndex])
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
bool isLowerBandToched = IsValid(lowerTouchTime);
|
||||
if (!isLowerBandToched)
|
||||
{
|
||||
//
|
||||
isLowerBandToched =
|
||||
//
|
||||
(cBar.low < lowerHs[cIndex])
|
||||
//
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
// Looking for Signals Based on Conditions ...
|
||||
|
||||
//
|
||||
if (isLowerBandToched)
|
||||
{
|
||||
//
|
||||
hasLong =
|
||||
//
|
||||
hasBullishPattern
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasLong)
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_BUY;
|
||||
Print("");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (isUpperBandToched)
|
||||
{
|
||||
//
|
||||
hasShort =
|
||||
//
|
||||
hasBearishPattern
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (hasShort)
|
||||
{
|
||||
//
|
||||
type = POSITION_TYPE_SELL;
|
||||
Print("");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Preparing Signals for Execution ...
|
||||
|
||||
//
|
||||
result = hasLong || hasShort;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
CheckSupportValidation();
|
||||
CheckResistanceValidation();
|
||||
|
||||
//
|
||||
CheckUpperTouchTimeValidation();
|
||||
CheckLowerTouchTimeValidation();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
supportTime = NULL;
|
||||
isSupportTested = false;
|
||||
RemoveSupport(support);
|
||||
support.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (hasResistance)
|
||||
{
|
||||
//
|
||||
resistanceTime = NULL;
|
||||
isResistanceTested = false;
|
||||
RemoveResistance(resistance);
|
||||
resistance.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Entry Price based on Position Type ...
|
||||
entry = GetEntry(mSymbol, type);
|
||||
|
||||
//
|
||||
// Calculate TP and SL ...
|
||||
// based on Strategy ...
|
||||
CalculateTPSLByPrice(
|
||||
sl,
|
||||
tp,
|
||||
type,
|
||||
entry,
|
||||
r2r //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing Signal ...
|
||||
result = signal.Prepare(
|
||||
mSymbol,
|
||||
GetTag(),
|
||||
mPeriod,
|
||||
type,
|
||||
mode,
|
||||
entry,
|
||||
mVolume,
|
||||
sl,
|
||||
tp //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
XOHCL support;
|
||||
XOHCL resistance;
|
||||
|
||||
//
|
||||
// XTD ...
|
||||
XTDInputs tdInputs;
|
||||
XSCXTDHelper *tdHelper;
|
||||
|
||||
//
|
||||
// XOSC ...
|
||||
XOSCInputs oscInputs;
|
||||
XSCXOSCHelper *oscHelper;
|
||||
|
||||
//
|
||||
// XVLM ...
|
||||
XVLMInputs vlmInputs;
|
||||
XSCXVLMHelper *vlmHelper;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XHKInputs hkInputs;
|
||||
XSCXHKHelper *hkHelper;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVInputs pvInputs;
|
||||
XSCXPVHelper *pvHelper;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
XDONInputs donInputs;
|
||||
XSCXDONHelper *donHelper;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
void PrepareRequirements()
|
||||
{
|
||||
//
|
||||
support.Clean();
|
||||
supportTime = NULL;
|
||||
isSupportTested = false;
|
||||
|
||||
//
|
||||
resistance.Clean();
|
||||
resistanceTime = NULL;
|
||||
isResistanceTested = false;
|
||||
|
||||
//
|
||||
// Prepare XTD ...
|
||||
tdInputs.Default();
|
||||
|
||||
//
|
||||
tdHelper = new XSCXTDHelper();
|
||||
tdHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
tdInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XHK ...
|
||||
hkInputs.Default();
|
||||
hkInputs.smoothingLength = 14;
|
||||
|
||||
//
|
||||
hkInputs.drawHikenAshi = false;
|
||||
hkInputs.drawSmoothedHikenAshi = true;
|
||||
|
||||
//
|
||||
hkHelper = new XSCXHKHelper();
|
||||
hkHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
hkInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XPV ...
|
||||
pvInputs.Default();
|
||||
|
||||
//
|
||||
pvInputs.showPeaksAndVales = true;
|
||||
pvInputs.showLevels = false;
|
||||
pvInputs.showConsolidations = false;
|
||||
pvInputs.showFibo1Levels = false;
|
||||
pvInputs.showFibo2Levels = false;
|
||||
pvInputs.showFibo3Levels = true;
|
||||
pvInputs.showFibo4Levels = false;
|
||||
pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
pvHelper = new XSCXPVHelper();
|
||||
pvHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
pvInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XOSC ...
|
||||
oscInputs.Default();
|
||||
oscHelper = new XSCXOSCHelper();
|
||||
oscHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
oscInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// Preparing XVLM ...
|
||||
vlmInputs.Default();
|
||||
vlmHelper = new XSCXVLMHelper();
|
||||
vlmHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
vlmInputs //
|
||||
);
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
|
||||
//
|
||||
donInputs.Default();
|
||||
|
||||
//
|
||||
donInputs.showLow = true;
|
||||
donInputs.showHigh = true;
|
||||
donInputs.showOpen = false;
|
||||
donInputs.showClose = false;
|
||||
|
||||
//
|
||||
donHelper = new XSCXDONHelper();
|
||||
donHelper.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
donInputs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool isSupportTested;
|
||||
datetime supportTime;
|
||||
void CheckSupportValidation()
|
||||
{
|
||||
//
|
||||
if (!isSupportTested)
|
||||
{
|
||||
//
|
||||
if (support.IsValid() && IsValid(supportTime))
|
||||
{
|
||||
//
|
||||
int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(supportTime))) / PeriodSeconds(mPeriod));
|
||||
if (age >= 50)
|
||||
{
|
||||
//
|
||||
isSupportTested = false;
|
||||
supportTime = NULL;
|
||||
RemoveSupport(support);
|
||||
support.Clean();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
// Find Price Distance ...
|
||||
double highDiff = MathAbs(cBar.high - support.high);
|
||||
double lowDiff = MathAbs(cBar.low - support.high);
|
||||
|
||||
//
|
||||
bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points;
|
||||
if (!isBreaked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
isSupportTested = false;
|
||||
RemoveSupport(support);
|
||||
supportTime = NULL;
|
||||
support.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
bool isResistanceTested;
|
||||
datetime resistanceTime;
|
||||
void CheckResistanceValidation()
|
||||
{
|
||||
//
|
||||
if (!isResistanceTested)
|
||||
{
|
||||
//
|
||||
if (resistance.IsValid() && IsValid(resistanceTime))
|
||||
{
|
||||
//
|
||||
int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(resistanceTime))) / PeriodSeconds(mPeriod));
|
||||
if (age >= 50)
|
||||
{
|
||||
//
|
||||
isResistanceTested = false;
|
||||
resistanceTime = NULL;
|
||||
RemoveResistance(resistance);
|
||||
resistance.Clean();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(mSymbol);
|
||||
|
||||
//
|
||||
// Find Price Distance ...
|
||||
double highDiff = MathAbs(cBar.high - resistance.low);
|
||||
double lowDiff = MathAbs(cBar.low - resistance.low);
|
||||
|
||||
//
|
||||
bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points;
|
||||
if (!isBreaked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
isResistanceTested = false;
|
||||
RemoveResistance(resistance);
|
||||
resistanceTime = NULL;
|
||||
resistance.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
datetime lowerTouchTime;
|
||||
void CheckLowerTouchTimeValidation() {
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
datetime upperTouchTime;
|
||||
void CheckUpperTouchTimeValidation() {
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user