last ...
This commit is contained in:
@@ -0,0 +1,535 @@
|
|||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy 1 ...
|
||||||
|
* POI ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL, reference to Bar ...
|
||||||
|
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||||
|
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||||
|
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Strategy1HasSignal(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &zone,
|
||||||
|
XTarget &targets[],
|
||||||
|
ENUM_X_DIRECTION &dir //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int scoreBullish = 0;
|
||||||
|
int scoreBearish = 0;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
int barIndex = bar.Index() + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
XOHCL iBar;
|
||||||
|
result = iBar.Init(bar.symbol, bar.period, barIndex);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #region Market Structure ...
|
||||||
|
XBoxZone supports[];
|
||||||
|
XBoxZone resistances[];
|
||||||
|
XBoxZone minorSupport;
|
||||||
|
XBoxZone majorSupport;
|
||||||
|
XBoxZone minorResistance;
|
||||||
|
XBoxZone majorResistance;
|
||||||
|
poiDetector.GetCurrentStructure(
|
||||||
|
supports,
|
||||||
|
resistances,
|
||||||
|
minorSupport,
|
||||||
|
majorSupport,
|
||||||
|
minorResistance,
|
||||||
|
majorResistance,
|
||||||
|
barIndex,
|
||||||
|
bar.symbol,
|
||||||
|
iBar.period, // Minor ...
|
||||||
|
PERIOD_H1, // Major ...
|
||||||
|
50,
|
||||||
|
14,
|
||||||
|
21,
|
||||||
|
0 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refining Zones ...
|
||||||
|
int refineLoopback = 500;
|
||||||
|
double refineBreakThreshold = 10;
|
||||||
|
ENUM_X_PRICE refineBreakBy = X_PRICE_CLOSE;
|
||||||
|
poiDetector.RefineStructure(
|
||||||
|
supports,
|
||||||
|
resistances,
|
||||||
|
minorSupport,
|
||||||
|
majorSupport,
|
||||||
|
minorResistance,
|
||||||
|
majorResistance,
|
||||||
|
refineLoopback,
|
||||||
|
refineBreakThreshold,
|
||||||
|
refineBreakBy //
|
||||||
|
);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region Reading Conditions and Scoring ...
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
bool isATRUp = kiParser.IsVolatilityHigh(barIndex) ||
|
||||||
|
kiParser.IsVolatilitySwitchdToHigh(barIndex);
|
||||||
|
|
||||||
|
// #region KI ...
|
||||||
|
//
|
||||||
|
bool isKIBullish = (kiParser.IsKIFastBullish(barIndex) ||
|
||||||
|
kiParser.IsKIFastSwitchedToBullish(barIndex)) &&
|
||||||
|
(kiParser.IsKISlowBullish(barIndex) ||
|
||||||
|
kiParser.IsKISlowSwitchedToBullish(barIndex));
|
||||||
|
if (isKIBullish)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIBearish = (kiParser.IsKIFastBearish(barIndex) ||
|
||||||
|
kiParser.IsKIFastSwitchedToBearish(barIndex)) &&
|
||||||
|
(kiParser.IsKISlowBearish(barIndex) ||
|
||||||
|
kiParser.IsKISlowSwitchedToBearish(barIndex));
|
||||||
|
if (isKIBearish)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region KI Wave ...
|
||||||
|
//
|
||||||
|
bool isKIWaveBullish = kiParser.IsKIWaveBullish(barIndex) ||
|
||||||
|
kiParser.IsKIWaveSwitchedToBullish(barIndex);
|
||||||
|
if (isKIWaveBullish)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIWaveBearish = kiParser.IsKIWaveBearish(barIndex) ||
|
||||||
|
kiParser.IsKIWaveSwitchedToBearish(barIndex);
|
||||||
|
if (isKIWaveBearish)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region MA ...
|
||||||
|
//
|
||||||
|
bool isMaBullish = kiParser.IsMACrossoverBullish(barIndex) ||
|
||||||
|
kiParser.IsMACrossoverSwitchedToBullish(barIndex);
|
||||||
|
if (isMaBullish)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isMaBearish = kiParser.IsMACrossoverBearish(barIndex) ||
|
||||||
|
kiParser.IsMACrossoverSwitchedToBearish(barIndex);
|
||||||
|
if (isMaBearish)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region LowerTF Candlstick ...
|
||||||
|
//
|
||||||
|
bool isLowerTFBullish = IsTFBullishPattern(barIndex, PERIOD_M5);
|
||||||
|
if (isLowerTFBullish)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isLowerTFBearish = IsTFBearishPattern(barIndex, PERIOD_M5);
|
||||||
|
if (isLowerTFBearish)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region Candlestick ...
|
||||||
|
//
|
||||||
|
bool isCandlestickBullish = poiDetector.HasCandlestickDirection(
|
||||||
|
iBar,
|
||||||
|
X_DIRECTION_BULLISH //
|
||||||
|
);
|
||||||
|
if (isCandlestickBullish)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCandlestickBearish = poiDetector.HasCandlestickDirection(
|
||||||
|
iBar,
|
||||||
|
X_DIRECTION_BEARISH //
|
||||||
|
);
|
||||||
|
if (isCandlestickBearish)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region NearInside Support/Resistance ...
|
||||||
|
//
|
||||||
|
int tmpSupportIDX = -1;
|
||||||
|
bool isNearSupport = poiDetector.HasNearZone(tmpSupportIDX, iBar.close, 5, supports);
|
||||||
|
if (isNearSupport)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int tmpResistanceIDX = -1;
|
||||||
|
bool isNearResistance = poiDetector.HasNearZone(tmpResistanceIDX, iBar.close, 5, resistances);
|
||||||
|
if (isNearResistance)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region Summarize Directional Conditions ...
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isATRUp &&
|
||||||
|
scoreBullish >= 4 &&
|
||||||
|
(isMaBullish ||
|
||||||
|
isNearSupport ||
|
||||||
|
isKIWaveBullish ||
|
||||||
|
isLowerTFBullish ||
|
||||||
|
isCandlestickBullish);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isATRUp &&
|
||||||
|
scoreBearish >= 4 &&
|
||||||
|
(isMaBearish ||
|
||||||
|
isNearResistance ||
|
||||||
|
isKIWaveBearish ||
|
||||||
|
isLowerTFBearish ||
|
||||||
|
isCandlestickBearish);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Conditions ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
XClean(supports);
|
||||||
|
XClean(resistances);
|
||||||
|
minorSupport.Clean();
|
||||||
|
majorSupport.Clean();
|
||||||
|
minorResistance.Clean();
|
||||||
|
majorResistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select Operational Zone ...
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Nearest Support ...
|
||||||
|
if (IsValidIndex(tmpSupportIDX))
|
||||||
|
{
|
||||||
|
zone = supports[tmpSupportIDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make Sure Zone Exists ...
|
||||||
|
if (!zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Looking Bar Patterns to Detect Zone ...
|
||||||
|
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BULLISH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isBearish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Nearest Resistance ...
|
||||||
|
if (IsValidIndex(tmpResistanceIDX))
|
||||||
|
{
|
||||||
|
zone = resistances[tmpResistanceIDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make Sure Zone Exists ...
|
||||||
|
if (!zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Looking Bar Patterns to Detect Zone ...
|
||||||
|
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BEARISH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refactor Result ...
|
||||||
|
result = result &&
|
||||||
|
zone.IsValid();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Refine Zone ...
|
||||||
|
poiDetector.RefineZone(zone);
|
||||||
|
|
||||||
|
//
|
||||||
|
// SL Refactoring ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL toBar;
|
||||||
|
if (zone.ToBar(toBar))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int to = zone.ToIndex();
|
||||||
|
int from = zone.FromIndex();
|
||||||
|
int length = from - to;
|
||||||
|
double iValue =
|
||||||
|
isBullish
|
||||||
|
? toBar.FindLowest(length, MODE_LOW)
|
||||||
|
: isBearish
|
||||||
|
? toBar.FindHighest(length, MODE_HIGH)
|
||||||
|
: EMPTY_VALUE;
|
||||||
|
if (NotEmptyZero(iValue))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
zone.lower = MathMin(zone.lower, iValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isBearish)
|
||||||
|
{
|
||||||
|
zone.upper = MathMax(zone.upper, iValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toBar.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do Directional Validation ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isLowerTFBullish &&
|
||||||
|
isCandlestickBullish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
if (isBearish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isLowerTFBearish &&
|
||||||
|
isCandlestickBearish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Result ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
XClean(supports);
|
||||||
|
XClean(resistances);
|
||||||
|
minorSupport.Clean();
|
||||||
|
majorSupport.Clean();
|
||||||
|
minorResistance.Clean();
|
||||||
|
majorResistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draws ...
|
||||||
|
bool draw = true;
|
||||||
|
if (draw && result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int drawn = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIDrawConfig config;
|
||||||
|
config.Default();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
|
||||||
|
//
|
||||||
|
config.zonesWidth = 3;
|
||||||
|
config.bullishColor = clrYellow;
|
||||||
|
config.bearishColor = clrOrange;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(zone, config);
|
||||||
|
|
||||||
|
//
|
||||||
|
config.Default();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Minors ...
|
||||||
|
if (minorSupport.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(minorSupport, config);
|
||||||
|
}
|
||||||
|
if (minorResistance.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(minorResistance, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Majors ...
|
||||||
|
config.bullishColor = clrLime;
|
||||||
|
config.bearishColor = clrRed;
|
||||||
|
config.zonesWidth = 4;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (majorSupport.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(majorSupport, config);
|
||||||
|
}
|
||||||
|
if (majorResistance.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(majorResistance, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
config.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (drawn > 0)
|
||||||
|
{
|
||||||
|
DebugBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check and Prepare Direction ...
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: isBearish ? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_NONE;
|
||||||
|
result = result &&
|
||||||
|
HasDirection(dir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
XClean(supports);
|
||||||
|
XClean(resistances);
|
||||||
|
minorSupport.Clean();
|
||||||
|
majorSupport.Clean();
|
||||||
|
minorResistance.Clean();
|
||||||
|
majorResistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Zone ...
|
||||||
|
double entry = GetEntry(iBar.symbol, dir);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double upper = isBullish
|
||||||
|
? entry
|
||||||
|
: zone.upper;
|
||||||
|
double lower = isBullish
|
||||||
|
? zone.lower
|
||||||
|
: entry;
|
||||||
|
datetime to = bar.time;
|
||||||
|
datetime from = isBullish
|
||||||
|
? zone.from
|
||||||
|
: zone.from;
|
||||||
|
result = zone.Init(
|
||||||
|
iBar.symbol,
|
||||||
|
iBar.period,
|
||||||
|
upper,
|
||||||
|
lower,
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
dir,
|
||||||
|
"XS1" //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
XClean(supports);
|
||||||
|
XClean(resistances);
|
||||||
|
minorSupport.Clean();
|
||||||
|
majorSupport.Clean();
|
||||||
|
minorResistance.Clean();
|
||||||
|
majorResistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
zone.IsValid() &&
|
||||||
|
HasDirection(dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1976,3 +1976,152 @@ bool Strategy1HasSignal(
|
|||||||
// zone = resistances[tmpResistanceIDX];
|
// zone = resistances[tmpResistanceIDX];
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
// #region Market Structure ...
|
||||||
|
XBoxZone supports[];
|
||||||
|
XBoxZone resistances[];
|
||||||
|
XBoxZone minorSupport;
|
||||||
|
XBoxZone majorSupport;
|
||||||
|
XBoxZone minorResistance;
|
||||||
|
XBoxZone majorResistance;
|
||||||
|
poiDetector.GetCurrentStructure(
|
||||||
|
supports,
|
||||||
|
resistances,
|
||||||
|
minorSupport,
|
||||||
|
majorSupport,
|
||||||
|
minorResistance,
|
||||||
|
majorResistance,
|
||||||
|
barIndex,
|
||||||
|
bar.symbol,
|
||||||
|
iBar.period, // Minor ...
|
||||||
|
PERIOD_H1, // Major ...
|
||||||
|
50,
|
||||||
|
14,
|
||||||
|
21,
|
||||||
|
0 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refining Zones ...
|
||||||
|
int refineLoopback = 500;
|
||||||
|
double refineBreakThreshold = 10;
|
||||||
|
ENUM_X_PRICE refineBreakBy = X_PRICE_CLOSE;
|
||||||
|
poiDetector.RefineStructure(
|
||||||
|
supports,
|
||||||
|
resistances,
|
||||||
|
minorSupport,
|
||||||
|
majorSupport,
|
||||||
|
minorResistance,
|
||||||
|
majorResistance,
|
||||||
|
refineLoopback,
|
||||||
|
refineBreakThreshold,
|
||||||
|
refineBreakBy //
|
||||||
|
);
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
// #region NearInside Support/Resistance ...
|
||||||
|
//
|
||||||
|
int tmpSupportIDX = -1;
|
||||||
|
bool isNearSupport = poiDetector.HasNearZone(tmpSupportIDX, iBar.close, 5, supports);
|
||||||
|
if (isNearSupport)
|
||||||
|
{
|
||||||
|
scoreBullish++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int tmpResistanceIDX = -1;
|
||||||
|
bool isNearResistance = poiDetector.HasNearZone(tmpResistanceIDX, iBar.close, 5, resistances);
|
||||||
|
if (isNearResistance)
|
||||||
|
{
|
||||||
|
scoreBearish++;
|
||||||
|
}
|
||||||
|
// #endregion
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
XClean(supports);
|
||||||
|
XClean(resistances);
|
||||||
|
minorSupport.Clean();
|
||||||
|
majorSupport.Clean();
|
||||||
|
minorResistance.Clean();
|
||||||
|
majorResistance.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draws ...
|
||||||
|
bool draw = true;
|
||||||
|
if (draw && result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int drawn = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIDrawConfig config;
|
||||||
|
config.Default();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
|
||||||
|
//
|
||||||
|
config.zonesWidth = 3;
|
||||||
|
config.bullishColor = clrYellow;
|
||||||
|
config.bearishColor = clrOrange;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(zone, config);
|
||||||
|
|
||||||
|
//
|
||||||
|
config.Default();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Minors ...
|
||||||
|
if (minorSupport.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(minorSupport, config);
|
||||||
|
}
|
||||||
|
if (minorResistance.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(minorResistance, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Majors ...
|
||||||
|
config.bullishColor = clrLime;
|
||||||
|
config.bearishColor = clrRed;
|
||||||
|
config.zonesWidth = 4;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (majorSupport.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(majorSupport, config);
|
||||||
|
}
|
||||||
|
if (majorResistance.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawn++;
|
||||||
|
poiDrawer.DrawZone(majorResistance, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
config.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (drawn > 0)
|
||||||
|
{
|
||||||
|
DebugBreak();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ input double eaDynamicVolumeStepVolume = X_MIN_VOLUME; // Step of V
|
|||||||
input double eaConstantRiskBalance = 0.0; // Constant Risk Balance per Trade
|
input double eaConstantRiskBalance = 0.0; // Constant Risk Balance per Trade
|
||||||
input double eaConstantPercent = 1; // Constant Percent of Balance Per Trade
|
input double eaConstantPercent = 1; // Constant Percent of Balance Per Trade
|
||||||
input double eaConstantBalance = 1000.0; // Constant Balance for Calculations
|
input double eaConstantBalance = 1000.0; // Constant Balance for Calculations
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Alert ...
|
// #region Alert ...
|
||||||
input group "Alert";
|
input group "Alert";
|
||||||
@@ -61,7 +61,7 @@ input bool eaProcessAllTicks = false; // Process All Ticks
|
|||||||
input double eaSignallerR2R = 2.0; // Risk To Reward Ratio
|
input double eaSignallerR2R = 2.0; // Risk To Reward Ratio
|
||||||
input double eaSignallerVolume = 0.01; // Default Volume
|
input double eaSignallerVolume = 0.01; // Default Volume
|
||||||
input double eaSignallerRiskInPoint = 50; // Default Risk In Point
|
input double eaSignallerRiskInPoint = 50; // Default Risk In Point
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Bar Time ...
|
// #region Bar Time ...
|
||||||
input group "Bar Timer";
|
input group "Bar Timer";
|
||||||
|
|||||||
@@ -988,48 +988,6 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #region Market Structure ...
|
|
||||||
XBoxZone supports[];
|
|
||||||
XBoxZone resistances[];
|
|
||||||
XBoxZone minorSupport;
|
|
||||||
XBoxZone majorSupport;
|
|
||||||
XBoxZone minorResistance;
|
|
||||||
XBoxZone majorResistance;
|
|
||||||
poiDetector.GetCurrentStructure(
|
|
||||||
supports,
|
|
||||||
resistances,
|
|
||||||
minorSupport,
|
|
||||||
majorSupport,
|
|
||||||
minorResistance,
|
|
||||||
majorResistance,
|
|
||||||
barIndex,
|
|
||||||
bar.symbol,
|
|
||||||
iBar.period, // Minor ...
|
|
||||||
PERIOD_H1, // Major ...
|
|
||||||
50,
|
|
||||||
14,
|
|
||||||
21,
|
|
||||||
0 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Refining Zones ...
|
|
||||||
int refineLoopback = 500;
|
|
||||||
double refineBreakThreshold = 10;
|
|
||||||
ENUM_X_PRICE refineBreakBy = X_PRICE_CLOSE;
|
|
||||||
poiDetector.RefineStructure(
|
|
||||||
supports,
|
|
||||||
resistances,
|
|
||||||
minorSupport,
|
|
||||||
majorSupport,
|
|
||||||
minorResistance,
|
|
||||||
majorResistance,
|
|
||||||
refineLoopback,
|
|
||||||
refineBreakThreshold,
|
|
||||||
refineBreakBy //
|
|
||||||
);
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region Reading Conditions and Scoring ...
|
// #region Reading Conditions and Scoring ...
|
||||||
//
|
//
|
||||||
// ATR ...
|
// ATR ...
|
||||||
@@ -1037,6 +995,26 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
kiParser.IsVolatilitySwitchdToHigh(barIndex);
|
kiParser.IsVolatilitySwitchdToHigh(barIndex);
|
||||||
|
|
||||||
// #region KI ...
|
// #region KI ...
|
||||||
|
//
|
||||||
|
bool isKIReadyForBullish = ((kiParser.IsKIFastBearish(barIndex) ||
|
||||||
|
(kiParser.IsKIFastBullish(barIndex) &&
|
||||||
|
iBar.IsRejected(kiHelper.GetKIFast(barIndex), X_DIRECTION_BULLISH))) &&
|
||||||
|
kiParser.IsKISlowBullish(barIndex));
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIReadyForBearish = ((kiParser.IsKIFastBullish(barIndex) ||
|
||||||
|
(kiParser.IsKIFastBearish(barIndex) &&
|
||||||
|
iBar.IsRejected(kiHelper.GetKIFast(barIndex), X_DIRECTION_BEARISH))) &&
|
||||||
|
kiParser.IsKISlowBearish(barIndex));
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIBandBullish = (kiHelper.GetKIUpper(barIndex) > kiHelper.GetKIUpper(barIndex + 1) ||
|
||||||
|
kiHelper.GetKILower(barIndex) > kiHelper.GetKILower(barIndex + 1));
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIBandBearish = (kiHelper.GetKIUpper(barIndex) < kiHelper.GetKIUpper(barIndex + 1) ||
|
||||||
|
kiHelper.GetKILower(barIndex) < kiHelper.GetKILower(barIndex + 1));
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isKIBullish = (kiParser.IsKIFastBullish(barIndex) ||
|
bool isKIBullish = (kiParser.IsKIFastBullish(barIndex) ||
|
||||||
kiParser.IsKIFastSwitchedToBullish(barIndex)) &&
|
kiParser.IsKIFastSwitchedToBullish(barIndex)) &&
|
||||||
@@ -1131,46 +1109,32 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
scoreBearish++;
|
scoreBearish++;
|
||||||
}
|
}
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region NearInside Support/Resistance ...
|
|
||||||
//
|
|
||||||
int tmpSupportIDX = -1;
|
|
||||||
bool isNearSupport = poiDetector.HasNearZone(tmpSupportIDX, iBar.close, 5, supports);
|
|
||||||
if (isNearSupport)
|
|
||||||
{
|
|
||||||
scoreBullish++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int tmpResistanceIDX = -1;
|
|
||||||
bool isNearResistance = poiDetector.HasNearZone(tmpResistanceIDX, iBar.close, 5, resistances);
|
|
||||||
if (isNearResistance)
|
|
||||||
{
|
|
||||||
scoreBearish++;
|
|
||||||
}
|
|
||||||
// #endregion
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Summarize Directional Conditions ...
|
// #region Summarize Directional Conditions ...
|
||||||
//
|
//
|
||||||
isBullish =
|
isBullish =
|
||||||
isATRUp &&
|
isATRUp &&
|
||||||
scoreBullish >= 4 &&
|
isLowerTFBullish &&
|
||||||
(isMaBullish ||
|
isKIReadyForBullish &&
|
||||||
isNearSupport ||
|
isCandlestickBullish &&
|
||||||
|
scoreBullish >= 2 &&
|
||||||
|
(isKIBullish ||
|
||||||
|
isMaBullish ||
|
||||||
isKIWaveBullish ||
|
isKIWaveBullish ||
|
||||||
isLowerTFBullish ||
|
isKIBandBullish);
|
||||||
isCandlestickBullish);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
isBearish =
|
isBearish =
|
||||||
isATRUp &&
|
isATRUp &&
|
||||||
scoreBearish >= 4 &&
|
isLowerTFBearish &&
|
||||||
(isMaBearish ||
|
isKIReadyForBearish &&
|
||||||
isNearResistance ||
|
isCandlestickBearish &&
|
||||||
|
scoreBearish >= 2 &&
|
||||||
|
(isKIBearish ||
|
||||||
|
isMaBearish ||
|
||||||
isKIWaveBearish ||
|
isKIWaveBearish ||
|
||||||
isLowerTFBearish ||
|
isKIBandBearish);
|
||||||
isCandlestickBearish);
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1180,54 +1144,30 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
XClean(supports);
|
|
||||||
XClean(resistances);
|
|
||||||
minorSupport.Clean();
|
|
||||||
majorSupport.Clean();
|
|
||||||
minorResistance.Clean();
|
|
||||||
majorResistance.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
// DebugBreak();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Select Operational Zone ...
|
// Select Operational Zone ...
|
||||||
if (isBullish)
|
if (isBullish)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Nearest Support ...
|
// Looking Bar Patterns to Detect Zone ...
|
||||||
if (IsValidIndex(tmpSupportIDX))
|
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BULLISH);
|
||||||
{
|
|
||||||
zone = supports[tmpSupportIDX];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make Sure Zone Exists ...
|
|
||||||
if (!zone.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Looking Bar Patterns to Detect Zone ...
|
|
||||||
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BULLISH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (isBearish)
|
else if (isBearish)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Nearest Resistance ...
|
// Looking Bar Patterns to Detect Zone ...
|
||||||
if (IsValidIndex(tmpResistanceIDX))
|
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BEARISH);
|
||||||
{
|
|
||||||
zone = resistances[tmpResistanceIDX];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make Sure Zone Exists ...
|
|
||||||
if (!zone.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Looking Bar Patterns to Detect Zone ...
|
|
||||||
poiDetector.HasRecentPatternTouched(zone, iBar.close, barIndex, 5, 5, iBar.period, X_DIRECTION_BEARISH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1317,12 +1257,6 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
XClean(supports);
|
|
||||||
XClean(resistances);
|
|
||||||
minorSupport.Clean();
|
|
||||||
majorSupport.Clean();
|
|
||||||
minorResistance.Clean();
|
|
||||||
majorResistance.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1358,48 +1292,13 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
config.Default();
|
config.Default();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Minors ...
|
|
||||||
if (minorSupport.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
drawn++;
|
|
||||||
poiDrawer.DrawZone(minorSupport, config);
|
|
||||||
}
|
|
||||||
if (minorResistance.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
drawn++;
|
|
||||||
poiDrawer.DrawZone(minorResistance, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Majors ...
|
|
||||||
config.bullishColor = clrLime;
|
|
||||||
config.bearishColor = clrRed;
|
|
||||||
config.zonesWidth = 4;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (majorSupport.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
drawn++;
|
|
||||||
poiDrawer.DrawZone(majorSupport, config);
|
|
||||||
}
|
|
||||||
if (majorResistance.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
drawn++;
|
|
||||||
poiDrawer.DrawZone(majorResistance, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
config.Clean();
|
config.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
if (drawn > 0)
|
if (drawn > 0)
|
||||||
{
|
{
|
||||||
DebugBreak();
|
// DebugBreak();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1416,12 +1315,6 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
XClean(supports);
|
|
||||||
XClean(resistances);
|
|
||||||
minorSupport.Clean();
|
|
||||||
majorSupport.Clean();
|
|
||||||
minorResistance.Clean();
|
|
||||||
majorResistance.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1455,15 +1348,12 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #region Preparing Target ...
|
||||||
|
// #endregion
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup Resources ...
|
// Cleanup Resources ...
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
XClean(supports);
|
|
||||||
XClean(resistances);
|
|
||||||
minorSupport.Clean();
|
|
||||||
majorSupport.Clean();
|
|
||||||
minorResistance.Clean();
|
|
||||||
majorResistance.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
result =
|
result =
|
||||||
|
|||||||
@@ -1207,7 +1207,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
isPBarSignalKeyBar = isPBarSignalKeyBarBullish || isPBarSignalKeyBarBearish;
|
isPBarSignalKeyBar = isPBarSignalKeyBarBullish || isPBarSignalKeyBarBearish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
bool hasBullishBar = isPBarIsPinBarBullish ||
|
bool hasBullishBar = isPBarIsPinBarBullish ||
|
||||||
isPBarSignalKeyBarBullish;
|
isPBarSignalKeyBarBullish;
|
||||||
@@ -1456,14 +1455,14 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
true, // Contains Fair Value Gaps ...
|
true, // Contains Fair Value Gaps ...
|
||||||
true, // Contains Supports ...
|
true, // Contains Supports ...
|
||||||
true, // Contains Resistances ...
|
true, // Contains Resistances ...
|
||||||
|
50, // Loopback ...
|
||||||
X_DIRECTION_ALL, // For All Directions ...
|
X_DIRECTION_ALL, // For All Directions ...
|
||||||
X_SORT_BY_DATE, // Sort by Date ...
|
X_SORT_BY_DATE, // Sort by Date ...
|
||||||
X_DIRECTION_BEARISH, // Sorting Direction ...
|
X_DIRECTION_BEARISH, // Sorting Direction ...
|
||||||
10, // Zones Validation Points Factor ...
|
10, // Zones Validation Points Factor ...
|
||||||
5, // Zones Loopback ...
|
5, // Zones Loopback ...
|
||||||
3, // Zones Validation ...
|
3, // Zones Validation ...
|
||||||
0, // All Zones ...
|
0 // All Zones ...
|
||||||
50 // Loopback Length ...
|
|
||||||
);
|
);
|
||||||
UpdateToTime(zones, bar.time);
|
UpdateToTime(zones, bar.time);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user