last works on supporting ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ struct XTradeInfo
|
||||
double volume; // Volume
|
||||
string provider; // Signaller
|
||||
ENUM_TIMEFRAMES period; // Trading Timeframe
|
||||
ENUM_X_POSITION_TYPE type; // Position Type
|
||||
ENUM_X_POSITION_TYPES type; // Position Type
|
||||
|
||||
//
|
||||
ulong ticket; // Position Ticket
|
||||
@@ -3851,7 +3851,7 @@ public:
|
||||
{
|
||||
//
|
||||
// Select Signal Opposit Positions ...
|
||||
ENUM_X_POSITION_TYPE iOpposit = GetOppositPositionType(iSignal.type);
|
||||
ENUM_X_POSITION_TYPES iOpposit = GetOppositPositionType(iSignal.type);
|
||||
|
||||
//
|
||||
XPosition iPositions[];
|
||||
@@ -3995,9 +3995,8 @@ public:
|
||||
//
|
||||
// Signal Info Manager ...
|
||||
XSignal tSignal = signal;
|
||||
bool isSupport = ExtractSupportedTicket(signal.comment) > 0;
|
||||
bool isEQMSupport = ExtractEQMSupportedTicket(signal.comment) > 0;
|
||||
if (!isSupport && !isEQMSupport)
|
||||
bool isSupport = IsSupport(signal.comment);
|
||||
if (!isSupport)
|
||||
{
|
||||
mTradeHandler.Update(tSignal);
|
||||
}
|
||||
@@ -4019,6 +4018,13 @@ public:
|
||||
mTradeHandler.Sync();
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Support of Supports here ...
|
||||
void OnPositionsChangedHandler(int count) override
|
||||
{
|
||||
EQMHandleSupportProtection(count);
|
||||
}
|
||||
|
||||
//
|
||||
void OnPositionClosed(
|
||||
const XPosition &position,
|
||||
@@ -4739,6 +4745,102 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void EQMHandleSupportProtection(int positionsCount)
|
||||
{
|
||||
//
|
||||
if (!IsValidSize(positionsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
ulong ticket = mTrader.GetLastOpenPositionTicket();
|
||||
XPosition position;
|
||||
bool hasPosition = mTrader.GetPosition(
|
||||
ticket,
|
||||
position //
|
||||
);
|
||||
if (!hasPosition)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSupport = IsSupport(position.comment);
|
||||
if (!isSupport)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isDIRInDIRSupport = position.provider == XEQMSupportToken + XDirectionalToken ||
|
||||
position.provider == XEQMSupportToken + XINDirectionalToken;
|
||||
if (!isDIRInDIRSupport)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
ulong parentTicket = ExtractParentTicket(position.comment);
|
||||
XPosition parent;
|
||||
bool hasParent = mTrader.GetPosition(
|
||||
parentTicket,
|
||||
parent //
|
||||
);
|
||||
if (!hasParent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Parent TP SL ...
|
||||
if (parent.tp > 0 || parent.sl > 0)
|
||||
{
|
||||
//
|
||||
string comment = XEQMSupportToken + "Remoove TPSL due Protect ...";
|
||||
bool isModeified = mTrader.Modify(
|
||||
parentTicket,
|
||||
0,
|
||||
0,
|
||||
comment //
|
||||
);
|
||||
if (isModeified)
|
||||
{
|
||||
//
|
||||
string message = XEQMSupportToken + " Removes Position (" + ToString(parentTicket) + ")' TP/SL Due Start Supporting ...";
|
||||
|
||||
//
|
||||
Alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XSignal signal;
|
||||
X121SignalGenerator signalGenerator;
|
||||
bool hasSupport = signalGenerator.UpdateSupportSignals(
|
||||
position,
|
||||
parent,
|
||||
signal //
|
||||
);
|
||||
if (!hasSupport)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XSignal signals[];
|
||||
|
||||
//
|
||||
AddRef(
|
||||
signal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
EQMExecuteSignals(signals);
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
XSignal &support, // Holds Support Signal, if Provided
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period // Specified Time Frame
|
||||
)
|
||||
{
|
||||
@@ -1261,7 +1261,7 @@ protected:
|
||||
void HandleGuardHedgeAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period, // Specified Time Frame
|
||||
double minProfitForHedging = 1, // Specified Profit for Hedge
|
||||
double minProfitForHedgingVolumeFactor = 0.01 // Specified Volume Factor for Hedge
|
||||
@@ -1320,7 +1320,7 @@ protected:
|
||||
void HandleGuardCloseInProfitAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period, // Specified Time Frame
|
||||
ENUM_X_POSITION_SELECT_METHODS method = NULL // Select Method
|
||||
)
|
||||
@@ -1362,7 +1362,7 @@ protected:
|
||||
void HandleGuardCloseInDrawdownAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period, // Specified Time Frame
|
||||
ENUM_X_POSITION_SELECT_METHODS method = NULL // Select Method
|
||||
)
|
||||
@@ -1404,7 +1404,7 @@ protected:
|
||||
void HandleGuardForceCloseAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period, // Specified Time Frame
|
||||
ulong ticket = 0 // Specific Ticket
|
||||
)
|
||||
@@ -1481,7 +1481,7 @@ protected:
|
||||
void HandleGuardTrailingStopAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period, // Specified Time Frame
|
||||
double sl // Desired SL Value ...
|
||||
)
|
||||
@@ -1559,7 +1559,7 @@ protected:
|
||||
void HandleGuardAddSupportPositionAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period // Specified Time Frame
|
||||
)
|
||||
{
|
||||
@@ -1613,7 +1613,7 @@ protected:
|
||||
void HandleGuardCancelPendingOrdersAction(
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_X_POSITION_TYPE type, // Trading Type
|
||||
ENUM_X_POSITION_TYPES type, // Trading Type
|
||||
ENUM_TIMEFRAMES period // Specified Time Frame
|
||||
)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
|
||||
#include "../Classes/x-saherelm.xaccount.class.mq5"
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
@@ -0,0 +1,736 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCRange
|
||||
// Description: provides all Range 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"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
struct XSCCFInput
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
int length; // Minimum of Same Bars
|
||||
|
||||
//
|
||||
color clrUpper; // Upper Color ...
|
||||
color clrLower; // Lower Color ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCCFInput()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
|
||||
//
|
||||
clrUpper = CLR_NONE;
|
||||
clrLower = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Defualt Configs ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 4;
|
||||
|
||||
//
|
||||
clrLower = clrAqua;
|
||||
clrUpper = clrMagenta;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
|
||||
class XSCCF : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCCF(
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period //
|
||||
) : XSCBase()
|
||||
{
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCCF() {}
|
||||
|
||||
//
|
||||
// Initialize ...
|
||||
bool Init(XSCCFInput &inputs)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
// Find Bullish Bar ...
|
||||
result = FindBullishBar(0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Bearish Bar ...
|
||||
result = FindBearishBar(0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
XSCCFInput GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(XSCCFInput &inputs)
|
||||
{
|
||||
return Init(inputs);
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetBullishBar()
|
||||
{
|
||||
return bullishBar;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL GetBearishBar()
|
||||
{
|
||||
return bearishBar;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
string GetTag() override
|
||||
{
|
||||
return "XCF";
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
bullishBar.IsValid() &&
|
||||
bearishBar.IsValid()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Title Prefix ...
|
||||
string GetIdentifier()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = GetTag() + "_" +
|
||||
mSymbol + "_" +
|
||||
ToString(mPeriod) + "_" +
|
||||
ToFormatString(bullishBar.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;
|
||||
}
|
||||
|
||||
//
|
||||
RemoveDraws(
|
||||
prefix,
|
||||
chartId,
|
||||
subWindow //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool Draw(
|
||||
long chartId = 0,
|
||||
string prefix = NULL,
|
||||
int subWindow = 0,
|
||||
string upperPrefix = "Upper",
|
||||
string lowerPrefix = "Lower" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = DrawBullishBar(
|
||||
chartId,
|
||||
prefix,
|
||||
subWindow,
|
||||
upperPrefix,
|
||||
lowerPrefix //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = DrawBearishBar(
|
||||
chartId,
|
||||
prefix,
|
||||
subWindow,
|
||||
upperPrefix,
|
||||
lowerPrefix //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
bool FindBullishBar(
|
||||
int barIndex //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int next = barIndex + 1;
|
||||
|
||||
//
|
||||
int totalBars = iBars(
|
||||
mSymbol,
|
||||
mPeriod //
|
||||
);
|
||||
result = barIndex >= 0 && barIndex + 1 + mInputs.length < totalBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isNextValid = next >= 0 && next + 1 + mInputs.length < totalBars;
|
||||
|
||||
//
|
||||
int bullBarIndex = barIndex + 1;
|
||||
int start = bullBarIndex + 1;
|
||||
int end = start + mInputs.length;
|
||||
|
||||
//
|
||||
XOHCL startBar;
|
||||
result = startBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
bullBarIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = startBar.IsBullish();
|
||||
if (!result)
|
||||
{
|
||||
if (isNextValid)
|
||||
{
|
||||
return FindBullishBar(next);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Back to Find Bearish Bars ...
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
i //
|
||||
);
|
||||
if (!result || !iBar.IsBearish())
|
||||
{
|
||||
//
|
||||
if (isNextValid)
|
||||
{
|
||||
return FindBullishBar(next);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
bullishBar = startBar;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool FindBearishBar(
|
||||
int barIndex //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int next = barIndex + 1;
|
||||
|
||||
//
|
||||
int totalBars = iBars(
|
||||
mSymbol,
|
||||
mPeriod //
|
||||
);
|
||||
result = barIndex >= 0 && barIndex + 1 + mInputs.length < totalBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isNextValid = next >= 0 && next + 1 + mInputs.length < totalBars;
|
||||
|
||||
//
|
||||
int bearBarIndex = barIndex + 1;
|
||||
int start = bearBarIndex + 1;
|
||||
int end = start + mInputs.length;
|
||||
|
||||
//
|
||||
XOHCL startBar;
|
||||
result = startBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
bearBarIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = startBar.IsBearish();
|
||||
if (!result)
|
||||
{
|
||||
if (isNextValid)
|
||||
{
|
||||
return FindBearishBar(next);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Back to Find Bearish Bars ...
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
i //
|
||||
);
|
||||
if (!result || !iBar.IsBullish())
|
||||
{
|
||||
//
|
||||
if (isNextValid)
|
||||
{
|
||||
return FindBearishBar(next);
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
bearishBar = startBar;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DrawBullishBar(
|
||||
long chartId = 0,
|
||||
string prefix = NULL,
|
||||
int subWindow = 0,
|
||||
string upperPrefix = "Upper",
|
||||
string lowerPrefix = "Lower" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bullishBar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(upperPrefix))
|
||||
{
|
||||
upperPrefix = "High";
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(lowerPrefix))
|
||||
{
|
||||
lowerPrefix = "Low";
|
||||
}
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
string identifier = GetIdentifier();
|
||||
|
||||
//
|
||||
// High Line ...
|
||||
string bullishHighLineName =
|
||||
(IsSpecifiedValid(prefix)
|
||||
? prefix + "_"
|
||||
: "") +
|
||||
identifier + "_" +
|
||||
"BULL_" +
|
||||
upperPrefix;
|
||||
|
||||
//
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
bullishHighLineName,
|
||||
subWindow,
|
||||
bullishBar.time,
|
||||
bullishBar.high,
|
||||
cTime,
|
||||
bullishBar.high,
|
||||
mInputs.clrUpper,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
|
||||
//
|
||||
// Low Line ...
|
||||
string bullishLowLineName =
|
||||
(IsSpecifiedValid(prefix)
|
||||
? prefix + "_"
|
||||
: "") +
|
||||
identifier + "_" +
|
||||
"BULL_" +
|
||||
lowerPrefix;
|
||||
|
||||
//
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
bullishLowLineName,
|
||||
subWindow,
|
||||
bullishBar.time,
|
||||
bullishBar.low,
|
||||
cTime,
|
||||
bullishBar.low,
|
||||
mInputs.clrLower,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool DrawBearishBar(
|
||||
long chartId = 0,
|
||||
string prefix = NULL,
|
||||
int subWindow = 0,
|
||||
string upperPrefix = "Upper",
|
||||
string lowerPrefix = "Lower" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bearishBar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(upperPrefix))
|
||||
{
|
||||
upperPrefix = "High";
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(lowerPrefix))
|
||||
{
|
||||
lowerPrefix = "Low";
|
||||
}
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
string identifier = GetIdentifier();
|
||||
|
||||
//
|
||||
// High Line ...
|
||||
string bearishHighLineName =
|
||||
(IsSpecifiedValid(prefix)
|
||||
? prefix + "_"
|
||||
: "") +
|
||||
identifier + "_" +
|
||||
"BEAR_" +
|
||||
upperPrefix;
|
||||
|
||||
//
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
bearishHighLineName,
|
||||
subWindow,
|
||||
bearishBar.time,
|
||||
bearishBar.high,
|
||||
cTime,
|
||||
bearishBar.high,
|
||||
mInputs.clrUpper,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
|
||||
//
|
||||
// Low Line ...
|
||||
string bearishLowLineName =
|
||||
(IsSpecifiedValid(prefix)
|
||||
? prefix + "_"
|
||||
: "") +
|
||||
identifier + "_" +
|
||||
"BEAR_" +
|
||||
lowerPrefix;
|
||||
|
||||
//
|
||||
result = DrawTrendLine(
|
||||
chartId,
|
||||
bearishLowLineName,
|
||||
subWindow,
|
||||
bearishBar.time,
|
||||
bearishBar.low,
|
||||
cTime,
|
||||
bearishBar.low,
|
||||
mInputs.clrLower,
|
||||
STYLE_SOLID,
|
||||
2,
|
||||
false,
|
||||
false,
|
||||
true // Ray Right ...
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
string mSymbol; // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES mPeriod; // Trading Period ...
|
||||
|
||||
//
|
||||
XOHCL bearishBar; // Bearish Order Block Bar
|
||||
XOHCL bullishBar; // Bullish Order Block Bar
|
||||
|
||||
//
|
||||
XSCCFInput mInputs; // Configs ...
|
||||
};
|
||||
|
||||
//
|
||||
@@ -120,7 +120,9 @@ public:
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCTrend() {}
|
||||
void ~XSCTrend() {
|
||||
Remove();
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize ...
|
||||
@@ -281,6 +283,15 @@ public:
|
||||
return secondSwingHighBar;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
//
|
||||
string GetTag() override
|
||||
{
|
||||
return "XTREND";
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
@@ -320,7 +331,8 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
result = mSymbol + "_" +
|
||||
result = GetTag() + "_" +
|
||||
mSymbol + "_" +
|
||||
ToString(mPeriod) + "_" +
|
||||
ToFormatString(zBar.time);
|
||||
|
||||
@@ -354,7 +366,7 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
result = RemoveDraw(
|
||||
RemoveDraws(
|
||||
prefix,
|
||||
chartId,
|
||||
subWindow //
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
#define defZoneBGColor clrLightGray
|
||||
#define defZoneBGColor CLR_NONE // clrLightGray
|
||||
#define defZoneLBLColor clrWhite
|
||||
|
||||
//
|
||||
@@ -286,6 +286,56 @@ public:
|
||||
return Init(inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
//
|
||||
string GetTag() override
|
||||
{
|
||||
return "XZONE";
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Title Prefix ...
|
||||
string GetIdentifier()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = GetTag() + "_" +
|
||||
mSymbol + "_" +
|
||||
ToString(mPeriod) +
|
||||
ToFormatString(mStartTime) + "_" +
|
||||
ToFormatString(mEndTime);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
mZones.Total() > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Specified Level/Color ...
|
||||
void AddLevelColor(
|
||||
@@ -502,7 +552,7 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
bool DrawZones(
|
||||
bool Draw(
|
||||
long chartId = 0,
|
||||
string prefix = "XSCZone",
|
||||
int subWindow = 0,
|
||||
@@ -645,6 +695,31 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool Remove(
|
||||
long chartId = 0,
|
||||
string prefix = "XSCZone",
|
||||
int subWindow = 0,
|
||||
bool redraw = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mChartObjects.Clear();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
true
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
@@ -1845,7 +1845,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
bool filterByMagic = true // Get Only Self Open Positions
|
||||
)
|
||||
{
|
||||
@@ -2034,7 +2034,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
bool filterByMagic = true // Get Only Self Open Positions
|
||||
)
|
||||
{
|
||||
@@ -2099,7 +2099,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
bool filterByMagic = true, // Get Only Self Open Positions
|
||||
bool forceClean = true // Clean Result Array
|
||||
)
|
||||
@@ -2215,7 +2215,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_SELECT_METHODS method = NULL, // Selection Method
|
||||
bool filterByMagic = true, // Get Only Self Open Positions
|
||||
bool forceClean = true // Clean Result Array
|
||||
@@ -2346,7 +2346,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_SELECT_METHODS method = NULL, // Selection Method
|
||||
bool filterByMagic = true, // Get Only Self Open Positions
|
||||
bool forceClean = true // Clean Result Array
|
||||
@@ -2567,7 +2567,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_ORDER_STATE state = NULL, // Order State
|
||||
bool filterByMagic = true, // Get Only Self Open Positions
|
||||
bool forceClean = true // Clean Result Array
|
||||
@@ -2649,7 +2649,7 @@ public:
|
||||
string symbol = NULL, // Trading Symbol
|
||||
string provider = NULL, // Signal Provider
|
||||
ENUM_TIMEFRAMES period = NULL, // Trading Period
|
||||
ENUM_X_POSITION_TYPE type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_X_POSITION_TYPES type = NULL, // Long (Buy) or Short (Sell)
|
||||
ENUM_ORDER_STATE state = NULL, // Order State
|
||||
datetime startDate = NULL, // Specify Start Date
|
||||
datetime endDate = NULL, // Specify End Date
|
||||
|
||||
Reference in New Issue
Block a user