last ...
This commit is contained in:
@@ -651,7 +651,7 @@ double mSameValeGolden = 0;
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool mDrawLiquidities = false;
|
bool mDrawLiquidities = false;
|
||||||
bool mDrawRangeBreakes = false;
|
bool mDrawRangeBreakes = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool mDetectLiquidities = true;
|
bool mDetectLiquidities = true;
|
||||||
@@ -3663,6 +3663,9 @@ void DoProcess(
|
|||||||
// Detecting Trigger Bar ...
|
// Detecting Trigger Bar ...
|
||||||
|
|
||||||
//
|
//
|
||||||
|
bool hasSignal = false;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
string namePrefix = NULL;
|
string namePrefix = NULL;
|
||||||
int triggerBarPushers = 0;
|
int triggerBarPushers = 0;
|
||||||
ENUM_X_DIRECTION triggerDir;
|
ENUM_X_DIRECTION triggerDir;
|
||||||
@@ -3898,206 +3901,209 @@ void DoProcess(
|
|||||||
;
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validating Trigger Bar ...
|
// Reading Required Condiions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// HK Signal Bar ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iHKSOpen = hkSBarOpenBuffer[barIndex];
|
||||||
|
double iHKSClose = hkSBarCloseBuffer[barIndex];
|
||||||
|
|
||||||
|
//
|
||||||
|
double iHKSMax = MathMax(iHKSOpen, iHKSClose);
|
||||||
|
double iHKSMin = MathMin(iHKSOpen, iHKSClose);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isHKSBullish = hkSBarOpenBuffer[barIndex] < hkSBarCloseBuffer[barIndex];
|
||||||
|
bool isPHKSBullish = hkSBarOpenBuffer[barIndex + 1] < hkSBarCloseBuffer[barIndex + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isHKSBearish = hkSBarOpenBuffer[barIndex] > hkSBarCloseBuffer[barIndex];
|
||||||
|
bool isPHKSBearish = hkSBarOpenBuffer[barIndex + 1] > hkSBarCloseBuffer[barIndex + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isHKSSwitchedToBullish =
|
||||||
|
isHKSBullish &&
|
||||||
|
!isPHKSBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isHKSSwitchedToBearish =
|
||||||
|
isHKSBearish &&
|
||||||
|
!isPHKSBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// TREND ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double iTrend = trendBuffer[barIndex];
|
||||||
|
bool isTrendBullish = trendStateBuffer[barIndex] > 0;
|
||||||
|
bool isTrendBearish = trendStateBuffer[barIndex] < 0;
|
||||||
|
bool isTrendSwitchedToBullish =
|
||||||
|
trendStateBuffer[barIndex] > 0 &&
|
||||||
|
trendStateBuffer[barIndex + 1] <= 0;
|
||||||
|
bool isTrendSwitchedToBearish =
|
||||||
|
trendStateBuffer[barIndex] < 0 &&
|
||||||
|
trendStateBuffer[barIndex + 1] >= 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// RSI ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSIOverOB = rsiBuffer[barIndex] > rsiOBLevel;
|
||||||
|
bool isPRSIOverOB = rsiBuffer[barIndex + 1] > rsiOBLevel;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSIUnderOB = rsiBuffer[barIndex] < rsiOBLevel;
|
||||||
|
bool isPRSIUnderOB = rsiBuffer[barIndex + 1] < rsiOBLevel;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSICrossedOverOB =
|
||||||
|
isRSIOverOB &&
|
||||||
|
!isPRSIOverOB;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSICrossedUnderOB =
|
||||||
|
isRSIUnderOB &&
|
||||||
|
!isPRSIUnderOB;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSIOverOS = rsiBuffer[barIndex] > rsiOSLevel;
|
||||||
|
bool isPRSIOverOS = rsiBuffer[barIndex + 1] > rsiOSLevel;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSIUnderOS = rsiBuffer[barIndex] < rsiOSLevel;
|
||||||
|
bool isPRSIUnderOS = rsiBuffer[barIndex + 1] < rsiOSLevel;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSICrossedOverOS =
|
||||||
|
isRSIOverOS &&
|
||||||
|
!isPRSIOverOS;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isRSICrossedUnderOS =
|
||||||
|
isRSIUnderOS &&
|
||||||
|
!isPRSIUnderOS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// ADX ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXOverThreshold = adxBuffer[barIndex] > adxThreshold;
|
||||||
|
bool isPADXOverThreshold = adxBuffer[barIndex + 1] > adxThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXUnderThreshold = adxBuffer[barIndex] < adxThreshold;
|
||||||
|
bool isPADXUnderThreshold = adxBuffer[barIndex + 1] < adxThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXCrossedOverThreshold =
|
||||||
|
isADXOverThreshold &&
|
||||||
|
!isPADXOverThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXCrossedUnderThreshold =
|
||||||
|
isADXUnderThreshold &&
|
||||||
|
!isPADXUnderThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXBullish = adxpBuffer[barIndex] > adxnBuffer[barIndex];
|
||||||
|
bool isPADXBullish = adxpBuffer[barIndex + 1] > adxnBuffer[barIndex + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXBearish = adxpBuffer[barIndex] < adxnBuffer[barIndex];
|
||||||
|
bool isPADXBearish = adxpBuffer[barIndex + 1] < adxnBuffer[barIndex + 1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXSwitchedToBullish =
|
||||||
|
isADXBullish &&
|
||||||
|
!isPADXBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXSwitchedToBearish =
|
||||||
|
isADXBearish &&
|
||||||
|
!isPADXBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXFullySwitchedToBullish =
|
||||||
|
isADXSwitchedToBullish &&
|
||||||
|
isADXCrossedOverThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isADXFullySwitchedToBearish =
|
||||||
|
isADXSwitchedToBearish &&
|
||||||
|
isADXCrossedUnderThreshold;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTriggerBarOverHKS =
|
||||||
|
iBar.low > iHKSMax;
|
||||||
|
bool isTriggerBarUnderHKS =
|
||||||
|
iBar.high < iHKSMin;
|
||||||
|
|
||||||
|
//
|
||||||
|
// KI ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIBullish = kiStateBuffer[barIndex] > 0;
|
||||||
|
bool isPKIBullish = kiStateBuffer[barIndex + 1] > 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKIBearish = kiStateBuffer[barIndex] < 0;
|
||||||
|
bool isPKIBearish = kiStateBuffer[barIndex = 1] < 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKISwitchedToBullish =
|
||||||
|
isKIBullish &&
|
||||||
|
!isPKIBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isKISwitchedToBearish =
|
||||||
|
isKIBearish &&
|
||||||
|
!isPKIBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validating Trigger Bar based on Conditions ...
|
||||||
if (isTriggerBar)
|
if (isTriggerBar)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Reading Required Info ...
|
// TODO: Remove this if required ...
|
||||||
|
|
||||||
//
|
|
||||||
// HK Signal Bar ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double iHKSOpen = hkSBarOpenBuffer[barIndex];
|
|
||||||
double iHKSClose = hkSBarCloseBuffer[barIndex];
|
|
||||||
|
|
||||||
//
|
|
||||||
double iHKSMax = MathMax(iHKSOpen, iHKSClose);
|
|
||||||
double iHKSMin = MathMin(iHKSOpen, iHKSClose);
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isHKSBullish = hkSBarOpenBuffer[barIndex] < hkSBarCloseBuffer[barIndex];
|
|
||||||
bool isPHKSBullish = hkSBarOpenBuffer[barIndex + 1] < hkSBarCloseBuffer[barIndex + 1];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isHKSBearish = hkSBarOpenBuffer[barIndex] > hkSBarCloseBuffer[barIndex];
|
|
||||||
bool isPHKSBearish = hkSBarOpenBuffer[barIndex + 1] > hkSBarCloseBuffer[barIndex + 1];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isHKSSwitchedToBullish =
|
|
||||||
isHKSBullish &&
|
|
||||||
!isPHKSBullish;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isHKSSwitchedToBearish =
|
|
||||||
isHKSBearish &&
|
|
||||||
!isPHKSBearish;
|
|
||||||
|
|
||||||
//
|
|
||||||
// TREND ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double iTrend = trendBuffer[barIndex];
|
|
||||||
bool isTrendBullish = trendStateBuffer[barIndex] > 0;
|
|
||||||
bool isTrendBearish = trendStateBuffer[barIndex] < 0;
|
|
||||||
bool isTrendSwitchedToBullish =
|
|
||||||
trendStateBuffer[barIndex] > 0 &&
|
|
||||||
trendStateBuffer[barIndex + 1] <= 0;
|
|
||||||
bool isTrendSwitchedToBearish =
|
|
||||||
trendStateBuffer[barIndex] < 0 &&
|
|
||||||
trendStateBuffer[barIndex + 1] >= 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// RSI ...
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSIOverOB = rsiBuffer[barIndex] > rsiOBLevel;
|
|
||||||
bool isPRSIOverOB = rsiBuffer[barIndex + 1] > rsiOBLevel;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSIUnderOB = rsiBuffer[barIndex] < rsiOBLevel;
|
|
||||||
bool isPRSIUnderOB = rsiBuffer[barIndex + 1] < rsiOBLevel;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSICrossedOverOB =
|
|
||||||
isRSIOverOB &&
|
|
||||||
!isPRSIOverOB;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSICrossedUnderOB =
|
|
||||||
isRSIUnderOB &&
|
|
||||||
!isPRSIUnderOB;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSIOverOS = rsiBuffer[barIndex] > rsiOSLevel;
|
|
||||||
bool isPRSIOverOS = rsiBuffer[barIndex + 1] > rsiOSLevel;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSIUnderOS = rsiBuffer[barIndex] < rsiOSLevel;
|
|
||||||
bool isPRSIUnderOS = rsiBuffer[barIndex + 1] < rsiOSLevel;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSICrossedOverOS =
|
|
||||||
isRSIOverOS &&
|
|
||||||
!isPRSIOverOS;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isRSICrossedUnderOS =
|
|
||||||
isRSIUnderOS &&
|
|
||||||
!isPRSIUnderOS;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ADX ...
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXOverThreshold = adxBuffer[barIndex] > adxThreshold;
|
|
||||||
bool isPADXOverThreshold = adxBuffer[barIndex + 1] > adxThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXUnderThreshold = adxBuffer[barIndex] < adxThreshold;
|
|
||||||
bool isPADXUnderThreshold = adxBuffer[barIndex + 1] < adxThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXCrossedOverThreshold =
|
|
||||||
isADXOverThreshold &&
|
|
||||||
!isPADXOverThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXCrossedUnderThreshold =
|
|
||||||
isADXUnderThreshold &&
|
|
||||||
!isPADXUnderThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXBullish = adxpBuffer[barIndex] > adxnBuffer[barIndex];
|
|
||||||
bool isPADXBullish = adxpBuffer[barIndex + 1] > adxnBuffer[barIndex + 1];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXBearish = adxpBuffer[barIndex] < adxnBuffer[barIndex];
|
|
||||||
bool isPADXBearish = adxpBuffer[barIndex + 1] < adxnBuffer[barIndex + 1];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXSwitchedToBullish =
|
|
||||||
isADXBullish &&
|
|
||||||
!isPADXBullish;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXSwitchedToBearish =
|
|
||||||
isADXBearish &&
|
|
||||||
!isPADXBearish;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXFullySwitchedToBullish =
|
|
||||||
isADXSwitchedToBullish &&
|
|
||||||
isADXCrossedOverThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isADXFullySwitchedToBearish =
|
|
||||||
isADXSwitchedToBearish &&
|
|
||||||
isADXCrossedUnderThreshold;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isTriggerBarOverHKS =
|
|
||||||
iBar.low > iHKSMax;
|
|
||||||
bool isTriggerBarUnderHKS =
|
|
||||||
iBar.high < iHKSMin;
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate Bullish Trigger Bar ...
|
|
||||||
isBullishTriggerBar =
|
|
||||||
//
|
|
||||||
isBullishTriggerBar &&
|
|
||||||
//
|
|
||||||
(
|
|
||||||
//
|
|
||||||
// isHKSBullish &&
|
|
||||||
// isTrendBullish
|
|
||||||
//
|
|
||||||
// isRSICrossedOverOS
|
|
||||||
//
|
|
||||||
isHKSSwitchedToBullish
|
|
||||||
//
|
|
||||||
)
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate Bearish Trigger Bar ...
|
|
||||||
isBearishTriggerBar =
|
|
||||||
//
|
|
||||||
isBearishTriggerBar &&
|
|
||||||
//
|
|
||||||
(
|
|
||||||
//
|
|
||||||
// isHKSBearish &&
|
|
||||||
// isTrendBearish
|
|
||||||
//
|
|
||||||
// isRSICrossedUnderOB
|
|
||||||
//
|
|
||||||
isHKSSwitchedToBearish
|
|
||||||
//
|
|
||||||
)
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Summarizing Result ...
|
|
||||||
isTriggerBar =
|
|
||||||
//
|
|
||||||
isBullishTriggerBar ||
|
|
||||||
isBearishTriggerBar
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isTriggerBar = false;
|
isTriggerBar = false;
|
||||||
isBullishTriggerBar = false;
|
isBullishTriggerBar = false;
|
||||||
isBearishTriggerBar = false;
|
isBearishTriggerBar = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detecting Signal ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
isHKSBullish &&
|
||||||
|
isKISwitchedToBullish &&
|
||||||
|
iBar.close > kiBuffer[barIndex]
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
isHKSBearish &&
|
||||||
|
isKISwitchedToBearish &&
|
||||||
|
iBar.close < kiBuffer[barIndex]
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarizing Signal ...
|
||||||
|
hasSignal =
|
||||||
|
isBullish ||
|
||||||
|
isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Requirements ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw Trigger Bar ...
|
// Draw Trigger Bar ...
|
||||||
if (isTriggerBar)
|
if (isTriggerBar)
|
||||||
@@ -4209,6 +4215,104 @@ void DoProcess(
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Signal ...
|
||||||
|
if (hasSignal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int bullishArrowCode = 225;
|
||||||
|
int bearishArrowCode = 226;
|
||||||
|
|
||||||
|
//
|
||||||
|
color bullishColor = clrLime;
|
||||||
|
color bearishColor = clrRed;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_ARROW_ANCHOR bullishAnchor = ANCHOR_TOP;
|
||||||
|
ENUM_ARROW_ANCHOR bearishAnchor = ANCHOR_BOTTOM;
|
||||||
|
|
||||||
|
//
|
||||||
|
int arrowWidth = 3;
|
||||||
|
int arrowCode =
|
||||||
|
isBullish
|
||||||
|
? bullishArrowCode
|
||||||
|
: bearishArrowCode;
|
||||||
|
ENUM_X_PRICE arrowPriceType =
|
||||||
|
isBullish
|
||||||
|
? X_PRICE_LOW
|
||||||
|
: X_PRICE_HIGH;
|
||||||
|
color arrowColor =
|
||||||
|
isBullish
|
||||||
|
? bullishColor
|
||||||
|
: bearishColor;
|
||||||
|
ENUM_ARROW_ANCHOR arrowAnchor =
|
||||||
|
isBullish
|
||||||
|
? bullishAnchor
|
||||||
|
: bearishAnchor;
|
||||||
|
|
||||||
|
//
|
||||||
|
XCBarArrowObject *iObj;
|
||||||
|
has = mDrawer.CreateBarArrow(
|
||||||
|
iBar,
|
||||||
|
iObj,
|
||||||
|
arrowPriceType,
|
||||||
|
arrowCode,
|
||||||
|
arrowColor,
|
||||||
|
arrowWidth,
|
||||||
|
arrowAnchor,
|
||||||
|
namePrefix //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
mObjects.Add(iObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Converts to Box ...
|
||||||
|
XBoxZone iBox;
|
||||||
|
iBox.type = "XSG";
|
||||||
|
iBox.to = iBar.time;
|
||||||
|
iBox.symbol = _Symbol;
|
||||||
|
iBox.period = _Period;
|
||||||
|
iBox.lower = iPBar.low;
|
||||||
|
iBox.from = iPBar.time;
|
||||||
|
iBox.upper = iPBar.high;
|
||||||
|
iBox.dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
if (iBox.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XSignal iSignal;
|
||||||
|
double iRewardRatios[] = {
|
||||||
|
1,
|
||||||
|
1.5,
|
||||||
|
2 //
|
||||||
|
};
|
||||||
|
has = ToSignal(
|
||||||
|
iBox,
|
||||||
|
iSignal,
|
||||||
|
iRewardRatios,
|
||||||
|
0 // Additional SL ...
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSignalObject *iObj;
|
||||||
|
has = mDrawer.DrawSignal(
|
||||||
|
iSignal,
|
||||||
|
iObj,
|
||||||
|
4 //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
mObjects.Add(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup Resources ...
|
// Cleanup Resources ...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user