// int minRequiredRange = 20; if (barIndex > maxBarIndex - minRequiredRange - 4) { return; } // double iP2SCLL = sLLBuffer[barIndex + 2]; double iP2SCHH = sHHBuffer[barIndex + 2]; // double iP3SCLL = sLLBuffer[barIndex + 3]; double iP3SCHH = sHHBuffer[barIndex + 3]; // double iP4SCLL = sLLBuffer[barIndex + 4]; double iP4SCHH = sHHBuffer[barIndex + 4]; // double iP2MCLL = mLLBuffer[barIndex + 2]; double iP2MCHH = mHHBuffer[barIndex + 2]; // double iP3MCLL = mLLBuffer[barIndex + 3]; double iP3MCHH = mHHBuffer[barIndex + 3]; // double iP4MCLL = mLLBuffer[barIndex + 4]; double iP4MCHH = mHHBuffer[barIndex + 4]; // double iP2LCLL = lLLBuffer[barIndex + 2]; double iP2LCHH = lHHBuffer[barIndex + 2]; // double iP3LCLL = lLLBuffer[barIndex + 3]; double iP3LCHH = lHHBuffer[barIndex + 3]; // double iP4LCLL = lLLBuffer[barIndex + 4]; double iP4LCHH = lHHBuffer[barIndex + 4]; // double iP2HCLL = hLLBuffer[barIndex + 2]; double iP2HCHH = hHHBuffer[barIndex + 2]; // double iP3HCLL = hLLBuffer[barIndex + 3]; double iP3HCHH = hHHBuffer[barIndex + 3]; // double iP4HCLL = hLLBuffer[barIndex + 4]; double iP4HCHH = hHHBuffer[barIndex + 4]; // // Cycle States ... // // Create Conditions ... // bool isSCMaOverMCMa = iSCMa > iMCMa; bool isPSCMaOverMCMa = iPSCMa > iPMCMa; // bool isSCMaUnderMCMa = iSCMa < iMCMa; bool isPSCMaUnderMCMa = iPSCMa < iPMCMa; // bool isSCMaCrossedOverMCMa = isSCMaOverMCMa && !isPSCMaOverMCMa; // bool isSCMaCrossedUnderMCMa = isSCMaUnderMCMa && !isPSCMaUnderMCMa; // bool isLCMaOverHCMa = iLCMa > iHCMa; bool isPLCMaOverHCMa = iPLCMa > iPHCMa; // bool isLCMaUnderHCMa = iLCMa < iHCMa; bool isPLCMaUnderHCMa = iPLCMa < iPHCMa; // bool isLCMaCrossedOverHCMa = isLCMaOverHCMa && !isPLCMaOverHCMa; // bool isLCMaCrossedUnderHCMa = isLCMaUnderHCMa && !isPLCMaUnderHCMa; // // SC State ... // bool isSCMaBullish = iSCMaState == bullishState; bool isPSCMaBullish = iPSCMaState == bullishState; // bool isSCMaBearish = iSCMaState == bearishState; bool isPSCMaBearish = iPSCMaState == bearishState; // bool isSCMaSwitchedToBullish = isSCMaBullish && !isPSCMaBullish; // bool isSCMaSwitchedToBearish = isSCMaBearish && !isPSCMaBearish; // bool isSCLLOverMCLL = iSCLL > iMCLL; bool isPSCLLOverMCLL = iPSCLL > iPMCLL; bool isP2SCLLOverMCLL = iP2SCLL > iP2MCLL; bool isP3SCLLOverMCLL = iP3SCLL > iP3MCLL; bool isP4SCLLOverMCLL = iP4SCLL > iP4MCLL; // bool isSCHHUnderMCHH = iSCHH < iMCHH; bool isPSCHHUnderMCHH = iPSCHH < iPMCHH; bool isP2SCHHUnderMCHH = iP2SCHH < iP2MCHH; bool isP3SCHHUnderMCHH = iP3SCHH < iP3MCHH; bool isP4SCHHUnderMCHH = iP4SCHH < iP4MCHH; // bool isSCLLCrossedOverMCLL = isSCLLOverMCLL && !isPSCLLOverMCLL; bool isPSCLLCrossedOverMCLL = isPSCLLOverMCLL && !isP2SCLLOverMCLL; bool isP2SCLLCrossedOverMCLL = isP2SCLLOverMCLL && !isP3SCLLOverMCLL; bool isP3SCLLCrossedOverMCLL = isP3SCLLOverMCLL && !isP4SCLLOverMCLL; // bool isSCHHCrossedUnderMCHH = isSCHHUnderMCHH && !isPSCHHUnderMCHH; bool isPSCHHCrossedUnderMCHH = isPSCHHUnderMCHH && !isP2SCHHUnderMCHH; bool isP2SCHHCrossedUnderMCHH = isP2SCHHUnderMCHH && !isP3SCHHUnderMCHH; bool isP3SCHHCrossedUnderMCHH = isP3SCHHUnderMCHH && !isP4SCHHUnderMCHH; // // MC State ... // bool isMCMaBullish = iMCMaState == bullishState; bool isPMCMaBullish = iPMCMaState == bullishState; // bool isMCMaBearish = iMCMaState == bearishState; bool isPMCMaBearish = iPMCMaState == bearishState; // bool isMCMaSwitchedToBullish = isMCMaBullish && !isPMCMaBullish; // bool isMCMaSwitchedToBearish = isMCMaBearish && !isPMCMaBearish; // bool isMCLLOverLCLL = iMCLL > iLCLL; bool isPMCLLOverLCLL = iPMCLL > iPLCLL; bool isP2MCLLOverLCLL = iP2MCLL > iP2LCLL; bool isP3MCLLOverLCLL = iP3MCLL > iP3LCLL; bool isP4MCLLOverLCLL = iP4MCLL > iP4LCLL; // bool isMCHHUnderLCHH = iMCHH < iLCHH; bool isPMCHHUnderLCHH = iPMCHH < iPLCHH; bool isP2MCHHUnderLCHH = iP2MCHH < iP2LCHH; bool isP3MCHHUnderLCHH = iP3MCHH < iP3LCHH; bool isP4MCHHUnderLCHH = iP4MCHH < iP4LCHH; // bool isMCLLCrossedOverLCLL = isMCLLOverLCLL && !isPMCLLOverLCLL; bool isPMCLLCrossedOverLCLL = isPMCLLOverLCLL && !isP2MCLLOverLCLL; bool isP2MCLLCrossedOverLCLL = isP2MCLLOverLCLL && !isP3MCLLOverLCLL; bool isP3MCLLCrossedOverLCLL = isP3MCLLOverLCLL && !isP4MCLLOverLCLL; // bool isMCHHCrossedUnderLCHH = isMCHHUnderLCHH && !isPMCHHUnderLCHH; bool isPMCHHCrossedUnderLCHH = isPMCHHUnderLCHH && !isP2MCHHUnderLCHH; bool isP2MCHHCrossedUnderLCHH = isP2MCHHUnderLCHH && !isP3MCHHUnderLCHH; bool isP3MCHHCrossedUnderLCHH = isP3MCHHUnderLCHH && !isP4MCHHUnderLCHH; // // LC State ... // bool isLCMaBullish = iLCMaState == bullishState; bool isPLCMaBullish = iPLCMaState == bullishState; // bool isLCMaBearish = iLCMaState == bearishState; bool isPLCMaBearish = iPLCMaState == bearishState; // bool isLCMaSwitchedToBullish = isLCMaBullish && !isPLCMaBullish; // bool isLCMaSwitchedToBearish = isLCMaBearish && !isPLCMaBearish; // bool isLCLLOverHCLL = iLCLL > iHCLL; bool isPLCLLOverHCLL = iPLCLL > iPHCLL; bool isP2LCLLOverHCLL = iP2LCLL > iP2HCLL; bool isP3LCLLOverHCLL = iP3LCLL > iP3HCLL; bool isP4LCLLOverHCLL = iP4LCLL > iP4HCLL; // bool isLCHHUnderHCHH = iLCHH < iHCHH; bool isPLCHHUnderHCHH = iPLCHH < iPHCHH; bool isP2LCHHUnderHCHH = iP2LCHH < iP2HCHH; bool isP3LCHHUnderHCHH = iP3LCHH < iP3HCHH; bool isP4LCHHUnderHCHH = iP4LCHH < iP4HCHH; // bool isLCLLCrossedOverHCLL = isLCLLOverHCLL && !isPLCLLOverHCLL; bool isPLCLLCrossedOverHCLL = isPLCLLOverHCLL && !isP2LCLLOverHCLL; bool isP2LCLLCrossedOverHCLL = isP2LCLLOverHCLL && !isP3LCLLOverHCLL; bool isP3LCLLCrossedOverHCLL = isP3LCLLOverHCLL && !isP4LCLLOverHCLL; // bool isLCHHCrossedUnderHCHH = isLCHHUnderHCHH && !isPLCHHUnderHCHH; bool isPLCHHCrossedUnderHCHH = isPLCHHUnderHCHH && !isP2LCHHUnderHCHH; bool isP2LCHHCrossedUnderHCHH = isP2LCHHUnderHCHH && !isP3LCHHUnderHCHH; bool isP3LCHHCrossedUnderHCHH = isP3LCHHUnderHCHH && !isP4LCHHUnderHCHH; // // HC State ... // bool isHCMaBullish = iHCMaState == bullishState; bool isPHCMaBullish = iPHCMaState == bullishState; // bool isHCMaBearish = iHCMaState == bearishState; bool isPHCMaBearish = iPHCMaState == bearishState; // bool isHCMaSwitchedToBullish = isHCMaBullish && !isPHCMaBullish; // bool isHCMaSwitchedToBearish = isHCMaBearish && !isPHCMaBearish; /////////////////////////////////////////////////////////////////////////////// // // HK Signal Bar ... // double iHKSOpen = hkSBarOpenBuffer[barIndex]; double iHKSClose = hkSBarCloseBuffer[barIndex]; // double iHKSMax = MathMax(iHKSOpen, iHKSClose); double iHKSMin = MathMin(iHKSOpen, iHKSClose); // bool isHKSBullish = hkSBarOpenBuffer[barIndex] < hkSBarCloseBuffer[barIndex]; bool isPHKSBullish = hkSBarOpenBuffer[barIndex + 1] < hkSBarCloseBuffer[barIndex + 1]; // bool isHKSBearish = hkSBarOpenBuffer[barIndex] > hkSBarCloseBuffer[barIndex]; bool isPHKSBearish = hkSBarOpenBuffer[barIndex + 1] > hkSBarCloseBuffer[barIndex + 1]; // bool isHKSSwitchedToBullish = isHKSBullish && !isPHKSBullish; // bool isHKSSwitchedToBearish = isHKSBearish && !isPHKSBearish; // // TREND ... // double iTrend = trendBuffer[barIndex]; bool isTrendBullish = trendStateBuffer[barIndex] > 0; bool isTrendBearish = trendStateBuffer[barIndex] < 0; bool isTrendSwitchedToBullish = trendStateBuffer[barIndex] > 0 && trendStateBuffer[barIndex + 1] <= 0; bool isTrendSwitchedToBearish = trendStateBuffer[barIndex] < 0 && trendStateBuffer[barIndex + 1] >= 0; // // RSI ... // bool isRSIOverOB = rsiBuffer[barIndex] > rsiOBLevel; bool isPRSIOverOB = rsiBuffer[barIndex + 1] > rsiOBLevel; // bool isRSIUnderOB = rsiBuffer[barIndex] < rsiOBLevel; bool isPRSIUnderOB = rsiBuffer[barIndex + 1] < rsiOBLevel; // bool isRSICrossedOverOB = isRSIOverOB && !isPRSIOverOB; // bool isRSICrossedUnderOB = isRSIUnderOB && !isPRSIUnderOB; // bool isRSIOverOS = rsiBuffer[barIndex] > rsiOSLevel; bool isPRSIOverOS = rsiBuffer[barIndex + 1] > rsiOSLevel; // bool isRSIUnderOS = rsiBuffer[barIndex] < rsiOSLevel; bool isPRSIUnderOS = rsiBuffer[barIndex + 1] < rsiOSLevel; // bool isRSICrossedOverOS = isRSIOverOS && !isPRSIOverOS; // bool isRSICrossedUnderOS = isRSIUnderOS && !isPRSIUnderOS; // // ADX ... // bool isADXOverThreshold = adxBuffer[barIndex] > adxThreshold; bool isPADXOverThreshold = adxBuffer[barIndex + 1] > adxThreshold; // bool isADXUnderThreshold = adxBuffer[barIndex] < adxThreshold; bool isPADXUnderThreshold = adxBuffer[barIndex + 1] < adxThreshold; // bool isADXCrossedOverThreshold = isADXOverThreshold && !isPADXOverThreshold; // bool isADXCrossedUnderThreshold = isADXUnderThreshold && !isPADXUnderThreshold; // bool isADXBullish = adxpBuffer[barIndex] > adxnBuffer[barIndex]; bool isPADXBullish = adxpBuffer[barIndex + 1] > adxnBuffer[barIndex + 1]; // bool isADXBearish = adxpBuffer[barIndex] < adxnBuffer[barIndex]; bool isPADXBearish = adxpBuffer[barIndex + 1] < adxnBuffer[barIndex + 1]; // bool isADXSwitchedToBullish = isADXBullish && !isPADXBullish; // bool isADXSwitchedToBearish = isADXBearish && !isPADXBearish; // bool isADXFullySwitchedToBullish = isADXSwitchedToBullish && isADXCrossedOverThreshold; // bool isADXFullySwitchedToBearish = isADXSwitchedToBearish && isADXCrossedUnderThreshold; // bool isTriggerBarOverHKS = iBar.low > iHKSMax; bool isTriggerBarUnderHKS = iBar.high < iHKSMin; // // KI ... // bool isKIBullish = kiStateBuffer[barIndex] > 0; bool isPKIBullish = kiStateBuffer[barIndex + 1] > 0; // bool isKIBearish = kiStateBuffer[barIndex] < 0; bool isPKIBearish = kiStateBuffer[barIndex = 1] < 0; // // // bool isKIOverHKS = // kiBuffer[barIndex] > iHKSMax; // // // bool isKIUnderHKS = // kiBuffer[barIndex] < iHKSMin; // bool isKISwitchedToBullish = isKIBullish && !isPKIBullish; // bool isKISwitchedToBearish = isKIBearish && !isPKIBearish; // // Detecting Signal ... // // Bullish ... isBullish = // false // Conditions Validation ... // isKIOverHKS && // isHKSBullish && // isKISwitchedToBullish // && // // Bar Validation ... // iBar.IsBullish() && // iBar.close > kiBuffer[barIndex] // ; // // Bearish ... isBearish = // false // Conditions Validation ... // isKIUnderHKS && // isHKSBearish && // isKISwitchedToBearish // && // // Bar Validation ... // iBar.IsBearish() && // iBar.close < kiBuffer[barIndex] // ;