last ...
This commit is contained in:
@@ -3608,7 +3608,12 @@ struct X121SignalGenerator
|
|||||||
//
|
//
|
||||||
if (canUseZones)
|
if (canUseZones)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
signal.zones.Draw();
|
signal.zones.Draw();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find Hot Zones ...
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -35,13 +35,13 @@
|
|||||||
struct XTradeInfo
|
struct XTradeInfo
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int pushers; // Signal Pushers
|
int pushers; // Signal Pushers
|
||||||
datetime time; // Issue Time (Open Position)
|
datetime time; // Issue Time (Open Position)
|
||||||
string symbol; // Trading Symbol
|
string symbol; // Trading Symbol
|
||||||
double entry; // Entry Price
|
double entry; // Entry Price
|
||||||
double volume; // Volume
|
double volume; // Volume
|
||||||
string provider; // Signaller
|
string provider; // Signaller
|
||||||
ENUM_TIMEFRAMES period; // Trading Timeframe
|
ENUM_TIMEFRAMES period; // Trading Timeframe
|
||||||
ENUM_X_POSITION_TYPES type; // Position Type
|
ENUM_X_POSITION_TYPES type; // Position Type
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3885,6 +3885,16 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Remove this ...
|
||||||
|
// isSignalValid = !AllowSupport()
|
||||||
|
// ? true
|
||||||
|
// : IsValidSize(ArraySize(iSignal.supports));
|
||||||
|
// if (!isSignalValid)
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Filter Signals Based On Max Allowed ...
|
// Filter Signals Based On Max Allowed ...
|
||||||
if (maxAllowed > 0)
|
if (maxAllowed > 0)
|
||||||
|
|||||||
@@ -0,0 +1,330 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XSCSupRes
|
||||||
|
// Description: provides all Support and Resistances 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 "../Helpers/x-saherelm.xpv.helper.mq5"
|
||||||
|
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
struct XSCSupResInput
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
int numberOfSupports; // Number of Required Supports
|
||||||
|
int numberOfResistances; // Number of Required Resistances
|
||||||
|
|
||||||
|
//
|
||||||
|
int pivotsVerifications; // Pivots Verifications
|
||||||
|
|
||||||
|
//
|
||||||
|
double distance; // Distance between Pivots
|
||||||
|
|
||||||
|
//
|
||||||
|
double price; // Price for Support and Resistance Finding
|
||||||
|
|
||||||
|
//
|
||||||
|
color clrSupport;
|
||||||
|
color clrResistance;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
void XSCSupResInput()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
numberOfSupports = 0;
|
||||||
|
numberOfResistances = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
price = 0;
|
||||||
|
distance = 0;
|
||||||
|
pivotsVerifications = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
clrSupport = CLR_NONE;
|
||||||
|
clrResistance = CLR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Defualt Configs ...
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
numberOfSupports = 5;
|
||||||
|
numberOfResistances = 5;
|
||||||
|
|
||||||
|
//
|
||||||
|
price = 0;
|
||||||
|
distance = 10;
|
||||||
|
pivotsVerifications = 35;
|
||||||
|
|
||||||
|
//
|
||||||
|
clrSupport = clrAqua;
|
||||||
|
clrResistance = clrMagenta;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
price > 0 &&
|
||||||
|
distance >= 0 &&
|
||||||
|
numberOfSupports > 0 &&
|
||||||
|
numberOfResistances > 0 &&
|
||||||
|
pivotsVerifications > 2
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class ...
|
||||||
|
|
||||||
|
//
|
||||||
|
class XSCSupRes : public XSCBase
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
void XSCSupRes(
|
||||||
|
string symbol,
|
||||||
|
ENUM_TIMEFRAMES period //
|
||||||
|
) : XSCBase()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
mSymbol = symbol;
|
||||||
|
mPeriod = period;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
void ~XSCSupRes() {}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initializer ...
|
||||||
|
bool Init(XSCSupResInput &inputs)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = inputs.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mInputs = inputs;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find Pivots ...
|
||||||
|
result = FindPivots();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Getter(s) / Setter(s) ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string GetSymbol()
|
||||||
|
{
|
||||||
|
return mSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_TIMEFRAMES GetPeriod()
|
||||||
|
{
|
||||||
|
return mPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XSCSupResInput GetInputs()
|
||||||
|
{
|
||||||
|
return mInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool SetInputs(XSCSupResInput &inputs)
|
||||||
|
{
|
||||||
|
return Init(inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Overrides ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string GetTag() override
|
||||||
|
{
|
||||||
|
return "XSupRes";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
false
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Title Prefix ...
|
||||||
|
string GetIdentifier()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = GetTag() + "_" +
|
||||||
|
mSymbol + "_" +
|
||||||
|
ToString(mPeriod) + "_";
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
string mSymbol; // Trading Symbol ...
|
||||||
|
ENUM_TIMEFRAMES mPeriod; // Trading Period ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XSCSupResInput mInputs; // Configs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double mSupports[];
|
||||||
|
double mResistances[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool FindPivots(int barIndex = 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int totalBars = iBars(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = barIndex >= 0 && barIndex < totalBars - mInputs.pivotsVerifications;
|
||||||
|
if (!result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int next = barIndex + 1;
|
||||||
|
bool canNext = next >= 0 && next < totalBars - mInputs.pivotsVerifications;
|
||||||
|
|
||||||
|
//
|
||||||
|
XSCXPVHelper helper = new XSCXPVHelper();
|
||||||
|
XPVInputs pvInputs;
|
||||||
|
pvInputs.Default();
|
||||||
|
result = helper.Init(
|
||||||
|
mSymbol,
|
||||||
|
mPeriod,
|
||||||
|
pvInputs //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Complete this ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check States ...
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
Reference in New Issue
Block a user