last ...
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCZone
|
||||
// Description: provides all Alerts requirements ...
|
||||
// Description: provides all Zone requirements ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
|
||||
@@ -0,0 +1,557 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCTrend
|
||||
// Description: provides all Trend requirements ...
|
||||
//
|
||||
//
|
||||
// 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 ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// All Required Inputs ...
|
||||
struct XSCTrendInput
|
||||
{
|
||||
//
|
||||
int numberOfShoulders; // Number of Shoulders
|
||||
|
||||
//
|
||||
color clrUpper; // Upper Colors
|
||||
color clrLower; // Lower Colors
|
||||
color clrHighs; // Highs Colors
|
||||
color clrLows; // Lows Colors
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCTrendInput()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
numberOfShoulders = 0;
|
||||
|
||||
//
|
||||
clrUpper = CLR_NONE;
|
||||
clrLower = CLR_NONE;
|
||||
clrHighs = CLR_NONE;
|
||||
clrLows = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Defualt Configs ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
numberOfShoulders = 7;
|
||||
|
||||
//
|
||||
clrUpper = clrRed;
|
||||
clrLower = clrGreen;
|
||||
|
||||
//
|
||||
clrHighs = clrAqua;
|
||||
clrLows = clrMagenta;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
numberOfShoulders >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class Definitions ...
|
||||
class XSCTrend : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCTrend(
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period //
|
||||
) : XSCBase()
|
||||
{
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCTrend() {}
|
||||
|
||||
//
|
||||
// Initialize ...
|
||||
bool Init(XSCTrendInput &inputs)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
result = zBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
0 //
|
||||
);
|
||||
|
||||
//
|
||||
int firstSwingLowIndex = FindSwing(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
X_SWING_LOW,
|
||||
mInputs.numberOfShoulders,
|
||||
zBar.Index() + 1 //
|
||||
);
|
||||
result = firstSwingLowBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
firstSwingLowIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int secondSwingLowIndex = FindSwing(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
X_SWING_LOW,
|
||||
mInputs.numberOfShoulders,
|
||||
firstSwingLowIndex + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
result = secondSwingLowBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
secondSwingLowIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int firstSwingHighIndex = FindSwing(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
X_SWING_HIGH,
|
||||
mInputs.numberOfShoulders,
|
||||
zBar.Index() + 1 //
|
||||
);
|
||||
result = firstSwingHighBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
firstSwingHighIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int secondSwingHighIndex = FindSwing(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
X_SWING_HIGH,
|
||||
mInputs.numberOfShoulders,
|
||||
firstSwingHighIndex + 1 //
|
||||
);
|
||||
result = secondSwingHighBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
secondSwingHighIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
XSCTrendInput GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(XSCTrendInput &inputs)
|
||||
{
|
||||
return Init(inputs);
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetBar()
|
||||
{
|
||||
return zBar;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetFirstSwingLowBar()
|
||||
{
|
||||
return firstSwingLowBar;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetSecondSwingLowBar()
|
||||
{
|
||||
return secondSwingLowBar;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetFirstSwingHighBar()
|
||||
{
|
||||
return firstSwingHighBar;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetSecondSwingHighBar()
|
||||
{
|
||||
return secondSwingHighBar;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
zBar.IsValid() &&
|
||||
firstSwingLowBar.IsValid() &&
|
||||
secondSwingLowBar.IsValid() &&
|
||||
firstSwingHighBar.IsValid() &&
|
||||
secondSwingHighBar.IsValid()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Title Prefix ...
|
||||
string GetIdentifier()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mSymbol + "_" +
|
||||
ToString(mPeriod) +
|
||||
ToFormatString(zBar.time);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Draws ...
|
||||
bool Remove(
|
||||
long chartId = 0,
|
||||
int subWindow = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = GetIdentifier();
|
||||
result = IsSpecifiedValid(prefix);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = RemoveDraw(
|
||||
prefix,
|
||||
chartId,
|
||||
subWindow //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool Draw(
|
||||
long chartId = 0,
|
||||
string prefix = NULL,
|
||||
int subWindow = 0,
|
||||
string upperPrefix = "Upper",
|
||||
string lowerPrefix = "Lower",
|
||||
string highsPrefix = "Highs",
|
||||
string lowsPrefix = "Lows" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize Prefixes ...
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(upperPrefix))
|
||||
{
|
||||
upperPrefix = "Upper";
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(lowerPrefix))
|
||||
{
|
||||
lowerPrefix = "Lower";
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(highsPrefix))
|
||||
{
|
||||
highsPrefix = "Highs";
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(lowsPrefix))
|
||||
{
|
||||
lowsPrefix = "Lows";
|
||||
}
|
||||
|
||||
//
|
||||
string identifier = GetIdentifier();
|
||||
result = IsSpecifiedValid(identifier);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double support = secondSwingLowBar.low;
|
||||
datetime supportTime = secondSwingLowBar.time;
|
||||
string supportName =
|
||||
//
|
||||
identifier +
|
||||
(IsSpecifiedValid(prefix)
|
||||
? "_" + prefix + "_"
|
||||
: "") +
|
||||
"_" + lowerPrefix + "_" +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
double resistance = secondSwingHighBar.high;
|
||||
datetime resistanceTime = secondSwingLowBar.time;
|
||||
string resistanceName =
|
||||
//
|
||||
identifier +
|
||||
(IsSpecifiedValid(prefix)
|
||||
? "_" + prefix + "_"
|
||||
: "") +
|
||||
"_" + upperPrefix + "_" +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
double newLow = firstSwingLowBar.low;
|
||||
datetime newLowTime = firstSwingLowBar.time;
|
||||
|
||||
//
|
||||
double oldLow = secondSwingLowBar.low;
|
||||
datetime oldLowTime = secondSwingLowBar.time;
|
||||
string lowsName =
|
||||
//
|
||||
identifier +
|
||||
(IsSpecifiedValid(prefix)
|
||||
? "_" + prefix + "_"
|
||||
: "") +
|
||||
"_" + lowsPrefix + "_" +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
double newHigh = firstSwingHighBar.high;
|
||||
datetime newHighTime = firstSwingHighBar.time;
|
||||
|
||||
//
|
||||
double oldHigh = secondSwingHighBar.high;
|
||||
datetime oldHighTime = secondSwingHighBar.time;
|
||||
string highsName =
|
||||
//
|
||||
identifier +
|
||||
(IsSpecifiedValid(prefix)
|
||||
? "_" + prefix + "_"
|
||||
: "") +
|
||||
"_" + lowsPrefix + "_" +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Draw Support ...
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
supportName,
|
||||
subWindow,
|
||||
supportTime,
|
||||
support,
|
||||
newLowTime,
|
||||
support,
|
||||
mInputs.clrLower,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Resistance ...
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
resistanceName,
|
||||
subWindow,
|
||||
resistanceTime,
|
||||
resistance,
|
||||
newHighTime,
|
||||
resistance,
|
||||
mInputs.clrUpper,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
string mSymbol; // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Trading Period ...
|
||||
|
||||
//
|
||||
XSCTrendInput mInputs; // Configs ...
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL firstSwingLowBar;
|
||||
XOHCL secondSwingLowBar;
|
||||
XOHCL firstSwingHighBar;
|
||||
XOHCL secondSwingHighBar;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -39,7 +39,8 @@ input int x121EASlippage = 10; // Slippgae
|
||||
// Signals ...
|
||||
// EURUSDb,GBPUSDb,XAUUSDb,USDCHFb,USDJPYb
|
||||
input group "Signals";
|
||||
input string x121EASymbols = "EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD"; // Symbols
|
||||
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
|
||||
input string x121EASymbols = ""; // Symbols
|
||||
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
||||
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
|
||||
input bool x121EAAllowLong = true; // Allow Long Trades
|
||||
@@ -70,12 +71,12 @@ input group "Trailling";
|
||||
input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses
|
||||
input double x121EAFirstTrailDistance = 110; // Start Trailling Distance
|
||||
input double x121EAFirstTrailPoint = 60; // First Stop Trail
|
||||
input double x121EANextTrailDistance = 60; // Next Trailling Distance
|
||||
input double x121EANextTrailDistance = 50; // Next Trailling Distance
|
||||
input double x121EANextTrailPoint = 20; // Next Trailling Step
|
||||
|
||||
//
|
||||
input group "Supporting";
|
||||
input bool x121EAAllowSupport = false; // Allow Support Signals
|
||||
input bool x121EAAllowSupport = true; // Allow Support Signals
|
||||
double x121EASupportDistance = 50; // Supporting Distance
|
||||
input int x121EAMaxNumberOfSupports = 1; // Max Number of Support Signals
|
||||
input double x121EASupportVolumeMultiplier = 2.0; // Support Signals Volume Multiplier
|
||||
@@ -100,9 +101,9 @@ input double x121EAMaxAllowedRecoveryVolume = 0.08; // Max Allowed Recovery Sign
|
||||
//
|
||||
input group "Hedging";
|
||||
input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge
|
||||
input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging
|
||||
input double x121EAMinRequiredProfitPerTrade = 0.4; // Minimum Required Profit for Hedging
|
||||
input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume
|
||||
input double x121EAForceCloseProfit = 40; // Close All Positions Regardless of Policies when Profit Reached
|
||||
input double x121EAForceCloseProfit = 20; // Close All Positions Regardless of Policies when Profit Reached
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
|
||||
Reference in New Issue
Block a user