From fbe701f198705caf2c750de2519f21e17a21dcb5 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 22 Jun 2024 15:42:08 +0330 Subject: [PATCH] add new indicators ... --- Classes/x-saherelm.x121.setup.xea.mq5 | 7 +- Classes/x-saherelm.xea.class.mq5 | 38 +- Documents/BKP/Ideas/x-saherelm.xmgtd.mq5 | 504 ++++++++ .../atr_trailing_stop_1_buffer.mq5 | Bin 0 -> 16510 bytes Documents/BKP/Source Codes/dcc_piercing.mq5 | 115 ++ Documents/BKP/Source Codes/dominant.mq5 | 99 ++ Documents/BKP/Source Codes/fair_value_gap.mq5 | 105 ++ .../Source Codes/geometric_moving_average.mq5 | 111 ++ .../Source Codes/harmonic_moving_average.mq5 | 110 ++ .../higher_highs_s_lower_lows.mq5 | Bin 0 -> 10720 bytes Documents/BKP/Source Codes/marubozu.mq5 | 96 ++ Documents/BKP/Source Codes/minpricechange.mq5 | 133 +++ Documents/BKP/Source Codes/rainbow.mq5 | Bin 0 -> 7490 bytes Documents/BKP/Source Codes/rmo_yfl6.mq5 | Bin 0 -> 16794 bytes .../BKP/Source Codes/round_price_doc.mq5 | 208 ++++ .../shved_supply_and_demand_v1.7.mq5 | 1046 +++++++++++++++++ .../BKP/Source Codes/slope_direction_line.mq5 | Bin 0 -> 12724 bytes .../BKP/Source Codes/slope_entry_points.mq5 | Bin 0 -> 17420 bytes .../BKP/Source Codes/strong_levels_v1.mq5 | 451 +++++++ .../BKP/Source Codes/super_trend_hull.mq5 | 204 ++++ Documents/BKP/Source Codes/supertrend.mq5 | 192 +++ Documents/BKP/Source Codes/swing_line.mq5 | 117 ++ Documents/BKP/Source Codes/swings.mq5 | 97 ++ .../Source Codes/time_segmented_volume.mq5 | 289 +++++ .../timeframe_confluence_detector.mq5 | 114 ++ Documents/BKP/Source Codes/trendlinearreg.mq5 | 114 ++ Experts/x-saherelm.x121.ea.mq5 | 8 +- Indicators/x-saherelm.xatsl.mq5 | 333 ++++++ Indicators/x-saherelm.xdmnt.mq5 | 222 ++++ Indicators/x-saherelm.xhtd.mq5 | 368 ++++++ Indicators/x-saherelm.xsln.mq5 | 264 +++++ Indicators/yma.mq5 | 67 ++ Libraries/x-saherelm.common.lib.mq5 | 214 +++- 33 files changed, 5602 insertions(+), 24 deletions(-) create mode 100644 Documents/BKP/Ideas/x-saherelm.xmgtd.mq5 create mode 100644 Documents/BKP/Source Codes/atr_trailing_stop_1_buffer.mq5 create mode 100644 Documents/BKP/Source Codes/dcc_piercing.mq5 create mode 100644 Documents/BKP/Source Codes/dominant.mq5 create mode 100644 Documents/BKP/Source Codes/fair_value_gap.mq5 create mode 100644 Documents/BKP/Source Codes/geometric_moving_average.mq5 create mode 100644 Documents/BKP/Source Codes/harmonic_moving_average.mq5 create mode 100644 Documents/BKP/Source Codes/higher_highs_s_lower_lows.mq5 create mode 100644 Documents/BKP/Source Codes/marubozu.mq5 create mode 100644 Documents/BKP/Source Codes/minpricechange.mq5 create mode 100644 Documents/BKP/Source Codes/rainbow.mq5 create mode 100644 Documents/BKP/Source Codes/rmo_yfl6.mq5 create mode 100644 Documents/BKP/Source Codes/round_price_doc.mq5 create mode 100644 Documents/BKP/Source Codes/shved_supply_and_demand_v1.7.mq5 create mode 100644 Documents/BKP/Source Codes/slope_direction_line.mq5 create mode 100644 Documents/BKP/Source Codes/slope_entry_points.mq5 create mode 100644 Documents/BKP/Source Codes/strong_levels_v1.mq5 create mode 100644 Documents/BKP/Source Codes/super_trend_hull.mq5 create mode 100644 Documents/BKP/Source Codes/supertrend.mq5 create mode 100644 Documents/BKP/Source Codes/swing_line.mq5 create mode 100644 Documents/BKP/Source Codes/swings.mq5 create mode 100644 Documents/BKP/Source Codes/time_segmented_volume.mq5 create mode 100644 Documents/BKP/Source Codes/timeframe_confluence_detector.mq5 create mode 100644 Documents/BKP/Source Codes/trendlinearreg.mq5 create mode 100644 Indicators/x-saherelm.xatsl.mq5 create mode 100644 Indicators/x-saherelm.xdmnt.mq5 create mode 100644 Indicators/x-saherelm.xhtd.mq5 create mode 100644 Indicators/x-saherelm.xsln.mq5 create mode 100644 Indicators/yma.mq5 diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 735bf18b..9dca355f 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -4917,8 +4917,8 @@ private: if (mMaxDrawdownForce > 0) { // - double drawdown = GetDrawdownPercent(); - if (drawdown > 5) + double drawdown = CalculateMaxDrawdown(); + if (drawdown > mMaxDrawdownForce) { // // Try to Hedge ... @@ -5166,6 +5166,9 @@ private: // if (isValid) { + // + // bool canHandle = mMaxDrawdownForce <= 0 || mMaxDrawdownForce + // // Check Delay Between Two Signals ... bool isDelayPassed = IsSignalDelayPassed(signal); diff --git a/Classes/x-saherelm.xea.class.mq5 b/Classes/x-saherelm.xea.class.mq5 index 9a47a845..8bb9cab0 100644 --- a/Classes/x-saherelm.xea.class.mq5 +++ b/Classes/x-saherelm.xea.class.mq5 @@ -579,24 +579,11 @@ public: } // - // Protected ... -protected: - // - // Props ... - - // - // Check in Test Mode or not ... - bool mIsInTestMode; - - // - // Save Max Drawdown ... - double mMaxDrawdown; - double mDrawdownPercent; - double mStaticBalanceForCalculateDrawdown; - + // Tools ... + // // Calculate Max Drawdown and it's Percent ... - void CalculateMaxDrawdown() + double CalculateMaxDrawdown() { // int positionsCount = PositionsTotal(); @@ -618,8 +605,27 @@ protected: mMaxDrawdown = 0.0; mDrawdownPercent = 0.0; } + + // + return mDrawdownPercent; } + // + // Protected ... +protected: + // + // Props ... + + // + // Check in Test Mode or not ... + bool mIsInTestMode; + + // + // Save Max Drawdown ... + double mMaxDrawdown; + double mDrawdownPercent; + double mStaticBalanceForCalculateDrawdown; + // // diff --git a/Documents/BKP/Ideas/x-saherelm.xmgtd.mq5 b/Documents/BKP/Ideas/x-saherelm.xmgtd.mq5 new file mode 100644 index 00000000..f9283ab8 --- /dev/null +++ b/Documents/BKP/Ideas/x-saherelm.xmgtd.mq5 @@ -0,0 +1,504 @@ +/////////////////////////////////////////////////////// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------- +// Name: XMGTD +// Description: Mega Trend ... +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm XMGTD Indicator" +#property strict + +// +#define ShortName "XMGTD" + +// +// Imports ... +#include "../Libraries/x-saherelm.common.lib.mq5" + +// +// Inputs ... + +// +input group "Market"; +input int length = 14; // Length +input double coeff = 2.0; // Coefficient +input double multiplier = 3.0; // Multiplier +input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To + +// +input group "Presentation"; +input bool show = true; // Show +input bool showSTR = false; // Show STR +input bool showHTD = false; // Show HTR +input bool showATSL = false; // Show ATSL + +// +// Buffers ... + +// +#property indicator_chart_window + +// +#property indicator_buffers 13 +#property indicator_plots 6 + +// +#define mainBufferIndex 0 +double mainBuffer[]; + +// +#define mainBufferColorIndex 1 +double mainBufferColor[]; + +// +#define hideColorIDX 0 +#define bullColorIDX 1 +#define bearColorIDX 2 + +// +#property indicator_label1 "XMGTD" +#property indicator_type1 DRAW_COLOR_LINE +#property indicator_color1 CLR_NONE, clrGreen, clrDarkRed +#property indicator_style1 STYLE_DOT +#property indicator_width1 1 + +// +#define atslBufferIndex 2 +#define atslBufferPlotIndex 1 +double atslBuffer[]; + +// +#define atslBufferColorIndex 3 +double atslBufferColor[]; + +// +#property indicator_label2 "XATSL" +#property indicator_type2 DRAW_COLOR_LINE +#property indicator_color2 CLR_NONE, clrGreen, clrDarkRed +#property indicator_style2 STYLE_DOT +#property indicator_width2 1 + +// +#define htdBufferIndex 4 +#define htdBufferPlotIndex 2 +double htdBuffer[]; + +// +#define htdBufferColorIndex 5 +double htdBufferColor[]; + +// +#property indicator_label3 "XHTD" +#property indicator_type3 DRAW_COLOR_LINE +#property indicator_color3 CLR_NONE, clrGreen, clrDarkRed +#property indicator_style3 STYLE_DOT +#property indicator_width3 1 + +// +#define hlBufferIndex 6 +double hlBuffer[]; + +// +#define wmaBufferIndex 7 +double wmaBuffer[]; + +// +#define tmpBufferIndex 8 +double tmpBuffer[]; + +// +#define diffBufferIndex 9 +double diffBuffer[]; + +// +#define upBufferIndex 10 +double upBuffer[]; + +// +#define downBufferIndex 11 +double downBuffer[]; + +// +#define directionBufferIndex 12 +double directionBuffer[]; + +// +// Variables ... + +// +int maPeriod; +double kpi; + +// +// Event Handlers ... + +// +// Initialization ... +int OnInit() +{ + // + // Validate Inputs ... + if (!ValidateInputs()) + { + return INIT_PARAMETERS_INCORRECT; + } + + // + maPeriod = int(length < 1 ? 1 : length); + double n1 = 2.0 * double(maPeriod - 1); + kpi = 2.0 / (n1 + 1); + + // + // Define Index Buffers ... + DefineBuffers(); + + // + // Set Indicator ShortName ... + SetIndicatorName(); + + // + // 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 +} + +// +// Calculating what we want ... +int OnCalculate( + const int rates_total, // Total Bars on Chart ... + const int prev_calculated, // Total Calculated Bars on Charts ... + const datetime &time[], // History of Open Time ... + const double &open[], // History of Open Price ... + const double &high[], // History of High Price ... + const double &low[], // History of Low Price ... + const double &close[], // History of Close Price ... + const long &tick_volume[], // History of Tick Volumes on Bar ... + const long &volume[], // History of Trade Volumes ... + const int &spread[] // History of Spread Price ... +) +{ + // + ArraySetAsSeries(high, true); + ArraySetAsSeries(low, true); + ArraySetAsSeries(close, true); + + // + if (rates_total < maPeriod) + { + return 0; + } + + // + int limit = rates_total - prev_calculated; + if (limit > 1) + { + // + limit = rates_total - 2; + + // + ArrayInitialize(atslBuffer, EMPTY_VALUE); + ArrayInitialize(hlBuffer, 0); + ArrayInitialize(diffBuffer, 0); + ArrayInitialize(wmaBuffer, 0); + ArrayInitialize(tmpBuffer, 0); + } + + // + for (int i = limit; i >= 0 && !IsStopped(); i--) + { + // + hlBuffer[i] = high[i] - low[i]; + + // + double href = 0; + double lref = 0; + + // + double sma = MAOnArray(hlBuffer, 0, maPeriod, 0, MODE_SMA, i); + double hiLo = fmin(hlBuffer[i], sma); + + // + href = (low[i] <= high[i + 1] ? high[i] - close[i + 1] : (hlBuffer[i] - close[i + 1] + high[i + 1]) / 2); + lref = (high[i] >= low[i + 1] ? close[i + 1] - low[i] : (close[i + 1] - low[i + 1] + hlBuffer[i]) / 2); + + // + diffBuffer[i] = fmax(hiLo, fmax(href, lref)); + } + + // + for (int i = limit; i >= 0 && !IsStopped(); i--) + { + // + if (i == rates_total - 2) + { + wmaBuffer[i] = MAOnArray(diffBuffer, 0, maPeriod, 0, MODE_EMA, i); + } + else + { + wmaBuffer[i] = (diffBuffer[i] - wmaBuffer[i + 1]) * kpi + wmaBuffer[i + 1]; + } + } + + // + for (int i = limit; i >= 0 && !IsStopped(); i--) + { + // + double loss = wmaBuffer[i] * coeff; + if (close[i] > tmpBuffer[i + 1] && close[i + 1] > tmpBuffer[i + 1]) + { + // + tmpBuffer[i] = fmax(tmpBuffer[i + 1], close[i] - loss); + + // + atslBuffer[i] = tmpBuffer[i]; + } + else + { + // + if (close[i] < tmpBuffer[i + 1] && close[i + 1] < tmpBuffer[i + 1]) + { + // + tmpBuffer[i] = fmin(tmpBuffer[i + 1], close[i] + loss); + + // + atslBuffer[i] = tmpBuffer[i]; + } + else + { + // + if (close[i] > tmpBuffer[i + 1]) + { + // + tmpBuffer[i] = close[i] - loss; + + // + atslBuffer[i] = tmpBuffer[i]; + } + else + { + // + tmpBuffer[i] = close[i] + loss; + + // + atslBuffer[i] = tmpBuffer[i]; + } + } + } + + // + // Define Color Buffer ... + double clrValue = !showATSL + ? hideColorIDX + : atslBuffer[i] > close[i] + ? bearColorIDX + : bullColorIDX; + atslBufferColor[i] = clrValue; + } + + // + return rates_total; +} + +// +// Custom Functions ... + +// +// Validate Input Args for Initialization ... +bool ValidateInputs() +{ + // + bool result = false; + + // + result = length >= 2 && + coeff > 0; + + // + return result; +} + +// +// Set Indicator Short Name and also we can define Buffers Labels ... +void SetIndicatorName() +{ + IndicatorSetString(INDICATOR_SHORTNAME, ShortName); +} + +// +// Define Indexes and Styles ... + +// +void DefineBuffers() +{ + // + // Main ... + ENUM_DRAW_TYPE mainDrawType = show ? DRAW_COLOR_LINE : DRAW_NONE; + + // + ArraySetAsSeries(mainBuffer, true); + ArraySetAsSeries(mainBufferColor, true); + PlotIndexSetInteger(mainBufferIndex, PLOT_SHOW_DATA, show); + SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA); + PlotIndexSetInteger(mainBufferIndex, PLOT_DRAW_TYPE, mainDrawType); + SetIndexBuffer(mainBufferColorIndex, mainBufferColor, INDICATOR_COLOR_INDEX); + + // + // XATSL ... + ENUM_DRAW_TYPE atslDrawType = showATSL ? DRAW_COLOR_LINE : DRAW_NONE; + + // + ArraySetAsSeries(atslBuffer, true); + ArraySetAsSeries(atslBufferColor, true); + SetIndexBuffer(atslBufferIndex, atslBuffer, INDICATOR_DATA); + SetIndexBuffer(atslBufferColorIndex, atslBufferColor, INDICATOR_COLOR_INDEX); + PlotIndexSetInteger(atslBufferPlotIndex, PLOT_SHOW_DATA, showATSL); + PlotIndexSetInteger(atslBufferPlotIndex, PLOT_DRAW_TYPE, atslDrawType); + + // + // XHTD ... + ENUM_DRAW_TYPE htdDrawType = showHTD ? DRAW_COLOR_LINE : DRAW_NONE; + + // + SetIndexBuffer(htdBufferIndex, htdBuffer, INDICATOR_DATA); + SetIndexBuffer(htdBufferColorIndex, htdBufferColor, INDICATOR_COLOR_INDEX); + PlotIndexSetInteger(htdBufferPlotIndex, PLOT_SHOW_DATA, showHTD); + PlotIndexSetInteger(htdBufferPlotIndex, PLOT_DRAW_TYPE, htdDrawType); + + // + ArraySetAsSeries(hlBuffer, true); + SetIndexBuffer(hlBufferIndex, hlBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(wmaBuffer, true); + SetIndexBuffer(wmaBufferIndex, wmaBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(tmpBuffer, true); + SetIndexBuffer(tmpBufferIndex, tmpBuffer, INDICATOR_CALCULATIONS); + + // + ArraySetAsSeries(diffBuffer, true); + SetIndexBuffer(diffBufferIndex, diffBuffer, INDICATOR_CALCULATIONS); + + // + SetIndexBuffer(upBufferIndex, upBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(downBufferIndex, downBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(directionBufferIndex, directionBuffer, INDICATOR_CALCULATIONS); +} + +// +// Hull Handler ... +double workHull[][2]; +double iHull( + double price, + double period, + int r, + int bars, + int instanceNo = 0 // +) +{ + // + if (ArrayRange(workHull, 0) != bars) + { + ArrayResize(workHull, bars); + } + + // + int HmaPeriod = (int)MathMax(period, 2); + int HalfPeriod = (int)MathFloor(HmaPeriod / 2); + int HullPeriod = (int)MathFloor(MathSqrt(HmaPeriod)); + double hma, hmw, weight; + instanceNo *= 2; + + // + workHull[r][instanceNo] = price; + + // + hmw = HalfPeriod; + hma = hmw * price; + for (int k = 1; k < HalfPeriod && (r - k) >= 0; k++) + { + // + weight = HalfPeriod - k; + hmw += weight; + hma += weight * workHull[r - k][instanceNo]; + } + workHull[r][instanceNo + 1] = 2.0 * hma / hmw; + + // + hmw = HmaPeriod; + hma = hmw * price; + for (int k = 1; k < period && (r - k) >= 0; k++) + { + // + weight = HmaPeriod - k; + hmw += weight; + hma += weight * workHull[r - k][instanceNo]; + } + workHull[r][instanceNo + 1] -= hma / hmw; + + // + hmw = HullPeriod; + hma = hmw * workHull[r][instanceNo + 1]; + for (int k = 1; k < HullPeriod && (r - k) >= 0; k++) + { + // + weight = HullPeriod - k; + hmw += weight; + hma += weight * workHull[r - k][1 + instanceNo]; + } + + // + return (hma / hmw); +} + +// +double getPrice(ENUM_APPLIED_PRICE price, const double &open[], const double &close[], const double &high[], const double &low[], int i, int bars) +{ + switch (price) + { + case PRICE_CLOSE: + return (close[i]); + case PRICE_OPEN: + return (open[i]); + case PRICE_HIGH: + return (high[i]); + case PRICE_LOW: + return (low[i]); + case PRICE_MEDIAN: + return ((high[i] + low[i]) / 2.0); + case PRICE_TYPICAL: + return ((high[i] + low[i] + close[i]) / 3.0); + case PRICE_WEIGHTED: + return ((high[i] + low[i] + close[i] + close[i]) / 4.0); + // case PRICE_AVERAGE: return((high[i]+low[i]+close[i]+open[i])/4.0); + } + return (0); +} + +// \ No newline at end of file diff --git a/Documents/BKP/Source Codes/atr_trailing_stop_1_buffer.mq5 b/Documents/BKP/Source Codes/atr_trailing_stop_1_buffer.mq5 new file mode 100644 index 0000000000000000000000000000000000000000..4b1973c09df193fab563dc931481c820109cf91e GIT binary patch literal 16510 zcmds8ZEqXL5#A5{RG_~hR|OC#ld>p9Mpau>LQ8@zSbj-lHz*20ko95_q9vA;tT;~o zdfVsO;c$2Fc8@P&8m1sf9`9ynXJ?*y*}3C?{=H&WOwBCM!K-HeZ2kmkR?IIZo5`zX z-kKlG5k7n7*tAUt?XRE+?sQ|&OrCjd^GI8`8xn9ZKMcN}+=E7qA23~kK;C788MuM0gV?5q_ z-b*ifG|}iTP)!fyNWNBwUN12*19F5SGw;lsiFkLgw)fCx2VBW}!R+G~ZP&rCTX0TW zDz;LhnYb2inb|>fYndORyM41~UYXsAq@!1GWxW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#V^`rUNgq}ctljTG zt^c}|JH4^UIB7K>?no!E=gXsqTW37mr?e$L;^K|t^8h+1AEg%I4#SNrALHwmV{d9U-cM92KaQm6XP?6~{)!ZS-0^jgl1J>4uPbAnlzen%{l^{0G4fbBcadyV zRAa3@n#S3Gdi-f*=KU%~q~ptab=;kwj(2-M$)NFPJbVr6$ni0q!f1TgH>=8)|6MtU ejrq*&O`@-p-+AV{TwJ#=eJF8AEp+qNhyE|E)^u0^ literal 0 HcmV?d00001 diff --git a/Documents/BKP/Source Codes/dcc_piercing.mq5 b/Documents/BKP/Source Codes/dcc_piercing.mq5 new file mode 100644 index 00000000..de2cb05e --- /dev/null +++ b/Documents/BKP/Source Codes/dcc_piercing.mq5 @@ -0,0 +1,115 @@ +//+------------------------------------------------------------------+ +//| DCC_Piercing.mq5 | +//| Rajesh Nait, Copyright 2023 | +//| https://www.mql5.com/en/users/rajeshnait/seller | +//+------------------------------------------------------------------+ +#property copyright "Rajesh Nait, Copyright 2023" +#property link "https://www.mql5.com/en/users/rajeshnait/seller" +#property version "1.00" +#property indicator_chart_window +#property indicator_buffers 2 +#property indicator_plots 2 + +//--- plot Bullish Marubozu +#property indicator_label1 "+DCCP" +#property indicator_type1 DRAW_ARROW +#property indicator_color1 clrSnow +#property indicator_style1 STYLE_SOLID +#property indicator_width1 1 +//--- plot Bearish Marubozu +#property indicator_label2 "-DCCP" +#property indicator_type2 DRAW_ARROW +#property indicator_color2 clrSnow +#property indicator_style2 STYLE_SOLID +#property indicator_width2 1 + + +//--- input parameters +input group "Bearish" +input uchar InpBullishDCCPCode = 217; // BullishDCCP: code for style DRAW_ARROW (font Wingdings) +input int InpBullishDCCPShift = 10; // BullishDCCP: vertical shift of arrows in pixels +input group "Bullish" +input uchar InpBearishDCCPCode = 218; // BearishDCCP: code for style DRAW_ARROW (font Wingdings) +input int InpBearishDCCPShift =10; // BearishDCCP: vertical shift of arrows in pixels +//--- indicator buffers +double BullishDCCPBuffer[]; +double BearishDCCPBuffer[]; +int min_rates_total; +//+------------------------------------------------------------------+ +//| Custom indicator initialization function | +//+------------------------------------------------------------------+ +int OnInit() { + min_rates_total=2; +//--- indicator buffers mapping + SetIndexBuffer(0,BullishDCCPBuffer,INDICATOR_DATA); + SetIndexBuffer(1,BearishDCCPBuffer,INDICATOR_DATA); + + IndicatorSetInteger(INDICATOR_DIGITS,Digits()); +//--- setting a code from the Wingdings charset as the property of PLOT_ARROW + PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); + PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total); + + PlotIndexSetInteger(0,PLOT_ARROW,InpBullishDCCPCode); + PlotIndexSetInteger(1,PLOT_ARROW,InpBearishDCCPCode); + + ArraySetAsSeries(BullishDCCPBuffer,true); + ArraySetAsSeries(BearishDCCPBuffer,true); + +//--- set the vertical shift of arrows in pixels + PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,InpBullishDCCPShift); + PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-InpBearishDCCPShift); +//--- set as an empty value 0.0 + PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); + PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0); +//--- + return(INIT_SUCCEEDED); +} +//+------------------------------------------------------------------+ +//| Custom indicator iteration function | +//+------------------------------------------------------------------+ +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[]) { +//--- + if(rates_totalrates_total || prev_calculated<=0) { + limit=rates_total-min_rates_total; + } else { + limit=rates_total-prev_calculated; + } + ArraySetAsSeries(open,true); + ArraySetAsSeries(high,true); + ArraySetAsSeries(low,true); + ArraySetAsSeries(close,true); + +//--- + + for(int i=limit; i>=0 && !IsStopped(); i--) { + BullishDCCPBuffer[i]=0.0; + BearishDCCPBuffer[i]=0.0; + + + BearishDCCPBuffer[0]=0.0; + if(open[i]>close[i] && open[i+1]close[i+1]) + BearishDCCPBuffer[i]=high[i]; + + BullishDCCPBuffer[0]=0.0; + if(open[i]close[i+1] && open[i]=close[i+1] && low[i]open[i]) + crearFlecha(prefix+"Bull_Dominanat"+IntegerToString(i),time[i],low[i+1],clr,225,ANCHOR_TOP); + + if(open[i]>close[i] && open[i+1]>close[i+1] && open[i]<=close[i+1] && high[i]>close[i+1] && low[i+1]