/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // -------------------------------------- // Name: XCX121SMCTestStrategy // Description: provides all based classes for use ... // // // 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 // // Imports ... // #include "../../Helpers/x-saherelm.x3ma.helper.mq5" #include "../../Helpers/x-saherelm.x3vwap.helper.mq5" #include "../Classes/x-121.smc.base.strategy.class.mq5" // // Helper(s) ... // // XStrategy Class Implementation(s) ... class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy { // // Public ... public: // // // Constructor(s) ... void XCX121SMCTestStrategy( // // Base ... string _symbol, // Trading Symbol ENUM_TIMEFRAMES _period // Trading TimeFrame ) : XCX121SMCBaseStrategy(_symbol, _period) { InitialHelpers(); } // // Deconstructor ... void ~XCX121SMCTestStrategy() { // delete x3maHelper; delete x3vwapHelper; } // // Overrides Actions ... // // Check Conditions For Signal ... bool HasSignal( XSignal &signal, X121SMCStrategyConditions &conditions // ) override { // bool result = false; // signal.Clean(); conditions.Clean(); // int pushers = 0; // double sl = 0; double tp = 0; double risk = 0; double entry = 0; double reward = 0; double r2r = R2R(); double volume = Volume(); ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; // bool hasLong = false; bool hasShort = false; // bool isAllowLong = AllowLong(); bool isAllowShort = AllowShort(); result = isAllowLong || isAllowShort; if (!result) { return result; ; } // // Start Calculations ... // string _symbol = GetSymbol(); ENUM_TIMEFRAMES _period = GetPeriod(); // double points = GetPoints(_symbol); double pip = GetPipPrice(_symbol); double pip2 = 2 * pip; double pip3 = 3 * pip; // int zIndex = 0; int cIndex = zIndex + 1; int pIndex = cIndex + 1; int ppIndex = pIndex + 1; // int loopback = 7; int dest = cIndex + loopback; datetime cTime = TimeCurrent(); // conditions.Clean(); conditions.time = cTime; conditions.symbol = _symbol; conditions.period = _period; // // Retrieve Bars ... // // Zero Bar ... XOHCL zBar; result = zBar.Init( _symbol, _period, zIndex // ); if (!result) { return result; } // // Last Bar ... XOHCL cBar; result = cBar.Init( _symbol, _period, cIndex // ); if (!result) { return result; } // // Previous Bar ... XOHCL pBar; result = pBar.Init( _symbol, _period, pIndex // ); if (!result) { return result; } // bool isSpreadPassed = IsSpreadPass(); result = isSpreadPassed; if (!result) { return result; } // // Ticks States ... bool isTicksBullish = IsTicksBullish(); bool isTicksBearish = IsTicksBearish(); bool isTicksHasMomentum = IsTicksHasMomentum(); // result = conditions.supplyZone.IsValid() || conditions.demandZone.IsValid(); if (!result) { // DetectMarketConditions(); return result; } // // TODO: Update Conditions Zones To Time ... // bool isBullish = // false // ; // bool isBearish = // false // ; // if (isBullish || isBearish) { // hasLong = isBullish; hasShort = isBearish; Print(""); } // result = hasLong || hasShort; if (!result) { conditions.Clean(); } // // Rmove Signal Condition ... if (result) { // // TYPE ... type = hasLong ? POSITION_TYPE_BUY : POSITION_TYPE_SELL; ENUM_X_POSITION_TYPES xType = hasLong ? X_POSITION_TYPE_LONG : X_POSITION_TYPE_SHORT; // entry = GetEntry( conditions.symbol, type // ); // double slCandidates[]; // double selectedSL = hasLong ? GetMin(slCandidates) : GetMax(slCandidates); sl = hasLong ? selectedSL - pip3 : selectedSL + pip3; // // RISK Reward ... risk = hasLong ? entry - sl : sl - entry; reward = risk * r2r; tp = hasLong ? entry + reward : entry - reward; // signal.sl = sl; signal.tp = tp; signal.type = type; signal.mode = mode; signal.entry = entry; signal.volume = volume; signal.symbol = _symbol; signal.pushers = pushers; signal.provider = GetTag(); signal.time = TimeCurrent(); signal.period = _5MState.period; // result = PrepareSignal(signal); // hasLong = false; hasShort = false; } // return result; } // // Customize Strategy Identifier ... string GetTag() override { return X121SMCSUPDEMStrategyToken; } // // Protected ... protected: // // // Props ... XOHCL dailyHHBar; XOHCL dailyLLBar; XZone dailyHHZone; XZone dailyLLZone; XZone dailyMiddleZone; // // XPV ... X3MAInputs x3maInputs; XSCX3MAHelper *x3maHelper; // // XCHVWAP ... X3VWAPInputs x3vwapInputs; XSCX3VWAPHelper *x3vwapHelper; // // Private ... private: // // Props ... /** * Initial Required Indicators Helper ... */ void InitialHelpers() { // string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // // X3MA ... // x3maInputs.Default(); // x3maInputs.showFast = false; x3maInputs.showMid = false; x3maInputs.showSlow = false; // x3maHelper = new XSCX3MAHelper(); x3maHelper.Init( symbol, period, x3maInputs // ); // // XCHVWAP ... // x3vwapInputs.Default(); // x3vwapInputs.showFast = true; x3vwapInputs.showMid = true; x3vwapInputs.showSlow = true; // x3vwapHelper = new XSCX3VWAPHelper(); x3vwapHelper.Init( symbol, period, x3vwapInputs // ); } /** * Detect POIs ... */ void DetectPOIs() { // // 1 Min ... // DrawState(_1MState); // // 5 Min ... // DrawState(_5MState); // // 15 Min ... // DrawState(_15MState); // // 1 Hour ... // DrawState(_1HState); // // 2 Hour ... // DrawState(_2HState); // // 4 Hour ... // DrawState(_4HState); // // 1 Day ... // DrawState(_1DState); // // Combine ... // DrawState(_CombineState); // int zIndex = 0; int cIndex = zIndex + 1; int pIndex = cIndex + 1; int ppIndex = pIndex + 1; // int loopback = 7; int dest = cIndex + loopback; datetime cTime = TimeCurrent(); // string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // // Retrieve Bars ... // // Zero Bar ... XOHCL zBar; bool isInited = zBar.Init( symbol, period, zIndex // ); if (!isInited) { return; } // // Last Bar ... XOHCL cBar; isInited = cBar.Init( symbol, period, cIndex // ); if (!isInited) { return; } // int count = 0; XPOIState state = _CombineState; // // // Supply Zones ... count = ArraySize(state.supplyZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.supplyZones[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.supplyZone, cBar // ); if (canRefine) { mConditions.supplyZone = iZone; } } } // // Demand Zones .... count = ArraySize(state.demandZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.demandZones[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.demandZone, cBar // ); if (canRefine) { mConditions.demandZone = iZone; } } } // // Bullish Order Blocks .... count = ArraySize(state.bullishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bullishOrderBlocks[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.bullishOrderBlock, cBar // ); if (canRefine) { mConditions.bullishOrderBlock = iZone; } } } // // Bearish Order Blocks .... count = ArraySize(state.bearishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bearishOrderBlocks[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.bearishOrderBlock, cBar // ); if (canRefine) { mConditions.bearishOrderBlock = iZone; } } } // // Bullish Fair Value Gaps .... count = ArraySize(state.bullishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bullishFVGs[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.bullishFVG, cBar // ); if (canRefine) { mConditions.bullishFVG = iZone; } } } // // Bearish Fair Value Gaps .... count = ArraySize(state.bearishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bearishFVGs[i]; iZone.to = cTime; // bool canRefine = CanRefineZone( iZone, mConditions.bearishFVG, cBar // ); if (canRefine) { mConditions.bearishFVG = iZone; } } } // // Support Zones .... count = ArraySize(state.supportZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.supportZones[i]; // bool canRefine = // !mConditions.support.IsValid() ? ( // iBar.low < cBar.low && iBar.GetDown() > cBar.high // ) : ( // mConditions.support.low < cBar.low && mConditions.support.GetDown() > cBar.high && iBar.low < cBar.low && iBar.GetDown() > cBar.high && iBar.GetDown() - iBar.low < mConditions.support.GetDown() - mConditions.support.low // ) // ; if (canRefine) { mConditions.support = iBar; } } } // // Resistance Zones .... count = ArraySize(state.resistanceZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.resistanceZones[i]; // bool canRefine = // !mConditions.resistance.IsValid() ? ( // iBar.GetUp() < cBar.low && iBar.high > cBar.high // ) : ( // mConditions.resistance.GetUp() < cBar.low && mConditions.resistance.high > cBar.high && iBar.GetUp() < cBar.low && iBar.high > cBar.high && iBar.high - iBar.GetUp() < mConditions.resistance.high - mConditions.resistance.GetUp() // ) // ; if (canRefine) { mConditions.resistance = iBar; } } } // // Momentum Bars .... count = ArraySize(state.momentumBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.momentumBars[i]; bool isBullish = iBar.IsBullish(); // // Bullish Momentum Bar .... if (isBullish) { // bool canRefine = iBar.high < cBar.low; if (canRefine) { mConditions.bullishMomentumBar = iBar; } } // // Bearish Momentum Bar .... if (!isBullish) { // bool canRefine = iBar.low > cBar.high; if (canRefine) { mConditions.bearishMomentumBar = iBar; } } } } // // Rejection Bars ... count = ArraySize(state.rejectionBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.rejectionBars[i]; bool isBullish = iBar.GetLowShadow() > iBar.GetHighShadow(); // // Bullish Rejection Bar .... if (isBullish) { // bool canRefine = iBar.high < cBar.low; if (canRefine) { mConditions.bullishRejectionBar = iBar; } } // // Bearish Rejection Bar .... if (!isBullish) { // bool canRefine = iBar.low > cBar.high; if (canRefine) { mConditions.bearishRejectionBar = iBar; } } } } // // Swing Highs .... count = ArraySize(state.swingHighs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.swingHighs[i]; // bool canRefine = iBar.high > cBar.high; if (canRefine) { mConditions.swingHigh = iBar; } } } // // Swing Lows .... count = ArraySize(state.swingLows); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.swingLows[i]; // bool canRefine = iBar.low > cBar.high; if (canRefine) { mConditions.swingLow = iBar; } } } // // Draw Market Conditions ... DrawMarketConditions(); } /** * Detect Previous Day Range ... */ void DetectDailyRange() { // // Detect Daily High / Low and Middle Zones ... // Period 5M is Source ... // string symbol = GetSymbol(); datetime cTime = TimeCurrent(); ENUM_TIMEFRAMES period = GetPeriod(); // // Extract Common Requirements ... datetime dailyStartBarTime = iTime( symbol, PERIOD_D1, 1 // ); int dailyStartBarIndex = iBarShift( symbol, period, dailyStartBarTime // ); datetime dailyEndBarTime = (datetime)((int)dailyStartBarTime + PeriodSeconds(PERIOD_D1) - PeriodSeconds(period)); int dailyEndBarIndex = iBarShift( symbol, period, dailyEndBarTime // ); int dailyLenght = MathAbs(dailyStartBarIndex - dailyEndBarIndex); // // Highest High ... int dailyHHBarIndex = iHighest( symbol, period, MODE_HIGH, dailyLenght, dailyEndBarIndex // ); dailyHHBar.Clean(); bool isInited = dailyHHBar.Init( symbol, period, dailyHHBarIndex // ); if (!isInited) { return; } // isInited = mBarAnalyser.ToZone( dailyHHBar, dailyHHZone, X_DIRECTION_BULLISH // ); if (!isInited) { return; } // // Lowest Low ... int dailyLLBarIndex = iLowest( symbol, period, MODE_LOW, dailyLenght, dailyEndBarIndex // ); dailyLLBar.Clean(); isInited = dailyLLBar.Init( symbol, period, dailyLLBarIndex // ); if (!isInited) { return; } // isInited = mBarAnalyser.ToZone( dailyLLBar, dailyLLZone, X_DIRECTION_BEARISH // ); if (!isInited) { return; } // // Daily Middle Zone ... double range = MathMax( (dailyHHBar.high - dailyHHBar.GetUp()), (dailyLLBar.GetDown() - dailyLLBar.low)); // double middle = dailyHHBar.GetUp() - ((dailyHHBar.GetUp() - dailyLLBar.GetDown()) / 2); // dailyMiddleZone.Clean(); string middleZonePrefix = "XDailyMiddle_"; // double upper = middle + (range / 2); double lower = middle - (range / 2); isInited = dailyMiddleZone.Init( upper, lower, middleZonePrefix, dailyStartBarTime, cTime // ); if (!isInited) { return; } // DrawDailyRange(); } /** * Detect Market Conditions ... */ void DetectMarketConditions() { // int zIndex = 0; int cIndex = zIndex + 1; int pIndex = cIndex + 1; int ppIndex = pIndex + 1; // int loopback = 7; int dest = cIndex + loopback; datetime cTime = TimeCurrent(); // string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // // Retrieve Bars ... // // Zero Bar ... XOHCL zBar; bool isInited = zBar.Init( symbol, period, zIndex // ); if (!isInited) { return; } // // Last Bar ... XOHCL cBar; isInited = cBar.Init( symbol, period, cIndex // ); if (!isInited) { return; } // // Prev Bar ... XOHCL pBar; isInited = pBar.Init( symbol, period, pIndex // ); if (!isInited) { return; } // // Prev of Prev Bar ... XOHCL ppBar; isInited = ppBar.Init( symbol, period, ppIndex // ); if (!isInited) { return; } // DetectDailyRange(); // bool isExtended = mBarAnalyser .IsExtended( cBar, 2 // Loopback Length ... ); // ENUM_X_DIRECTION chochDirection; bool hasCHOCH = mBarAnalyser .HasCHOCH( chochDirection, cBar, 2, // Loopback Length ... true // Force Body ... ); bool hasBullishCHOCH = hasCHOCH && IsBullish(chochDirection); bool hasBearishCHOCH = hasCHOCH && IsBearish(chochDirection); // // Reading Rejection and Momentum Bars ... double rejectionPercent = 70; double momentumPercent = 70; // // CBar ... // // Rejection Bar ... ENUM_X_DIRECTION cBarRejectionDir; bool isCBarRejectionBar = mBarAnalyser .IsRejectionBar( cBarRejectionDir, cBar, rejectionPercent // ); bool isCBarBullishRejectionBar = isCBarRejectionBar && IsBullish(cBarRejectionDir); bool isCBarBearishRejectionBar = isCBarRejectionBar && IsBearish(cBarRejectionDir); // // Momentum Bar ... ENUM_X_DIRECTION cBarMomentumDir; bool isCBarMomentumBar = mBarAnalyser .IsMomentumBar( cBarMomentumDir, cBar, momentumPercent // ); bool isCBarBullishMomentumBar = isCBarMomentumBar && IsBullish(cBarMomentumDir); bool isCBarBearishMomentumBar = isCBarMomentumBar && IsBearish(cBarMomentumDir); // // PBar ... // // Rejection Bar ... ENUM_X_DIRECTION pBarRejectionDir; bool isPBarRejectionBar = mBarAnalyser .IsRejectionBar( pBarRejectionDir, pBar, rejectionPercent // ); bool isPBarBullishRejectionBar = isPBarRejectionBar && IsBullish(pBarRejectionDir); bool isPBarBearishRejectionBar = isPBarRejectionBar && IsBearish(pBarRejectionDir); // // Momentum Bar ... ENUM_X_DIRECTION pBarMomentumDir; bool isPBarMomentumBar = mBarAnalyser .IsMomentumBar( pBarMomentumDir, pBar, momentumPercent // ); bool isPBarBullishMomentumBar = isPBarMomentumBar && IsBullish(pBarMomentumDir); bool isPBarBearishMomentumBar = isPBarMomentumBar && IsBearish(pBarMomentumDir); // // PPBar ... // // Rejection Bar ... ENUM_X_DIRECTION ppBarRejectionDir; bool isPPBarRejectionBar = mBarAnalyser .IsRejectionBar( ppBarRejectionDir, ppBar, rejectionPercent // ); bool isPPBarBullishRejectionBar = isPPBarRejectionBar && IsBullish(ppBarRejectionDir); bool isPPBarBearishRejectionBar = isPPBarRejectionBar && IsBearish(ppBarRejectionDir); // // Momentum Bar ... ENUM_X_DIRECTION ppBarMomentumDir; bool isPPBarMomentumBar = mBarAnalyser .IsMomentumBar( ppBarMomentumDir, ppBar, momentumPercent // ); bool isPPBarBullishMomentumBar = isPPBarMomentumBar && IsBullish(ppBarMomentumDir); bool isPPBarBearishMomentumBar = isPPBarMomentumBar && ppBarMomentumDir == X_DIRECTION_BEARISH; // // Combine Rejection and Momentum Conditions ... // // Rejection Bars ... bool hasCPPPBullishRejectionBar = isCBarBullishRejectionBar || isPBarBullishRejectionBar || isPPBarBullishRejectionBar; bool hasCPPPBearishRejectionBar = isCBarBearishRejectionBar || isPBarBearishRejectionBar || isPPBarBearishRejectionBar; // // Momentum Bars ... bool hasCPPPBullishMomentumBar = isCBarBullishMomentumBar || isPBarBullishMomentumBar || isPPBarBullishMomentumBar; bool hasCPPPBearishMomentumBar = isCBarBearishMomentumBar || isPBarBearishMomentumBar || isPPBarBearishMomentumBar; // bool hasBarsValidBullishMovement = hasCPPPBullishRejectionBar && hasCPPPBullishMomentumBar; // bool hasBarsValidBearishMovement = hasCPPPBearishRejectionBar && hasCPPPBearishMomentumBar; // // // // bool hasBullishConditions = // isExtended && hasBullishCHOCH && hasBarsValidBullishMovement // ; // bool hasBearishConditions = // isExtended && hasBearishCHOCH && hasBarsValidBearishMovement // ; // bool hasConditions = hasBullishConditions || hasBearishConditions; // if (hasConditions) { Print("hasConditions..."); } } /** * Draw Specific States on Screen ... * * @param state: XPOIState instance ... */ void DrawState(XPOIState &state) { // bool drawSupplyZones = true; bool drawDemandZones = true; // bool drawBullishOrderBlocks = true; bool drawBearishOrderBlocks = true; // bool drawBullishFVGs = true; bool drawBearishFVGs = true; // bool drawBullishMomentumBars = true; bool drawBearishMomentumBars = true; // bool drawBullishRejectionBars = true; bool drawBearishRejectionBars = true; // bool drawSwingHighs = true; bool drawSwingLows = true; // bool drawSupports = true; bool drawResistances = true; // int count = 0; datetime cTime = TimeCurrent(); // // Supply Zones ... count = ArraySize(state.supplyZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.supplyZones[i]; iZone.to = cTime; // if (drawSupplyZones) { // XCSupplyZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupplyZone( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Demand Zones .... count = ArraySize(state.demandZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.demandZones[i]; iZone.to = cTime; // if (drawDemandZones) { // XCDemandZoneObject *iObj; bool isCreated = mPOIDrawer.CreateDemandZone( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Order Blocks .... count = ArraySize(state.bullishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bullishOrderBlocks[i]; iZone.to = cTime; // if (drawBullishOrderBlocks) { // XCBullishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBullishOrderBlock( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Order Blocks .... count = ArraySize(state.bearishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bearishOrderBlocks[i]; iZone.to = cTime; // if (drawBearishOrderBlocks) { // XCBearishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBearishOrderBlock( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Fair Value Gaps .... count = ArraySize(state.bullishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bullishFVGs[i]; iZone.to = cTime; // if (drawBullishFVGs) { // XCBullishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBullishFVG( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Fair Value Gaps .... count = ArraySize(state.bearishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = state.bearishFVGs[i]; iZone.to = cTime; // if (drawBullishFVGs) { // XCBearishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBearishFVG( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Momentum Bar .... // Bearish Momentum Bar .... count = ArraySize(state.momentumBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.momentumBars[i]; bool isBullish = iBar.IsBullish(); // // Bullish Rejection Bar .... if (isBullish && drawBullishMomentumBars) { // XCBullishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishMomentumBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } // if (!isBullish && drawBearishMomentumBars) { // // Bearish Rejection Bar .... XCBearishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishMomentumBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Rejection Bars ... count = ArraySize(state.rejectionBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.rejectionBars[i]; bool isBullish = iBar.GetLowShadow() > iBar.GetHighShadow(); // // Bullish Rejection Bar .... if (isBullish && drawBullishRejectionBars) { // XCBullishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishRejectionBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } // if (!isBullish && drawBearishRejectionBars) { // // Bearish Rejection Bar .... XCBearishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishRejectionBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Swing Highs .... count = ArraySize(state.swingHighs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.swingHighs[i]; // if (drawSwingHighs) { // XCSwingHighObject *iObj; bool isCreated = mPOIDrawer.CreateSwingHigh( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Swing Lows .... count = ArraySize(state.swingLows); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.swingLows[i]; // if (drawSwingLows) { // XCSwingLowObject *iObj; bool isCreated = mPOIDrawer.CreateSwingLow( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Supports .... count = ArraySize(state.supportZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.supportZones[i]; // if (drawSupports) { // XCSupportZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupportZone( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Resistances .... count = ArraySize(state.resistanceZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = state.resistanceZones[i]; // if (drawResistances) { // XCResistanceZoneObject *iObj; bool isCreated = mPOIDrawer.CreateResistanceZone( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } } /** * Draw Daily Range Zones ... */ void DrawDailyRange() { // if (!dailyHHBar.IsValid() && !dailyLLBar.IsValid() && !dailyMiddleZone.IsValid()) { return; } // bool drawDailySupport = true; bool drawDailyResistance = true; bool drawDailyMiddle = true; // datetime cTime = TimeCurrent(); // // Daily Support ... if (drawDailySupport && dailyLLBar.IsValid()) { // XCSupportZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupportZone( dailyLLBar, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } // // Daily Resistance ... if (drawDailyResistance && dailyHHBar.IsValid()) { // XCResistanceZoneObject *iObj; bool isCreated = mPOIDrawer.CreateResistanceZone( dailyHHBar, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } // // Daily Middle ... if (drawDailyMiddle && dailyMiddleZone.IsValid()) { // XCZoneObject *iObj; iObj = new XCZoneObject(); // string iName = dailyMiddleZone.GetTag(); bool isCreated = iObj.CreateByZone( ChartIdentification(), iName, SubWindowIdentification(), dailyMiddleZone, NULL, true // ); if (isCreated) { // iObj.ZoneWidth(1); iObj.ZoneColor(clrYellow); iObj.ZoneStyle(STYLE_DASHDOT); // mDrawnObjects.Add(iObj); } } } /** * Draw Market Conditions ... */ void DrawMarketConditions() { // bool tmpDraw = false; // bool drawSupplyZone = tmpDraw; bool drawDemandZone = tmpDraw; // bool drawSupplyZones = tmpDraw; bool drawDemandZones = tmpDraw; // bool drawBullishOrderBlock = tmpDraw; bool drawBearishOrderBlock = tmpDraw; // bool drawBullishOrderBlocks = tmpDraw; bool drawBearishOrderBlocks = tmpDraw; // bool drawBullishFVG = tmpDraw; bool drawBearishFVG = tmpDraw; // bool drawBullishFVGs = tmpDraw; bool drawBearishFVGs = tmpDraw; // bool drawBullishMomentumBar = tmpDraw; bool drawBearishMomentumBar = tmpDraw; // bool drawBullishMomentumBars = tmpDraw; bool drawBearishMomentumBars = tmpDraw; // bool drawBullishRejectionBar = tmpDraw; bool drawBearishRejectionBar = tmpDraw; // bool drawBullishRejectionBars = tmpDraw; bool drawBearishRejectionBars = tmpDraw; // bool drawSwingHigh = tmpDraw; bool drawSwingLow = tmpDraw; // bool drawSwingHighs = tmpDraw; bool drawSwingLows = tmpDraw; // bool drawSupport = tmpDraw; bool drawResistance = tmpDraw; // bool drawSupports = tmpDraw; bool drawResistances = tmpDraw; // int count = 0; datetime cTime = TimeCurrent(); // // Supply Zones ... if (drawSupplyZone && mConditions.supplyZone.IsValid()) { // XCSupplyZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupplyZone( mConditions.supplyZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.supplyZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.supplyZones[i]; iZone.to = cTime; // if (drawSupplyZones) { // XCSupplyZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupplyZone( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Demand Zones .... if (drawDemandZone && mConditions.demandZone.IsValid()) { // XCDemandZoneObject *iObj; bool isCreated = mPOIDrawer.CreateDemandZone( mConditions.demandZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.demandZones); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.demandZones[i]; iZone.to = cTime; // if (drawDemandZones) { // XCDemandZoneObject *iObj; bool isCreated = mPOIDrawer.CreateDemandZone( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Order Blocks .... if (drawBullishOrderBlock && mConditions.bullishOrderBlock.IsValid()) { // XCBullishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBullishOrderBlock( mConditions.bullishOrderBlock, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bullishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.bullishOrderBlocks[i]; iZone.to = cTime; // if (drawBullishOrderBlocks) { // XCBullishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBullishOrderBlock( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Order Blocks .... if (drawBearishOrderBlock && mConditions.bearishOrderBlock.IsValid()) { // XCBearishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBearishOrderBlock( mConditions.bearishOrderBlock, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bearishOrderBlocks); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.bearishOrderBlocks[i]; iZone.to = cTime; // if (drawBearishOrderBlocks) { // XCBearishOrderBlockObject *iObj; bool isCreated = mPOIDrawer.CreateBearishOrderBlock( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Fair Value Gaps .... if (drawBullishFVG && mConditions.bullishFVG.IsValid()) { // XCBullishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBullishFVG( mConditions.bullishFVG, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bullishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.bullishFVGs[i]; iZone.to = cTime; // if (drawBullishFVGs) { // XCBullishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBullishFVG( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Fair Value Gaps .... if (drawBearishFVG && mConditions.bearishFVG.IsValid()) { // XCBearishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBearishFVG( mConditions.bearishFVG, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bearishFVGs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XZone iZone = mConditions.bearishFVGs[i]; iZone.to = cTime; // if (drawBullishFVGs) { // XCBearishFVGObject *iObj; bool isCreated = mPOIDrawer.CreateBearishFVG( iZone, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Momentum Bar .... if (drawBullishMomentumBar && mConditions.bullishMomentumBar.IsValid()) { // XCBullishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishMomentumBar( mConditions.bullishMomentumBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bullishMomentumBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.bullishMomentumBars[i]; // if (drawBullishMomentumBars) { // XCBullishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishMomentumBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Momentum Bar .... if (drawBearishMomentumBar && mConditions.bearishMomentumBar.IsValid()) { // XCBearishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishMomentumBar( mConditions.bearishMomentumBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bearishMomentumBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.bearishMomentumBars[i]; // if (drawBearishMomentumBars) { // XCBearishMomentumBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishMomentumBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bullish Rejection Bars ... if (drawBullishRejectionBars && mConditions.bullishRejectionBar.IsValid()) { // XCBullishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishRejectionBar( mConditions.bullishRejectionBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bullishRejectionBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.bullishRejectionBars[i]; // if (drawBullishRejectionBars) { // XCBullishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBullishRejectionBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Bearish Rejection Bars ... if (drawBearishRejectionBars && mConditions.bearishRejectionBar.IsValid()) { // XCBearishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishRejectionBar( mConditions.bearishRejectionBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.bearishRejectionBars); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.bearishRejectionBars[i]; // if (drawBearishRejectionBars) { // XCBearishRejectionBarObject *iObj; bool isCreated = mPOIDrawer.CreateBearishRejectionBar( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Swing Highs .... if (drawSwingHigh && mConditions.swingHigh.IsValid()) { // XCSwingHighObject *iObj; bool isCreated = mPOIDrawer.CreateSwingHigh( mConditions.swingHigh, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.swingHighs); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.swingHighs[i]; // if (drawSwingHighs) { // XCSwingHighObject *iObj; bool isCreated = mPOIDrawer.CreateSwingHigh( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Swing Lows .... if (drawSwingLow && mConditions.swingLow.IsValid()) { // XCSwingLowObject *iObj; bool isCreated = mPOIDrawer.CreateSwingLow( mConditions.swingLow, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.swingLows); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.swingLows[i]; // if (drawSwingLows) { // XCSwingLowObject *iObj; bool isCreated = mPOIDrawer.CreateSwingLow( iBar, iObj // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Supports .... if (drawSupport && mConditions.support.IsValid()) { // XCSupportZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupportZone( mConditions.support, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.supports); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.supports[i]; // if (drawSupports) { // XCSupportZoneObject *iObj; bool isCreated = mPOIDrawer.CreateSupportZone( iBar, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } // // Resistances .... if (drawResistance && mConditions.resistance.IsValid()) { // XCResistanceZoneObject *iObj; bool isCreated = mPOIDrawer.CreateResistanceZone( mConditions.resistance, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } count = ArraySize(mConditions.resistances); if (IsValidSize(count)) { // for (int i = 0; i < count; i++) { // XOHCL iBar = mConditions.resistances[i]; // if (drawResistances) { // XCResistanceZoneObject *iObj; bool isCreated = mPOIDrawer.CreateResistanceZone( iBar, iObj, cTime // ); if (isCreated) { mDrawnObjects.Add(iObj); } } } } } // bool DetectBar() { // bool result = false; // int zIndex = 0; int cIndex = zIndex + 1; int pIndex = cIndex + 1; int ppIndex = pIndex + 1; // int loopback = 7; int dest = cIndex + loopback; datetime cTime = TimeCurrent(); // string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // // Retrieve Bars ... // // Zero Bar ... XOHCL zBar; result = zBar.Init( symbol, period, zIndex // ); if (!result) { return result; } // // Last Bar ... XOHCL cBar; result = cBar.Init( symbol, period, cIndex // ); if (!result) { return result; } // ENUM_X_DIRECTION dir; result = mBarAnalyser.HasDirection( dir, cBar // ); if (result) { Print("Has Direction: " + EnumToString(dir)); } // return result; } // }; //