/////////////////////////////////////////////////////// // // SaherElm IT Center XBEEA MQL5 Expert Advisor // ------------------------------------------------- // Name: XBEEA // Description: an Exper Advisor which used RSI and MA // to Analyse Market ... // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // //////////////////////////////////////////////////////x // // Global Properties ... #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm XBEEA" #property strict // #define ShortName "XBEEA" // enum ENUM_X_ZIGZAG_BUFFERS { X_ZIGZAG_MAIN_LINE = 0, X_ZIGZAG_PIVOTS_LINE = 1, }; // #include "../Libraries/x-saherelm.log.lib.mq5" #include "../Libraries/x-saherelm.draw.lib.mq5" #include "../Libraries/x-saherelm.common.lib.mq5" #include "../Classes/x-saherelm.xtrade.class.mq5" // #include "../Helpers/x-saherelm.xche.helper.mq5" // // Inputs ... // long xBEEAMagicNumber = 78692110; // Magic Number int xBEEASlippage = 10; // Slippgae // input double xBEEAVolume = 0.01; // // Indicator Inputs ... // // Maarket ... input group "Cycles"; // // Short ... input group "Short"; input ENUM_X_PERIOD_METHOD scMode = X_PERIOD_MANUALLY; // Method input ENUM_TIMEFRAMES scPeriod = PERIOD_H4; // Period // // Presentation ... input bool xBEEADrawSCLabel = true; input bool xBEEADrawSCCBar = true; input bool xBEEADrawSCPBar = false; input bool xBEEADrawSCCMid = true; input bool xBEEADrawSCPMid = true; // // Medium ... input group "Medium"; input ENUM_X_PERIOD_METHOD mcMode = X_PERIOD_MANUALLY; // Method input ENUM_TIMEFRAMES mcPeriod = PERIOD_H12; // Mid Period // // Presentation ... input bool xBEEADrawMCLabel = true; input bool xBEEADrawMCCBar = true; input bool xBEEADrawMCPBar = false; input bool xBEEADrawMCCMid = true; input bool xBEEADrawMCPMid = true; // // Long ... input group "Long"; input ENUM_X_PERIOD_METHOD lcMode = X_PERIOD_MANUALLY; // Method input ENUM_TIMEFRAMES lcPeriod = PERIOD_D1; // Long Period // // Presentation ... input bool xBEEADrawLCLabel = true; input bool xBEEADrawLCCBar = true; input bool xBEEADrawLCPBar = false; input bool xBEEADrawLCCMid = true; input bool xBEEADrawLCPMid = true; // // Hind ... input group "Hind"; input ENUM_X_PERIOD_METHOD hcMode = X_PERIOD_MANUALLY; // Method input ENUM_TIMEFRAMES hcPeriod = PERIOD_W1; // Hind Period // // Moving Averages ... input group "Moving Average"; input int xBEEAMaFastLength = 9; // Fast Length input int xBEEAMaSlowLength = 18; // Slow Length input int xBEEAMaShift = 0; // Shift input ENUM_MA_METHOD xBEEAMaMethod = MODE_EMA; // Method input ENUM_APPLIED_PRICE xBEEAMaAppliedTo = PRICE_CLOSE; // AppliedTo // // Presentation ... input bool xBEEADrawHCLabel = true; input bool xBEEADrawHCCBar = true; input bool xBEEADrawHCPBar = true; input bool xBEEADrawHCCMid = true; input bool xBEEADrawHCPMid = true; // // Vars ... // string xBEEASymbol; ENUM_TIMEFRAMES xBEEAPeriod; // int maxBuys = 1; int maxSells = 1; int buyCount = 0; int sellCount = 0; // double _tp = 0; double _sl = 0; double _entry = 0; ENUM_POSITION_TYPE _type = NULL; // MqlTick xBEEATick; XSCTrade *xBEEATrader; // // ZigZag ... int zigZagHandler = INVALID_HANDLE; double zigZagBuffer[]; bool isZigZagInPeak; // // Cycles Definitions ... // XMarketCycle sc; XDrawSpecifications scCMidSpecs; XDrawSpecifications scPMidSpecs; XOHCLDrawSpecification scCBSpecs; XOHCLDrawSpecification scPBSpecs; // XOHCL scCBar; double scCMidLine; XOHCL scPBar; double scPMidLine; // double scTrndBuffer[]; double scFastBuffer[]; double scSlowBuffer[]; double scLongExit1[]; double scLongExit2[]; double scShortExit1[]; double scShortExit2[]; int scCheHandler = INVALID_HANDLE; int scFastHandler = INVALID_HANDLE; int scSlowHandler = INVALID_HANDLE; int scTrndHandler = INVALID_HANDLE; // bool isSCCBullish; bool isSCPBullish; bool isSCFastOverSlow; bool isSCFastUnderSlow; // XMarketCycle mc; XDrawSpecifications mcCMidSpecs; XDrawSpecifications mcPMidSpecs; XOHCLDrawSpecification mcCBSpecs; XOHCLDrawSpecification mcPBSpecs; // XOHCL mcCBar; double mcCMidLine; XOHCL mcPBar; double mcPMidLine; // double mcTrndBuffer[]; double mcFastBuffer[]; double mcSlowBuffer[]; double mcLongExit1[]; double mcLongExit2[]; double mcShortExit1[]; double mcShortExit2[]; int mcFastHandler = INVALID_HANDLE; int mcSlowHandler = INVALID_HANDLE; int mcTrndHandler = INVALID_HANDLE; int mcCheHandler = INVALID_HANDLE; // bool isMCCBullish; bool isMCPBullish; bool isMCFastOverSlow; bool isMCFastUnderSlow; // XMarketCycle lc; XDrawSpecifications lcCMidSpecs; XDrawSpecifications lcPMidSpecs; XOHCLDrawSpecification lcCBSpecs; XOHCLDrawSpecification lcPBSpecs; // XOHCL lcCBar; double lcCMidLine; XOHCL lcPBar; double lcPMidLine; // double lcTrndBuffer[]; double lcFastBuffer[]; double lcSlowBuffer[]; double lcLongExit1[]; double lcLongExit2[]; double lcShortExit1[]; double lcShortExit2[]; int lcFastHandler = INVALID_HANDLE; int lcSlowHandler = INVALID_HANDLE; int lcTrndHandler = INVALID_HANDLE; int lcCheHandler = INVALID_HANDLE; // bool isLCCBullish; bool isLCPBullish; bool isLCFastOverSlow; bool isLCFastUnderSlow; // XMarketCycle hc; XDrawSpecifications hcCMidSpecs; XDrawSpecifications hcPMidSpecs; XOHCLDrawSpecification hcCBSpecs; XOHCLDrawSpecification hcPBSpecs; // XOHCL hcCBar; double hcCMidLine; XOHCL hcPBar; double hcPMidLine; // double hcTrndBuffer[]; double hcFastBuffer[]; double hcSlowBuffer[]; double hcLongExit1[]; double hcLongExit2[]; double hcShortExit1[]; double hcShortExit2[]; int hcFastHandler = INVALID_HANDLE; int hcSlowHandler = INVALID_HANDLE; int hcTrndHandler = INVALID_HANDLE; int hcCheHandler = INVALID_HANDLE; // bool isHCCBullish; bool isHCPBullish; bool isHCFastOverSlow; bool isHCFastUnderSlow; // int mBullishScore; int mBearishScore; bool xBEEAIsSummaryTrendBullish; bool xBEEALastIsSummaryTrendBullish; string mLastCommentHash; // int mMaxBullishScore = 0; int mMinBullishScore = 0; int mMaxBearishScore = 0; int mMinBearishScore = 0; // double mPivots[]; bool mPivotsScanStart; int mPivotsLoopback = 52; int mMinRequiredPivots = 400; int mNumberPivotsSequential = 10; // X121CHEInputs xBEEACheInputs; XSCX121CHEHelper xBEEACheHelper; // // Event Handlers ... // // Initialization ... int OnInit() { // if (xBEEASymbol == NULL || StringLen(xBEEASymbol) <= 0) { xBEEASymbol = _Symbol; } // if (xBEEAPeriod == NULL) { xBEEAPeriod = _Period; } // // Validate Inputs ... if (!XBEEAValidateInputs()) { return INIT_PARAMETERS_INCORRECT; } // logTag = ShortName; drawPrefix = ShortName; // // Initialize XTrader ... xBEEATrader = new XSCTrade( xBEEASlippage, xBEEAMagicNumber); // // Init Indicators ... if (!InitIndicators()) { return INIT_PARAMETERS_INCORRECT; } // // Prepare Style Specs ... PrepareStyleSpecs(); // // Init Succeed ... return INIT_SUCCEEDED; } // // DeInitialization ... 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 // // De Initialize XBEEA Providers ... delete xBEEATrader; // // Short ... IndicatorRelease(scCheHandler); IndicatorRelease(scTrndHandler); IndicatorRelease(scFastHandler); IndicatorRelease(scSlowHandler); // // Medium ... IndicatorRelease(mcCheHandler); IndicatorRelease(mcTrndHandler); IndicatorRelease(mcFastHandler); IndicatorRelease(mcSlowHandler); // // Long ... IndicatorRelease(lcCheHandler); IndicatorRelease(lcTrndHandler); IndicatorRelease(lcFastHandler); IndicatorRelease(lcSlowHandler); // // Hind ... IndicatorRelease(hcCheHandler); IndicatorRelease(hcTrndHandler); IndicatorRelease(hcFastHandler); IndicatorRelease(hcSlowHandler); // IndicatorRelease(zigZagHandler); } // // On Tick Handler ... void OnTick() { // if (!HasEnoughPivots()) { // if (!mPivotsScanStart) { ProcessPivots(); } // return; } // if (!IsNewCandle( xBEEASymbol, xBEEAPeriod)) { return; } // // Reading Tick ... if (!SymbolInfoTick(xBEEASymbol, xBEEATick)) { return; } // // Reading Data From XDSR Indicator ... ReadData(); // // Counting Currently Open Positions ... buyCount = xBEEATrader.CountPositions(xBEEASymbol, POSITION_TYPE_BUY); sellCount = xBEEATrader.CountPositions(xBEEASymbol, POSITION_TYPE_SELL); // if (buyCount < maxBuys) { // // Check For Buy Signals ... } // if (sellCount < maxSells) { // // Check for Sell Signals ... } // UpdatePivots(); // string comment = XBEEAGenerateState(); Comment(comment); } // // Custom Functions ... // // Validate Variables nd Inputs ... bool XBEEAValidateInputs() { // bool result = false; // result = // xBEEASlippage > 0 && xBEEAMagicNumber > 0 // && // // Short ... IsValidCycle( scMode, scPeriod) // && // // Medium ... IsValidCycle( mcMode, mcPeriod) // && // // Long ... IsValidCycle( lcMode, lcPeriod) // && // // Hind ... IsValidCycle( hcMode, hcPeriod) // ; // return result; } // // Initial Indicators ... bool InitIndicators() { // bool result = false; // // Init XZG Indicator ... zigZagHandler = iCustom( xBEEASymbol, xBEEAPeriod, "x-saherelm.x121.xzg", // // Inputs ... // TODO: // add these inputs to TODO ... 12, // Depth ... 5, // Deviation ... 3, // Back Step ... 1 // MODE ENUM_X_ZG_PRICE_MODE (X_ZG_PRICE_HIGH_LOW_MODE) ... // ); result = zigZagHandler != INVALID_HANDLE; if (!result) { return result; } // // Here we have to Init XMarketCycles also ... result = InitMarketCycles(); // xBEEACheInputs.Default(); result = xBEEACheInputs.IsValid(); if (!result) { return result; } // result = xBEEACheHelper.Init( xBEEASymbol, xBEEAPeriod, xBEEACheInputs); if (!result) { return result; } // return result; } // // Initial Market Cycles ... bool InitMarketCycles() { // bool result = false; // // Short ... sc.method = scMode; sc.period = scPeriod; result = sc.Init( xBEEASymbol, xBEEAPeriod, X_MARKET_CYCLE_SHORT // ); if (!result) { return result; } // // Trend ... ArraySetAsSeries(scTrndBuffer, true); scTrndHandler = iCustom( xBEEASymbol, sc.period, "x-saherelm.x121.xstr", // // Inputs ... // // ATR ... "", 14, // Length 3.5, // Multiplier PRICE_MEDIAN, // Applied To // // Presentation ... "", true, // Show Trends false // Fill Trends // ); // // Che ... ArraySetAsSeries(scLongExit1, true); ArraySetAsSeries(scLongExit2, true); ArraySetAsSeries(scShortExit1, true); ArraySetAsSeries(scShortExit2, true); scCheHandler = iCustom( xBEEASymbol, sc.period, "x-saherelm.x121.xche", // // Inputs ... // // Market ... "", 35, 26, 3.0, 3.5, // // Calculations ... "", PRICE_HIGH, PRICE_LOW, // // Presentation ... "", true, true, true, true // ); // // MA's ... ArraySetAsSeries(scFastBuffer, true); scFastHandler = iMA( xBEEASymbol, sc.period, xBEEAMaFastLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); ArraySetAsSeries(scSlowBuffer, true); scSlowHandler = iMA( xBEEASymbol, sc.period, xBEEAMaSlowLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); // result = // scCheHandler != INVALID_HANDLE && scTrndHandler != INVALID_HANDLE && scFastHandler != INVALID_HANDLE && scSlowHandler != INVALID_HANDLE // ; if (!result) { return result; } // // Medium ... mc.method = mcMode; mc.period = mcPeriod; result = mc.Init( xBEEASymbol, xBEEAPeriod, X_MARKET_CYCLE_MEDIUM // ); if (!result) { return result; } // // Trend ... ArraySetAsSeries(mcTrndBuffer, true); mcTrndHandler = iCustom( xBEEASymbol, mc.period, "x-saherelm.x121.xstr", // // Inputs ... // // ATR ... "", 14, // Length 3.5, // Multiplier PRICE_MEDIAN, // Applied To // // Presentation ... "", true, // Show Trends false // Fill Trends // ); // // Che ... ArraySetAsSeries(mcLongExit1, true); ArraySetAsSeries(mcLongExit2, true); ArraySetAsSeries(mcShortExit1, true); ArraySetAsSeries(mcShortExit2, true); mcCheHandler = iCustom( xBEEASymbol, mc.period, "x-saherelm.x121.xche", // // Inputs ... // // Market ... "", 35, 26, 3.0, 3.5, // // Calculations ... "", PRICE_HIGH, PRICE_LOW, // // Presentation ... "", true, true, true, true // ); // // MA's ... ArraySetAsSeries(mcFastBuffer, true); mcFastHandler = iMA( xBEEASymbol, mc.period, xBEEAMaFastLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); ArraySetAsSeries(mcSlowBuffer, true); mcSlowHandler = iMA( xBEEASymbol, mc.period, xBEEAMaSlowLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); // result = // mcTrndHandler != INVALID_HANDLE && mcFastHandler != INVALID_HANDLE && mcSlowHandler != INVALID_HANDLE // ; if (!result) { return result; } // // Long ... lc.method = lcMode; lc.period = lcPeriod; result = lc.Init( xBEEASymbol, xBEEAPeriod, X_MARKET_CYCLE_LONG // ); if (!result) { return result; } // // Trend ... ArraySetAsSeries(lcTrndBuffer, true); lcTrndHandler = iCustom( xBEEASymbol, lc.period, "x-saherelm.x121.xstr", // // Inputs ... // // ATR ... "", 14, // Length 3.5, // Multiplier PRICE_MEDIAN, // Applied To // // Presentation ... "", true, // Show Trends false // Fill Trends // ); // // Che ... ArraySetAsSeries(lcLongExit1, true); ArraySetAsSeries(lcLongExit2, true); ArraySetAsSeries(lcShortExit1, true); ArraySetAsSeries(lcShortExit2, true); lcCheHandler = iCustom( xBEEASymbol, lc.period, "x-saherelm.x121.xche", // // Inputs ... // // Market ... "", 35, 26, 3.0, 3.5, // // Calculations ... "", PRICE_HIGH, PRICE_LOW, // // Presentation ... "", true, true, true, true // ); // // MA's ... ArraySetAsSeries(lcFastBuffer, true); lcFastHandler = iMA( xBEEASymbol, lc.period, xBEEAMaFastLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); ArraySetAsSeries(lcSlowBuffer, true); lcSlowHandler = iMA( xBEEASymbol, lc.period, xBEEAMaSlowLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); // result = // lcTrndHandler != INVALID_HANDLE && lcFastHandler != INVALID_HANDLE && lcSlowHandler != INVALID_HANDLE // ; if (!result) { return result; } // // Hind ... hc.method = hcMode; hc.period = hcPeriod; result = hc.Init( xBEEASymbol, xBEEAPeriod, X_MARKET_CYCLE_HIND // ); if (!result) { return result; } // // Trend ... ArraySetAsSeries(hcTrndBuffer, true); hcTrndHandler = iCustom( xBEEASymbol, hc.period, "x-saherelm.x121.xstr", // // Inputs ... // // ATR ... "", 14, // Length 3.5, // Multiplier PRICE_MEDIAN, // Applied To // // Presentation ... "", true, // Show Trends false // Fill Trends // ); // // Che ... ArraySetAsSeries(hcLongExit1, true); ArraySetAsSeries(hcLongExit2, true); ArraySetAsSeries(hcShortExit1, true); ArraySetAsSeries(hcShortExit2, true); hcCheHandler = iCustom( xBEEASymbol, hc.period, "x-saherelm.x121.xche", // // Inputs ... // // Market ... "", 35, 26, 3.0, 3.5, // // Calculations ... "", PRICE_HIGH, PRICE_LOW, // // Presentation ... "", true, true, true, true // ); // // MA's ... ArraySetAsSeries(hcFastBuffer, true); hcFastHandler = iMA( xBEEASymbol, hc.period, xBEEAMaFastLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); ArraySetAsSeries(hcSlowBuffer, true); hcSlowHandler = iMA( xBEEASymbol, hc.period, xBEEAMaSlowLength, xBEEAMaShift, xBEEAMaMethod, xBEEAMaAppliedTo // ); // result = // hcTrndHandler != INVALID_HANDLE && hcFastHandler != INVALID_HANDLE && hcSlowHandler != INVALID_HANDLE // ; if (!result) { return result; } // return result; } // // Prepare Style Specs for Drawings ... void PrepareStyleSpecs() { // // Each Cycle has 2 Kind of Specs: // 1- MidLines; // 2- Candles; // // also for each Cycle we have 2 Series of Specs: // 1- For Current Bar; // 2- Prev Bar; // // Short ... // // Current ... // // MidLine ... scCMidSpecs.width = 1; scCMidSpecs.style = STYLE_DOT; scCMidSpecs.clr = clrSpringGreen; scCMidSpecs.Label( sc.prefix + "_C MID", scCMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... scCBSpecs.Default(); scCBSpecs.Width(1); scCBSpecs.Style(STYLE_DOT); // // scCBSpecs.openStyle.clr = clrDarkOliveGreen; // scCBSpecs.closeStyle.clr = clrDarkOrchid; // scCBSpecs.highStyle.clr = clrDarkSeaGreen; // scCBSpecs.lowStyle.clr = clrPink; // scCBSpecs.openStyle.Label( sc.prefix + "_C O", scCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scCBSpecs.highStyle.Label( sc.prefix + "_C H", scCBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scCBSpecs.closeStyle.Label( sc.prefix + "_C C", scCBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scCBSpecs.lowStyle.Label( sc.prefix + "_C L", scCBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Prev ... // // MidLine ... scPMidSpecs.width = 2; scPMidSpecs.style = STYLE_SOLID; scPMidSpecs.clr = clrLimeGreen; scPMidSpecs.Label( sc.prefix + "_P MID", scPMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... scPBSpecs.Default(); scPBSpecs.Width(2); // // scPBSpecs.openStyle.clr = ; // scPBSpecs.closeStyle.clr = ; // scPBSpecs.highStyle.clr = ; // scPBSpecs.lowStyle.clr = ; // scPBSpecs.openStyle.Label( sc.prefix + "_P O", scPBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scPBSpecs.highStyle.Label( sc.prefix + "_P H", scPBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scPBSpecs.closeStyle.Label( sc.prefix + "_P C", scPBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); scPBSpecs.lowStyle.Label( sc.prefix + "_P L", scPBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Medium ... // // Current ... // // MidLine ... mcCMidSpecs.width = 1; mcCMidSpecs.style = STYLE_DOT; mcCMidSpecs.clr = clrSteelBlue; mcCMidSpecs.Label( mc.prefix + "_C MID", mcCMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... mcCBSpecs.Default(); mcCBSpecs.Width(1); mcCBSpecs.Style(STYLE_DOT); // // mcCBSpecs.openStyle.clr = clrDarkOliveGreen; // mcCBSpecs.closeStyle.clr = clrDarkOrchid; // mcCBSpecs.highStyle.clr = clrDarkSeaGreen; // mcCBSpecs.lowStyle.clr = clrPink; // mcCBSpecs.openStyle.Label( mc.prefix + "_C O", mcCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcCBSpecs.highStyle.Label( mc.prefix + "_C H", mcCBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcCBSpecs.closeStyle.Label( mc.prefix + "_C C", mcCBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcCBSpecs.lowStyle.Label( mc.prefix + "_C L", mcCBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Prev ... // // MidLine ... mcPMidSpecs.width = 2; mcPMidSpecs.style = STYLE_SOLID; mcPMidSpecs.clr = clrRoyalBlue; mcPMidSpecs.Label( mc.prefix + "_P MID", mcPMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... mcPBSpecs.Default(); mcPBSpecs.Width(2); // // mcPBSpecs.openStyle.clr = ; // mcPBSpecs.closeStyle.clr = ; // mcPBSpecs.highStyle.clr = ; // mcPBSpecs.lowStyle.clr = ; // mcPBSpecs.openStyle.Label( mc.prefix + "_P O", mcCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcPBSpecs.highStyle.Label( mc.prefix + "_P H", mcPBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcPBSpecs.closeStyle.Label( mc.prefix + "_P C", mcPBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); mcPBSpecs.lowStyle.Label( mc.prefix + "_P L", mcPBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Long ... // // Current ... // // MidLine ... lcCMidSpecs.width = 1; lcCMidSpecs.style = STYLE_DOT; lcCMidSpecs.clr = clrYellow; lcCMidSpecs.Label( lc.prefix + "_C MID", lcCMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... lcCBSpecs.Default(); lcCBSpecs.Width(1); lcCBSpecs.Style(STYLE_DOT); // // lcCBSpecs.openStyle.clr = clrDarkOliveGreen; // lcCBSpecs.closeStyle.clr = clrDarkOrchid; // lcCBSpecs.highStyle.clr = clrDarkSeaGreen; // lcCBSpecs.lowStyle.clr = clrPink; // lcCBSpecs.openStyle.Label( lc.prefix + "_C O", lcCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcCBSpecs.highStyle.Label( lc.prefix + "_C H", lcCBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcCBSpecs.closeStyle.Label( lc.prefix + "_C C", lcCBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcCBSpecs.lowStyle.Label( lc.prefix + "_C L", lcCBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Prev ... // // MidLine ... lcPMidSpecs.width = 2; lcPMidSpecs.style = STYLE_SOLID; lcPMidSpecs.clr = clrOrange; lcPMidSpecs.Label( lc.prefix + "_P MID", lcPMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... lcPBSpecs.Default(); lcPBSpecs.Width(2); // // lcPBSpecs.openStyle.clr = ; // lcPBSpecs.closeStyle.clr = ; // lcPBSpecs.highStyle.clr = ; // lcPBSpecs.lowStyle.clr = ; // lcPBSpecs.openStyle.Label( lc.prefix + "_P O", lcCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcPBSpecs.highStyle.Label( lc.prefix + "_P H", lcPBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcPBSpecs.closeStyle.Label( lc.prefix + "_P C", lcPBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); lcPBSpecs.lowStyle.Label( lc.prefix + "_P L", lcPBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Hind ... // // Current ... // // MidLine ... hcCMidSpecs.width = 1; hcCMidSpecs.style = STYLE_DOT; hcCMidSpecs.clr = clrSandyBrown; hcCMidSpecs.Label( hc.prefix + "_C MID", hcCMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... hcCBSpecs.Default(); hcCBSpecs.Width(1); hcCBSpecs.Style(STYLE_DOT); // // hcCBSpecs.openStyle.clr = clrDarkOliveGreen; // hcCBSpecs.closeStyle.clr = clrDarkOrchid; // hcCBSpecs.highStyle.clr = clrDarkSeaGreen; // hcCBSpecs.lowStyle.clr = clrPink; // hcCBSpecs.openStyle.Label( hc.prefix + "_C O", hcCBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcCBSpecs.highStyle.Label( hc.prefix + "_C H", hcCBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcCBSpecs.closeStyle.Label( hc.prefix + "_C C", hcCBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcCBSpecs.lowStyle.Label( hc.prefix + "_C L", hcCBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // Prev ... // // MidLine ... hcPMidSpecs.width = 2; hcPMidSpecs.style = STYLE_SOLID; hcPMidSpecs.clr = clrSaddleBrown; hcPMidSpecs.Label( hc.prefix + "_P MID", hcPMidSpecs.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); // // XOHCL ... hcPBSpecs.Default(); hcPBSpecs.Width(2); // // hcPBSpecs.openStyle.clr = clrDarkOliveGreen; // hcPBSpecs.closeStyle.clr = clrDarkOrchid; // hcPBSpecs.highStyle.clr = clrDarkSeaGreen; // hcPBSpecs.lowStyle.clr = clrPink; // hcPBSpecs.openStyle.Label( hc.prefix + "_P O", hcPBSpecs.openStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcPBSpecs.highStyle.Label( hc.prefix + "_P H", hcPBSpecs.highStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcPBSpecs.closeStyle.Label( hc.prefix + "_P C", hcPBSpecs.closeStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); hcPBSpecs.lowStyle.Label( hc.prefix + "_P L", hcPBSpecs.lowStyle.clr, "Arial", 8, ANCHOR_LEFT_UPPER, 90 // ); } // // Reading Data From Indicators ... void ReadData() { // int mLoopBack = 15; // // Update Market Cycles ... UpdateMarketCycles(0); // // Short ... CopyBuffer( scFastHandler, 0, 0, mLoopBack, scFastBuffer // ); CopyBuffer( scSlowHandler, 0, 0, mLoopBack, scSlowBuffer // ); isSCFastOverSlow = scFastBuffer[1] > scSlowBuffer[1]; isSCFastUnderSlow = scFastBuffer[1] > scSlowBuffer[1]; // // Medium ... CopyBuffer( mcFastHandler, 0, 0, mLoopBack, mcFastBuffer // ); CopyBuffer( mcSlowHandler, 0, 0, mLoopBack, mcSlowBuffer // ); isMCFastOverSlow = mcFastBuffer[1] > mcSlowBuffer[1]; isMCFastUnderSlow = mcFastBuffer[1] > mcSlowBuffer[1]; // // Long ... CopyBuffer( lcFastHandler, 0, 0, mLoopBack, lcFastBuffer // ); CopyBuffer( lcSlowHandler, 0, 0, mLoopBack, lcSlowBuffer // ); isLCFastOverSlow = lcFastBuffer[1] > lcSlowBuffer[1]; isLCFastUnderSlow = lcFastBuffer[1] > lcSlowBuffer[1]; // // Hind ... CopyBuffer( hcFastHandler, 0, 0, mLoopBack, hcFastBuffer // ); CopyBuffer( hcSlowHandler, 0, 0, mLoopBack, hcSlowBuffer // ); isHCFastOverSlow = hcFastBuffer[1] > hcSlowBuffer[1]; isHCFastUnderSlow = hcFastBuffer[1] > hcSlowBuffer[1]; // // XZigZag ... CopyBuffer( zigZagHandler, X_ZIGZAG_PIVOTS_LINE, 0, mLoopBack, zigZagBuffer // ); // isZigZagInPeak = zigZagBuffer[0] < MathMax(xBEEATick.ask, xBEEATick.bid); // // Summary ... CalculateSummary(); // // Provide all Draws ... XBEEAHandleDraws( // // Short ... xBEEADrawSCLabel, xBEEADrawSCCBar, xBEEADrawSCPBar, xBEEADrawSCCMid, xBEEADrawSCPMid, // // Medium ... xBEEADrawMCLabel, xBEEADrawMCCBar, xBEEADrawMCPBar, xBEEADrawMCCMid, xBEEADrawMCPMid, // // Long ... xBEEADrawLCLabel, xBEEADrawLCCBar, xBEEADrawLCPBar, xBEEADrawLCCMid, xBEEADrawLCPMid, // // Hind ... xBEEADrawHCLabel, xBEEADrawHCCBar, xBEEADrawHCPBar, xBEEADrawHCCMid, xBEEADrawHCPMid // ); } // // Update Market Cycles ... bool UpdateMarketCycles(int barIndex) { // bool result = false; // XOHCL cBar; XOHCL pBar; // // Short ... result = sc.Update(barIndex); if (!result) { return result; } // cBar = sc.GetBar(0); pBar = sc.GetBar(1); scCBar = cBar; scPBar = pBar; scCMidLine = (cBar.high - cBar.low) / 2; scPMidLine = (pBar.high - pBar.low) / 2; isSCCBullish = cBar.close > cBar.open; isSCPBullish = pBar.close > pBar.open; // // Medium ... result = mc.Update(barIndex); if (!result) { return result; } // cBar = mc.GetBar(0); pBar = mc.GetBar(1); mcCBar = cBar; mcPBar = pBar; mcCMidLine = (cBar.high - cBar.low) / 2; mcPMidLine = (pBar.high - pBar.low) / 2; isMCCBullish = cBar.close > cBar.open; isMCPBullish = pBar.close > pBar.open; // // Long ... result = lc.Update(barIndex); if (!result) { return result; } // cBar = lc.GetBar(0); pBar = lc.GetBar(1); lcCBar = cBar; lcPBar = pBar; lcCMidLine = (cBar.high - cBar.low) / 2; lcPMidLine = (pBar.high - pBar.low) / 2; isLCCBullish = cBar.close > cBar.open; isLCPBullish = pBar.close > pBar.open; // // Hind ... result = hc.Update(barIndex); if (!result) { return result; } // cBar = hc.GetBar(0); pBar = hc.GetBar(1); hcCBar = cBar; hcPBar = pBar; hcCMidLine = (cBar.high - cBar.low) / 2; hcPMidLine = (pBar.high - pBar.low) / 2; isHCCBullish = cBar.close > cBar.open; isHCPBullish = pBar.close > pBar.open; // return result; } // // Pivots ... // int CountPivots() { return ArraySize(mPivots); } // bool HasEnoughPivots() { return CountPivots() >= mMinRequiredPivots; } // // First time Scan for Previous Pivots ... void ProcessPivots() { // if (mPivotsScanStart) { return; } // mPivotsScanStart = true; // ArraySetAsSeries(mPivots, true); // double tmpPivots[]; // int count = iBars( xBEEASymbol, xBEEAPeriod) - mPivotsLoopback * 2; // // Reading Pivots based on ZigZag ... int bIdx = 0; while (!HasEnoughPivots() && bIdx < count) { // UpdatePivots(bIdx); // bIdx++; } } // // Update Pivots on Running ... void UpdatePivots(int barIndex = 0) { // double tmpPivots[]; // CopyBuffer( zigZagHandler, X_ZIGZAG_PIVOTS_LINE, barIndex, mPivotsLoopback, tmpPivots); // int valueVerifications = 0; double selectedValue = tmpPivots[0]; // int start = 1; int end = ArraySize(tmpPivots) - 1; for (int i = start; i < end; i++) { // double iValue = tmpPivots[i]; // if (iValue == selectedValue) { valueVerifications++; } } // if (valueVerifications >= mNumberPivotsSequential) { // AddIfNotExists( selectedValue, mPivots // ); } // ArrayFree(tmpPivots); } // // Other ... // // Calculated Suggested States ... void CalculateSummary() { // // Summary ... // int bullishSigns = 0; int bearishSigns = 0; // // Short ... // if (isSCCBullish) { bullishSigns++; } else { bearishSigns++; } // if (isSCPBullish) { bullishSigns++; } else { bearishSigns++; } // if (isSCFastOverSlow) { bullishSigns++; } else if (isSCFastUnderSlow) { bearishSigns++; } // if (scCMidLine < MathMin(scCBar.open, scCBar.close)) { bearishSigns++; } if (scCMidLine < scCBar.low) { bearishSigns++; } if (scPMidLine < MathMin(scPBar.open, scPBar.close)) { bearishSigns++; } if (scPMidLine < scPBar.low) { bearishSigns++; } if (scCMidLine < MathMin(scPBar.open, scPBar.close)) { bearishSigns++; } if (scCMidLine < scPBar.low) { bearishSigns++; } // if (scCMidLine > MathMax(scCBar.open, scCBar.close)) { bullishSigns++; } if (scCMidLine > scCBar.high) { bullishSigns++; } if (scPMidLine > MathMax(scPBar.open, scPBar.close)) { bullishSigns++; } if (scPMidLine > scPBar.high) { bullishSigns++; } if (scCMidLine > MathMax(scPBar.open, scPBar.close)) { bullishSigns++; } if (scCMidLine > scPBar.high) { bullishSigns++; } // // Medium ... // if (isMCCBullish) { bullishSigns++; } else { bearishSigns++; } // if (isMCPBullish) { bullishSigns++; } else { bearishSigns++; } // if (isMCFastOverSlow) { bullishSigns++; } else if (isMCFastUnderSlow) { bearishSigns++; } // if (mcCMidLine < MathMin(mcCBar.open, mcCBar.close)) { bearishSigns++; } if (mcCMidLine < mcCBar.low) { bearishSigns++; } if (mcPMidLine < MathMin(mcPBar.open, mcPBar.close)) { bearishSigns++; } if (mcPMidLine < mcPBar.low) { bearishSigns++; } if (mcCMidLine < MathMin(mcPBar.open, mcPBar.close)) { bearishSigns++; } if (mcCMidLine < mcPBar.low) { bearishSigns++; } // if (mcCMidLine > MathMax(mcCBar.open, mcCBar.close)) { bullishSigns++; } if (mcCMidLine > mcCBar.high) { bullishSigns++; } if (mcPMidLine > MathMax(mcPBar.open, mcPBar.close)) { bullishSigns++; } if (mcPMidLine > mcPBar.high) { bullishSigns++; } if (mcCMidLine > MathMax(mcPBar.open, mcPBar.close)) { bullishSigns++; } if (mcCMidLine > mcPBar.high) { bullishSigns++; } // // Long ... // if (isLCCBullish) { bullishSigns++; } else { bearishSigns++; } // if (isLCPBullish) { bullishSigns++; } else { bearishSigns++; } // if (isLCFastOverSlow) { bullishSigns++; } else if (isLCFastUnderSlow) { bearishSigns++; } // if (lcCMidLine < MathMin(lcCBar.open, lcCBar.close)) { bearishSigns++; } if (lcCMidLine < lcCBar.low) { bearishSigns++; } if (lcPMidLine < MathMin(lcPBar.open, lcPBar.close)) { bearishSigns++; } if (lcPMidLine < lcPBar.low) { bearishSigns++; } if (lcCMidLine < MathMin(lcPBar.open, lcPBar.close)) { bearishSigns++; } if (lcCMidLine < lcPBar.low) { bearishSigns++; } // if (lcCMidLine > MathMax(lcCBar.open, lcCBar.close)) { bullishSigns++; } if (lcCMidLine > lcCBar.high) { bullishSigns++; } if (lcPMidLine > MathMax(lcPBar.open, lcPBar.close)) { bullishSigns++; } if (lcPMidLine > lcPBar.high) { bullishSigns++; } if (lcCMidLine > MathMax(lcPBar.open, lcPBar.close)) { bullishSigns++; } if (lcCMidLine > lcPBar.high) { bullishSigns++; } // // Hind ... // if (isHCCBullish) { bullishSigns++; } else { bearishSigns++; } // if (isHCPBullish) { bullishSigns++; } else { bearishSigns++; } // if (isHCFastOverSlow) { bullishSigns++; } else if (isHCFastUnderSlow) { bearishSigns++; } // if (hcCMidLine < MathMin(hcCBar.open, hcCBar.close)) { bearishSigns++; } if (hcCMidLine < hcCBar.low) { bearishSigns++; } if (hcPMidLine < MathMin(hcPBar.open, hcPBar.close)) { bearishSigns++; } if (hcPMidLine < hcPBar.low) { bearishSigns++; } if (hcCMidLine < MathMin(hcPBar.open, hcPBar.close)) { bearishSigns++; } if (hcCMidLine < hcPBar.low) { bearishSigns++; } // if (hcCMidLine > MathMax(hcCBar.open, hcCBar.close)) { bullishSigns++; } if (hcCMidLine > hcCBar.high) { bullishSigns++; } if (hcPMidLine > MathMax(hcPBar.open, hcPBar.close)) { bullishSigns++; } if (hcPMidLine > hcPBar.high) { bullishSigns++; } if (hcCMidLine > MathMax(hcPBar.open, hcPBar.close)) { bullishSigns++; } if (hcCMidLine > hcPBar.high) { bullishSigns++; } // // ZigZag ... if (isZigZagInPeak) { bearishSigns++; } else { bullishSigns++; } // mBullishScore = bullishSigns; mBearishScore = bearishSigns; xBEEAIsSummaryTrendBullish = bullishSigns > bearishSigns; // // Calculate Max an Min Scores ... // mMinBullishScore = // mMinBullishScore == 0 || mMinBullishScore > mBullishScore ? mBullishScore : mMinBullishScore // ; // mMinBearishScore = // mMinBearishScore == 0 || mMinBearishScore > mBearishScore ? mBearishScore : mMinBearishScore // ; // mMaxBullishScore = // mMaxBullishScore == 0 || mMaxBullishScore < mBullishScore ? mBullishScore : mMaxBullishScore // ; // mMaxBearishScore = // mMaxBearishScore == 0 || mMaxBearishScore < mBearishScore ? mBearishScore : mMaxBearishScore // ; // if (xBEEAIsSummaryTrendBullish != xBEEALastIsSummaryTrendBullish) { // // TODO: Summary Trend Change Alert ... LogMessage("Majour Trend Changed Happens: " + (xBEEAIsSummaryTrendBullish ? "Bullish" : "Bearish")); } // xBEEALastIsSummaryTrendBullish = xBEEAIsSummaryTrendBullish; } // // Handle All Draws of Experts ... void XBEEAHandleDraws( // // Short ... bool drawSCLabel = true, bool drawSCCBar = true, bool drawSCPBar = true, bool drawSCCMid = true, bool drawSCPMid = true, // // Medium ... bool drawMCLabel = true, bool drawMCCBar = true, bool drawMCPBar = true, bool drawMCCMid = true, bool drawMCPMid = true, // // Long ... bool drawLCLabel = true, bool drawLCCBar = true, bool drawLCPBar = true, bool drawLCCMid = true, bool drawLCPMid = true, // // Hind ... bool drawHCLabel = true, bool drawHCCBar = true, bool drawHCPBar = true, bool drawHCCMid = true, bool drawHCPMid = true // ) { // int offset = 0; // // Short ... // // Cycle ... if (drawSCCBar || drawSCPBar) { // XBEEADrawCycle( sc.cycle, drawSCLabel, !drawSCCBar && drawSCPBar, !drawSCPBar && drawSCCBar, offset // ); // if (drawSCLabel) { // if (drawSCCBar) { offset += 3; } // if (drawSCPBar) { offset += 3; } // if (drawSCCMid) { offset++; } // if (drawSCPMid) { offset++; } } } // // MidLine ... if (drawSCCMid || drawSCPMid) { // XBEEADrawMidLine( sc.cycle, drawSCLabel, !drawSCCMid && drawSCPMid, !drawSCPMid && drawSCCMid, offset // ); // if (drawSCLabel) { // if (drawSCCMid) { offset++; } // if (drawSCPMid) { offset++; } } } // // Medium ... // // Cycle ... if (drawMCCBar || drawMCPBar) { // XBEEADrawCycle( mc.cycle, drawMCLabel, !drawMCCBar && drawMCPBar, !drawMCPBar && drawMCCBar, offset // ); // if (drawMCLabel) { // if (drawMCCBar) { offset += 3; } // if (drawMCPBar) { offset += 3; } // if (drawMCCMid) { offset++; } // if (drawMCPMid) { offset++; } } } // // Mid Line ... if (drawMCCMid || drawMCPMid) { // XBEEADrawMidLine( mc.cycle, drawMCLabel, !drawMCCMid && drawMCPMid, !drawMCPMid && drawMCCMid, offset // ); // if (drawMCLabel) { // if (drawMCCMid) { offset++; } // if (drawMCPMid) { offset++; } } } // // Long ... // // Cycle ... if (drawLCCBar || drawLCPBar) { // XBEEADrawCycle( lc.cycle, drawLCLabel, !drawLCCBar && drawLCPBar, !drawLCPBar && drawLCCBar, offset // ); // if (drawLCLabel) { // if (drawLCCBar) { offset += 3; } // if (drawLCPBar) { offset += 3; } // if (drawLCCMid) { offset++; } // if (drawLCPMid) { offset++; } } } // // MidLine ... if (drawLCCMid || drawLCPMid) { // XBEEADrawMidLine( lc.cycle, drawLCLabel, !drawLCCMid && drawLCPMid, !drawLCPMid && drawLCCMid, offset // ); // if (drawLCLabel) { // if (drawLCCMid) { offset++; } // if (drawLCPMid) { offset++; } } } // // Hind ... // // Cycle ... if (drawHCCBar || drawHCPBar) { // XBEEADrawCycle( hc.cycle, drawHCLabel, !drawHCCBar && drawHCPBar, !drawHCPBar && drawHCCBar, offset // ); // if (drawHCLabel) { // if (drawHCCBar) { offset += 3; } // if (drawHCPBar) { offset += 3; } // if (drawHCCMid) { offset++; } // if (drawHCPMid) { offset++; } } } // // MidLine ... if (drawHCCMid || drawHCPMid) { // XBEEADrawMidLine( hc.cycle, drawHCLabel, !drawHCCMid && drawHCPMid, !drawHCPMid && drawHCCMid, offset // ); } } // // Draw Middle Line of Cycle ... void XBEEADrawCycle( ENUM_X_MARKET_CYCLES cycle, // Specify Which Cycle to Draw ... bool drawLabel = false, // Specify Draw Label of Mid Line or not ... bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ... bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ... int offset = 0 // Distance used for Labels ... ) { // if (offset < 0) { offset = 0; } // XMarketCycle cycleModel; XOHCLDrawSpecification cycleCBarSpecs; XOHCLDrawSpecification cyclePBarSpecs; // switch (cycle) { // case X_MARKET_CYCLE_SHORT: // cycleModel = sc; cycleCBarSpecs = scCBSpecs; cyclePBarSpecs = scPBSpecs; break; // case X_MARKET_CYCLE_MEDIUM: // cycleModel = mc; cycleCBarSpecs = mcCBSpecs; cyclePBarSpecs = mcPBSpecs; break; // case X_MARKET_CYCLE_LONG: // cycleModel = lc; cycleCBarSpecs = lcCBSpecs; cyclePBarSpecs = lcPBSpecs; break; // case X_MARKET_CYCLE_HIND: // cycleModel = hc; cycleCBarSpecs = hcCBSpecs; cyclePBarSpecs = hcPBSpecs; break; } // string baseTag = ToString(cycle); // XOHCL cBar = cycleModel.GetBar(0); XOHCL pBar = cycleModel.GetBar(1); // datetime fromCDate = cycleModel.GetBarTime(0); datetime fromPDate = cycleModel.GetBarTime(1); // datetime cTime = TimeCurrent(); // // Try to Draw ... // bool canDrawPrev = !drawOnlyCurrent; bool canDrawCurrent = !drawOnlyPrev; // // Set Cycles Color based on Current Candle ... // bool isCBarBullish = cBar.open < cBar.close; // bool isPBarBullish = pBar.open < pBar.close; // color clrTemoBullishColor = cycleCBarSpecs.openStyle.clr; color clrTemoBearishColor = cycleCBarSpecs.closeStyle.clr; // color cBarSelectedColor = isCBarBullish ? clrTemoBullishColor : clrTemoBearishColor; color pBarSelectedColor = isPBarBullish ? clrTemoBullishColor : clrTemoBearishColor; // cycleCBarSpecs.openStyle.clr = cBarSelectedColor; cycleCBarSpecs.openStyle.labelColor = cBarSelectedColor; // cycleCBarSpecs.closeStyle.clr = cBarSelectedColor; cycleCBarSpecs.closeStyle.labelColor = cBarSelectedColor; // cyclePBarSpecs.openStyle.clr = pBarSelectedColor; cyclePBarSpecs.openStyle.labelColor = pBarSelectedColor; // cyclePBarSpecs.closeStyle.clr = pBarSelectedColor; cyclePBarSpecs.closeStyle.labelColor = pBarSelectedColor; // if (canDrawPrev) { offset++; } // // Label ... if (drawLabel) { // if (canDrawPrev) { // // Draw Prev Bar Lables ... // XBEEADrawCycleXOHCLLabel( cycleModel, pBar, cyclePBarSpecs, "P", cTime, offset - 1 // ); // offset += 3; } // if (canDrawCurrent) { // // Draw Current Bar Lables ... // XBEEADrawCycleXOHCLLabel( cycleModel, cBar, cycleCBarSpecs, "C", cTime, offset // ); } } // // Line ... // if (canDrawPrev) { // // Draw Cycle Prev Bar ... XBEEADrawCycleXOHCLContent( cycleModel, pBar, cyclePBarSpecs, "P", fromPDate // ); } // if (canDrawCurrent) { // // Draw Cycle Current Bar ... XBEEADrawCycleXOHCLContent( cycleModel, cBar, cycleCBarSpecs, "C", fromCDate // ); } } // // Draw Middle Line of Cycle ... void XBEEADrawMidLine( ENUM_X_MARKET_CYCLES cycle, // Specify Which Cycle to Draw ... bool drawLabel = false, // Specify Draw Label of Mid Line or not ... bool drawOnlyPrev = false, // Specify Draw Only Prev Bar of Cycle ... bool drawOnlyCurrent = false, // Specify Draw Only Current Bar of Cycle ... int offset = 0 // Distance used for Labels ... ) { // if (offset < 0) { offset = 0; } // XMarketCycle cycleModel; XDrawSpecifications cycleCMidSpecs; XDrawSpecifications cyclePMidSpecs; // switch (cycle) { // case X_MARKET_CYCLE_SHORT: // cycleModel = sc; cycleCMidSpecs = scCMidSpecs; cyclePMidSpecs = scPMidSpecs; break; // case X_MARKET_CYCLE_MEDIUM: // cycleModel = mc; cycleCMidSpecs = mcCMidSpecs; cyclePMidSpecs = mcPMidSpecs; break; // case X_MARKET_CYCLE_LONG: // cycleModel = lc; cycleCMidSpecs = lcCMidSpecs; cyclePMidSpecs = lcPMidSpecs; break; // case X_MARKET_CYCLE_HIND: // cycleModel = hc; cycleCMidSpecs = hcCMidSpecs; cyclePMidSpecs = hcPMidSpecs; break; } // // Calculate Mid Line ... double midLine = (cycleModel.bar.high + cycleModel.bar.low) / 2; // XOHCL cyclePrevBar = cycleModel.GetBar(1); double midLinePrev = (cyclePrevBar.high + cyclePrevBar.low) / 2; // string baseTag = ToString(cycle); // string midCTag = baseTag + "|MID|C|"; string midPTag = baseTag + "|MID|P|"; // string midCLblTag = midCTag + "lbl"; string midPLblTag = midPTag + "lbl"; // datetime fromCDate = cycleModel.GetBarTime(0); datetime fromPDate = cycleModel.GetBarTime(1); // datetime cTime = TimeCurrent(); // // Try to Draw ... // bool canDrawPrev = !drawOnlyCurrent; bool canDrawCurrent = !drawOnlyPrev; // if (canDrawPrev) { offset++; } // // Label ... if (drawLabel) { // if (canDrawPrev) { // // Draw Prev Candle MidLine Lable ... XBEEADrawLabel( cyclePMidSpecs, midPLblTag, cTime, midLinePrev, offset // ); } // if (canDrawCurrent) { // // Draw Current Candle MidLine Label ... XBEEADrawLabel( cycleCMidSpecs, midCLblTag, cTime, midLine, offset - 1 // ); } } // // Line ... // if (canDrawPrev) { // // Draw Prev Candle MidLine ... XBEEADrawTrendLine( cyclePMidSpecs, midPTag, fromPDate, midLinePrev // ); } // if (canDrawCurrent) { // // Draw Current Candle MidLine ... XBEEADrawTrendLine( cycleCMidSpecs, midCTag, fromCDate, midLine // ); } } // // Generate Expert State ... string XBEEAGenerateState() { // string result = ""; // // Summary ... result += // "Summary: \n" + "------------------\n" + "Pivots: " + ToString(CountPivots()) + "\n" + "BullishScore: " + ToString(mBullishScore) + ", min: " + ToString(mMinBullishScore) + ", max: " + ToString(mMaxBullishScore) + "\n" + "BearishScore: " + ToString(mBearishScore) + ", min: " + ToString(mMinBearishScore) + ", max: " + ToString(mMaxBearishScore) + "\n" + "isSUmmaryBullish: " + ToString(xBEEAIsSummaryTrendBullish) + "\n" + "\n" // ; // // ZigZag ... result += // "Peaks and Vales: \n" + "------------------\n" + "Looking for New: " + (isZigZagInPeak ? "Vale" : "Peak") + "\n" + "\n" // ; // // Short ... result += // "Short: \n" + "------------------\n" + "Period: " + ToString(sc.period) + "\n" + "Bar 0: " + (isSCCBullish ? "Bullish" : "Bearish") + "\n" + "Bar 1: " + (isSCPBullish ? "Bullish" : "Bearish") + "\n" + "Trend MA: " + (isSCFastOverSlow ? "Bullish" : "Bearish") + "\n" + "\n" // ; // // Long ... result += // "Medium: \n" + "------------------\n" + "Period: " + ToString(mc.period) + "\n" + "Bar 0: " + (isMCCBullish ? "Bullish" : "Bearish") + "\n" + "Bar 1: " + (isMCPBullish ? "Bullish" : "Bearish") + "\n" + "Trend MA: " + (isMCFastOverSlow ? "Bullish" : "Bearish") + "\n" + "\n" // ; // // Medium ... result += // "Long: \n" + "------------------\n" + "Period: " + ToString(lc.period) + "\n" + "Bar 0: " + (isLCCBullish ? "Bullish" : "Bearish") + "\n" + "Bar 1: " + (isLCPBullish ? "Bullish" : "Bearish") + "\n" + "Trend MA: " + (isLCFastOverSlow ? "Bullish" : "Bearish") + "\n" + "\n" // ; // // Hind ... result += // "Hind: \n" + "------------------\n" + "Period: " + ToString(hc.period) + "\n" + "Bar 0: " + (isHCCBullish ? "Bullish" : "Bearish") + "\n" + "Bar 1: " + (isHCPBullish ? "Bullish" : "Bearish") + "\n" + "Trend MA: " + (isHCFastOverSlow ? "Bullish" : "Bearish") + "\n" + "\n" // ; // // Test CHE ... double shortExit1s[]; xBEEACheHelper.CopyShortExit1( 0, 2, shortExit1s // ); // string shortExit1sStr = // "[0] => " + (shortExit1s[0] != EMPTY_VALUE ? ToString(shortExit1s[0]) : "EMPTY") + "\n" + "[1] => " + (shortExit1s[1] != EMPTY_VALUE ? ToString(shortExit1s[1]) : "EMPTY") + "\n" + "\n" // ; // result = shortExit1sStr; // string hash = ToMD5(result); if (hash != mLastCommentHash) { // LogMessage(result); // LogMessage(hash); // mLastCommentHash = hash; } // return result; } // // Custom DRAW(s) ... // // Draw OHCL Labels ... void XBEEADrawCycleXOHCLLabel( XMarketCycle &cycleModel, // Specify Which Cycle to Draw ... XOHCL &bar, // Specify Cycle XOHCL Model to Draw ... XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ... string baseTag, // Specify a Unique Tag ... datetime time, // Draw Time ... int offset = 0 // ) { // // Open ... string openTag = cycleModel.prefix + "_" + baseTag + "_O_lbl"; XBEEADrawLabel( specs.openStyle, openTag, time, bar.open, offset // ); // // High ... string highTag = cycleModel.prefix + "_" + baseTag + "_H_lbl"; XBEEADrawLabel( specs.highStyle, highTag, time, bar.high, offset + 1 // ); // // Close ... string closeTag = cycleModel.prefix + "_" + baseTag + "_C_lbl"; XBEEADrawLabel( specs.closeStyle, closeTag, time, bar.close, offset + 2 // ); // // Low ... string lowTag = cycleModel.prefix + "_" + baseTag + "_L_lbl"; XBEEADrawLabel( specs.lowStyle, lowTag, time, bar.low, offset + 3 // ); } // // Draw OHCL Content ... void XBEEADrawCycleXOHCLContent( XMarketCycle &cycleModel, // Specify Which Cycle to Draw ... XOHCL &bar, // Specify Cycle XOHCL Model to Draw ... XOHCLDrawSpecification &specs, // Specify Cycle XOHCL Draw Specifications ... string baseTag, // Specify a Unique Tag ... datetime time // Draw Time ... ) { // // Open ... string openTag = cycleModel.prefix + "_" + baseTag + "_O"; XBEEADrawTrendLine( specs.openStyle, openTag, time, bar.open // ); // // High ... string highTag = cycleModel.prefix + "_" + baseTag + "_H"; XBEEADrawTrendLine( specs.highStyle, highTag, time, bar.high // ); // // Close ... string closeTag = cycleModel.prefix + "_" + baseTag + "_C"; XBEEADrawTrendLine( specs.closeStyle, closeTag, time, bar.close // ); // // Low ... string lowTag = cycleModel.prefix + "_" + baseTag + "_L"; XBEEADrawTrendLine( specs.lowStyle, lowTag, time, bar.low // ); } // // Draw Label Using Specifications ... void XBEEADrawLabel( XDrawSpecifications &specs, string tag, datetime time, double price, int offset = 0 // ) { // long chartId = ChartID(); int subWindow = 0; // if (offset < 0) { offset = 0; } // int offsetSeconds = PeriodSeconds(xBEEAPeriod) * offset; // string value = specs.label; // DrawText( chartId, tag, subWindow, time - offsetSeconds, price, specs.label, specs.labelFont, specs.labelFontSize, specs.labelColor, specs.labelAngel, specs.labelAnchor, specs.back, specs.selection, specs.hidden, specs.zOrder // ); } // // Draw TrendLine Using Specifications ... void XBEEADrawTrendLine( XDrawSpecifications &specs, string tag, datetime fromDate, double fromPrice, datetime toDate = NULL, double toPrice = 0 // ) { // long chartId = ChartID(); int subWindow = 0; // if (toPrice <= 0) { toPrice = fromPrice; } // if (toDate == 0 || toDate == NULL) { toDate = TimeCurrent(); } // DrawTrendLine( chartId, tag, subWindow, fromDate, fromPrice, toDate, toPrice, specs.clr, specs.style, specs.width, specs.back, specs.selection, specs.rayRight, specs.hidden, specs.zOrder // ); }