Last Works ...
This commit is contained in:
@@ -35,6 +35,8 @@ struct XCTInputs
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string font; // Font
|
||||
int fontSize; // Font Size;
|
||||
color clr; // Text Color
|
||||
ENUM_BASE_CORNER corner; // Text Position
|
||||
|
||||
@@ -46,7 +48,6 @@ struct XCTInputs
|
||||
// Constructor(s) ...
|
||||
XCTInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
@@ -58,6 +59,8 @@ struct XCTInputs
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
font = NULL;
|
||||
fontSize = 15;
|
||||
clr = CLR_NONE;
|
||||
corner = CORNER_RIGHT_LOWER;
|
||||
|
||||
@@ -71,6 +74,8 @@ struct XCTInputs
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
font = "Arial";
|
||||
fontSize = 15;
|
||||
clr = clrYellow;
|
||||
corner = CORNER_RIGHT_LOWER;
|
||||
|
||||
@@ -118,26 +123,29 @@ class XCXCTHelper : public XCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XCXCTHelper() : XCBaseHelper(_Symbol, _Period)
|
||||
XCXCTHelper()
|
||||
: XCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCXCTHelper() {}
|
||||
~XCXCTHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCTInputs &inputs // Inputs
|
||||
XCTInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -164,8 +172,10 @@ public:
|
||||
"x-saherelm.xct",
|
||||
//
|
||||
// Inputs ...
|
||||
mInputs.clr, // Text Color
|
||||
mInputs.corner, // Text Position
|
||||
mInputs.fontSize, // Font Size ...
|
||||
mInputs.font, // Font ...
|
||||
mInputs.clr, // Text Color ...
|
||||
mInputs.corner, // Text Position ...
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
@@ -207,10 +217,10 @@ public:
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCTInputs mInputs; // Inputs ...
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
//
|
||||
|
||||
//
|
||||
input int fontSize = 15; // Font Size
|
||||
input string font = "Arial"; // Font
|
||||
input color clr = clrYellow; // Text Color
|
||||
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER; // Text Position
|
||||
|
||||
@@ -65,7 +67,7 @@ input bool showCandleTime = true; // Show Candle Time
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
string tag;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
@@ -80,13 +82,18 @@ int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
|
||||
//
|
||||
tag = ShortName + _Symbol + ToString(_Period);
|
||||
|
||||
//
|
||||
if (showCandleTime)
|
||||
{
|
||||
CreateIndicatorObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectDelete(0, ShortName);
|
||||
ObjectDelete(0, tag);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -114,16 +121,9 @@ void OnDeinit(const int reason)
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
ulong chID = FindChartID(
|
||||
_Symbol,
|
||||
_Period
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Delete Object ...
|
||||
ObjectDelete(chID, ShortName);
|
||||
ObjectDelete(0, tag);
|
||||
|
||||
//
|
||||
Comment("");
|
||||
@@ -204,10 +204,7 @@ int OnCalculate(
|
||||
string objText = "Spread: " + IntegerToString(mSpread) + _sp + ", Next Bar in: " + msg;
|
||||
|
||||
//
|
||||
ObjectSetInteger(chID, ShortName, OBJPROP_COLOR, clr);
|
||||
ObjectSetString(chID, ShortName, OBJPROP_TEXT, objText);
|
||||
ObjectSetInteger(chID, ShortName, OBJPROP_FONTSIZE, 10);
|
||||
ObjectSetString(chID, ShortName, OBJPROP_FONT, "Courier");
|
||||
ObjectSetString(0, tag, OBJPROP_TEXT, objText);
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
@@ -238,9 +235,9 @@ void CreateIndicatorObject()
|
||||
}
|
||||
|
||||
//
|
||||
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
|
||||
ObjectCreate(0, tag, OBJ_LABEL, 0, 0, 0);
|
||||
ObjectSetInteger(0, tag, OBJPROP_CORNER, corner);
|
||||
ObjectSetInteger(0, tag, OBJPROP_XDISTANCE, 10);
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2);
|
||||
|
||||
//
|
||||
@@ -262,7 +259,20 @@ void CreateIndicatorObject()
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor);
|
||||
int mFontSize = fontSize > 0
|
||||
? fontSize
|
||||
: 10;
|
||||
|
||||
//
|
||||
string mFont = IsValid(font)
|
||||
? font
|
||||
: "Arial";
|
||||
|
||||
//
|
||||
ObjectSetString(0, tag, OBJPROP_FONT, mFont);
|
||||
ObjectSetInteger(0, tag, OBJPROP_COLOR, clr);
|
||||
ObjectSetInteger(0, tag, OBJPROP_ANCHOR, Anchor);
|
||||
ObjectSetInteger(0, tag, OBJPROP_FONTSIZE, mFontSize);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -38,6 +38,55 @@ struct X121SMCStrategyConditions
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// D1 ...
|
||||
XPOIState d1State;
|
||||
ENUM_X_DIRECTION d1MarketDirection;
|
||||
XCSupportZone *d1SupportZones[];
|
||||
XCResistanceZone *d1ResistanceZones[];
|
||||
|
||||
//
|
||||
// H4 ...
|
||||
XPOIState h4State;
|
||||
ENUM_X_DIRECTION h4MarketDirection;
|
||||
XCSupportZone *h4SupportZones[];
|
||||
XCResistanceZone *h4ResistanceZones[];
|
||||
|
||||
//
|
||||
// H2 ...
|
||||
XPOIState h2State;
|
||||
ENUM_X_DIRECTION h2MarketDirection;
|
||||
XCSupportZone *h2SupportZones[];
|
||||
XCResistanceZone *h2ResistanceZones[];
|
||||
|
||||
//
|
||||
// H1 ...
|
||||
XPOIState h1State;
|
||||
ENUM_X_DIRECTION h1MarketDirection;
|
||||
XCSupportZone *h1SupportZones[];
|
||||
XCResistanceZone *h1ResistanceZones[];
|
||||
|
||||
//
|
||||
// M15 ...
|
||||
XPOIState m15State;
|
||||
ENUM_X_DIRECTION m15MarketDirection;
|
||||
XCSupportZone *m15SupportZones[];
|
||||
XCResistanceZone *m15ResistanceZones[];
|
||||
|
||||
//
|
||||
// M5 ...
|
||||
XPOIState m5State;
|
||||
ENUM_X_DIRECTION m5MarketDirection;
|
||||
XCSupportZone *m5SupportZones[];
|
||||
XCResistanceZone *m5ResistanceZones[];
|
||||
|
||||
//
|
||||
// M1 ...
|
||||
XPOIState m1State;
|
||||
ENUM_X_DIRECTION m1MarketDirection;
|
||||
XCSupportZone *m1SupportZones[];
|
||||
XCResistanceZone *m1ResistanceZones[];
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
@@ -56,6 +105,55 @@ struct X121SMCStrategyConditions
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
// D1 ...
|
||||
d1State.Clean();
|
||||
d1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(d1SupportZones);
|
||||
Clean(d1ResistanceZones);
|
||||
|
||||
//
|
||||
// H4 ...
|
||||
h4State.Clean();
|
||||
h4MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h4SupportZones);
|
||||
Clean(h4ResistanceZones);
|
||||
|
||||
//
|
||||
// H2 ...
|
||||
h2State.Clean();
|
||||
h2MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h2SupportZones);
|
||||
Clean(h2ResistanceZones);
|
||||
|
||||
//
|
||||
// H1 ...
|
||||
h1State.Clean();
|
||||
h1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h1SupportZones);
|
||||
Clean(h1ResistanceZones);
|
||||
|
||||
//
|
||||
// M15 ...
|
||||
m15State.Clean();
|
||||
m15MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m15SupportZones);
|
||||
Clean(m15ResistanceZones);
|
||||
|
||||
//
|
||||
// M5 ...
|
||||
m5State.Clean();
|
||||
m5MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m5SupportZones);
|
||||
Clean(m5ResistanceZones);
|
||||
|
||||
//
|
||||
// M1 ...
|
||||
m1State.Clean();
|
||||
m1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m1SupportZones);
|
||||
Clean(m1ResistanceZones);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +175,99 @@ struct X121SMCStrategyConditions
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Tools ...
|
||||
|
||||
/**
|
||||
* Check Conditions for Detect Market Structure ...
|
||||
*
|
||||
* @param structure: ENUM_X_DIRECTION member, Market Structure Direction reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasMarketStructure(
|
||||
ENUM_X_DIRECTION &structure //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
structure = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool is1DBullish = IsBullish(d1MarketDirection);
|
||||
bool is1DBearish = IsBearish(d1MarketDirection);
|
||||
|
||||
//
|
||||
bool is4HBullish = IsBullish(h4MarketDirection);
|
||||
bool is4HBearish = IsBearish(h4MarketDirection);
|
||||
|
||||
//
|
||||
bool is2HBullish = IsBullish(h2MarketDirection);
|
||||
bool is2HBearish = IsBearish(h2MarketDirection);
|
||||
|
||||
//
|
||||
bool is1HBullish = IsBullish(h1MarketDirection);
|
||||
bool is1HBearish = IsBearish(h1MarketDirection);
|
||||
|
||||
//
|
||||
bool is15MBullish = IsBullish(m15MarketDirection);
|
||||
bool is15MBearish = IsBearish(m15MarketDirection);
|
||||
|
||||
//
|
||||
bool is5MBullish = IsBullish(m5MarketDirection);
|
||||
bool is5MBearish = IsBearish(m5MarketDirection);
|
||||
|
||||
//
|
||||
bool is1MBullish = IsBullish(m1MarketDirection);
|
||||
bool is1MBearish = IsBearish(m1MarketDirection);
|
||||
|
||||
//
|
||||
bool isStructuresBullish =
|
||||
//
|
||||
is1HBullish &&
|
||||
is15MBullish &&
|
||||
is5MBullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isStructuresBearish =
|
||||
//
|
||||
is1HBearish &&
|
||||
is15MBearish &&
|
||||
is5MBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasMarketStructure =
|
||||
isStructuresBullish ||
|
||||
isStructuresBearish;
|
||||
result = hasMarketStructure;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
structure =
|
||||
isStructuresBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Provided Scores ...
|
||||
*
|
||||
|
||||
@@ -331,18 +331,132 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// TODO: Implement ...
|
||||
ENUM_X_DIRECTION marketStructureDir;
|
||||
result = DetectMarketStructure(
|
||||
marketStructureDir,
|
||||
_5MState //
|
||||
);
|
||||
// Detect Market Structures ...
|
||||
|
||||
//
|
||||
// 1D ...
|
||||
mConditions.d1State = _1DState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.d1MarketDirection,
|
||||
_1DState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1DBullish = IsBullish(mConditions.d1MarketDirection);
|
||||
bool is1DBearish = IsBearish(mConditions.d1MarketDirection);
|
||||
|
||||
//
|
||||
// 4H ...
|
||||
mConditions.h4State = _4HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h4MarketDirection,
|
||||
_4HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is4HBullish = IsBullish(mConditions.h4MarketDirection);
|
||||
bool is4HBearish = IsBearish(mConditions.h4MarketDirection);
|
||||
|
||||
//
|
||||
// 2H ...
|
||||
mConditions.h2State = _2HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h2MarketDirection,
|
||||
_2HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is2HBullish = IsBullish(mConditions.h2MarketDirection);
|
||||
bool is2HBearish = IsBearish(mConditions.h2MarketDirection);
|
||||
|
||||
//
|
||||
// 1H ...
|
||||
mConditions.h1State = _1HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h1MarketDirection,
|
||||
_1HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1HBullish = IsBullish(mConditions.h1MarketDirection);
|
||||
bool is1HBearish = IsBearish(mConditions.h1MarketDirection);
|
||||
|
||||
//
|
||||
// 15M ...
|
||||
mConditions.m15State = _15MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m15MarketDirection,
|
||||
_15MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is15MBullish = IsBullish(mConditions.m15MarketDirection);
|
||||
bool is15MBearish = IsBearish(mConditions.m15MarketDirection);
|
||||
|
||||
//
|
||||
// 5M ...
|
||||
mConditions.m5State = _5MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m5MarketDirection,
|
||||
_5MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is5MBullish = IsBullish(mConditions.m5MarketDirection);
|
||||
bool is5MBearish = IsBearish(mConditions.m5MarketDirection);
|
||||
|
||||
//
|
||||
// 1M ...
|
||||
mConditions.m1State = _1MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m1MarketDirection,
|
||||
_1MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1MBullish = IsBullish(mConditions.m1MarketDirection);
|
||||
bool is1MBearish = IsBearish(mConditions.m1MarketDirection);
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE;
|
||||
result = mConditions.HasMarketStructure(marketStructure);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DrawState(_5MState);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -364,17 +478,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// DrawState(state);
|
||||
|
||||
//
|
||||
// Print("Salam");
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
|
||||
//
|
||||
// Filter Untouched Supports ...
|
||||
int untouchedSupportsCount = 0;
|
||||
XCSupportZone *untouchedSupportZones[];
|
||||
count = ArraySize(state.supportZones);
|
||||
if (IsValidSize(count))
|
||||
@@ -436,31 +545,33 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
int untouchedSupportsCount = ArraySize(untouchedSupportZones);
|
||||
untouchedSupportsCount = ArraySize(untouchedSupportZones);
|
||||
if (IsValidSize(untouchedSupportsCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < untouchedSupportsCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZone *item = untouchedSupportZones[i];
|
||||
// Draw ...
|
||||
// for (int i = 0; i < untouchedSupportsCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCSupportZone *item = untouchedSupportZones[i];
|
||||
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||
item,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// XCSupportZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||
// item,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Filter Untouched Resistances ...
|
||||
int untouchedResistancesCount = 0;
|
||||
XCResistanceZone *untouchedResistanceZones[];
|
||||
count = ArraySize(state.resistanceZones);
|
||||
if (IsValidSize(count))
|
||||
@@ -522,29 +633,54 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
int untouchedResistancesCount = ArraySize(untouchedResistanceZones);
|
||||
untouchedResistancesCount = ArraySize(untouchedResistanceZones);
|
||||
if (IsValidSize(untouchedResistancesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < untouchedResistancesCount; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *item = untouchedResistanceZones[i];
|
||||
// Draw ...
|
||||
// for (int i = 0; i < untouchedResistancesCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCResistanceZone *item = untouchedResistanceZones[i];
|
||||
|
||||
//
|
||||
XCResistanceZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||
item,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// XCResistanceZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||
// item,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool hasBullishStructure =
|
||||
IsValidSize(untouchedSupportsCount) &&
|
||||
untouchedSupportsCount > untouchedResistancesCount;
|
||||
bool hasBearishStructure =
|
||||
IsValidSize(untouchedResistancesCount) &&
|
||||
untouchedResistancesCount > untouchedSupportsCount;
|
||||
|
||||
//
|
||||
result = (hasBullishStructure &&
|
||||
!hasBearishStructure) ||
|
||||
(hasBearishStructure &&
|
||||
!hasBullishStructure);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
hasBullishStructure
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user