/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Indicator // ------------------------------------------------- // Name: X121 XWZ // Description: XWZ ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Glzoneal Properties ... #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm X121 XWZ Indicator" #property strict // // Definitions ... // #define ShortName "X121_XWZ" // // Includes Common Library ... #include "../Classes/x-saherelm.x-alert.class.mq5" #include "../Classes/x-saherelm.x-bar.analyser.class.mq5" #include "../Classes/x-saherelm.x-poi.class.mq5" #include "../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../Libraries/x-saherelm.common.lib.mq5" #include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5" // // Inputs ... // // Market ... input group "Market"; // input group "Calculation"; input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Detect Price Type // input group "MA Detection"; input int maLength = 20; // MA Length input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method // input group "ATR StopLoss"; input int atrLength = 14; // ATR Length input double atrMultiplier = 2; // ATR Multiplier // input group "ADX Detection"; input int adxLength = 14; // ADX Length input double adxThreshold = 25; // ADX Threshold for Strong Trends // input group "POI Detection"; input ENUM_TIMEFRAMES orderBlockTF = PERIOD_H1; // Order Block Detection Time Frame input ENUM_TIMEFRAMES fairValueGapTF = PERIOD_M15; // Fair Value Gap Detection Time Frame input ENUM_TIMEFRAMES supDemTF = PERIOD_H4; // Supply and Demand Detection Time Frame // input group "Alert"; input bool mXWZEnableAlerts = true; // Enable Alerts input bool mXWZPushAlerts = false; // Push Alerts input bool mXWZMailAlerts = false; // Mail Alerts input bool mXWZTerminalAlerts = false; // Terminal Alerts // // Presentation ... input group "Presentation"; // input group "Buffer Presentation"; input bool showMA = true; // Show Moving Average input bool showPin = true; // Show Pin Bars input bool showSwing = true; // Show Swing Bars input bool showTrend = true; // Show Trend input bool showEngulf = true; // Show Engulf Bars input bool showLongSL = true; // Show Long SL input bool showShortSL = true; // Show Short SL input bool showMomentum = true; // Show Momentum Bars input bool showRejection = true; // Show Rejection Bars // input group "POI Presentation"; input bool showPOIs = true; // Show POI(s) input bool showOrderBlocks = true; // Show Order Blocks input bool showFairValueGaps = true; // Show Fair Value Gaps input bool showSupplyZones = true; // Show Supply Zones input bool showDemandZones = true; // Show Demand Zones // input group "Presentation Config"; input int startCalculationForLastBars = 1000; // Calculate Last n Bars input int upTrendArrowCode = 236; // Up Trend Arrow Code input int downTrendArrowCode = 238; // Down Trend Arrow Code input int swingLowArrowCode = 108; // Swing Low Arrow Code input int swingHighArrowCode = 108; // Swing High Arrow Code input int bullishPinArrowCode = 246; // Bullish Pin Arrow Code input int bearishPinArrowCode = 248; // Bearish Pin Arrow Code input int bullishEngulfArrowCode = 200; // Bullish Engulf Arrow Code input int bearishEngulfArrowCode = 202; // Bearish Engulf Arrow Code input int bullishMomentumArrowCode = 233; // Bullish Momentum Arrow Code input int bearishMomentumArrowCode = 234; // Bearish Momentum Arrow Code input int bullishRejectionArrowCode = 241; // Bullish Rejection Arrow Code input int bearishRejectionArrowCode = 242; // Bearish Rejection Arrow Code // #property indicator_chart_window // #property indicator_buffers 17 #property indicator_plots 15 // // Plot Buffers ... // #define maBufferIndex 0 double maBuffer[]; // #property indicator_label1 "X121-XWZ MA" #property indicator_type1 DRAW_LINE #property indicator_color1 clrLightSkyBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 2 // #define longSLBufferIndex 1 double longSLBuffer[]; // #property indicator_label2 "X121-XWZ Long SL" #property indicator_type2 DRAW_LINE #property indicator_color2 clrOrange #property indicator_style2 STYLE_SOLID #property indicator_width2 1 // #define shortSLBufferIndex 2 double shortSLBuffer[]; // #property indicator_label3 "X121-XWZ Short SL" #property indicator_type3 DRAW_LINE #property indicator_color3 clrOrange #property indicator_style3 STYLE_SOLID #property indicator_width3 1 // #define upTrendBufferIndex 3 double upTrendBuffer[]; // #property indicator_label4 "X121-XWZ Trend Up" #property indicator_type4 DRAW_ARROW #property indicator_color4 clrAqua #property indicator_width4 3 // #define downTrendBufferIndex 4 double downTrendBuffer[]; // #property indicator_label5 "X121-XWZ Trend Down" #property indicator_type5 DRAW_ARROW #property indicator_color5 clrMagenta #property indicator_width5 3 // #define bullishMomentumBufferIndex 5 double bullishMomentumBuffer[]; // #property indicator_label6 "X121-XWZ Bull Momentum" #property indicator_type6 DRAW_ARROW #property indicator_color6 clrAqua #property indicator_width6 3 // #define bearishMomentumBufferIndex 6 double bearishMomentumBuffer[]; // #property indicator_label7 "X121-XWZ Bear Momentum" #property indicator_type7 DRAW_ARROW #property indicator_color7 clrMagenta #property indicator_width7 3 // #define bullishRejectionBufferIndex 7 double bullishRejectionBuffer[]; // #property indicator_label8 "X121-XWZ Bull Rejection" #property indicator_type8 DRAW_ARROW #property indicator_color8 clrAqua #property indicator_width8 3 // #define bearishRejectionBufferIndex 8 double bearishRejectionBuffer[]; // #property indicator_label9 "X121-XWZ Bear Rejection" #property indicator_type9 DRAW_ARROW #property indicator_color9 clrMagenta #property indicator_width9 3 // #define bullishPinBufferIndex 9 double bullishPinBuffer[]; // #property indicator_label10 "X121-XWZ Bull Pin" #property indicator_type10 DRAW_ARROW #property indicator_color10 clrAqua #property indicator_width10 3 // #define bearishPinBufferIndex 10 double bearishPinBuffer[]; // #property indicator_label11 "X121-XWZ Bear Pin" #property indicator_type11 DRAW_ARROW #property indicator_color11 clrMagenta #property indicator_width11 3 // #define bullishEngulfBufferIndex 11 double bullishEngulfBuffer[]; // #property indicator_label12 "X121-XWZ Bull Engulf" #property indicator_type12 DRAW_ARROW #property indicator_color12 clrAqua #property indicator_width12 3 // #define bearishEngulfBufferIndex 12 double bearishEngulfBuffer[]; // #property indicator_label13 "X121-XWZ Bear Engulf" #property indicator_type13 DRAW_ARROW #property indicator_color13 clrMagenta #property indicator_width13 3 // #define swingLowBufferIndex 13 double swingLowBuffer[]; // #property indicator_label14 "X121-XWZ Swing Low" #property indicator_type14 DRAW_ARROW #property indicator_color14 clrAqua #property indicator_width14 3 // #define swingHighBufferIndex 14 double swingHighBuffer[]; // #property indicator_label15 "X121-XWZ Swing High" #property indicator_type15 DRAW_ARROW #property indicator_color15 clrMagenta #property indicator_width15 3 // // Data Buffers ... // int mLastBufferIndex = 14; // #define atrBufferIndex mLastBufferIndex + 1 double atrBuffer[]; // #define adxBufferIndex mLastBufferIndex + 2 double adxBuffer[]; // // Variables, Properties and etc ... // // this counts Available Bars ... int limit; // int maxLength; // // MA Handler ... int maHandler = INVALID_HANDLE; // // ATR Handler ... int atrHandler = INVALID_HANDLE; // // ADX Handler ... int adxHandler = INVALID_HANDLE; // XCAlert *mXWZAlert; XBarTracker mXWZBarTracker; CArrayObj mXWZDrawnObjects; XCPOIDrawer *mXWZPOIDrawer; XCBarAnalyser *mXWZBarAnalyser; // // POI(s) ... // bool mXWZDetectOrderBlocks = true; bool mXWZDetectFairValueGaps = true; bool mXWZDetectSupplyZones = true; bool mXWZDetectDemandZones = true; // bool mXWZIgnoreUnActivateds = true; // bool mXWZForceStarteds = true; bool mXWZForceUnBreaked = true; bool mXWZForceActivation = true; // int mXWZSuResRange = 21; int mXWZOBFVGSameBars = 3; // // Un Activated POI(s) ... XCFVG *mXWZUnActivatedFVGs[]; XCOrderBlock *mXWZUnActivatedOBs[]; XCSupplyZone *mXWZUnActivatedSupplyZones[]; XCDemandZone *mXWZUnActivatedDemandZones[]; // // Activated POI(s) ... XCFVG *mXWZActivatedFVGs[]; XCOrderBlock *mXWZActivatedOBs[]; XCSupplyZone *mXWZActivatedSupplyZones[]; XCDemandZone *mXWZActivatedDemandZones[]; // // Event Handlers ... /** * Initialize Indicator ... * * @return ( int ) */ int OnInit() { // mXWZDrawnObjects.Clear(); // // Validate Inputs ... if (!ValidateInputs()) { return INIT_PARAMETERS_INCORRECT; } // // Initialize Indicator Handlers ... // // MA ... maHandler = iMA( _Symbol, _Period, maLength, 0, maMethod, appliedTo // ); bool isInited = maHandler != INVALID_HANDLE; if (!isInited) { return INIT_FAILED; } // // ATR ... atrHandler = iATR( _Symbol, _Period, atrLength // ); isInited = maHandler != INVALID_HANDLE; if (!isInited) { return INIT_FAILED; } // // ADX ... adxHandler = iADX( _Symbol, _Period, adxLength // ); isInited = maHandler != INVALID_HANDLE; if (!isInited) { return INIT_FAILED; } // // because in some cases we may have more than one input for // calculation and we must prevent any calculation // untill we pass the biggest input length, here we get max Input length // and then wait until pass it ... maxLength = ExtractMaxLengthOfInputs(); // // Define Index Buffers ... DefineBuffers(); // // Set Indicator ShortName ... SetIndicatorName(); IndicatorSetInteger(INDICATOR_DIGITS, 2); // // Initialize Bar Tracker ... mXWZBarTracker.Init( _Symbol, _Period // ); // mXWZPOIDrawer = new XCPOIDrawer(); ConfigurePOIDrawer(); // mXWZAlert = new XCAlert(); ConfigureAlert(); // mXWZBarAnalyser = new XCBarAnalyser(); // // Init Succeed ... return INIT_SUCCEEDED; } /** * De Initialize Indicator ... * * @param reason: Integer, De Initialization Reason ... */ void OnDeinit(const int reason) { // // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function // REASON_REMOVE 1 Program removed from a chart // REASON_RECOMPILE 2 Program recompiled // REASON_CHARTCHANGE 3 A symbol or a chart period is changed // REASON_CHARTCLOSE 4 Chart closed // REASON_PARAMETERS 5 Inputs changed by a user // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings // REASON_TEMPLATE 7 Another chart template applied // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value // REASON_CLOSE 9 Terminal closed // IndicatorRelease(maHandler); IndicatorRelease(atrHandler); IndicatorRelease(adxHandler); // mXWZDrawnObjects.Clear(); // ZeroMemory(mXWZAlert); ZeroMemory(mXWZPOIDrawer); ZeroMemory(mXWZBarAnalyser); // Clean(mXWZActivatedOBs); Clean(mXWZActivatedFVGs); Clean(mXWZActivatedSupplyZones); Clean(mXWZActivatedDemandZones); // Clean(mXWZUnActivatedOBs); Clean(mXWZUnActivatedFVGs); Clean(mXWZUnActivatedSupplyZones); Clean(mXWZUnActivatedDemandZones); } /** * Calculate Bars ... * * @param rates_total: Integer, Total Bars on Chart ... * @param prev_calculated: Integer, Total Calculated Bars on Charts ... * @param time: DateTime Array, History of Open Time ... * @param open: Double Array, History of Open Prices ... * @param high: Double Array, History of High Prices ... * @param low: Double Array, History of Low Prices ... * @param close: Double Array, History of Close Prices ... * @param tick_volume: Long, History of Tick Volumes on Bar ... * @param volume: Long, History of Trade Volumes ... * @param spread: Double, History of Spread Price ... * * @return ( int ) */ int OnCalculate( const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] // ) { // // Prepare Buffers ... ArraySetAsSeries(time, true); ArraySetAsSeries(open, true); ArraySetAsSeries(high, true); ArraySetAsSeries(low, true); ArraySetAsSeries(close, true); ArraySetAsSeries(tick_volume, true); ArraySetAsSeries(volume, true); ArraySetAsSeries(spread, true); // // Validate Calculated Bars ... // // MA ... int maCalculatedBars = BarsCalculated(maHandler); // // ATR ... int atrCalculatedBars = BarsCalculated(atrHandler); // // ADX ... int adxCalculatedBars = BarsCalculated(adxHandler); // bool isPassedRequiredCalculatedBars = // // MA ... maCalculatedBars >= maxLength && // // ATR ... atrCalculatedBars >= maxLength && // // ADX ... adxCalculatedBars >= maxLength // ; if (!isPassedRequiredCalculatedBars) { return prev_calculated; } // limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1; // // Buffers Copy ... // // MA ... int copiedMas = CopyBuffer(maHandler, 0, 0, limit, maBuffer); // // ATR ... int copiedAtr = CopyBuffer(atrHandler, MAIN_LINE, 0, limit, atrBuffer); // // ADX ... int copiedAdxs = CopyBuffer(adxHandler, MAIN_LINE, 0, limit, adxBuffer); // // Validate Copied Items ... bool isPassedRequiredCopiedItems = // // MA ... copiedMas > 0 && // // ATR ... copiedAtr > 0 && // // ADX ... copiedAdxs > 0 // ; if (!isPassedRequiredCopiedItems) { return prev_calculated; } // // Main Loop ... for (int i = limit - 1; i >= 0 && !IsStopped(); i--) { // CalculateBuffers( // i, prev_calculated, rates_total, // open, high, close, low, tick_volume // ); } // return rates_total; } // // Functions ... /** * Validate Input Args for Initialization ... * * @return ( bool ) */ bool ValidateInputs() { // bool result = false; // result = // // MA ... maLength > 0 && // // ATR ... atrLength > 0 && atrMultiplier > 0 && // // ADX ... adxLength > 0 && adxThreshold > 0 // ; // return result; } /** * Extract Max Length of Inputs ... * * @return ( int ) */ int ExtractMaxLengthOfInputs() { // int result = 0; // result = MathMax(maLength, atrLength); result = MathMax(result, adxLength); // return result; } /** * Set Indicator Short Name and also we can define Buffers Labels ... */ void SetIndicatorName() { IndicatorSetString(INDICATOR_SHORTNAME, ShortName); } /** * Define Required Buffers ... */ void DefineBuffers() { // // Plot Buffers ... // // MA Buffer ... // ENUM_DRAW_TYPE maDrawType = showMA ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(maBuffer, true); SetIndexBuffer(maBufferIndex, maBuffer, INDICATOR_DATA); // PlotIndexSetInteger(maBufferIndex, PLOT_SHOW_DATA, showMA); PlotIndexSetInteger(maBufferIndex, PLOT_DRAW_TYPE, maDrawType); // PlotIndexSetDouble(maBufferIndex, PLOT_EMPTY_VALUE, 0); // // LONG SL Buffer ... // ENUM_DRAW_TYPE longSLDrawType = showLongSL ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(longSLBuffer, true); SetIndexBuffer(longSLBufferIndex, longSLBuffer, INDICATOR_DATA); // PlotIndexSetInteger(longSLBufferIndex, PLOT_SHOW_DATA, showLongSL); PlotIndexSetInteger(longSLBufferIndex, PLOT_DRAW_TYPE, longSLDrawType); // PlotIndexSetDouble(longSLBufferIndex, PLOT_EMPTY_VALUE, 0); // // SHORT SL Buffer ... // ENUM_DRAW_TYPE shortSLDrawType = showShortSL ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(shortSLBuffer, true); SetIndexBuffer(shortSLBufferIndex, shortSLBuffer, INDICATOR_DATA); // PlotIndexSetInteger(shortSLBufferIndex, PLOT_SHOW_DATA, showShortSL); PlotIndexSetInteger(shortSLBufferIndex, PLOT_DRAW_TYPE, shortSLDrawType); // PlotIndexSetDouble(shortSLBufferIndex, PLOT_EMPTY_VALUE, 0); // // UP Trend ... // ENUM_DRAW_TYPE upTrendDrawType = showTrend ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(upTrendBuffer, true); SetIndexBuffer(upTrendBufferIndex, upTrendBuffer, INDICATOR_DATA); // PlotIndexSetInteger(upTrendBufferIndex, PLOT_SHOW_DATA, showTrend); PlotIndexSetInteger(upTrendBufferIndex, PLOT_DRAW_TYPE, upTrendDrawType); // PlotIndexSetDouble(upTrendBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(upTrendBufferIndex, PLOT_ARROW, upTrendArrowCode); // // DOWN Trend ... // ENUM_DRAW_TYPE downTrendDrawType = showTrend ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(downTrendBuffer, true); SetIndexBuffer(downTrendBufferIndex, downTrendBuffer, INDICATOR_DATA); // PlotIndexSetInteger(downTrendBufferIndex, PLOT_SHOW_DATA, showTrend); PlotIndexSetInteger(downTrendBufferIndex, PLOT_DRAW_TYPE, downTrendDrawType); // PlotIndexSetDouble(downTrendBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(downTrendBufferIndex, PLOT_ARROW, downTrendArrowCode); // // Bullish Momentum ... // ENUM_DRAW_TYPE bullishMomentumDrawType = showMomentum ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bullishMomentumBuffer, true); SetIndexBuffer(bullishMomentumBufferIndex, bullishMomentumBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bullishMomentumBufferIndex, PLOT_SHOW_DATA, showMomentum); PlotIndexSetInteger(bullishMomentumBufferIndex, PLOT_DRAW_TYPE, bullishMomentumDrawType); // PlotIndexSetDouble(bullishMomentumBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bullishMomentumBufferIndex, PLOT_ARROW, bullishMomentumArrowCode); // // Bearish Momentum ... // ENUM_DRAW_TYPE bearishMomentumDrawType = showMomentum ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bearishMomentumBuffer, true); SetIndexBuffer(bearishMomentumBufferIndex, bearishMomentumBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bearishMomentumBufferIndex, PLOT_SHOW_DATA, showMomentum); PlotIndexSetInteger(bearishMomentumBufferIndex, PLOT_DRAW_TYPE, bearishMomentumDrawType); // PlotIndexSetDouble(bearishMomentumBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bearishMomentumBufferIndex, PLOT_ARROW, bearishMomentumArrowCode); // // Bullish Rejection ... // ENUM_DRAW_TYPE bullishRejectionDrawType = showRejection ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bullishRejectionBuffer, true); SetIndexBuffer(bullishRejectionBufferIndex, bullishRejectionBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bullishRejectionBufferIndex, PLOT_SHOW_DATA, showRejection); PlotIndexSetInteger(bullishRejectionBufferIndex, PLOT_DRAW_TYPE, bullishRejectionDrawType); // PlotIndexSetDouble(bullishRejectionBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bullishRejectionBufferIndex, PLOT_ARROW, bullishRejectionArrowCode); // // Bearish Rejection ... // ENUM_DRAW_TYPE bearishRejectionDrawType = showRejection ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bearishRejectionBuffer, true); SetIndexBuffer(bearishRejectionBufferIndex, bearishRejectionBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bearishRejectionBufferIndex, PLOT_SHOW_DATA, showRejection); PlotIndexSetInteger(bearishRejectionBufferIndex, PLOT_DRAW_TYPE, bearishRejectionDrawType); // PlotIndexSetDouble(bearishRejectionBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bearishRejectionBufferIndex, PLOT_ARROW, bearishRejectionArrowCode); // // Bullish Pin ... // ENUM_DRAW_TYPE bullishPinDrawType = showPin ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bullishPinBuffer, true); SetIndexBuffer(bullishPinBufferIndex, bullishPinBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bullishPinBufferIndex, PLOT_SHOW_DATA, showPin); PlotIndexSetInteger(bullishPinBufferIndex, PLOT_DRAW_TYPE, bullishPinDrawType); // PlotIndexSetDouble(bullishPinBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bullishPinBufferIndex, PLOT_ARROW, bullishPinArrowCode); // // Bearish Pin ... // ENUM_DRAW_TYPE bearishPinDrawType = showPin ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bearishPinBuffer, true); SetIndexBuffer(bearishPinBufferIndex, bearishPinBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bearishPinBufferIndex, PLOT_SHOW_DATA, showPin); PlotIndexSetInteger(bearishPinBufferIndex, PLOT_DRAW_TYPE, bearishPinDrawType); // PlotIndexSetDouble(bearishPinBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bearishPinBufferIndex, PLOT_ARROW, bearishPinArrowCode); // // Bullish Engulf ... // ENUM_DRAW_TYPE bullishEngulfDrawType = showEngulf ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bullishEngulfBuffer, true); SetIndexBuffer(bullishEngulfBufferIndex, bullishEngulfBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bullishEngulfBufferIndex, PLOT_SHOW_DATA, showEngulf); PlotIndexSetInteger(bullishEngulfBufferIndex, PLOT_DRAW_TYPE, bullishEngulfDrawType); // PlotIndexSetDouble(bullishEngulfBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bullishEngulfBufferIndex, PLOT_ARROW, bullishEngulfArrowCode); // // Bearish Engulf ... // ENUM_DRAW_TYPE bearishEngulfDrawType = showEngulf ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(bearishEngulfBuffer, true); SetIndexBuffer(bearishEngulfBufferIndex, bearishEngulfBuffer, INDICATOR_DATA); // PlotIndexSetInteger(bearishEngulfBufferIndex, PLOT_SHOW_DATA, showEngulf); PlotIndexSetInteger(bearishEngulfBufferIndex, PLOT_DRAW_TYPE, bearishEngulfDrawType); // PlotIndexSetDouble(bearishEngulfBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(bearishEngulfBufferIndex, PLOT_ARROW, bearishEngulfArrowCode); // // Swing Low ... // ENUM_DRAW_TYPE swingLowDrawType = showSwing ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(swingLowBuffer, true); SetIndexBuffer(swingLowBufferIndex, swingLowBuffer, INDICATOR_DATA); // PlotIndexSetInteger(swingLowBufferIndex, PLOT_SHOW_DATA, showSwing); PlotIndexSetInteger(swingLowBufferIndex, PLOT_DRAW_TYPE, swingLowDrawType); // PlotIndexSetDouble(swingLowBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(swingLowBufferIndex, PLOT_ARROW, swingLowArrowCode); // // Swing High ... // ENUM_DRAW_TYPE swingHighDrawType = showSwing ? DRAW_ARROW : DRAW_NONE; // ArraySetAsSeries(swingHighBuffer, true); SetIndexBuffer(swingHighBufferIndex, swingHighBuffer, INDICATOR_DATA); // PlotIndexSetInteger(swingHighBufferIndex, PLOT_SHOW_DATA, showSwing); PlotIndexSetInteger(swingHighBufferIndex, PLOT_DRAW_TYPE, swingHighDrawType); // PlotIndexSetDouble(swingHighBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(swingHighBufferIndex, PLOT_ARROW, swingHighArrowCode); // // DATA Buffers ... // ArraySetAsSeries(atrBuffer, true); SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS); // ArraySetAsSeries(adxBuffer, true); SetIndexBuffer(adxBufferIndex, adxBuffer, INDICATOR_CALCULATIONS); } /** * Calculate Custom Buffers ... * * @param bar_index: Integer, Represent Current Bar ... * @param prevCalculated: Integer, Represent Previous Calculated Bars ... * @param ratesTotal: Integer, Represents All Available Bars ... * @param open: Double Array, History of Open Prices ... * @param high: Double Array, History of High Prices ... * @param close: Double Array, History of Close Prices ... * @param low: Double Array, History of Low Prices ... * @param tickVolume: Long, History of Tick Volumes on Bar ... */ void CalculateBuffers( int bar_index, // Selected Bar Index const int prevCalculated, const int ratesTotal, const double &open[], const double &high[], const double &close[], const double &low[], const long &tickVolume[] // ) { // int barsLimit = startCalculationForLastBars > 0 ? startCalculationForLastBars : 0; // // bool canCalculate = true; bool canCalculate = barsLimit == 0 || bar_index <= barsLimit; if (canCalculate) { // CalculatedPOIs( // bar_index, prevCalculated, ratesTotal, // open, high, close, low, tickVolume // ); // CalculateValues( bar_index, prevCalculated, ratesTotal, open, high, close, low, tickVolume // ); } else { FillBuffersZero(bar_index); } } /** * Fill All Bufers to Zero Vlue for Specified Bar Index ... * * @param barIndex: Integer ... */ void FillBuffersZero(int barIndex) { // maBuffer[barIndex] = 0; atrBuffer[barIndex] = 0; adxBuffer[barIndex] = 0; longSLBuffer[barIndex] = 0; shortSLBuffer[barIndex] = 0; upTrendBuffer[barIndex] = 0; swingLowBuffer[barIndex] = 0; swingHighBuffer[barIndex] = 0; downTrendBuffer[barIndex] = 0; bullishPinBuffer[barIndex] = 0; bearishPinBuffer[barIndex] = 0; bullishEngulfBuffer[barIndex] = 0; bearishEngulfBuffer[barIndex] = 0; bullishMomentumBuffer[barIndex] = 0; bearishMomentumBuffer[barIndex] = 0; bullishRejectionBuffer[barIndex] = 0; bearishRejectionBuffer[barIndex] = 0; } /** * Calculate Vales ... * * @param bar_index: Integer, Represent Current Bar ... * @param prevCalculated: Integer, Represent Previous Calculated Bars ... * @param ratesTotal: Integer, Represents All Available Bars ... * @param open: Double Array, History of Open Prices ... * @param high: Double Array, History of High Prices ... * @param close: Double Array, History of Close Prices ... * @param low: Double Array, History of Low Prices ... * @param tickVolume: Long, History of Tick Volumes on Bar ... */ void CalculateValues( int bar_index, // Selected Bar Index const int prevCalculated, const int ratesTotal, const double &open[], const double &high[], const double &close[], const double &low[], const long &tickVolume[] // ) { // // Prepare Requirements ... // XOHCL iBar; bool isInited = iBar.Init( _Symbol, _Period, bar_index // ); if (!isInited) { // iBar.Clean(); return; } // XOHCL pBar; isInited = iBar.GetPreviousBar(pBar); if (!isInited) { // iBar.Clean(); pBar.Clean(); return; } int pIndex = pBar.Index(); // // Calculate Applied Price ... double iPrice = GetAppliedPrice( appliedTo, open, high, low, close, bar_index // ); // double iMa = maBuffer[bar_index]; double iMaPrev = maBuffer[pIndex]; double iAtr = atrBuffer[bar_index]; double iAdx = adxBuffer[bar_index]; double iAppliedAtr = iAtr * atrMultiplier; // double points = GetPoints(_Symbol); double points10 = 10 * points; // ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; // // SL Buffers ... // double iLongSL = iPrice - iAppliedAtr; double iShortSL = iPrice + iAppliedAtr; // longSLBuffer[bar_index] = iLongSL; shortSLBuffer[bar_index] = iShortSL; // // Trend Buffers ... // bool isUpTrend = // iPrice > iMa && iBar.low < iMa && iAdx > adxThreshold // ; // bool isDownTrend = // iPrice < iMa && iBar.high > iMa && iAdx > adxThreshold // ; // double upTrendValue = 0; double downTrendValue = 0; if (isUpTrend) { upTrendValue = iBar.low; } if (isDownTrend) { downTrendValue = iBar.high; } // upTrendBuffer[bar_index] = upTrendValue; downTrendBuffer[bar_index] = downTrendValue; // // Momentum Buffers ... // bool isMomentum = mXWZBarAnalyser .IsMomentumBar( iBar, iDir, 1, // Extends ... 70 // Body Percent ... ); bool isBullishMomentum = isMomentum && IsBullish(iDir); bool isBearishMomentum = isMomentum && IsBearish(iDir); if (isMomentum) { // double iBullMomentumValue = 0; double iBearMomentumValue = 0; // if (isBullishMomentum) { // double selectedValue = iBar.low; // iBullMomentumValue = selectedValue; } // if (isBearishMomentum) { // double selectedValue = iBar.high; // iBearMomentumValue = selectedValue; } // bullishMomentumBuffer[bar_index] = iBullMomentumValue; bearishMomentumBuffer[bar_index] = iBearMomentumValue; } // // Rejection Buffers ... // bool isRejection = mXWZBarAnalyser .IsRejectionBar( iBar, iDir, 1, // Extends ... 70 // Body Percent ... ); bool isBullishRejection = isRejection && IsBullish(iDir); bool isBearishRejection = isRejection && IsBearish(iDir); if (isRejection) { // double iBullRejectionValue = 0; double iBearRejectionValue = 0; // if (isBullishRejection) { // double selectedValue = iBar.low; // iBullRejectionValue = selectedValue; } // if (isBearishRejection) { // double selectedValue = iBar.high; // iBearRejectionValue = selectedValue; } // bullishRejectionBuffer[bar_index] = iBullRejectionValue; bearishRejectionBuffer[bar_index] = iBearRejectionValue; } // // Pin Buffers ... // bool isPin = mXWZBarAnalyser .IsPinBar( iBar, iDir, 0, // Extends ... 50, // Shadow Percent ... 25 // Body Percent ... ); bool isBullishPin = isPin && IsBullish(iDir); bool isBearishPin = isPin && IsBearish(iDir); if (isPin) { // double iBullPinValue = 0; double iBearPinValue = 0; // if (isBullishPin) { // double selectedValue = iBar.low; // iBullPinValue = selectedValue; } // if (isBearishPin) { // double selectedValue = iBar.high; // iBearPinValue = selectedValue; } // bullishPinBuffer[bar_index] = iBullPinValue; bearishPinBuffer[bar_index] = iBearPinValue; } // // Engulf Buffers ... // bool isEngulf = mXWZBarAnalyser .IsEngulfBar( iBar, iDir, 1, // Extends ... 70 // Body Percent ... ); bool isBullishEngulf = isEngulf && IsBullish(iDir); bool isBearishEngulf = isEngulf && IsBearish(iDir); if (isEngulf) { // double iBullEngulfValue = 0; double iBearEngulfValue = 0; // if (isBullishEngulf) { // double selectedValue = iBar.low; // iBullEngulfValue = selectedValue; } // if (isBearishEngulf) { // double selectedValue = iBar.high; // iBearEngulfValue = selectedValue; } // bullishEngulfBuffer[bar_index] = iBullEngulfValue; bearishEngulfBuffer[bar_index] = iBearEngulfValue; } // // Swing Buffers ... // bool isSwing = mXWZBarAnalyser .IsSwing( iBar, iDir, 2 // Range ... ); bool isSwingLow = isSwing && IsBullish(iDir); bool isSwingHigh = isSwing && IsBearish(iDir); if (isSwing) { // double iSwingLowValue = 0; double iSwingHighValue = 0; // if (isSwingLow) { // double selectedValue = iBar.low; // iSwingLowValue = selectedValue; } // if (isSwingHigh) { // double selectedValue = iBar.high; // iSwingHighValue = selectedValue; } // swingLowBuffer[bar_index] = iSwingLowValue; swingHighBuffer[bar_index] = iSwingHighValue; } // // Cleanup Resources ... // iBar.Clean(); pBar.Clean(); } // // POIS Functions ... // void ConfigurePOIDrawer() { // if (mXWZPOIDrawer == NULL) { return; } // mXWZPOIDrawer.Prefix(ShortName); mXWZPOIDrawer.ChartIdentification(ChartID()); mXWZPOIDrawer.SubWindowIdentification(0); // mXWZPOIDrawer.BullishFVGWidth(2); mXWZPOIDrawer.BullishFVGStyle(STYLE_DOT); mXWZPOIDrawer.BullishFVGColor(clrAqua); // mXWZPOIDrawer.BearishFVGWidth(2); mXWZPOIDrawer.BearishFVGStyle(STYLE_DOT); mXWZPOIDrawer.BearishFVGColor(clrMagenta); // mXWZPOIDrawer.SupportZoneWidth(1); mXWZPOIDrawer.SupportZoneStyle(STYLE_DASHDOTDOT); mXWZPOIDrawer.SupportZoneColor(clrLime); // mXWZPOIDrawer.ResistanceZoneWidth(1); mXWZPOIDrawer.ResistanceZoneStyle(STYLE_DASHDOTDOT); mXWZPOIDrawer.ResistanceZoneColor(clrRed); // mXWZPOIDrawer.BullishOrderBlockWidth(3); mXWZPOIDrawer.BullishOrderBlockStyle(STYLE_DASH); mXWZPOIDrawer.BullishOrderBlockColor(clrAqua); // mXWZPOIDrawer.BearishOrderBlockWidth(3); mXWZPOIDrawer.BearishOrderBlockStyle(STYLE_DASH); mXWZPOIDrawer.BearishOrderBlockColor(clrMagenta); } // void ConfigureAlert() { // mXWZAlert.SetPrefix(ShortName); // mXWZAlert.SetPushAlerts(mXWZPushAlerts); mXWZAlert.SetMailAlerts(mXWZMailAlerts); mXWZAlert.SetEnableAlerts(mXWZEnableAlerts); mXWZAlert.SetTerminalAlerts(mXWZTerminalAlerts); } // void CalculatedPOIs( int bar_index, // Selected Bar Index const int prevCalculated, const int ratesTotal, const double &open[], const double &high[], const double &close[], const double &low[], const long &tickVolume[] // ) { // XOHCL iBar; bool isInited = iBar.Init( _Symbol, _Period, bar_index // ); if (!isInited) { // iBar.Clean(); return; } // XOHCL pBar; isInited = iBar.GetPreviousBar(pBar); if (!isInited) { // iBar.Clean(); pBar.Clean(); return; } // // POI ... DetectPOIs(iBar); UpdatePOIs(iBar); DrawPOIs(); // iBar.Clean(); pBar.Clean(); } // bool CanDetectPOIs() { // bool result = false; // result = // mXWZDetectOrderBlocks || mXWZDetectFairValueGaps || mXWZDetectSupplyZones || mXWZDetectDemandZones // ; // return result; } // void DetectPOIs( XOHCL &bar // ) { // if (!CanDetectPOIs()) { return; } // int barIndex = bar.Index(); // if (barIndex <= 0) { return; } // DetectOrderBlock(bar); DetectSupplyZone(bar); DetectDemandZone(bar); DetectFairValueGap(bar); // } // void UpdatePOIs( XOHCL &bar // ) { // int count = 0; bool has = false; // // OrderBlock(s) ... // has = HasChild(mXWZUnActivatedOBs); if (has) { // SpecifiedUpdateTo( mXWZUnActivatedOBs, bar.time // ); } // // Fair Value Gaps ... // has = HasChild(mXWZUnActivatedFVGs); if (has) { // SpecifiedUpdateTo( mXWZUnActivatedFVGs, bar.time // ); // count = ArraySize(mXWZUnActivatedFVGs); } // // Supply Zones ... // has = HasChild(mXWZUnActivatedSupplyZones); if (has) { // SpecifiedUpdateTo( mXWZUnActivatedSupplyZones, bar.time // ); // count = ArraySize(mXWZUnActivatedSupplyZones); } // // Demand Zones ... // has = HasChild(mXWZUnActivatedDemandZones); if (has) { // SpecifiedUpdateTo( mXWZUnActivatedDemandZones, bar.time // ); // count = ArraySize(mXWZUnActivatedDemandZones); } } // void DrawPOIs() { // int count = 0; bool has = false; bool isCreated = false; // if (!showPOIs) { return; } // // Order Blocks ... if (showOrderBlocks) { // bool showBullishOrderBlocks = true; bool showBearishOrderBlocks = true; // // UnActivated ... count = ArraySize(mXWZUnActivatedOBs); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { // bool isBullish = mXWZUnActivatedOBs[i].IsBullish(); // if ((isBullish && showBullishOrderBlocks) || (!isBullish && showBearishOrderBlocks)) { // XCBaseObject *iObj; isCreated = mXWZPOIDrawer .CreateOrderBlock( mXWZUnActivatedOBs[i], iObj // ); if (isCreated) { mXWZDrawnObjects.Add(iObj); } } } } } // // Fair Value Gaps ... if (showFairValueGaps) { // bool showBullishFairValueGaps = true; bool showBearishFairValueGaps = true; // // UnActivated ... count = ArraySize(mXWZUnActivatedFVGs); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { // bool isBullish = mXWZUnActivatedFVGs[i].IsBullish(); // if ((isBullish && showBullishFairValueGaps) || (!isBullish && showBearishFairValueGaps)) { // XCBaseObject *iObj; isCreated = mXWZPOIDrawer .CreateFairValueGap( mXWZUnActivatedFVGs[i], iObj // ); if (isCreated) { mXWZDrawnObjects.Add(iObj); } } } } } // // Supply Zones ... if (showSupplyZones) { // // UnActivated ... count = ArraySize(mXWZUnActivatedSupplyZones); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { // XCSupplyZoneObject *iObj; isCreated = mXWZPOIDrawer .CreateSupplyZone( mXWZUnActivatedSupplyZones[i], iObj // ); if (isCreated) { mXWZDrawnObjects.Add(iObj); } } } // // Activated ... count = ArraySize(mXWZActivatedSupplyZones); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { } } } // // Demand Zones ... if (showDemandZones) { // // UnActivated ... count = ArraySize(mXWZUnActivatedDemandZones); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { // XCDemandZoneObject *iObj; isCreated = mXWZPOIDrawer .CreateDemandZone( mXWZUnActivatedDemandZones[i], iObj // ); if (isCreated) { mXWZDrawnObjects.Add(iObj); } } } // // Activated ... count = ArraySize(mXWZActivatedDemandZones); has = IsValidSize(count); if (has) { // for (int i = 0; i < count; i++) { } } } // ChartRedraw(); // } // // // // // Detect Order Block ... void DetectOrderBlock(XOHCL &bar) { // int idx = -1; int count = 0; bool has = false; // if (!mXWZDetectOrderBlocks) { return; } // int iBarIndex = bar.Index(orderBlockTF); // XOHCL iBar; bool isInited = iBar.Init( bar.symbol, orderBlockTF, iBarIndex // ); if (!isInited) { return; } // XOHCL zoneBar; ENUM_X_DIRECTION zoneDir; has = mXWZBarAnalyser.HasOrderBlock( iBar, zoneBar, zoneDir, mXWZOBFVGSameBars // ); // if (!has) { // zoneBar.Clean(); return; } // XCOrderBlock *zone; zone = new XCOrderBlock(); has = zone.Init( zoneBar, zoneDir // ); // if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Check Start ... if (mXWZForceStarteds) { // XOHCL startedBar; bool isBodyOut = false; bool isStarted = zone.IsStarted( zoneDir, startedBar, isBodyOut, iBar.period // ); // has = isStarted; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); startedBar.Clean(); // return; } // startedBar.Clean(); } // // Check Activation ... if (mXWZForceActivation) { // XOHCL activationBar; bool isActivationBarBodyIn = false; bool isActivated = zone.IsActivated( zoneDir, activationBar, isActivationBarBodyIn, false, iBar.period // ); // has = !isActivated; if (!has) { // if (!mXWZIgnoreUnActivateds) { // zone.To(activationBar.time); // Add( zone, mXWZActivatedOBs // ); } // zoneBar.Clean(); ZeroMemory(zone); activationBar.Clean(); // return; } // activationBar.Clean(); } // // Check Breaktion ... if (mXWZForceUnBreaked) { // XOHCL breakedBar; bool isBodyOut = false; bool isBreaked = zone.IsBreaked( zoneDir, breakedBar, isBodyOut, false, iBar.period // ); // has = !isBreaked; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); breakedBar.Clean(); // return; } // breakedBar.Clean(); } // // Check Indexes ... // // UnActivateds ... idx = FindIndex( zone, mXWZUnActivatedOBs // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Activateds ... idx = FindIndex( zone, mXWZActivatedOBs // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // has = zone != NULL && zone.IsValid(); if (has) { // zone.To(bar.time); // Add( zone, mXWZUnActivatedOBs // ); } // iBar.Clean(); zoneBar.Clean(); } // // Detect Fair Value Gap ... void DetectFairValueGap(XOHCL &bar) { // int idx = -1; int count = 0; bool has = false; // if (!mXWZDetectFairValueGaps) { return; } // int iBarIndex = bar.Index(fairValueGapTF); // XOHCL iBar; bool isInited = iBar.Init( bar.symbol, fairValueGapTF, iBarIndex // ); if (!isInited) { return; } // XOHCL zoneEndBar; XOHCL zoneStartBar; ENUM_X_DIRECTION zoneDir; has = mXWZBarAnalyser.HasFairValueGap( iBar, zoneStartBar, zoneEndBar, zoneDir, mXWZOBFVGSameBars // ); // if (!has) { // zoneEndBar.Clean(); zoneStartBar.Clean(); return; } // XCFVG *zone; zone = new XCFVG(); has = zone.Init( zoneStartBar, zoneEndBar, zoneDir // ); // if (!has) { // ZeroMemory(zone); zoneEndBar.Clean(); zoneStartBar.Clean(); // return; } // // Check Start ... if (mXWZForceStarteds) { // XOHCL startedBar; bool isBodyOut = false; bool isStarted = zone.IsStarted( zoneDir, startedBar, isBodyOut, iBar.period // ); // has = isStarted; if (!has) { // ZeroMemory(zone); startedBar.Clean(); zoneEndBar.Clean(); zoneStartBar.Clean(); // return; } // startedBar.Clean(); } // // Check Activation ... if (mXWZForceActivation) { // XOHCL activationBar; bool isActivationBarBodyIn = false; bool isActivated = zone.IsActivated( zoneDir, activationBar, isActivationBarBodyIn, false, iBar.period // ); // has = !isActivated; if (!has) { // ZeroMemory(zone); zoneEndBar.Clean(); zoneStartBar.Clean(); activationBar.Clean(); // return; } // activationBar.Clean(); } // // Check Breaktion ... if (mXWZForceUnBreaked) { // XOHCL breakedBar; bool isBodyOut = false; bool isBreaked = zone.IsBreaked( zoneDir, breakedBar, isBodyOut, false, iBar.period // ); // has = !isBreaked; if (!has) { // ZeroMemory(zone); breakedBar.Clean(); zoneEndBar.Clean(); zoneStartBar.Clean(); // return; } // breakedBar.Clean(); } // // Check Indexes ... // // UnActivateds ... idx = FindIndex( zone, mXWZUnActivatedFVGs // ); has = !IsValidIndex(idx); if (!has) { // ZeroMemory(zone); zoneEndBar.Clean(); zoneStartBar.Clean(); // return; } // // Activateds ... idx = FindIndex( zone, mXWZActivatedFVGs // ); has = !IsValidIndex(idx); if (!has) { // ZeroMemory(zone); zoneEndBar.Clean(); zoneStartBar.Clean(); // return; } // has = zone != NULL && zone.IsValid(); if (has) { // zone.To(bar.time); // Add( zone, mXWZUnActivatedFVGs // ); } // iBar.Clean(); zoneEndBar.Clean(); zoneStartBar.Clean(); } // // Supply Zone ... void DetectSupplyZone(XOHCL &bar) { // int idx = -1; int count = 0; bool has = false; // if (!mXWZDetectSupplyZones) { return; } // int iBarIndex = bar.Index(supDemTF); // XOHCL iBar; bool isInited = iBar.Init( bar.symbol, supDemTF, iBarIndex // ); if (!isInited) { return; } // int range = mXWZSuResRange * 2; // XOHCL zoneBar; ENUM_X_DIRECTION zoneDir = X_DIRECTION_BEARISH; has = mXWZBarAnalyser.HasResistance( iBar, zoneBar, range // ); // if (!has) { // zoneBar.Clean(); return; } // XCSupplyZone *zone; zone = new XCSupplyZone(); has = zone.Init( zoneBar, range, true // ); // if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Check Start ... if (mXWZForceStarteds) { // XOHCL startedBar; bool isBodyOut = false; bool isStarted = zone.IsStarted( zoneDir, startedBar, isBodyOut, iBar.period // ); // has = isStarted; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); startedBar.Clean(); // return; } // startedBar.Clean(); } // // Check Activation ... if (mXWZForceActivation) { // XOHCL activationBar; bool isActivationBarBodyIn = false; bool isActivated = zone.IsActivated( zoneDir, activationBar, isActivationBarBodyIn, false, iBar.period // ); // has = !isActivated; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); activationBar.Clean(); // return; } // activationBar.Clean(); } // // Check Breaktion ... if (mXWZForceUnBreaked) { // XOHCL breakedBar; bool isBodyOut = false; bool isBreaked = zone.IsBreaked( zoneDir, breakedBar, isBodyOut, false, iBar.period // ); // has = !isBreaked; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); breakedBar.Clean(); // return; } // breakedBar.Clean(); } // // Check Indexes ... // // UnActivateds ... idx = FindIndex( zone, mXWZUnActivatedSupplyZones // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Activateds ... idx = FindIndex( zone, mXWZActivatedSupplyZones // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // has = zone != NULL && zone.IsValid(); if (has) { // zone.To(bar.time); // Add( zone, mXWZUnActivatedSupplyZones // ); } // iBar.Clean(); zoneBar.Clean(); } // // Demand Zone ... void DetectDemandZone(XOHCL &bar) { // int idx = -1; int count = 0; bool has = false; // if (!mXWZDetectDemandZones) { return; } // int iBarIndex = bar.Index(supDemTF); // XOHCL iBar; bool isInited = iBar.Init( bar.symbol, supDemTF, iBarIndex // ); if (!isInited) { return; } // int range = mXWZSuResRange * 2; // XOHCL zoneBar; ENUM_X_DIRECTION zoneDir = X_DIRECTION_BULLISH; has = mXWZBarAnalyser.HasSupport( iBar, zoneBar, range // ); // if (!has) { // zoneBar.Clean(); return; } // XCDemandZone *zone; zone = new XCDemandZone(); has = zone.Init( zoneBar, range, true // ); // if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Check Start ... if (mXWZForceStarteds) { // XOHCL startedBar; bool isBodyOut = false; bool isStarted = zone.IsStarted( zoneDir, startedBar, isBodyOut, iBar.period // ); // has = isStarted; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); startedBar.Clean(); // return; } // startedBar.Clean(); } // // Check Activation ... if (mXWZForceActivation) { // XOHCL activationBar; bool isActivationBarBodyIn = false; bool isActivated = zone.IsActivated( zoneDir, activationBar, isActivationBarBodyIn, false, iBar.period // ); // has = !isActivated; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); activationBar.Clean(); // return; } // activationBar.Clean(); } // // Check Breaktion ... if (mXWZForceUnBreaked) { // XOHCL breakedBar; bool isBodyOut = false; bool isBreaked = zone.IsBreaked( zoneDir, breakedBar, isBodyOut, false, iBar.period // ); // has = !isBreaked; if (!has) { // zoneBar.Clean(); ZeroMemory(zone); breakedBar.Clean(); // return; } // breakedBar.Clean(); } // // Check Indexes ... // // UnActivateds ... idx = FindIndex( zone, mXWZUnActivatedDemandZones // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // // Activateds ... idx = FindIndex( zone, mXWZActivatedDemandZones // ); has = !IsValidIndex(idx); if (!has) { // zoneBar.Clean(); ZeroMemory(zone); // return; } // has = zone != NULL && zone.IsValid(); if (has) { // zone.To(bar.time); // Add( zone, mXWZUnActivatedDemandZones // ); } // iBar.Clean(); zoneBar.Clean(); } //