// // Testing Bar Zones ... // XBoxZone barZones[]; // int barCounts = fima2Signaller.fimaHelper.ExtractBarZones( // barZones, // 1, // Bar Index ... // 50, // Number of Zones ... // 3, // Break Validation Length ... // true, // Validate Fake Breakes ... // 5, // Shadow Multiplier ... // 1, // Strength ... // 14 // Validation Length ... // ); // if (IsValidSize(barCounts)) // { // // // // XCBoxObject *iObj; // // for (int i = 0; i < barCounts; i++) // // { // // // // // iObj = NULL; // // bool isCreated = fima2Signaller.poiDrawer.DrawBox( // // barZones[i], // // iObj, // // true, // Ignore At ... // // barZones[i].type // Name ... // // ); // // // // // ZeroMemory(iObj); // // } // // // // // Print("Bar Zones Detected ..."); // } // // Testing HK Zones ... // XBoxZone hkZones[]; // int hkCounts = fima2Signaller.fimaHelper.ExtractHKZones( // hkZones, // 1, // Bar Index ... // 50, // Number of Zones ... // 5, // Shadow Multiplier ... // 1, // Strength ... // 14 // Validation Length ... // ); // if (IsValidSize(hkCounts)) // { // // // // // XCBoxObject *iObj; // // for (int i = 0; i < hkCounts; i++) // // { // // // // // iObj = NULL; // // bool isCreated = fima2Signaller.poiDrawer.DrawBox( // // hkZones[i], // // iObj, // // true, // Ignore At ... // // hkZones[i].type // Name ... // // ); // // // // // ZeroMemory(iObj); // // } // // // // // Print("HK Zones Detected ..."); // } // // Testing XFIMA MA Pivots ... // XPivot maPivots[]; // int maPivotsCount = fimaHelper.ExtractMAPivots( // maPivots, // 1, // Bar Index ... // 50, // Number of Pivots ... // 1 // Validation Diff ... // ); // if (IsValidSize(maPivotsCount)) // { // // // // CArrayObj *iPivotsObj; // // maPivotsCount = poiDrawer.DrawPivots( // // maPivots, // // iPivotsObj // // // ); // // // // Print("MA Pivots Detected ..."); // } // // Custom Indicator Direction Shifts ... bool hasMACross = HasDirection(structure.maCrossDir); bool hasHKSwitch = HasDirection(structure.hkSwitchDir); bool hasSARSwitch = HasDirection(structure.sarSwitchDir); // // Check Required Pattern Exists ... bool hasPinnedBar = HasDirection(structure.pinnedDir); bool hasEngulfedBar = HasDirection(structure.engulfedDir); bool hasFlagPattern = HasDirection(structure.flagPatternDir); bool hasStarPattern = HasDirection(structure.starPatternDir); bool hasRisingPattern = HasDirection(structure.risingPatternDir); bool hasPiercingPattern = HasDirection(structure.piercingPatternDir); bool hasSignalKeyBar = HasDirection(structure.signalKeyBarPatternDir); // // Check Bar Pattern Exists ... // and Select Pattern Direction and Price and Price Type ... has = hasPinnedBar || hasEngulfedBar || hasFlagPattern || hasStarPattern || hasSignalKeyBar || hasRisingPattern || hasPiercingPattern; if (has) { // if (hasPinnedBar) { // iDir = structure.pinnedDir; iName = "XPinned_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasEngulfedBar) { // iDir = structure.engulfedDir; iName = "XEngulfed_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasFlagPattern) { // iDir = structure.flagPatternDir; iName = "XFlag_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasStarPattern) { // iDir = structure.starPatternDir; iName = "XStar_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasSignalKeyBar) { // iDir = structure.risingPatternDir; iName = "XRising_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasRisingPattern) { // iDir = structure.piercingPatternDir; iName = "XPiercing_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } else if (hasPiercingPattern) { // iDir = structure.signalKeyBarPatternDir; iName = "XSignalKey_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); } // isBullish = IsSpecifiedBullish(iDir); isBearish = IsSpecifiedBearish(iDir); // // Retrieve Price Type for Validate ... iPriceType = isBullish ? X_PRICE_DOWN : X_PRICE_UP; iPriceEdgeType = isBullish ? X_PRICE_LOW : X_PRICE_HIGH; // iPrice = bar.GetPrice(iPriceType); iPriceEdge = bar.GetPrice(iPriceEdgeType); // // Validate Calculations ... has = HasDirection(iDir) && (isBullish || isBearish) && NotEmptyZero(iPrice) && NotEmptyZero(iPriceEdge) && iPrice != iPriceEdge; if (!has) { // isBullish = false; isBearish = false; iDir = X_DIRECTION_NONE; } } // // Disable Signallers ... has = false; // Strategy 1 ... // Works on Support or Resistances Areas ... // has = Strategy1HasSignal( // bar, // iZone, // iName, // supports, // resistances, // iDir, // structure, // fimaConditions // // ); // // Do all Draws Here ... bool canDraw = false; if (canDraw && has) { // int iWidth = 2; XPOIStyle iStyle; XCBoxObject *iBoxObj = NULL; color iClr = isBullish ? clrYellow : clrDarkOrange; // // Supports ... has = HasChild(supports); if (has) { // count = ArraySize(supports); for (int i = 0; i < count; i++) { // has = poiDrawer.DrawBox( supports[i], iBoxObj, true, // Ignore At ... supports[i].type // Name ... ); if (has) { // poiDrawer.GetBoxStyle( iStyle, supports[i].dir // ); // poiDrawer.ApplyBoxStyle( iBoxObj, iStyle // ); } // iStyle.Clean(); ZeroMemory(iBoxObj); } } // // Resistances ... has = HasChild(resistances); if (has) { // count = ArraySize(resistances); for (int i = 0; i < count; i++) { // has = poiDrawer.DrawBox( resistances[i], iBoxObj, true, // Ignore At ... resistances[i].type // Name ... ); if (has) { // poiDrawer.GetBoxStyle( iStyle, resistances[i].dir // ); // poiDrawer.ApplyBoxStyle( iBoxObj, iStyle // ); } // iStyle.Clean(); ZeroMemory(iBoxObj); } } // // Selected Zone ... has = iZone.IsValid(); if (has) { // has = poiDrawer.DrawBox( iZone, iBoxObj, true, // Ignore At ... iZone.type // Name ... ); if (has) { // poiDrawer.GetBoxStyle( iStyle, iZone.dir // ); // iStyle.clr = iClr; iStyle.width = iWidth; // poiDrawer.ApplyBoxStyle( iBoxObj, iStyle // ); } } // // TrendLines ... // // Pivots ... // has = HasChild(pvPivots); if (has) { // CArrayObj *drawnPivots = new CArrayObj(); count = poiDrawer.DrawPivots( pvPivots, drawnPivots // ); } // has = HasChild(zgPivots); if (has) { // CArrayObj *drawnPivots = new CArrayObj(); count = poiDrawer.DrawPivots( zgPivots, drawnPivots // ); } // // Patterns Bar ... has = HasDirection(iDir); if (has) { // int iCode = 159; ENUM_ARROW_ANCHOR iAnchor = isBullish ? ANCHOR_TOP : ANCHOR_BOTTOM; // XCBarArrowObject *iPatternObj; has = poiDrawer.DrawBarArrow( bar, iPatternObj, iPriceEdgeType, iCode, iClr, iWidth, iAnchor, iName, true, // Ignore Bar Tag ... 10 // Threshold ... ); } } ///////////////////////////////////////////////// /** * Check Pattern Has Signal Based on Strategy 2 ... * * @param bar: XOHCL, reference to Pattern Bar ... * @param iZone: XBoxZone, reference to holds affected zone ... * @param patternName: string, detected pattern's name ... * @param supports: XBoxZone, array reference to Provide Exists Supports ... * @param resistances: XBoxZone, array reference to Provide Exists Resistances ... * @param patternDir: ENUM_X_DIRECTION, detected pattern's direction ... * @param fimaConditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ... * @param fimaMarketStructure: XFIMAMarketStructure, refrence to Provides Market Structure ... * * @return ( bool ) */ bool Strategy2HasSignal( XOHCL &bar, XBoxZone &iZone, string patternName, XBoxZone &supports[], XBoxZone &resistances[], ENUM_X_DIRECTION patternDir, XFIMAMarketStructure &structure, XFIMAConditions &fimaConditions, XFIMAMarketStructure &fimaMarketStructure // ) { // bool result = false; // // Prepare ... iZone.Clean(); // // Validate ... // // Do Detection ... // // Validate result ... // // Cleanup Resources ... // return result; } /** * Check Pattern Has Signal Based on Strategy 1 ... * * @param bar: XOHCL, reference to Pattern Bar ... * @param iZone: XBoxZone, reference to holds affected zone ... * @param supports: XBoxZone, array reference to Provide Exists Supports ... * @param resistances: XBoxZone, array reference to Provide Exists Resistances ... * @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ... * @param fimaConditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ... * * @return ( bool ) */ bool Strategy3HasSignal( XOHCL &bar, XBoxZone &iZone, XBoxZone &supports[], XBoxZone &resistances[], XFIMAMarketStructure &structure, XFIMAConditions &fimaConditions // ) { // bool result = false; // // Prepare ... iZone.Clean(); // // Validate ... result = bar.IsValid(); if (!result) { return result; } // // Reading XHK ... // // Bar 1 ... double cHKO = fimaConditions.hkOpenBuffer[0]; double cHKH = fimaConditions.hkHighBuffer[0]; double cHKL = fimaConditions.hkLowBuffer[0]; double cHKC = fimaConditions.hkCloseBuffer[0]; // // Bar 2 ... double pHKO = fimaConditions.hkOpenBuffer[1]; double pHKH = fimaConditions.hkHighBuffer[1]; double pHKL = fimaConditions.hkLowBuffer[1]; double pHKC = fimaConditions.hkCloseBuffer[1]; // bool isCHKBullish = cHKO < cHKC; bool isCHKBearish = cHKO > cHKC; // bool isPHKBullish = pHKO < pHKC; bool isPHKBearish = pHKO > pHKC; // bool isCHKSwitchedToBullish = isCHKBullish && !isPHKBullish; bool isCHKSwitchedToBearish = isCHKBearish && !isPHKBearish; // return result; }