last works on supporting ...

This commit is contained in:
2024-06-20 00:05:45 +03:30
parent 7bae4c6723
commit 0ef22df67b
11 changed files with 2440 additions and 494 deletions
File diff suppressed because it is too large Load Diff
+107 -5
View File
@@ -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);
}
//
};
+8 -8
View File
@@ -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
)
{
+1 -2
View File
@@ -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 ...
+736
View File
@@ -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 ...
};
//
+15 -3
View File
@@ -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 //
+77 -2
View File
@@ -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:
+7 -7
View File
@@ -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
+597
View File
@@ -1742,3 +1742,600 @@
}
return;
}
//////////////////////////////////////////////////////////////////////
// //
// // Check Signal Has TP and SL ...
// if (signal.tp > 0 && signal.sl > 0)
// {
// //
// // Here we Can Provide Orders based on Signal TP and SL ...
// //
// // Calculate TP/Entry Distance ...
// double tpDistance =
// isLong
// ? signal.tp - signal.entry
// : signal.entry - signal.tp;
// //
// // Calculate Recovery Zone Step ...
// double slDistance =
// isLong
// ? signal.entry - signal.sl
// : signal.sl - signal.entry;
// }
// //
// // Add Zone Based Signals ...
// if (canUseZones)
// {
// //
// // signal.zones.DrawZones();
// //
// // Try to Find a Hot Level based on Signal Direction
// // as Resistance ...
// //
// for (int i = 0; i < signal.zones.CountZones(); i++)
// {
// //
// // Retrieve Indexed Zone ...
// XSCZone *iZone = signal.zones.GetZone(i);
// //
// // Check Zone is Hot Zone or not ...
// bool isHotZone = false;
// for (int j = 0; j < ArraySize(hotLevels); j++)
// {
// //
// isHotZone = (iZone.percent / 100 >= hotLevels[j]);
// if (isHotZone)
// {
// break;
// }
// }
// //
// // Prevent Moving Forward if there isn't Hot Zone ...
// if (!isHotZone)
// {
// continue;
// }
// //
// if (iZone.high > signal.entry && iZone.low > signal.entry)
// {
// //
// // Here we can Use Resistance Zone as SL Recovery for
// // Short Positions ...
// if (!isLong &&
// (signal.sl <= 0
// ? true
// : iZone.high < signal.sl && iZone.low < signal.sl))
// {
// //
// // Opposit Support on Resistance Upper ...
// //
// // rTP = signal.sl <= 0
// // ? iZone.high - (onePointValue * 15)
// // : signal.sl;
// // rSL = signal.entry;
// rType = POSITION_TYPE_BUY;
// rEntry = iZone.high + (onePointValue * 2);
// rMode = X_ORDER_MODE_STOP;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// //
// // Support Directional on Resistance Lower ...
// //
// // rTP = signal.entry;
// // rSL = signal.sl <= 0
// // ? signal.entry - (onePointValue * 15)
// // : signal.sl;
// rEntry = iZone.low - (onePointValue * 2);
// rVolume = signal.volume * 3;
// rType = POSITION_TYPE_SELL;
// rMode = X_ORDER_MODE_LIMIT;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// rVolume = signal.volume * 2;
// }
// }
// }
// //
// if (iZone.high < signal.entry && iZone.low < signal.entry)
// {
// //
// }
// }
// }
// //
// if (canUseTrend)
// {
// //
// // Check Ask and Bid Price ...
// //
// XOHCL fHighBar = signal.trend.GetFirstSwingHighBar();
// XOHCL sHighBar = signal.trend.GetSecondSwingHighBar();
// //
// XOHCL fLowBar = signal.trend.GetFirstSwingLowBar();
// XOHCL sLowBar = signal.trend.GetSecondSwingLowBar();
// //
// double twoPoint = onePointValue * 2;
// double fiftyPoint = onePointValue * 15;
// //
// // add resistance ...
// bool canAdd =
// isLong &&
// entryPrice < (sHighBar.high - fiftyPoint);
// if (canAdd)
// {
// //
// rSignal.Clean();
// //
// rEntry = sHighBar.high - fiftyPoint;
// rType = POSITION_TYPE_BUY;
// rMode = X_ORDER_MODE_STOP;
// rVolume = signal.volume * 2;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// //
// rEntry = sHighBar.high - fiftyPoint;
// rType = POSITION_TYPE_SELL;
// rMode = X_ORDER_MODE_LIMIT;
// rVolume = signal.volume * 3;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// }
// //
// canAdd =
// isLong &&
// entryPrice > (sLowBar.low + fiftyPoint);
// if (canAdd)
// {
// //
// rSignal.Clean();
// //
// rEntry = (sLowBar.low + fiftyPoint);
// rType = POSITION_TYPE_SELL;
// rMode = X_ORDER_MODE_STOP;
// rVolume = signal.volume * 2;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// //
// rEntry = (sLowBar.low - fiftyPoint);
// rType = POSITION_TYPE_BUY;
// rMode = X_ORDER_MODE_LIMIT;
// rVolume = signal.volume * 3;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// }
// //
// // add support ...
// canAdd =
// !isLong &&
// entryPrice > (sLowBar.low + fiftyPoint);
// if (canAdd)
// {
// //
// rSignal.Clean();
// //
// rEntry = sLowBar.low + fiftyPoint;
// rType = POSITION_TYPE_SELL;
// rMode = X_ORDER_MODE_STOP;
// rVolume = signal.volume * 2;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// //
// rEntry = sLowBar.low + fiftyPoint;
// rType = POSITION_TYPE_BUY;
// rMode = X_ORDER_MODE_LIMIT;
// rVolume = signal.volume * 3;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// }
// //
// canAdd =
// !isLong &&
// entryPrice < (sHighBar.high - fiftyPoint);
// if (canAdd)
// {
// //
// rSignal.Clean();
// //
// rEntry = (sHighBar.high - fiftyPoint);
// rType = POSITION_TYPE_BUY;
// rMode = X_ORDER_MODE_STOP;
// rVolume = signal.volume * 2;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// //
// rEntry = (sHighBar.high - fiftyPoint);
// rType = POSITION_TYPE_SELL;
// rMode = X_ORDER_MODE_LIMIT;
// rVolume = signal.volume * 3;
// //
// isSignalPrepared = rSignal.Prepare(
// signal.symbol,
// signal.provider,
// signal.period,
// rType,
// rMode,
// rEntry,
// rVolume,
// rSL,
// rTP //
// );
// if (isSignalPrepared)
// {
// //
// AddRef(
// rSignal,
// signal.supports //
// );
// //
// rSignal.Clean();
// //
// rSL = 0;
// rTP = 0;
// rEntry = 0;
// isSignalPrepared = false;
// }
// }
// }
///////////////////////////////////////////////////////////////
//
// Directional ...
rEntry = signal.entry;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * directionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
//
// Directional ...
rEntry = signal.entry;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * directionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
+71
View File
@@ -332,6 +332,7 @@ bool InitialEA()
// Configure Indicators ...
X121SetupInputs setupInputsDefault;
setupInputsDefault.Default();
PreConfigureStyles(setupInputsDefault);
//
// Prepare Providers and Add them into mX121EA class ...
@@ -366,3 +367,73 @@ bool InitialEA()
//
return result;
}
//
void PreConfigureStyles(X121SetupInputs &inputs) {
//
if (!inputs.IsValid()) {
return;
}
//
// XPV ...
inputs.pvInputs.showPeaksAndVales = true;
inputs.pvInputs.showLevels = false;
inputs.pvInputs.showConsolidations = false;
inputs.pvInputs.showFibo1Levels = true;
inputs.pvInputs.showFibo2Levels = true;
inputs.pvInputs.showFibo3Levels = true;
inputs.pvInputs.showFibo4Levels = true;
inputs.pvInputs.showFibo5Levels = true;
//
// 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;
//
// XSTR ...
inputs.strInputs.showTrends = false;
inputs.strInputs.fillTrends = 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;
}
//
+20 -14
View File
@@ -23,6 +23,7 @@
// Imports ...
#include <Trade/Trade.mqh>
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Classes/x-saherelm.xsccf.class.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xsczone.class.mq5"
#include "../Classes/x-saherelm.xsctrend.class.mq5"
@@ -62,6 +63,10 @@ string XSLTrailToken = "SLT";
//
string XActionToken = "A";
//
string XDirectionalToken = "D";
string XINDirectionalToken = "IND";
//
// Available Order Modes ...
enum ENUM_X_ORDER_MODES
@@ -148,7 +153,7 @@ enum ENUM_X_GUARD_ACTIONS
};
//
enum ENUM_X_POSITION_TYPE
enum ENUM_X_POSITION_TYPES
{
X_POSITION_TYPE_NONE = 0,
X_POSITION_TYPE_ALL = 1,
@@ -157,7 +162,7 @@ enum ENUM_X_POSITION_TYPE
};
//
string ToString(ENUM_X_POSITION_TYPE value)
string ToString(ENUM_X_POSITION_TYPES value)
{
//
string result = NULL;
@@ -191,7 +196,7 @@ string ToString(ENUM_X_POSITION_TYPE value)
}
//
bool IsLong(ENUM_X_POSITION_TYPE value)
bool IsLong(ENUM_X_POSITION_TYPES value)
{
return value == X_POSITION_TYPE_LONG;
}
@@ -199,7 +204,7 @@ bool IsLong(ENUM_X_POSITION_TYPE value)
//
bool ToPositinType(
ENUM_POSITION_TYPE &dest,
ENUM_X_POSITION_TYPE source //
ENUM_X_POSITION_TYPES source //
)
{
//
@@ -224,7 +229,7 @@ bool ToPositinType(
}
//
ENUM_X_POSITION_TYPE ToPositionType(ENUM_POSITION_TYPE value)
ENUM_X_POSITION_TYPES ToPositionType(ENUM_POSITION_TYPE value)
{
return IsLong(value)
? X_POSITION_TYPE_LONG
@@ -232,10 +237,10 @@ ENUM_X_POSITION_TYPE ToPositionType(ENUM_POSITION_TYPE value)
}
//
ENUM_X_POSITION_TYPE GetOppositPositionType(ENUM_POSITION_TYPE type)
ENUM_X_POSITION_TYPES GetOppositPositionType(ENUM_POSITION_TYPE type)
{
//
ENUM_X_POSITION_TYPE result = X_POSITION_TYPE_NONE;
ENUM_X_POSITION_TYPES result = X_POSITION_TYPE_NONE;
//
bool isLong = IsLong(type);
@@ -635,7 +640,7 @@ struct XPosition
string mSymbol = NULL, // Trading Symbol
string mProvider = NULL, // Signal Provider
ENUM_TIMEFRAMES mPeriod = NULL, // Trading Timeframe
ENUM_X_POSITION_TYPE mType = NULL, // Long (Buy), Short (Sell)
ENUM_X_POSITION_TYPES mType = NULL, // Long (Buy), Short (Sell)
ulong mMagic = NULL, // Magic Number
bool mFilterByMagic = true // Get Only Self Open Positions
)
@@ -730,9 +735,10 @@ struct XSignal
XSignal supports[]; // a Collecion of Support Signals ...
//
// Zones for Signal ...
// TODO: Temp ...
XSCZones *zones;
XSCTrend *trend;
XSCCF *cf;
//
// Constructor ...
@@ -1925,7 +1931,7 @@ struct XOrder
string mSymbol = NULL, // Trading Symbol
string mProvider = NULL, // Signal Provider
ENUM_TIMEFRAMES mPeriod = NULL, // Trading Timeframe
ENUM_X_POSITION_TYPE mType = NULL, // Long (Buy), Short (Sell)
ENUM_X_POSITION_TYPES mType = NULL, // Long (Buy), Short (Sell)
ENUM_ORDER_STATE mState = NULL, // Order State
ulong mMagic = NULL, // Magic Number
bool mFilterByMagic = true // Get Only Self Open Positions
@@ -2476,7 +2482,7 @@ struct XGuard
string symbol; // Trading Symbol ...
string provider; // Signal Provider ...
ENUM_TIMEFRAMES period; // Trading Timeframe ...
ENUM_X_POSITION_TYPE type; // Position Type ...
ENUM_X_POSITION_TYPES type; // Position Type ...
ENUM_X_GUARD_ACTIONS action; // Which Action to Do ...
//
@@ -2499,7 +2505,7 @@ struct XGuard
string mSymbol, // Trading Symbol ...
ENUM_TIMEFRAMES mPeriod, // Trading Timeframe ...
ENUM_X_GUARD_ACTIONS mAction, // Which Action to Do ...
ENUM_X_POSITION_TYPE mType = NULL, // Position Type ...
ENUM_X_POSITION_TYPES mType = NULL, // Position Type ...
string mProvider = NULL, // Signal Provider ...
double mDblPayLoad = NULL,
string mStrPayload = NULL //
@@ -3469,7 +3475,7 @@ bool IsTypeFilterPassed(
}
template <typename T>
bool IsTypeFilterPassed(
ENUM_X_POSITION_TYPE type,
ENUM_X_POSITION_TYPES type,
T &item
//
)
@@ -3978,7 +3984,7 @@ ENUM_ORDER_TYPE ToOrderType(ENUM_POSITION_TYPE value)
//
return result;
}
ENUM_ORDER_TYPE ToOrderType(ENUM_X_POSITION_TYPE value)
ENUM_ORDER_TYPE ToOrderType(ENUM_X_POSITION_TYPES value)
{
//
ENUM_POSITION_TYPE mType =