diff --git a/MQLTestWorkspace/BKPS/eqm.tools.mq5 b/MQLTestWorkspace/BKPS/eqm.tools.mq5 index c0aba13..4c959ba 100644 --- a/MQLTestWorkspace/BKPS/eqm.tools.mq5 +++ b/MQLTestWorkspace/BKPS/eqm.tools.mq5 @@ -344,3 +344,1036 @@ // return result; } + + + // + // Check Account is Ready for EQM Hedge or not ... + bool IsReadyForEQMHedge() + { + // + bool result = false; + + // + // Check required Inputs ... + if (mMinProfitPerTrade <= 0 || + mMinProfitPerVolumeFactor <= 0) + { + return result; + } + + // + // Check at least One EQM Support Position must be Open ... + XPosition eqmPositions[]; + int eqmPositionsCount = GetEQMPositions(eqmPositions); + if (eqmPositionsCount <= 0) + { + return result; + } + + // + // Get All Open Positions for Calculate Account Profit ... + XPosition positions[]; + int positionsCount = GetPositions( + positions); + if (positionsCount <= 0) + { + return result; + } + + // + // Define Factor Variables ... + double profit = 0; + double requiredProfit = 0; + + // + // Calculate Account Profit Factors ... + for (int i = 0; i < positionsCount; i++) + { + // + XPosition iPosition = positions[i]; + + // + profit += iPosition.profit; + requiredProfit += + ((iPosition.volume / mMinProfitPerVolumeFactor) * + mMinProfitPerTrade) + + (-1 * iPosition.swap); + } + + // + // Calculate the result ... + result = profit >= requiredProfit; + + // + return result; + } + + + + + + // + if (isLongSupport) + { + // + if (!onlyGoldenZone && isPriceUnderFib5) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? vale : 0; + signal.entry = fib5; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + // Since Price is Under Fib 5 + // this so Important to Handle also Vale Breakouts ... + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = vale; + signal.tp = placeTP ? 0 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceUnderFib4) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceUnderFib3) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceUnderFib2) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceUnderFib1) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.volume = volume; + signal.period = period; + signal.symbol = conditions.symbol; + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? peak : 0; + signal.entry = fib1; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + } + } + else + { + // + if (!onlyGoldenZone && isPriceOverFib1) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? peak : 0; + signal.entry = fib1; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + // Since Price is Over Fib 1 + // this so Important to Handle also Peak Breakouts ... + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = peak; + signal.tp = placeTP ? 0 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceOverFib2) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceOverFib3) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceOverFib4) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone && isPriceOverFib5) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + } + else if (!onlyGoldenZone) + { + // + // Diection Positions ... + XSignal signal; + Clean(signal); + + // + signal.volume = volume; + signal.period = period; + signal.symbol = conditions.symbol; + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? vale : 0; + signal.entry = fib5; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + } + } diff --git a/MQLTestWorkspace/BKPS/x-saherelm.x121.condition.parser.lib copy.mq5 b/MQLTestWorkspace/BKPS/x-saherelm.x121.condition.parser.lib copy.mq5 new file mode 100644 index 0000000..b400d27 --- /dev/null +++ b/MQLTestWorkspace/BKPS/x-saherelm.x121.condition.parser.lib copy.mq5 @@ -0,0 +1,5087 @@ +//////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 X12 Conditions Parser Library +// ----------------------------------------------------- +// Name: X121ConditionsParser +// Description: provides Market Conditions +// Parsing 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 + +// +#include "../Libraries/x-saherelm.common.lib.mq5" +#include "../Libraries/x-saherelm.models.lib.mq5" +#include "../Classes/x-saherelm.x121.provider.class.mq5" + +// +// START Functions ... +// + +// +// PARSE STATES ... +// + +// +// SSLC ... +// + +// +bool IsSSLCBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sslcUps[index] > conditions.xmanInfo.sslcDowns[index] + // + ; + + // + return result; +} + +// +bool IsSSLCSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSSLCBullish(conditions, index) && + !IsSSLCBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsSSLCBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sslcUps[index] < conditions.xmanInfo.sslcDowns[index] + // + ; + + // + return result; +} + +// +bool IsSSLCSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSSLCBearish(conditions, index) && + !IsSSLCBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// HULL ... +// + +// +bool IsHullBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullUpBullish(conditions, index) && + IsHullDownBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsHullSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullBullish(conditions, index) && + !IsHullBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsHullBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullUpBearish(conditions, index) && + IsHullDownBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsHullSwitchedBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullBearish(conditions, index) && + !IsHullBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// UP ... + +// +// BULLISH ... + +// +bool IsHullUpBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hullUps[index] > conditions.xmanInfo.hullUps[index + 1] + // + ; + + // + return result; +} + +// +bool IsHullUpSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullUpBullish(conditions, index) && + !IsHullUpBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// BEARISH ... + +// +bool IsHullUpBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hullUps[index] < conditions.xmanInfo.hullUps[index + 1] + // + ; + + // + return result; +} + +// +bool IsHullUpSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullUpBearish(conditions, index) && + !IsHullUpBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// DOWN ... + +// +// BULLISH ... + +// +bool IsHullDownBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hullDowns[index] > conditions.xmanInfo.hullDowns[index + 1] + // + ; + + // + return result; +} + +// +bool IsHullDownSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullDownBullish(conditions, index) && + !IsHullDownBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// BEARISH ... + +// +bool IsHullDownBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hullDowns[index] < conditions.xmanInfo.hullDowns[index + 1] + // + ; + + // + return result; +} + +// +bool IsHullDownSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullDownBearish(conditions, index) && + !IsHullDownBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// TREND ... +// + +// +// Check Trend Bullish ... +bool IsTrendBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.candles[index].low > conditions.xmanInfo.trends[index] + // + ; + + // + return result; +} + +// +// Check Trend Switched To Bullish ... +bool IsTrendSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsTrendBullish(conditions, index) && + !IsTrendBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// Check Trend Bearish ... +bool IsTrendBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.candles[index].high < conditions.xmanInfo.trends[index] + // + ; + + // + return result; +} + +// +// Check Trend Switched To Bearish ... +bool IsTrendSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsTrendBearish(conditions, index) && + !IsTrendBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// RIBBON ... +// + +// +double GetRibbonMax( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + double result = 0; + + // + result = MathMax(conditions.xmanInfo.ribbon1s[index], conditions.xmanInfo.ribbon2s[index]); + result = MathMax(result, conditions.xmanInfo.ribbon3s[index]); + result = MathMax(result, conditions.xmanInfo.ribbon4s[index]); + result = MathMax(result, conditions.xmanInfo.ribbon5s[index]); + result = MathMax(result, conditions.xmanInfo.ribbon6s[index]); + + // + return result; +} + +// +double GetRibbonMin( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + double result = 0; + + // + result = MathMin(conditions.xmanInfo.ribbon1s[index], conditions.xmanInfo.ribbon2s[index]); + result = MathMin(result, conditions.xmanInfo.ribbon3s[index]); + result = MathMin(result, conditions.xmanInfo.ribbon4s[index]); + result = MathMin(result, conditions.xmanInfo.ribbon5s[index]); + result = MathMin(result, conditions.xmanInfo.ribbon6s[index]); + + // + return result; +} + +// +// Check Ribbon States ... +// Working With Price and Ribbon Values ... +bool IsRibbonBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.candles[index].low > conditions.xmanInfo.ribbon1s[index] && + conditions.candles[index].low > conditions.xmanInfo.ribbon2s[index] && + conditions.candles[index].low > conditions.xmanInfo.ribbon3s[index] && + conditions.candles[index].low > conditions.xmanInfo.ribbon4s[index] && + conditions.candles[index].low > conditions.xmanInfo.ribbon5s[index] && + conditions.candles[index].low > conditions.xmanInfo.ribbon6s[index] + // + ; + + // + return result; +} + +// +// Check Ribbons Sequntial Statements ... +// Working with Price and Ribbon Values and also Ribbon Orders +bool IsRibbonOrderBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonBullish(conditions, index) + // + && + // + GetRibbonMax(conditions, index) == conditions.xmanInfo.ribbon1s[index] + // + && + // + GetRibbonMin(conditions, index) == conditions.xmanInfo.ribbon6s[index] + // + ; + + // + return result; +} + +// +bool IsRibbonSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonBullish(conditions, index) && + !IsRibbonBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// Check Ribbons Sequntial Statements ... +bool IsRibbonOrderSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonOrderBullish(conditions, index) && + !IsRibbonOrderBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// Check Ribbon States ... +// Working With Price and Ribbon Values ... +bool IsRibbonBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.candles[index].high < conditions.xmanInfo.ribbon1s[index] && + conditions.candles[index].high < conditions.xmanInfo.ribbon2s[index] && + conditions.candles[index].high < conditions.xmanInfo.ribbon3s[index] && + conditions.candles[index].high < conditions.xmanInfo.ribbon4s[index] && + conditions.candles[index].high < conditions.xmanInfo.ribbon5s[index] && + conditions.candles[index].high < conditions.xmanInfo.ribbon6s[index] + // + ; + + // + return result; +} + +// +// Check Ribbons Sequntial Statements ... +// Working with Price and Ribbon Values and also Ribbon Orders +bool IsRibbonOrderBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonBearish(conditions, index) + // + && + // + GetRibbonMax(conditions, index) == conditions.xmanInfo.ribbon1s[index] + // + && + // + GetRibbonMin(conditions, index) == conditions.xmanInfo.ribbon6s[index] + // + ; + + // + return result; +} + +// +bool IsRibbonSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonBearish(conditions, index) && + !IsRibbonBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// Check Ribbons Sequntial Statements ... +bool IsRibbonOrderSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsRibbonOrderBearish(conditions, index) && + !IsRibbonOrderBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// PEAKS and VALES and Levels ... +// + +// +// Check Peak Same as Last ... +bool IsPeakSameAs( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int length = 5 // Comparing Period +) +{ + // + bool result = false; + + // + if (length <= 0) + { + return result; + } + + // + double selected = conditions.xmanInfo.peaks[index]; + + // + int start = index + 1; + int end = start + length; + + // + int verified = 0; + for (int i = start; i < end; i++) + { + // + double iValue = conditions.xmanInfo.peaks[i]; + + // + if (iValue == selected) + { + verified++; + } + } + + // + result = verified == length; + + // + return result; +} + +// +// Check New Peaks Happens ... +bool IsNewPeak( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.peaks[index] != EMPTY_VALUE && + conditions.xmanInfo.peaks[index] != conditions.xmanInfo.peaks[index + 1] + // + ; + + // + return result; +} + +// +// Check New Peaks Happens Over Last ... +bool IsNewPeakOverLast( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsNewPeak(conditions, index) && + conditions.xmanInfo.peaks[index] > conditions.xmanInfo.peaks[index + 1] + // + ; + + // + return result; +} + +// +// Check New Peaks Happens Under Last ... +bool IsNewPeakUnderLast( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsNewPeak(conditions, index) && + conditions.xmanInfo.peaks[index] < conditions.xmanInfo.peaks[index + 1] + // + ; + + // + return result; +} + +// +// Check Valse Same as Last ... +bool IsValeSameAs( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int length = 5 // Comparing Period +) +{ + // + bool result = false; + + // + if (length <= 0) + { + return result; + } + + // + double selected = conditions.xmanInfo.vales[index]; + + // + int start = index + 1; + int end = start + length; + + // + int verified = 0; + for (int i = start; i < end; i++) + { + // + double iValue = conditions.xmanInfo.vales[i]; + + // + if (iValue == selected) + { + verified++; + } + } + + // + result = verified == length; + + // + return result; +} + +// +// Check New Vales Happens ... +bool IsNewVale( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.vales[index] != EMPTY_VALUE && + conditions.xmanInfo.vales[index] != conditions.xmanInfo.vales[index + 1] + // + ; + + // + return result; +} + +// +// Check New Vales Happens Over Last ... +bool IsNewValeOverLast( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsNewVale(conditions, index) && + conditions.xmanInfo.vales[index] > conditions.xmanInfo.vales[index + 1] + // + ; + + // + return result; +} + +// +// Check New Vales Happens Under Last ... +bool IsNewValeUnderLast( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsNewVale(conditions, index) && + conditions.xmanInfo.vales[index] < conditions.xmanInfo.vales[index + 1] + // + ; + + // + return result; +} + +// +// Check Finbonacci Increased ... +bool IsFiboIncreased( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.fibLevel1s[index] > conditions.xmanInfo.fibLevel1s[index + 1] && + conditions.xmanInfo.fibLevel2s[index] > conditions.xmanInfo.fibLevel2s[index + 1] && + conditions.xmanInfo.fibLevel3s[index] > conditions.xmanInfo.fibLevel3s[index + 1] && + conditions.xmanInfo.fibLevel4s[index] > conditions.xmanInfo.fibLevel4s[index + 1] && + conditions.xmanInfo.fibLevel5s[index] > conditions.xmanInfo.fibLevel5s[index + 1] + // + ; + + // + return result; +} + +// +// Check Fibonacci Decreased ... +bool IsFiboDecreased( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.fibLevel1s[index] < conditions.xmanInfo.fibLevel1s[index + 1] && + conditions.xmanInfo.fibLevel2s[index] < conditions.xmanInfo.fibLevel2s[index + 1] && + conditions.xmanInfo.fibLevel3s[index] < conditions.xmanInfo.fibLevel3s[index + 1] && + conditions.xmanInfo.fibLevel4s[index] < conditions.xmanInfo.fibLevel4s[index + 1] && + conditions.xmanInfo.fibLevel5s[index] < conditions.xmanInfo.fibLevel5s[index + 1] + // + ; + + // + return result; +} + +// +// Check Fibonacci Crossed ... +bool IsFiboCrossed( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.fibLevel1s[index] == conditions.xmanInfo.fibLevel2s[index] || + conditions.xmanInfo.fibLevel1s[index] == conditions.xmanInfo.fibLevel3s[index] || + conditions.xmanInfo.fibLevel1s[index] == conditions.xmanInfo.fibLevel4s[index] || + conditions.xmanInfo.fibLevel1s[index] == conditions.xmanInfo.fibLevel5s[index] || + conditions.xmanInfo.fibLevel2s[index] == conditions.xmanInfo.fibLevel3s[index] || + conditions.xmanInfo.fibLevel2s[index] == conditions.xmanInfo.fibLevel4s[index] || + conditions.xmanInfo.fibLevel2s[index] == conditions.xmanInfo.fibLevel5s[index] || + conditions.xmanInfo.fibLevel3s[index] == conditions.xmanInfo.fibLevel4s[index] || + conditions.xmanInfo.fibLevel3s[index] == conditions.xmanInfo.fibLevel5s[index] || + conditions.xmanInfo.fibLevel4s[index] == conditions.xmanInfo.fibLevel5s[index] + // + ; + + // + return result; +} + +// +// Check Fibonacci Section Changes ... +bool IsFiboSectionChanged( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + (IsNewPeakUnderLast(conditions, index) && + IsFiboDecreased(conditions, index)) + // + || + // + (IsNewValeOverLast(conditions, index) && + IsFiboIncreased(conditions, index)) + // + ; + + // + return result; +} + +// +// Market Cycles ... + +// +// ALL Cycles ... + +// +bool IsCyclesBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBullish(conditions, index) && + IsMCBullish(conditions, index) && + IsLCBullish(conditions, index) && + IsHCBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesBullish(conditions, index) && + !IsCyclesBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsCyclesBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBearish(conditions, index) && + IsMCBearish(conditions, index) && + IsLCBearish(conditions, index) && + IsHCBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesBearish(conditions, index) && + !IsCyclesBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsCyclesLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCLowBullish(conditions, index) && + IsMCLowBullish(conditions, index) && + IsLCLowBullish(conditions, index) && + IsHCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesLowSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesLowBullish(conditions, index) && + !IsCyclesLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsCyclesLowBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCLowBearish(conditions, index) && + IsMCLowBearish(conditions, index) && + IsLCLowBearish(conditions, index) && + IsHCLowBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesLowSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesLowBearish(conditions, index) && + !IsCyclesLowBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsCyclesHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBullish(conditions, index) && + IsMCHighBullish(conditions, index) && + IsLCHighBullish(conditions, index) && + IsHCHighBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesHighSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesHighBullish(conditions, index) && + !IsCyclesHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsCyclesHighBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBearish(conditions, index) && + IsMCHighBearish(conditions, index) && + IsLCHighBearish(conditions, index) && + IsHCHighBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsCyclesHighSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsCyclesHighBearish(conditions, index) && + !IsCyclesHighBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// INHIND Cycles ... + +// +bool IsInHindCyclesBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBullish(conditions, index) && + IsMCBullish(conditions, index) && + IsLCBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInHindCyclesBullish(conditions, index) && + !IsInHindCyclesBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBearish(conditions, index) && + IsMCBearish(conditions, index) && + IsLCBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInHindCyclesBearish(conditions, index) && + !IsInHindCyclesBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCLowBullish(conditions, index) && + IsMCLowBullish(conditions, index) && + IsLCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesLowSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInHindCyclesLowBullish(conditions, index) && + !IsInHindCyclesLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBullish(conditions, index) && + IsMCHighBullish(conditions, index) && + IsLCHighBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInHindCyclesHighSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInHindCyclesHighBullish(conditions, index) && + !IsInHindCyclesHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// INLONG Cycles ... + +// +bool IsInLongCyclesBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBullish(conditions, index) && + IsMCBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInLongCyclesSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInLongCyclesBullish(conditions, index) && + !IsInLongCyclesBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsInLongCyclesBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBearish(conditions, index) && + IsMCBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsInLongCyclesSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsInLongCyclesBearish(conditions, index) && + !IsInLongCyclesBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// SHORT ... + +// +bool IsSCBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBullish(conditions, index) && + IsSCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsSCSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBullish(conditions, index) && + !IsSCBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsSCBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBearish(conditions, index) && + IsSCLowBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsSCSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCBearish(conditions, index) && + !IsSCBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// SHORT HIGH ... + +// +bool IsSCHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sHHs[index] > conditions.xmanInfo.sHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsSCHighSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBullish(conditions, index) && + !IsSCHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsSCHighBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sHHs[index] < conditions.xmanInfo.sHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsSCHighSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCHighBearish(conditions, index) && + !IsSCHighBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// SHORT LOW ... + +// +bool IsSCLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sLLs[index] > conditions.xmanInfo.sLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsSCLowSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCLowBullish(conditions, index) && + !IsSCLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsSCLowBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.sLLs[index] < conditions.xmanInfo.sLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsSCLowSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsSCLowBearish(conditions, index) && + !IsSCLowBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// MEDIUM ... + +// +bool IsMCBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCHighBullish(conditions, index) && + IsMCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsMCSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCBullish(conditions, index) && + !IsMCBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsMCBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCHighBearish(conditions, index) && + IsMCLowBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsMCSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCBearish(conditions, index) && + !IsMCBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// MEDIUM HIGH ... + +// +bool IsMCHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.mHHs[index] > conditions.xmanInfo.mHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsMCHighSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCHighBullish(conditions, index) && + !IsMCHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsMCHighBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.mHHs[index] < conditions.xmanInfo.mHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsMCHighSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCHighBearish(conditions, index) && + !IsMCHighBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// MEDIUM LOW ... + +// +bool IsMCLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.mLLs[index] > conditions.xmanInfo.mLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsMCLowSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCLowBullish(conditions, index) && + !IsMCLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsMCLowBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.mLLs[index] < conditions.xmanInfo.mLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsMCLowSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsMCLowBearish(conditions, index) && + !IsMCLowBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// LONG ... + +// +bool IsLCBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCHighBullish(conditions, index) && + IsLCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsLCSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCBullish(conditions, index) && + !IsLCBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsLCBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCHighBearish(conditions, index) && + IsLCLowBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsLCSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCBearish(conditions, index) && + !IsLCBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// LONG HIGH ... + +// +bool IsLCHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.lHHs[index] > conditions.xmanInfo.lHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsLCHighSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCHighBullish(conditions, index) && + !IsLCHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsLCHighBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.lHHs[index] < conditions.xmanInfo.lHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsLCHighSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCHighBearish(conditions, index) && + !IsLCHighBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// LONG LOW ... + +// +bool IsLCLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.lLLs[index] > conditions.xmanInfo.lLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsLCLowSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCLowBullish(conditions, index) && + !IsLCLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsLCLowBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.lLLs[index] < conditions.xmanInfo.lLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsLCLowSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsLCLowBearish(conditions, index) && + !IsLCLowBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// HIND ... + +// +bool IsHCBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCHighBullish(conditions, index) && + IsHCLowBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsHCSwitchedToBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCBullish(conditions, index) && + !IsHCBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsHCBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCHighBearish(conditions, index) && + IsHCLowBearish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsHCSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCBearish(conditions, index) && + !IsHCBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// HIND HIGH ... + +// +bool IsHCHighBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hHHs[index] > conditions.xmanInfo.hHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsHCHighSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCHighBullish(conditions, index) && + !IsHCHighBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsHCHighBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hHHs[index] < conditions.xmanInfo.hHHs[index + 1] + // + ; + + // + return result; +} + +// +bool IsHCHighSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCHighBearish(conditions, index) && + !IsHCHighBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// HIND LOW ... + +// +bool IsHCLowBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hLLs[index] > conditions.xmanInfo.hLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsHCLowSwitchedBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCLowBullish(conditions, index) && + !IsHCLowBullish(conditions, index + 1) + // + ; + + // + return result; +} + +// +bool IsHCLowBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hLLs[index] < conditions.xmanInfo.hLLs[index + 1] + // + ; + + // + return result; +} + +// +bool IsHCLowSwitchedToBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHCLowBearish(conditions, index) && + !IsHCLowBearish(conditions, index + 1) + // + ; + + // + return result; +} + +// +// XHK XSMHK ... + +// +double GetHKMax( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + bool ignoreShadows = false // Ignore Shaddows +) +{ + // + double result = 0; + + // + result = MathMax(conditions.xmanInfo.hkOpens[index], conditions.xmanInfo.hkCloses[index]); + if (!ignoreShadows) + { + // + double selectedShadow = MathMax(conditions.xmanInfo.hkHighs[index], conditions.xmanInfo.hkLows[index]); + + // + result = MathMax(result, selectedShadow); + } + + // + return result; +} + +// +double iHKHighest( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5, // Count + ENUM_X_PRICE appliedPrice = X_PRICE_HIGH // Price Type +) +{ + // + double result = 0; + + // + // Validate Args ... + if (index < 0 || + count <= 0) + { + return result; + } + + // + int idx = -1; + double tmpArray[]; + + // + switch (appliedPrice) + { + // + case X_PRICE_HIGH: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkHighs, + 0, + index, + count // + ); + break; + + // + case X_PRICE_OPEN: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkOpens, + 0, + index, + count // + ); + break; + + // + case X_PRICE_CLOSE: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkCloses, + 0, + index, + count // + ); + break; + + // + case X_PRICE_LOW: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkLows, + 0, + index, + count // + ); + break; + } + + // + idx = ArrayMaximum(tmpArray); + if (idx < 0) + { + return result; + } + + // + result = tmpArray[idx]; + + // + return result; +} + +// +double iHKLowest( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5, // Count + ENUM_X_PRICE appliedPrice = X_PRICE_LOW // Price Type +) +{ + // + double result = 0; + + // + // Validate Args ... + if (index < 0 || + count <= 0) + { + return result; + } + + // + int idx = -1; + double tmpArray[]; + + // + switch (appliedPrice) + { + // + case X_PRICE_HIGH: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkHighs, + 0, + index, + count // + ); + break; + + // + case X_PRICE_OPEN: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkOpens, + 0, + index, + count // + ); + break; + + // + case X_PRICE_CLOSE: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkCloses, + 0, + index, + count // + ); + break; + + // + case X_PRICE_LOW: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.hkLows, + 0, + index, + count // + ); + break; + } + + // + idx = ArrayMinimum(tmpArray); + if (idx < 0) + { + return result; + } + + // + result = tmpArray[idx]; + + // + return result; +} + +// +double GetHKMin( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + bool ignoreShadows = false // Ignore Shaddows +) +{ + // + double result = 0; + + // + result = MathMin(conditions.xmanInfo.hkOpens[index], conditions.xmanInfo.hkCloses[index]); + if (!ignoreShadows) + { + // + double selectedShadow = MathMin(conditions.xmanInfo.hkHighs[index], conditions.xmanInfo.hkLows[index]); + + // + result = MathMin(result, selectedShadow); + } + + // + return result; +} + +// +double GetSMHKMax( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + bool ignoreShadows = false // Ignore Shaddows +) +{ + // + double result = 0; + + // + result = MathMax(conditions.xmanInfo.smhkOpens[index], conditions.xmanInfo.smhkCloses[index]); + if (!ignoreShadows) + { + // + double selectedShadow = MathMax(conditions.xmanInfo.smhkHighs[index], conditions.xmanInfo.smhkLows[index]); + + // + result = MathMax(result, selectedShadow); + } + + // + return result; +} + +// +double GetSMHKMin( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + bool ignoreShadows = false // Ignore Shaddows +) +{ + // + double result = 0; + + // + result = MathMin(conditions.xmanInfo.smhkOpens[index], conditions.xmanInfo.smhkCloses[index]); + if (!ignoreShadows) + { + // + double selectedShadow = MathMin(conditions.xmanInfo.smhkHighs[index], conditions.xmanInfo.smhkLows[index]); + + // + result = MathMin(result, selectedShadow); + } + + // + return result; +} + +// +double iSMHKHighest( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5, // Count + ENUM_X_PRICE appliedPrice = X_PRICE_HIGH // Price Type +) +{ + // + double result = 0; + + // + // Validate Args ... + if (index < 0 || + count <= 0) + { + return result; + } + + // + int idx = -1; + double tmpArray[]; + + // + switch (appliedPrice) + { + // + case X_PRICE_HIGH: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkHighs, + 0, + index, + count // + ); + break; + + // + case X_PRICE_OPEN: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkOpens, + 0, + index, + count // + ); + break; + + // + case X_PRICE_CLOSE: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkCloses, + 0, + index, + count // + ); + break; + + // + case X_PRICE_LOW: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkLows, + 0, + index, + count // + ); + break; + } + + // + idx = ArrayMaximum(tmpArray); + if (idx < 0) + { + return result; + } + + // + result = tmpArray[idx]; + + // + return result; +} + +// +double iSMHKLowest( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5, // Count + ENUM_X_PRICE appliedPrice = X_PRICE_LOW // Price Type +) +{ + // + double result = 0; + + // + // Validate Args ... + if (index < 0 || + count <= 0) + { + return result; + } + + // + int idx = -1; + double tmpArray[]; + + // + switch (appliedPrice) + { + // + case X_PRICE_HIGH: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkHighs, + 0, + index, + count // + ); + break; + + // + case X_PRICE_OPEN: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkOpens, + 0, + index, + count // + ); + break; + + // + case X_PRICE_CLOSE: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkCloses, + 0, + index, + count // + ); + break; + + // + case X_PRICE_LOW: + // + ArrayCopy( + tmpArray, + conditions.xmanInfo.smhkLows, + 0, + index, + count // + ); + break; + } + + // + idx = ArrayMinimum(tmpArray); + if (idx < 0) + { + return result; + } + + // + result = tmpArray[idx]; + + // + return result; +} + +// +bool IsHKBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hkOpens[index] < conditions.xmanInfo.hkCloses[index] + // + ; + + // + return result; +} + +// +bool IsHKBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.hkOpens[index] > conditions.xmanInfo.hkCloses[index] + // + ; + + // + return result; +} + +// +bool IsSMHKBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.smhkOpens[index] < conditions.xmanInfo.smhkCloses[index] + // + ; + + // + return result; +} + +// +bool IsSMHKBullishAs( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5 // Count +) +{ + // + bool result = false; + + // + int verified = 0; + for (int i = index; i < index + count; i++) + { + // + bool isTrue = IsSMHKBullish(conditions, i); + if (isTrue) + { + verified++; + } + } + + // + result = verified >= count; + + // + return result; +} + +// +bool IsSMHKChangedIn( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int length = 5 // Length +) +{ + // + bool result = false; + + // + bool isCurrentBullish = IsSMHKBullish(conditions, index); + + // + int numberOfChanges = 0; + bool isLastBullish = isCurrentBullish; + for (int i = index + 1; i < index + length; i++) + { + // + bool isBullish = IsSMHKBullish(conditions, i); + bool isBearish = IsSMHKBearish(conditions, i); + + // + if ((isBullish && isLastBullish) || (!isBullish && !isLastBullish)) + { + continue; + } + else if ((isBullish && !isLastBullish) || (isBearish && isLastBullish)) + { + numberOfChanges++; + } + } + + // + result = numberOfChanges > 0; + + // + return result; +} + +// +bool IsSMHKBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + conditions.xmanInfo.smhkOpens[index] > conditions.xmanInfo.smhkCloses[index] + // + ; + + // + return result; +} + +// +bool IsSMHKBearishAs( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0, // Array Index + int count = 5 // Count +) +{ + // + bool result = false; + + // + int verified = 0; + for (int i = index; i < index + count; i++) + { + // + bool isTrue = IsSMHKBearish(conditions, i); + if (isTrue) + { + verified++; + } + } + + // + result = verified >= count; + + // + return result; +} + +// +// END Functions ... +// + +// +// START Combination .... +// + +// +bool IsMarketBullish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullBullish(conditions, index) && + IsSSLCBullish(conditions, index) && + IsTrendBullish(conditions, index) && + IsRibbonBullish(conditions, index) + // + ; + + // + return result; +} + +// +bool IsMarketBearish( + const X121MarketConditions &conditions, // Specified Conditions + int index = 0 // Array Index +) +{ + // + bool result = false; + + // + result = + // + IsHullBearish(conditions, index) && + IsSSLCBearish(conditions, index) && + IsTrendBearish(conditions, index) && + IsRibbonBearish(conditions, index) + // + ; + + // + return result; +} + +// +// END Combination .... +// + +// +// START EQM Supports ... +// + +// +int GenerateFiboEQMSupports( + const X121MarketConditions &conditions, // Specified Conditions + const XPosition &inDPosition, // Supported Position + XSignal &supports[], // Holds Support Signals + const double volume, // Supported Volume + const bool placeSL = false, // Place SL for Supports + const bool placeTP = false // Place TP for Supports +) +{ + // + int result = 0; + + // + int beforeSize = ArraySize(supports); + + // + // + double fib1 = conditions.xmanInfo.fibLevel1s[0]; + double fib2 = conditions.xmanInfo.fibLevel2s[0]; + double fib3 = conditions.xmanInfo.fibLevel3s[0]; + double fib4 = conditions.xmanInfo.fibLevel4s[0]; + double fib5 = conditions.xmanInfo.fibLevel5s[0]; + + // + double peak = conditions.xmanInfo.peaks[0]; + double vale = conditions.xmanInfo.vales[0]; + + // + // Here we have multiple Senarios for Supporting ... + + // + // Support Using Peaks and Vales ... + // in this Senario we Place Two Order on Peaks and Vales ... + + // + bool isInDLong = + IsLong(inDPosition.type); + bool isLongSupport = !isInDLong; + ENUM_POSITION_TYPE type = + isLongSupport + ? POSITION_TYPE_BUY + : POSITION_TYPE_SELL; + + // + double entry = GetEntry(conditions.symbol, type); + + // + ENUM_TIMEFRAMES period = conditions.period; + + // + bool isPriceOverFib1 = entry > fib1; + bool isPriceOverFib2 = entry > fib2; + bool isPriceOverFib3 = entry > fib3; + bool isPriceOverFib4 = entry > fib4; + bool isPriceOverFib5 = entry > fib5; + + // + bool isPriceUnderFib1 = entry < fib1; + bool isPriceUnderFib2 = entry < fib2; + bool isPriceUnderFib3 = entry < fib3; + bool isPriceUnderFib4 = entry < fib4; + bool isPriceUnderFib5 = entry < fib5; + + // + if (isLongSupport) + { + // + if (isPriceUnderFib5) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? vale : 0; + signal.entry = fib5; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + // Since Price is Under Fib 5 + // this so Important to Handle also Vale Breakouts ... + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = vale; + signal.tp = placeTP ? 0 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceUnderFib4) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceUnderFib3) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceUnderFib2) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceUnderFib1) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + } + else + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.volume = volume; + signal.period = period; + signal.symbol = conditions.symbol; + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? peak : 0; + signal.entry = fib1; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + } + } + else + { + // + if (isPriceOverFib1) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? peak : 0; + signal.entry = fib1; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + // Since Price is Over Fib 1 + // this so Important to Handle also Peak Breakouts ... + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = peak; + signal.tp = placeTP ? 0 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceOverFib2) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + // In Direction Positions ... + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib1 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceOverFib3) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceOverFib4) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib5 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + } + else if (isPriceOverFib5) + { + // + // Price between Fib 1 and Peak ... + XSignal signal; + Clean(signal); + + // + signal.type = type; + signal.volume = volume; + signal.period = period; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = conditions.symbol; + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib5; + signal.tp = placeTP ? vale : 0; + + // + Add( + signal, + supports // + ); + + // + // Diection Positions ... + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + } + else + { + // + // Diection Positions ... + XSignal signal; + Clean(signal); + + // + signal.volume = volume; + signal.period = period; + signal.symbol = conditions.symbol; + + // + signal.mode = X_ORDER_MODE_STOP; + signal.type = inDPosition.type; + + // + signal.sl = placeSL ? fib2 : 0; + signal.entry = fib1; + signal.tp = placeTP ? peak : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib3 : 0; + signal.entry = fib2; + signal.tp = placeTP ? fib1 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib4 : 0; + signal.entry = fib3; + signal.tp = placeTP ? fib2 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? fib5 : 0; + signal.entry = fib4; + signal.tp = placeTP ? fib3 : 0; + + // + Add( + signal, + supports // + ); + + // + signal.sl = placeSL ? vale : 0; + signal.entry = fib5; + signal.tp = placeTP ? fib4 : 0; + + // + Add( + signal, + supports // + ); + } + } + + // + result = ArraySize(supports) - beforeSize; + + // + return result; +} + +// +int GenerateTrendBaseEQMSupports( + const X121MarketConditions &conditions, // Specified Conditions + const XPosition &inDPosition, // Supported Position + XSignal &supports[], // Holds Support Signals + const double volume, // Supported Volume + const bool placeSL = false, // Place SL for Supports + const bool placeTP = false // Place TP for Supports +) +{ + // + int result = 0; + + // + int beforeSize = ArraySize(supports); + + // + result = ArraySize(supports) - beforeSize; + + // + return result; +} + +// +int GenerateSupportAndResistanceEQMSupports( + const X121MarketConditions &conditions, // Specified Conditions + const XPosition &inDPosition, // Supported Position + const XOHCLSupRes &supRes, // Provided Supports and Resistances + XSignal &supports[], // Holds Support Signals + const double volume, // Supported Volume + const bool placeSL = false, // Place SL for Supports + const bool placeTP = false // Place TP for Supports +) +{ + // + int result = 0; + + // + int beforeSize = ArraySize(supports); + + // + double peak = conditions.xmanInfo.peaks[0]; + double vale = conditions.xmanInfo.vales[0]; + + // + bool isInDLong = + IsLong(inDPosition.type); + bool isLongSupport = !isInDLong; + ENUM_POSITION_TYPE type = + isLongSupport + ? POSITION_TYPE_BUY + : POSITION_TYPE_SELL; + + // + double entry = GetEntry(conditions.symbol, type); + + // + ENUM_TIMEFRAMES period = conditions.period; + + // + XSignal signal; + Clean(signal); + + // + signal.volume = volume; + signal.mode = X_ORDER_MODE_STOP; + signal.symbol = inDPosition.symbol; + signal.period = inDPosition.period; + + // + // find a Support nearest to Entry ... + double entryNearestSupport = FindLesserThanValue( + entry - conditions.momentumStep, + supRes.sup); + if (entryNearestSupport > 0 && entryNearestSupport < entry) + { + // + // BUY ... + signal.type = POSITION_TYPE_BUY; + signal.mode = X_ORDER_MODE_LIMIT; + + // + signal.entry = entryNearestSupport; + + // + signal.sl = placeSL + ? supRes.sup[ArraySize(supRes.sup) - 1] + : 0; + + // + signal.tp = placeTP + ? supRes.res[ArraySize(supRes.res) - 1] + : 0; + + // + Add( + signal, + supports // + ); + + // + // SELL ... + signal.type = POSITION_TYPE_SELL; + signal.mode = X_ORDER_MODE_STOP; + + // + signal.entry = entryNearestSupport; + + // + signal.sl = placeSL + ? supRes.res[ArraySize(supRes.res) - 1] + : 0; + + // + signal.tp = placeTP + ? supRes.sup[ArraySize(supRes.sup) - 1] + : 0; + + // + Add( + signal, + supports // + ); + } + + // + // find a Resistance nearest to Entry ... + double entryNearestResistance = FindBiggerThanValue( + entry + conditions.momentumStep, + supRes.res); + if (entryNearestResistance > 0 && entryNearestResistance > entry) + { + // + // BUY ... + signal.type = POSITION_TYPE_BUY; + signal.mode = X_ORDER_MODE_STOP; + + // + signal.entry = entryNearestResistance; + + // + signal.sl = placeSL + ? supRes.sup[ArraySize(supRes.sup) - 1] + : 0; + + // + signal.tp = placeTP + ? supRes.res[ArraySize(supRes.res) - 1] + : 0; + + // + Add( + signal, + supports // + ); + + // + // SELL ... + signal.type = POSITION_TYPE_SELL; + signal.mode = X_ORDER_MODE_LIMIT; + + // + signal.entry = entryNearestResistance; + + // + signal.sl = placeSL + ? supRes.res[ArraySize(supRes.res) - 1] + : 0; + + // + signal.tp = placeTP + ? supRes.sup[ArraySize(supRes.sup) - 1] + : 0; + + // + Add( + signal, + supports // + ); + } + + // + // Add Peaks and Vales Support and Resistance ... + signal.sl = placeSL ? vale : 0; + signal.entry = peak; + signal.tp = placeTP ? 0 : 0; + + // + result = ArraySize(supports) - beforeSize; + + // + return result; +} +// END EQM Supports ... +// + +// +// Generate a Collection Of Fib Signals ... +int GenerateSeqentialSignals( + XSignal &signals[], // Hold Result ... + double &pivots[], // Required Values For Generate Signals ... + string symbol, // Trading Symbol ... + ENUM_TIMEFRAMES period, // Trading Time Frame ... + double price, // Current Price Execution ... + double volume, // Volume ... + bool placeSL = false, // Place SL for Signals ... + bool placeTP = false, // Place TP for Signals ... + double staticTP = 0, // Static TP ... + bool staticTPAsPoint = false, // Detect Static TP as Point ... + double staticSL = 0, // Static SL ... + bool staticSLAsPoint = false, // Detect Static SL as Point ... + bool longSupport = true, // Generate Long Support Signals ... + bool shortSupport = true, // Generate Short Support Signals ... + bool forceCleanSignalsArray = false // Clean Result Array ... +) +{ + // + int result = 0; + + // + if (forceCleanSignalsArray) + { + Clean(signals); + } + int beforeSize = ArraySize(signals); + + // + // Validate Input States ... + int pivotsCount = ArraySize(pivots); + if ( + // + price <= 0 || + volume <= 0 || + pivotsCount <= 0 + // + ) + { + return result; + } + + // + if (pivotsCount == 1) + { + // + bool isValidSL = + !placeSL + ? true + : staticSL > 0 + ? true + : false; + + // + bool isValidTP = + !placeTP + ? true + : staticTP > 0 + ? true + : false; + + // + if (!isValidTP && !isValidSL) + { + return result; + } + } + else if ((placeSL || placeTP) && pivotsCount < 3) + { + return result; + } + + // + if (!longSupport && !shortSupport) + { + return result; + } + + // + double slValue = !placeSL + ? 0 + : staticSLAsPoint + ? PointToPrice( + symbol, + staticSL) + : staticSL + // + ; + + // + double tpValue = !placeTP + ? 0 + : staticTPAsPoint + ? PointToPrice( + symbol, + staticTP) + : staticTP + // + ; + + // + // Do Signal Generation ... + ArraySort(pivots); + for (int i = 0; i < pivotsCount; i++) + { + // + if ((((placeSL && slValue <= 0) && + (placeTP && slValue <= 0)) && + (i == 0 || i == pivotsCount - 1))) + { + continue; + } + + // + double iPivot = pivots[i]; + + // + bool isPriceOverPivot = price > iPivot; + bool isPriceUnderPivot = price < iPivot; + if (!isPriceOverPivot && !isPriceUnderPivot) + { + continue; + } + + // + if (isPriceOverPivot && shortSupport) + { + // + // Generate Short STOP Signal ... + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_STOP; + ENUM_POSITION_TYPE type = POSITION_TYPE_SELL; + + // + double tp = placeTP + ? tpValue > 0 + ? tpValue + : pivots[i - 1] + : 0 + // + ; + + // + double sl = placeSL + ? slValue > 0 + ? slValue + : pivots[i + 1] + : 0 + // + ; + + // + XSignal signal = CreateSignal( + symbol, + period, + type, + mode, + iPivot, // Entry ... + volume, + tp, + sl); + + // + Add( + signal, + signals // + ); + } + + // + if (isPriceOverPivot && longSupport) + { + // + // Generate Long LIMIT Signal ... + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_LIMIT; + ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; + + // + double tp = placeTP + ? tpValue > 0 + ? tpValue + : pivots[i + 1] + : 0 + // + ; + + // + double sl = placeSL + ? slValue > 0 + ? slValue + : pivots[i - 1] + : 0 + // + ; + + // + XSignal signal = CreateSignal( + symbol, + period, + type, + mode, + iPivot, // Entry ... + volume, + tp, + sl); + + // + Add( + signal, + signals // + ); + } + + // + if (isPriceUnderPivot && shortSupport) + { + // + // Generate Short LIMIT Signal ... + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_LIMIT; + ENUM_POSITION_TYPE type = POSITION_TYPE_SELL; + + // + double tp = placeTP + ? tpValue > 0 + ? tpValue + : pivots[i - 1] + : 0 + // + ; + + // + double sl = placeSL + ? slValue > 0 + ? slValue + : pivots[i + 1] + : 0 + // + ; + + // + XSignal signal = CreateSignal( + symbol, + period, + type, + mode, + iPivot, // Entry ... + volume, + tp, + sl); + + // + Add( + signal, + signals // + ); + } + + // + if (isPriceUnderPivot && longSupport) + { + // + // Generate Long STOP Signal ... + ENUM_X_ORDER_MODES mode = X_ORDER_MODE_STOP; + ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; + + // + double tp = placeTP + ? tpValue > 0 + ? tpValue + : pivots[i - 1] + : 0 + // + ; + + // + double sl = placeSL + ? slValue > 0 + ? slValue + : pivots[i + 1] + : 0 + // + ; + + // + XSignal signal = CreateSignal( + symbol, + period, + type, + mode, + iPivot, // Entry ... + volume, + tp, + sl); + + // + Add( + signal, + signals // + ); + } + } + + // + int afterSize = ArraySize(signals); + result = afterSize - beforeSize; + + // + return result; +} + +// +for (int i = 1; i < pivotsCount - 1; i++) +{ + // + double iPivot = pivots[i]; + + // + bool isPriceOverPivot = price > iPivot; + bool isPriceUnderPivot = price < iPivot; + if (!isPriceOverPivot && !isPriceUnderPivot) + { + continue; + } + + // + if (isPriceUnderPivot) + { + // + if (longSupport) + { + // + tp = pivots[i - 1]; + entry = pivots[i]; + sl = pivots[i + 1]; + + // + // Normalize SL ... + if (slValue > 0) + { + sl = slValue; + } + if (!placeSL) + { + sl = 0; + } + + // + // Normalize TP ... + if (tpValue > 0) + { + tp = tpValue; + } + if (!placeTP) + { + tp = 0; + } + + // + mode = X_ORDER_MODE_STOP; + type = POSITION_TYPE_BUY; + + // + XSignal signal = CreateSignal( + symbol, + period, + type, + mode, + entry, + volume, + tp, + sl); + + // + Add( + signal, + signals); + } + + // + if (shortSupport) + { + // // + // sl = pivots[i + 1]; + // entry = pivots[i]; + // tp = pivots[i - 1]; + + // // + // // Normalize SL ... + // if (slValue > 0) + // { + // sl = slValue; + // } + // if (!placeSL) + // { + // sl = 0; + // } + + // // + // // Normalize TP ... + // if (tpValue > 0) + // { + // tp = tpValue; + // } + // if (!placeTP) + // { + // tp = 0; + // } + + // // + // type = POSITION_TYPE_SELL; + // mode = X_ORDER_MODE_LIMIT; + + // // + // XSignal signal = CreateSignal( + // symbol, + // period, + // type, + // mode, + // entry, + // volume, + // tp, + // sl); + + // // + // Add( + // signal, + // signals); + } + } + + // + if (isPriceOverPivot) + { + // + if (longSupport) + { + // // + // tp = pivots[i + 1]; + // entry = pivots[i]; + // sl = pivots[i - 1]; + + // // + // // Normalize SL ... + // if (slValue > 0) + // { + // sl = slValue; + // } + // if (!placeSL) + // { + // sl = 0; + // } + + // // + // // Normalize TP ... + // if (tpValue > 0) + // { + // tp = tpValue; + // } + // if (!placeTP) + // { + // tp = 0; + // } + + // // + // type = POSITION_TYPE_BUY; + // mode = X_ORDER_MODE_LIMIT; + + // // + // XSignal signal = CreateSignal( + // symbol, + // period, + // type, + // mode, + // entry, + // volume, + // tp, + // sl); + + // // + // Add( + // signal, + // signals); + } + + // + if (shortSupport) + { + // // + // tp = pivots[i - 1]; + // entry = pivots[i]; + // sl = pivots[i + 1]; + + // // + // // Normalize SL ... + // if (slValue > 0) + // { + // sl = slValue; + // } + // if (!placeSL) + // { + // sl = 0; + // } + + // // + // // Normalize TP ... + // if (tpValue > 0) + // { + // tp = tpValue; + // } + // if (!placeTP) + // { + // tp = 0; + // } + + // // + // type = POSITION_TYPE_SELL; + // mode = X_ORDER_MODE_STOP; + + // // + // XSignal signal = CreateSignal( + // symbol, + // period, + // type, + // mode, + // entry, + // volume, + // tp, + // sl); + + // // + // Add( + // signal, + // signals); + } + } +}