ConfluenceForge Pro
Похожие материалы по тегам
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «confluenceforge_pro.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
ConfluenceForge Pro — это индикатор для MetaTrader 5, который отображается в окне графика и формирует сигналы LONG/SHORT на основе одного выбранного ведущего индикатора и набора подтверждающих фильтров. Пользователь выбирает ведущий триггер из каталога технических индикаторов и включает любые подтверждения из списка; сигнал появляется, когда ведущий индикатор и все выбранные подтверждения согласуются в пределах заданного числа свечей.
Индикатор поддерживает режим сигналов только по закрытым барам, альтернативные сигналы (без повторного LONG после LONG), отметку просроченных сетапов с подсказкой о не прошедших фильтрах, а также настраиваемый стиль отображения сигналов (стрелки, метки или оба варианта). Дополнительно выводится информационная панель с состоянием ведущего индикатора и каждого подтверждения, а также сведения о последнем сигнале.
На графике доступны накладываемые элементы: скользящие средние, Bollinger Bands, VWAP, Ichimoku, Parabolic SAR, SuperTrend, Half Trend, Range Filter, свечи PVSRA и Heikin-Ashi, зоны спроса и предложения, Fair Value Gaps, уровни пивотов, авто-Фибоначчи, фракталы, зоны ликвидности, сессии рынка и боксы диапазона. Есть оповещения через всплывающее окно, звук, push-уведомление и email. Индикатор не является торговым советником и не выполняет сделки.
Настройки программы
| Настройка | Описание |
|---|---|
| InpLeading | Ведущий индикатор, который служит триггером сигнала. |
| InpExpiry | Число свечей, в пределах которых подтверждения должны согласоваться с ведущим сигналом. |
| InpAlternate | Запрещает повторный сигнал LONG сразу после LONG (и аналогично для SHORT). |
| InpCloseOnly | Формирует сигналы только по закрытым барам без перерисовки. |
| InpBars | Количество баров для расчёта и отрисовки. |
| InpShowSignals | Показывает сигналы LONG и SHORT. |
| InpSigStyle | Стиль отображения сигналов: стрелки, метки или оба варианта. |
| InpShowExpired | Отмечает просроченные сетапы; при наведении показываются не прошедшие фильтры. |
| InpLongClr | Цвет отображения сигналов LONG. |
| InpShortClr | Цвет отображения сигналов SHORT. |
| InpShowDash | Показывает информационную панель на графике. |
| InpDashCorner | Положение информационной панели на графике. |
| InpDashSize | Размер информационной панели. |
| InpDashBar | Выбирает, по какому бару панель считывает данные: текущему или последнему закрытому. |
| InpDashMarginX | Горизонтальный отступ панели в пикселях. |
| InpDashMarginY | Вертикальный отступ панели в пикселях. |
| InpAlertPopup | Включает всплывающее окно оповещения при появлении сигнала. |
| InpAlertSound | Включает звуковое оповещение при появлении сигнала. |
| InpAlertSoundFile | Имя звукового файла, который воспроизводится при звуковом оповещении. |
| InpAlertPush | Включает push-уведомление при появлении сигнала. |
| InpAlertEmail | Включает отправку оповещений о сигналах по электронной почте. |
| InpC_RF | Включает Range Filter в качестве подтверждающего фильтра. |
| InpC_RQK | Включает Rational Quadratic Kernel в качестве подтверждающего фильтра. |
| InpC_ST | Включает SuperTrend в качестве подтверждающего фильтра. |
| InpC_HT | Включает Half Trend в качестве подтверждающего фильтра. |
| InpC_ICHI | Включает Ichimoku Cloud в качестве подтверждающего фильтра. |
| InpC_SICHI | Включает SuperIchi в качестве подтверждающего фильтра. |
| InpC_TSI | Включает True Strength Indicator в качестве подтверждающего фильтра. |
| InpC_TDFI | Включает Trend Direction Force Index в качестве подтверждающего фильтра. |
| InpC_TL | Включает Trendline Breakout в качестве подтверждающего фильтра. |
| InpC_RD | Включает Range Detector как фильтр выхода за активный диапазон. |
| InpC_HACOLT | Включает Heiken-Ashi Candlestick Oscillator в качестве подтверждающего фильтра. |
| InpC_DON | Включает Donchian Trend Ribbon в качестве подтверждающего фильтра. |
| InpC_STOCH | Включает Stochastic в качестве подтверждающего фильтра. |
| InpC_RSI | Включает RSI в качестве подтверждающего фильтра. |
| InpC_ROC | Включает Rate of Change в качестве подтверждающего фильтра. |
| InpC_VWAP | Включает VWAP в качестве подтверждающего фильтра. |
| InpC_CCI | Включает CCI в качестве подтверждающего фильтра. |
| InpC_EMA2 | Включает пересечение двух EMA в качестве подтверждающего фильтра. |
| InpC_EMA3 | Включает пересечение трёх EMA в качестве подтверждающего фильтра. |
| InpC_BXT | Включает B-Xtrender в качестве подтверждающего фильтра. |
| InpC_BBPT | Включает Bull Bear Power Trend в качестве подтверждающего фильтра. |
| InpC_DPO | Включает Detrended Price Oscillator в качестве подтверждающего фильтра. |
| InpC_BBOSC | Включает BB Oscillator в качестве подтверждающего фильтра. |
| InpC_CE | Включает Chandelier Exit в качестве подтверждающего фильтра. |
| InpC_DMI | Включает DMI (ADX) в качестве подтверждающего фильтра. |
| InpC_PSAR | Включает Parabolic SAR в качестве подтверждающего фильтра. |
| InpC_MACD | Включает MACD в качестве подтверждающего фильтра. |
| InpC_SSL | Включает SSL Channel в качестве подтверждающего фильтра. |
| InpC_WAE | Включает Waddah Attar Explosion в качестве подтверждающего фильтра. |
| InpC_CMF | Включает Chaikin Money Flow в качестве подтверждающего фильтра. |
| InpC_VI | Включает Vortex Index в качестве подтверждающего фильтра. |
| InpC_STC | Включает Schaff Trend Cycle в качестве подтверждающего фильтра. |
| InpC_AO | Включает Awesome Oscillator в качестве подтверждающего фильтра. |
| InpC_VO | Включает Volatility Oscillator в качестве подтверждающего фильтра. |
| InpC_WOLF | Включает Wolfpack ID в качестве подтверждающего фильтра. |
| InpC_QQE | Включает QQE Mod в качестве подтверждающего фильтра. |
| InpC_HULL | Включает Hull Suite в качестве подтверждающего фильтра. |
| InpC_UTBOT | Включает UT Bot (ATR Trailing Stop) в качестве подтверждающего фильтра. |
| InpC_AROON | Включает Aroon в качестве подтверждающего фильтра. |
| InpC_WPR | Включает Williams %R в качестве подтверждающего фильтра. |
| InpC_MFI | Включает Money Flow Index в качестве подтверждающего фильтра. |
| InpC_SQZ | Включает Squeeze Momentum в качестве подтверждающего фильтра. |
| InpC_LR | Включает наклон линейной регрессии в качестве подтверждающего фильтра. |
| InpC_KAMA | Включает Kaufman Adaptive MA в качестве подтверждающего фильтра. |
| InpC_FISHER | Включает Fisher Transform в качестве подтверждающего фильтра. |
| InpC_EMAF | Включает фильтр положения цены относительно EMA. |
| InpC_RSIMAD | Включает фильтр направления скользящей средней RSI. |
| InpC_RSILIM | Включает фильтр предельных значений RSI. |
| InpC_RSIMALIM | Включает фильтр предельных значений скользящей средней RSI. |
| InpC_MD | Включает McGinley Dynamic в качестве подтверждающего фильтра. |
| InpC_CHOP | Включает Choppiness Index как фильтр тренда. |
| InpC_DV | Включает Damiani Volatmeter как фильтр волатильности. |
| InpC_VOL | Включает Volume в качестве подтверждающего фильтра. |
| InpSw_MA | Включает отображение скользящих средних. |
| InpSw_SD | Включает отображение зон спроса и предложения. |
| InpSw_PSAR | Включает отображение Parabolic SAR. |
| InpSw_ICHI | Включает отображение Ichimoku Cloud. |
| InpSw_HA | Включает отображение свечей Heikin-Ashi. |
| InpSw_FIB | Включает отображение авто-Фибоначчи. |
| InpSw_RD | Включает отображение боксов Range Detector. |
| InpSw_VWAP | Включает отображение VWAP. |
| InpSw_BB | Включает отображение Bollinger Bands на графике. |
| InpSw_ST | Включает отображение SuperTrend. |
| InpSw_HT | Включает отображение Half Trend. |
| InpSw_RF | Включает отображение Range Filter. |
| InpSw_PVSRA | Включает отображение векторных свечей PVSRA. |
| InpSw_LZ | Включает отображение зон ликвидности по векторным свечам. |
| InpSw_FVG | Включает отображение Fair Value Gaps. |
| InpSw_PIV | Включает отображение уровней пивотов. |
| InpSw_FRACTAL | Включает отображение фракталов. |
| InpSw_SESS | Включает отображение торговых сессий рынка. |
| InpApplyTheme | Применяет тёмную цветовую тему графика ConfluenceForge. |
| InpMA1On | Включает отображение первой скользящей средней. |
| InpMA1Len | Период первой скользящей средней. |
| InpMA1Type | Тип расчёта первой скользящей средней. |
| InpMA2On | Включает отображение второй скользящей средней. |
| InpMA2Len | Период второй скользящей средней. |
| InpMA2Type | Тип расчёта второй скользящей средней. |
| InpMA3On | Включает отображение третьей скользящей средней. |
Поиск по коду файла
#property version "1.00"
#property description "ConfluenceForge Pro - build your own trading system from 53 indicators."
#property description "Pick 1 Leading trigger, stack any Confirmation filters, read the live dashboard."
#property description "Signals print on closed bars only (no repaint). Includes Supply/Demand, FVG,"
#property description "Market Sessions, PVSRA vector candles, Liquidity zones, Pivots, Fibonacci and more."
#property indicator_chart_window
#property indicator_buffers 32
#property indicator_plots 24
#property indicator_label1 "MA 1"
#property indicator_type1 DRAW_LINE
#property indicator_color1 C'254,234,74'
#property indicator_width1 2
#property indicator_label2 "MA 2"
#property indicator_type2 DRAW_LINE
#property indicator_color2 C'253,84,87'
#property indicator_width2 2
#property indicator_label3 "MA 3"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrAqua
#property indicator_width3 2
#property indicator_label4 "MA 4"
#property indicator_type4 DRAW_LINE
#property indicator_color4 clrDodgerBlue
#property indicator_width4 2
#property indicator_label5 "MA 5"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrWhite
#property indicator_width5 2
#property indicator_label6 "Range Filter"
#property indicator_type6 DRAW_COLOR_LINE
#property indicator_color6 clrLime,clrRed,clrOrange
#property indicator_width6 2
#property indicator_label7 "SuperTrend Up"
#property indicator_type7 DRAW_LINE
#property indicator_color7 C'0,200,83'
#property indicator_width7 2
#property indicator_label8 "SuperTrend Down"
#property indicator_type8 DRAW_LINE
#property indicator_color8 C'255,61,61'
#property indicator_width8 2
#property indicator_label9 "HalfTrend"
#property indicator_type9 DRAW_COLOR_LINE
#property indicator_color9 C'41,98,255',C'255,61,61'
#property indicator_width9 2
#property indicator_label10 "Parabolic SAR"
#property indicator_type10 DRAW_ARROW
#property indicator_color10 C'120,200,255'
#property indicator_width10 1
#property indicator_label11 "VWAP"
#property indicator_type11 DRAW_LINE
#property indicator_color11 C'41,98,255'
#property indicator_width11 2
#property indicator_label12 "BB Upper"
#property indicator_type12 DRAW_LINE
#property indicator_color12 C'41,98,255'
#property indicator_label13 "BB Basis"
#property indicator_type13 DRAW_LINE
#property indicator_color13 C'255,109,0'
#property indicator_label14 "BB Lower"
#property indicator_type14 DRAW_LINE
#property indicator_color14 C'41,98,255'
#property indicator_label15 "Ichimoku Conversion"
#property indicator_type15 DRAW_LINE
#property indicator_color15 C'41,98,255'
#property indicator_label16 "Ichimoku Base"
#property indicator_type16 DRAW_LINE
#property indicator_color16 C'183,28,28'
#property indicator_label17 "Cloud Span A;Cloud Span B"
#property indicator_type17 DRAW_FILLING
#property indicator_color17 C'24,58,32',C'66,26,26'
#property indicator_label18 "Range Top"
#property indicator_type18 DRAW_LINE
#property indicator_color18 C'33,87,243'
#property indicator_style18 STYLE_DOT
#property indicator_label19 "Range Bottom"
#property indicator_type19 DRAW_LINE
#property indicator_color19 C'33,87,243'
#property indicator_style19 STYLE_DOT
#property indicator_label20 "Open;High;Low;Close"
#property indicator_type20 DRAW_COLOR_CANDLES
#property indicator_color20 clrLime,clrRed,clrBlue,clrMagenta,C'200,200,200',C'77,77,77',C'38,166,154',C'239,83,80'
#property indicator_label21 "Fractal Up"
#property indicator_type21 DRAW_ARROW
#property indicator_color21 C'0,150,136'
#property indicator_label22 "Fractal Down"
#property indicator_type22 DRAW_ARROW
#property indicator_color22 C'244,67,54'
#property indicator_label23 "LONG Signal"
#property indicator_type23 DRAW_ARROW
#property indicator_color23 C'38,194,92'
#property indicator_width23 3
#property indicator_label24 "SHORT Signal"
#property indicator_type24 DRAW_ARROW
#property indicator_color24 C'243,64,64'
#property indicator_width24 3
enum ENUM_CF_IND
{
CF_RANGE_FILTER=0, CF_RQK, CF_SUPERTREND, CF_HALFTREND, CF_ICHIMOKU, CF_SUPERICHI, CF_TSI, CF_TDFI,
CF_TRENDLINE, CF_RANGE_DET, CF_HACOLT, CF_DONCHIAN, CF_STOCH, CF_RSI, CF_ROC, CF_VWAP, CF_CCI,
CF_EMA2, CF_EMA3, CF_BXT, CF_BBPT, CF_DPO, CF_BBOSC, CF_CHANDELIER, CF_DMI, CF_PSAR, CF_MACD,
CF_SSL, CF_WAE, CF_CMF, CF_VORTEX, CF_STC, CF_AO, CF_VOLOSC, CF_WOLF, CF_QQE, CF_HULL,
CF_UTBOT, CF_AROON, CF_WPR, CF_MFI, CF_SQUEEZE, CF_LINREG, CF_KAMA, CF_FISHER,
CF_EMA_FILTER, CF_RSI_MADIR, CF_RSI_LIMIT, CF_RSI_MALIMIT, CF_MCGINLEY, CF_CHOP, CF_DAMIANI, CF_VOLUME,
CF_COUNT
};
enum ENUM_CF_LEAD
{
LEAD_RANGE_FILTER=0, // Range Filter
LEAD_RQK=1, // Rational Quadratic Kernel (RQK)
LEAD_SUPERTREND=2, // SuperTrend
LEAD_HALFTREND=3, // Half Trend
LEAD_ICHIMOKU=4, // Ichimoku Cloud
LEAD_SUPERICHI=5, // SuperIchi
LEAD_TSI=6, // True Strength Indicator (TSI)
LEAD_TDFI=7, // Trend Direction Force Index (TDFI)
LEAD_TRENDLINE=8, // Trendline Breakout
LEAD_RANGE_DET=9, // Range Detector (breakout)
LEAD_HACOLT=10, // Heiken-Ashi Candlestick Oscillator
LEAD_DONCHIAN=11, // Donchian Trend Ribbon
LEAD_STOCH=12, // Stochastic
LEAD_RSI=13, // RSI
LEAD_ROC=14, // Rate of Change (ROC)
LEAD_VWAP=15, // VWAP
LEAD_CCI=16, // CCI
LEAD_EMA2=17, // 2 EMA Cross
LEAD_EMA3=18, // 3 EMA Cross
LEAD_BXT=19, // B-Xtrender
LEAD_BBPT=20, // Bull Bear Power Trend
LEAD_DPO=21, // Detrended Price Oscillator (DPO)
LEAD_BBOSC=22, // BB Oscillator
LEAD_CHANDELIER=23, // Chandelier Exit
LEAD_DMI=24, // DMI (ADX)
LEAD_PSAR=25, // Parabolic SAR (PSAR)
LEAD_MACD=26, // MACD
LEAD_SSL=27, // SSL Channel
LEAD_WAE=28, // Waddah Attar Explosion
LEAD_CMF=29, // Chaikin Money Flow
LEAD_VORTEX=30, // Vortex Index
LEAD_STC=31, // Schaff Trend Cycle (STC)
LEAD_AO=32, // Awesome Oscillator
LEAD_VOLOSC=33, // Volatility Oscillator
LEAD_WOLF=34, // Wolfpack ID
LEAD_QQE=35, // QQE Mod
LEAD_HULL=36, // Hull Suite
LEAD_UTBOT=37, // UT Bot (ATR Trailing Stop) [NEW]
LEAD_AROON=38, // Aroon [NEW]
LEAD_WPR=39, // Williams %R [NEW]
LEAD_MFI=40, // Money Flow Index (MFI) [NEW]
LEAD_SQUEEZE=41, // Squeeze Momentum [NEW]
LEAD_LINREG=42, // Linear Regression Slope [NEW]
LEAD_KAMA=43, // Kaufman Adaptive MA (KAMA) [NEW]
LEAD_FISHER=44 // Fisher Transform [NEW]
};
enum ENUM_CF_SIGSTYLE { SIG_ARROWS=0, // Arrows only
SIG_LABELS=1, // Labels only
SIG_BOTH=2 // Arrows + Labels
};
enum ENUM_CF_CORNER { DC_TL=0, // Top-Left
DC_TR=1, // Top-Right
DC_BL=2, // Bottom-Left
DC_BR=3 // Bottom-Right
};
enum ENUM_CF_SIZE { DS_SMALL=0, // Small
DS_NORMAL=1,// Normal
DS_LARGE=2 // Large
};
enum ENUM_CF_DASHBAR { DB_CURRENT=0, // Current bar (live)
DB_CLOSED=1 // Last closed bar
};
enum ENUM_CF_MA { MA_SMA=0, // SMA
MA_EMA=1, // EMA
MA_RMA=2, // RMA (Wilder)
MA_WMA=3, // WMA
MA_HMA=4, // HMA
MA_VWMA=5 // VWMA
};
enum ENUM_RF_TYPE { RF_DEFAULT=0, // Default
RF_DW=1 // DW (smoothed average change)
};
enum ENUM_TSI_TYPE { TSI_SIGNAL=0, // Signal Cross
TSI_ZERO=1 // Zero Line Cross
};
enum ENUM_EMA2_MODE { E2_DEFAULT=0, // Default (on cross bar)
E2_LOOKBACK=1 // Lookback confirmation
};
enum ENUM_BX_TYPE { BX_SHORTLONG=0, // Short and Long term trend
BX_SHORT=1 // Short term trend
};
enum ENUM_BBPT_TYPE { BBPT_FOLLOW=0, // Follow Trend
BBPT_WITHOUT=1 // Without Trend
};
enum ENUM_BBOSC_TYPE { BBO_ENTER=0, // Entering Lower/Upper Band
BBO_EXIT=1 // Exiting Lower/Upper Band
};
enum ENUM_AO_TYPE { AO_ZERO=0, // Zero Line Cross
AO_AC_ZERO=1,// AC Zero Line Cross
AO_AC_MOM=2 // AC Momentum Bar
};
enum ENUM_ADX_TYPE { ADX_ONLY=0, // ADX only
ADX_DI=1, // ADX & +DI -DI
ADX_ADV=2 // Advanced
};
enum ENUM_DV_TYPE { DV_SIMPLE=0, // Simple
DV_THRESH=1, // Threshold
DV_10P=2 // 10p Difference
};
enum ENUM_STOCH_TYPE { STO_CROSS=0, // CrossOver
STO_OBOS=1, // CrossOver in OB & OS levels
STO_KD=2 // %K above/below %D
};
enum ENUM_RSI_TYPE { RSI_MACROSS=0, // RSI MA Cross
RSI_EXIT=1, // RSI Exits OB/OS zones
RSI_LEVEL=2 // RSI Level
};
enum ENUM_MACD_TYPE { MACD_CROSS=0, // MACD Crossover
MACD_ZERO=1 // Zero line crossover
};
enum ENUM_VOL_TYPE { VOL_ABOVE=0, // Volume above MA
VOL_SIMPLE=1,// Simple up/down volume
VOL_DELTA=2 // Delta
};
enum ENUM_QQE_TYPE { QQE_LINE=0, // Line
QQE_BAR=1, // Bar
QQE_BOTH=2 // Line & Bar
};
enum ENUM_HULL_MODE { HULL_HMA=0, // HMA
HULL_THMA=1,// THMA
HULL_EHMA=2 // EHMA
};
enum ENUM_VI_TYPE { VI_SIMPLE=0, // Simple
VI_ADV=1 // Advanced
};
enum ENUM_PIV_TYPE { PV_TRAD=0, // Traditional
PV_FIB=1, // Fibonacci
PV_WOOD=2, // Woodie
PV_CLAS=3, // Classic
PV_CAM=4 // Camarilla
};
enum ENUM_PIV_TF { PVT_AUTO=0, // Auto
PVT_D1=1, // Daily
PVT_W1=2, // Weekly
PVT_MN=3 // Monthly
};
enum ENUM_VW_ANCHOR { VW_SESSION=0, // Session (day)
VW_WEEK=1, // Week
VW_MONTH=2 // Month
};
input group "======== SIGNAL ENGINE ========"
input ENUM_CF_LEAD InpLeading = LEAD_RANGE_FILTER; // Leading Indicator (trigger)
input int InpExpiry = 3; // Signal Expiry (candles for confirmations to agree)
input bool InpAlternate = true; // Alternate signals (no LONG after LONG)
input bool InpCloseOnly = true; // Signals on closed bars only (non-repainting)
input int InpBars = 3000; // Bars to calculate & draw
input bool InpShowSignals = true; // Show LONG / SHORT signals
input ENUM_CF_SIGSTYLE InpSigStyle = SIG_BOTH; // Signal style
input bool InpShowExpired = true; // Mark expired setups (hover = failed filters)
input color InpLongClr = C'38,194,92'; // Long colour
input color InpShortClr = C'243,64,64'; // Short colour
input group "======== DASHBOARD ========"
input bool InpShowDash = true; // Show dashboard
input ENUM_CF_CORNER InpDashCorner = DC_BR; // Dashboard position
input ENUM_CF_SIZE InpDashSize = DS_NORMAL; // Dashboard size
input ENUM_CF_DASHBAR InpDashBar = DB_CURRENT;// Dashboard reads
input int InpDashMarginX = 12; // Margin X (px)
input int InpDashMarginY = 28; // Margin Y (px)
input group "======== ALERTS ========"
input bool InpAlertPopup = true; // Popup alert
input bool InpAlertSound = false; // Sound alert
input string InpAlertSoundFile = "alert.wav"; // Sound file
input bool InpAlertPush = false; // Push notification
input bool InpAlertEmail = false; // Email
input group "======== CONFIRMATION INDICATORS (FILTERS) ========"
input bool InpC_RF = false; // Range Filter
input bool InpC_RQK = true; // Rational Quadratic Kernel (RQK)
input bool InpC_ST = false; // SuperTrend
input bool InpC_HT = false; // Half Trend
input bool InpC_ICHI = false; // Ichimoku Cloud
input bool InpC_SICHI = false; // SuperIchi
input bool InpC_TSI = false; // True Strength Indicator (TSI)
input bool InpC_TDFI = false; // Trend Direction Force Index (TDFI)
input bool InpC_TL = false; // Trendline Breakout
input bool InpC_RD = false; // Range Detector (filter: outside active range)
input bool InpC_HACOLT = false; // Heiken-Ashi Candlestick Oscillator
input bool InpC_DON = false; // Donchian Trend Ribbon
input bool InpC_STOCH = false; // Stochastic
input bool InpC_RSI = false; // RSI
input bool InpC_ROC = false; // Rate of Change (ROC)
input bool InpC_VWAP = false; // VWAP
input bool InpC_CCI = false; // CCI
input bool InpC_EMA2 = false; // 2 EMA Cross
input bool InpC_EMA3 = false; // 3 EMA Cross
input bool InpC_BXT = false; // B-Xtrender
input bool InpC_BBPT = false; // Bull Bear Power Trend
input bool InpC_DPO = false; // Detrended Price Oscillator (DPO)
input bool InpC_BBOSC = false; // BB Oscillator
input bool InpC_CE = false; // Chandelier Exit
input bool InpC_DMI = false; // DMI (ADX)
input bool InpC_PSAR = false; // Parabolic SAR
input bool InpC_MACD = false; // MACD
input bool InpC_SSL = false; // SSL Channel
input bool InpC_WAE = false; // Waddah Attar Explosion
input bool InpC_CMF = false; // Chaikin Money Flow
input bool InpC_VI = false; // Vortex Index
input bool InpC_STC = false; // Schaff Trend Cycle (STC)
input bool InpC_AO = false; // Awesome Oscillator
input bool InpC_VO = false; // Volatility Oscillator
input bool InpC_WOLF = false; // Wolfpack ID
input bool InpC_QQE = false; // QQE Mod
input bool InpC_HULL = false; // Hull Suite
input bool InpC_UTBOT = false; // UT Bot (ATR Trailing Stop)
input bool InpC_AROON = false; // Aroon
input bool InpC_WPR = false; // Williams %R
input bool InpC_MFI = false; // Money Flow Index (MFI)
input bool InpC_SQZ = false; // Squeeze Momentum
input bool InpC_LR = false; // Linear Regression Slope
input bool InpC_KAMA = false; // Kaufman Adaptive MA (KAMA)
input bool InpC_FISHER = false; // Fisher Transform
input bool InpC_EMAF = false; // EMA Filter (price vs EMA)
input bool InpC_RSIMAD = false; // RSI MA Direction
input bool InpC_RSILIM = false; // RSI Limit
input bool InpC_RSIMALIM = false; // RSI MA Limit
input bool InpC_MD = false; // McGinley Dynamic
input bool InpC_CHOP = false; // Choppiness Index (trend filter)
input bool InpC_DV = false; // Damiani Volatmeter (volatility filter)
input bool InpC_VOL = false; // Volume
input group "======== SWITCH BOARD (OVERLAYS) ========"
input bool InpSw_MA = false; // Moving Averages
input bool InpSw_SD = true; // Supply / Demand zones
input bool InpSw_PSAR = false; // Parabolic SAR
input bool InpSw_ICHI = false; // Ichimoku Cloud
input bool InpSw_HA = false; // Heikin-Ashi candles
input bool InpSw_FIB = false; // Auto Fibonacci
input bool InpSw_RD = false; // Range Detector
input bool InpSw_VWAP = false; // VWAP
input bool InpSw_BB = false; // Bollinger Bands
input bool InpSw_ST = false; // SuperTrend
input bool InpSw_HT = false; // Half Trend
input bool InpSw_RF = false; // Range Filter
input bool InpSw_PVSRA = true; // PVSRA vector candles
input bool InpSw_LZ = false; // Liquidity zones (vector candle zones)
input bool InpSw_FVG = false; // Fair Value Gaps
input bool InpSw_PIV = false; // Pivot levels
input bool InpSw_FRACTAL = false; // Fractals
input bool InpSw_SESS = true; // Market sessions
input bool InpApplyTheme = true; // Apply ConfluenceForge dark chart theme
input group "======== MOVING AVERAGES ========"
input bool InpMA1On=true; // MA1 On
input int InpMA1Len=5; // MA1 Len
input ENUM_CF_MA InpMA1Type=MA_EMA; // MA1 Type
input bool InpMA2On=true; // MA2 On
input int InpMA2Len=13; // MA2 Len
input ENUM_CF_MA InpMA2Type=MA_EMA; // MA2 Type
input bool InpMA3On=false; // MA3 On
input int InpMA3Len=20; // MA3 Len
input ENUM_CF_MA InpMA3Type=MA_EMA; // MA3 Type
input bool InpMA4On=true; // MA4 On
input int InpMA4Len=50; // MA4 Len
input ENUM_CF_MA InpMA4Type=MA_EMA; // MA4 Type
input bool InpMA5On=true; // MA5 On
input int InpMA5Len=200; // MA5 Len
input ENUM_CF_MA InpMA5Type=MA_EMA; // MA5 Type
input group "======== RANGE FILTER ========"
input ENUM_RF_TYPE InpRFType = RF_DEFAULT; // Type
input int InpRFPer = 100; // Period
input double InpRFMult = 3.0; // Multiplier
input double InpRFDWQty = 2.618;// DW range size
input int InpRFDWPer = 14; // DW range period
input int InpRFDWSm = 27; // DW smoothing period
input group "======== RATIONAL QUADRATIC KERNEL ========"
input double InpRQKLook = 8.0; // Lookback window
input double InpRQKWeight = 8.0; // Relative weighting
input int InpRQKStart = 25; // Start regression at bar
input group "======== SUPERTREND ========"
input int InpSTPer = 10; // ATR period
input double InpSTMult = 3.0; // ATR multiplier
input bool InpSTWilder = true; // Wilder ATR (false = SMA of TR)
input group "======== HALF TREND ========"
input int InpHTAmp = 2; // Amplitude
input double InpHTDev = 2; // Channel deviation
input group "======== ICHIMOKU / SUPERICHI ========"
input int InpIchiConv = 9; // Conversion line
input int InpIchiBase = 26; // Base line
input int InpIchiSpanB= 52; // Leading span B
input int InpIchiDisp = 26; // Displacement
input int InpSITenkan = 9; // SITenkan
input double InpSITenkanM = 2.0; // SITenkan M
input int InpSIKijun = 26; // SIKijun
input double InpSIKijunM = 4.0; // SIKijun M
input int InpSISpanB = 52; // SISpan B
input double InpSISpanBM = 6.0; // SISpan BM
input group "======== TSI / TDFI / TRENDLINE ========"
input int InpTSILong=25; // TSILong
input int InpTSIShort=13; // TSIShort
input int InpTSISig=13; // TSISig
input ENUM_TSI_TYPE InpTSIType=TSI_SIGNAL; // TSIType
input int InpTDFILook = 13; // TDFILook
input int InpTDFIMma=13; // TDFIMma
input int InpTDFISmma=13; // TDFISmma
input int InpTDFIN=3; // TDFIN
input double InpTDFIHigh = 0.05; // TDFIHigh
input double InpTDFILow = -0.05; // TDFILow
input int InpTLLen = 14; // TLLen
input double InpTLSlope = 1.0; // TLSlope
input group "======== RANGE DETECTOR / HACOLT / DONCHIAN ========"
input int InpRDLen=20; // RDLen
input double InpRDMult=1.0; // RDMult
input int InpRDAtr=500; // RDAtr
input int InpHATema=55; // HATema
input int InpHAEma=60; // HAEma
input double InpHACandle=1.1; // HACandle
input int InpDonLen=15; // Don Len
input group "======== STOCHASTIC / RSI / ROC / CCI ========"
input int InpStoLen=14; // Sto Len
input int InpStoK=3; // Sto K
input int InpStoD=3; // Sto D
input int InpStoOB=80; // Sto OB
input int InpStoOS=20; // Sto OS
input ENUM_STOCH_TYPE InpStoType=STO_CROSS; // Sto Type
input int InpRSILen=14; // RSILen
input int InpRSIMaLen=14; // RSIMa Len
input ENUM_CF_MA InpRSIMaType=MA_SMA; // RSIMa Type
input ENUM_RSI_TYPE InpRSIType=RSI_MACROSS; // RSIType
input int InpRSIOB=80; // RSIOB
input int InpRSIOS=20; // RSIOS
input int InpRSIMid=50; // RSIMid
input int InpRSILimUp=40; // RSILim Up
input int InpRSILimDn=60; // RSILim Dn
input int InpRSIMaLimUp=40; // RSIMa Lim Up
input int InpRSIMaLimDn=60; // RSIMa Lim Dn
input int InpROCLen=9; // ROCLen
input int InpCCILen=20; // CCILen
input int InpCCIUp=100; // CCIUp
input int InpCCIDn=-100; // CCIDn
input group "======== VWAP / EMA CROSS ========"
input ENUM_VW_ANCHOR InpVWAnchor=VW_SESSION; // VWAnchor
input int InpE2Fast=50; // E2 Fast
input int InpE2Slow=200; // E2 Slow
input ENUM_EMA2_MODE InpE2Mode=E2_DEFAULT; // E2 Mode
input int InpE2Look=3; // E2 Look
input int InpE3a=9; // E3a
input int InpE3b=21; // E3b
input int InpE3c=55; // E3c
input int InpEMAFLen=200; // EMA filter period
input group "======== B-XTRENDER / BBPT / DPO / BB OSC ========"
input int InpBXs1=5; // BXs1
input int InpBXs2=20; // BXs2
input int InpBXs3=15; // BXs3
input int InpBXl1=5; // BXl1
input int InpBXl2=10; // BXl2
input ENUM_BX_TYPE InpBXType=BX_SHORTLONG; // BXType
input ENUM_BBPT_TYPE InpBBPTType=BBPT_FOLLOW; // BBPTType
input int InpDPOLen=10; // DPOLen
input int InpBBOLen=20; // BBOLen
input double InpBBOMult=2.0; // BBOMult
input int InpBBOTrig=4; // BBOTrig
input ENUM_BBOSC_TYPE InpBBOType=BBO_ENTER; // BBOType
input group "======== CHANDELIER / DMI / PSAR / MACD / SSL ========"
input int InpCELen=22; // CELen
input double InpCEMult=3.0; // CEMult
input bool InpCEClose=true; // CEClose
input int InpADXLen=5; // ADXLen
input int InpADXKey=20; // ADXKey
input int InpDILen=10; // DILen
input ENUM_ADX_TYPE InpADXType=ADX_DI; // ADXType
input double InpSARStart=0.02; // SARStart
input double InpSARInc=0.02; // SARInc
input double InpSARMax=0.2; // SARMax
input int InpMACDFast=12; // MACDFast
input int InpMACDSlow=26; // MACDSlow
input int InpMACDSig=9; // MACDSig
input ENUM_MACD_TYPE InpMACDType=MACD_CROSS; // MACDType
input int InpSSLLen=10; // SSLLen
input group "======== WAE / CMF / VORTEX / STC / AO / VO / WOLF ========"
input int InpWAESens=150; // WAESens
input int InpWAEFast=20; // WAEFast
input int InpWAESlow=40; // WAESlow
input int InpWAEBB=20; // WAEBB
input double InpWAEMult=2.0; // WAEMult
input int InpCMFLen=20; // CMFLen
input int InpVILen=14; // VILen
input double InpVIUp=1.1; // VIUp
input double InpVILo=0.9; // VILo
input ENUM_VI_TYPE InpVIType=VI_SIMPLE; // VIType
input int InpSTCFast=23; // STCFast
input int InpSTCSlow=50; // STCSlow
input int InpSTCCycle=10; // STCCycle
input int InpSTCD1=3; // STCD1
input int InpSTCD2=3; // STCD2
input int InpSTCUp=75; // STCUp
input int InpSTCLo=25; // STCLo
input ENUM_AO_TYPE InpAOType=AO_ZERO; // AOType
input int InpVOLen=100; // VOLen
input int InpWolfFast=3; // Wolf Fast
input int InpWolfSlow=8; // Wolf Slow
input group "======== QQE MOD / HULL ========"
input int InpQQERsi=6; // QQERsi
input int InpQQESF=5; // QQESF
input double InpQQEF1=3.0; // QQEF1
input double InpQQEF2=1.61; // QQEF2
input int InpQQEThr=3; // QQEThr
input int InpQQEBBLen=50; // QQEBBLen
input double InpQQEBBMult=0.35; // QQEBBMult
input ENUM_QQE_TYPE InpQQEType=QQE_LINE; // QQEType
input ENUM_HULL_MODE InpHullMode=HULL_HMA; // Hull Mode
input int InpHullLen=55; // Hull Len
input group "======== NEW: UT BOT / AROON / W%R / MFI / SQUEEZE / LINREG / KAMA / FISHER ========"
input double InpUTKey=1.0; // UTKey
input int InpUTAtr=10; // UTAtr
input int InpAroonLen=14; // Aroon Len
input int InpWPRLen=14; // WPRLen
input int InpMFILen=14; // MFILen
input int InpSQZLen=20; // SQZLen
input double InpSQZBB=2.0; // SQZBB
input double InpSQZKC=1.5; // SQZKC
input int InpLRLen=20; // LRLen
input int InpKAMALen=10; // KAMALen
input int InpKAMAFast=2; // KAMAFast
input int InpKAMASlow=30; // KAMASlow
input int InpFisherLen=9; // Fisher Len
input group "======== McGINLEY / CHOP / DAMIANI / VOLUME ========"
input int InpMDLen=14; // MDLen
input int InpChopLen=14; // Chop Len
input double InpChopLim=61.8; // Chop Lim
input int InpDVVisAtr=13; // DVVis Atr
input int InpDVVisStd=20; // DVVis Std
input int InpDVSedAtr=40; // DVSed Atr
input int InpDVSedStd=100; // DVSed Std
input double InpDVThr=1.4; // DVThr
input bool InpDVLag=true; // DVLag
input ENUM_DV_TYPE InpDVType=DV_SIMPLE; // DVType
input ENUM_VOL_TYPE InpVolType=VOL_ABOVE; // Vol Type
input int InpVolMA=20; // Vol MA
input group "======== SUPPLY / DEMAND ========"
input int InpSDSwing=10; // Swing high/low length
input int InpSDHistory=20; // Zones to keep
input double InpSDWidth=2.5; // Zone width (ATR x 0.1)
input color InpSupplyClr=C'62,64,72'; // Supply colour
input color InpDemandClr=C'0,104,104'; // Demand colour
input bool InpSDShowBOS=true; // Show broken zones (BOS)
input group "======== FAIR VALUE GAP ========"
input int InpFVGDays=7; // Days lookback
input bool InpFVGCE=false; // Remove on CE (50%) instead of full fill
input color InpFVGUpClr=C'16,40,70'; // Bullish FVG
input color InpFVGDnClr=C'70,44,14'; // Bearish FVG
input group "======== PIVOTS / FIBONACCI / FRACTALS ========"
input ENUM_PIV_TYPE InpPivType=PV_TRAD; // Piv Type
input ENUM_PIV_TF InpPivTF=PVT_AUTO; // Piv TF
input int InpPivBack=1; // Piv Back
input color InpPivClr=C'251,140,0'; // Piv Clr
input int InpFibDepth=10; // Fib Depth
input double InpFibDevAtr=3.0; // Fib Dev Atr
input string InpFibLevels="0,0.236,0.382,0.5,0.618,0.786,1"; // Fibonacci levels
input int InpFractalN=2; // Fractal N
input group "======== PVSRA / LIQUIDITY ZONES ========"
input color InpPV200Bull=clrLime; // PV200 Bull
input color InpPV200Bear=clrRed; // PV200 Bear
input color InpPV150Bull=clrBlue; // PV150 Bull
input color InpPV150Bear=clrMagenta; // PV150 Bear
input color InpPVNormBull=C'200,200,200'; // PVNorm Bull
input color InpPVNormBear=C'77,77,77'; // PVNorm Bear
input int InpLZMax=100; // Max liquidity zones
input group "======== MARKET SESSIONS (UTC, DST aware) ========"
input int InpGMTOffset=99; // Broker GMT offset in hours (99 = auto)
input int InpSessDays=5; // Days to draw
input bool InpSessLondon=true; // Sess London
input bool InpSessNY=true; // Sess NY
input bool InpSessTokyo=true; // Sess Tokyo
input bool InpSessHK=false; // Sess HK
input bool InpSessSydney=false; // Sess Sydney
input bool InpSessEUB=false; // Sess EUB
input bool InpSessUSB=false; // Sess USB
double bMA1[],bMA2[],bMA3[],bMA4[],bMA5[],bRF[],bRFc[],bSTu[],bSTd[],bHT[],bHTc[],bSAR[],bVW[];
double bBBu[],bBBm[],bBBl[],bTK[],bKJ[],bSA[],bSB[],bRDt[],bRDb[],bCO[],bCH[],bCL[],bCC[],bCc[];
double bFU[],bFD[],bLong[],bShort[],bSig[];
#define PFX "CFP_"
#define WARMUP 700
struct SigArr { char L[]; char S[]; };
SigArr g_sig[CF_COUNT];
bool g_done[CF_COUNT];
bool g_use[CF_COUNT];
int g_lead=0;
int g_conf[]; int g_nconf=0;
int N=0, g_base=0, g_drawFrom=0;
double g_o[],g_h[],g_l[],g_c[],g_v[],g_hl2[],g_hlc3[],g_tr[],g_atr14[];
datetime g_t[];
int g_dir[]; // +1 long signal, -1 short signal
int g_expired[]; // +1 expired long setup, -1 expired short setup
double g_rf[],g_rfc[],g_stu[],g_std[],g_ht[],g_htc[],g_sar[],g_vwap[],g_bbu[],g_bbm[],g_bbl[];
double g_tk[],g_kj[],g_sa[],g_sb[],g_rdt[],g_rdb[];
int g_va[];
struct RDBox { int l; int r; double top; double bot; int os; };
RDBox g_rdBoxes[]; int g_nRD=0;
int g_lastRates=0;
uint g_lastMs=0;
datetime g_lastAlert=0;
long g_chartBg=0, g_chartFg=0, g_chartGrid=0, g_chartUp=0, g_chartDn=0, g_chartBull=0, g_chartBear=0, g_chartLine=0, g_foreground=0;
bool g_themeSaved=false;
string IndName(const int id)
{
switch(id)
{
case CF_RANGE_FILTER: return("Range Filter");
case CF_RQK: return("Rational Quadratic Kernel (RQK)");
case CF_SUPERTREND: return("SuperTrend");
case CF_HALFTREND: return("Half Trend");
case CF_ICHIMOKU: return("Ichimoku Cloud");
case CF_SUPERICHI: return("SuperIchi");
case CF_TSI: return("True Strength Indicator (TSI)");
case CF_TDFI: return("Trend Direction Force Index");
case CF_TRENDLINE: return("Trendline Breakout");
case CF_RANGE_DET: return("Range Detector");
case CF_HACOLT: return("Heiken-Ashi Candle Oscillator");
case CF_DONCHIAN: return("Donchian Trend Ribbon");
case CF_STOCH: return("Stochastic");
case CF_RSI: return("RSI");
case CF_ROC: return("Rate of Change (ROC)");
case CF_VWAP: return("VWAP");
case CF_CCI: return("CCI");
case CF_EMA2: return("2 EMA Cross ("+IntegerToString(InpE2Fast)+","+IntegerToString(InpE2Slow)+")");
case CF_EMA3: return("3 EMA Cross ("+IntegerToString(InpE3a)+","+IntegerToString(InpE3b)+","+IntegerToString(InpE3c)+")");
case CF_BXT: return("B-Xtrender");
case CF_BBPT: return("Bull Bear Power Trend");
case CF_DPO: return("Detrended Price Oscillator");
case CF_BBOSC: return("BB Oscillator");
case CF_CHANDELIER: return("Chandelier Exit");
case CF_DMI: return("DMI (ADX)");
case CF_PSAR: return("Parabolic SAR");
case CF_MACD: return("MACD");
case CF_SSL: return("SSL Channel");
case CF_WAE: return("Waddah Attar Explosion");
case CF_CMF: return("Chaikin Money Flow");
case CF_VORTEX: return("Vortex Index");
case CF_STC: return("Schaff Trend Cycle (STC)");
case CF_AO: return("Awesome Oscillator");
case CF_VOLOSC: return("Volatility Oscillator");
case CF_WOLF: return("Wolfpack ID");
case CF_QQE: return("QQE Mod");
case CF_HULL: return("Hull Suite");
case CF_UTBOT: return("UT Bot (ATR Trail)");
case CF_AROON: return("Aroon");
case CF_WPR: return("Williams %R");
case CF_MFI: return("Money Flow Index (MFI)");
case CF_SQUEEZE: return("Squeeze Momentum");
case CF_LINREG: return("Linear Regression Slope");
case CF_KAMA: return("Kaufman Adaptive MA");
case CF_FISHER: return("Fisher Transform");
case CF_EMA_FILTER: return("EMA Filter ("+IntegerToString(InpEMAFLen)+")");
case CF_RSI_MADIR: return("RSI MA Direction");
case CF_RSI_LIMIT: return("RSI Limit");
case CF_RSI_MALIMIT: return("RSI MA Limit");
case CF_MCGINLEY: return("McGinley Dynamic");
case CF_CHOP: return("Choppiness Index");
case CF_DAMIANI: return("Damiani Volatmeter");
case CF_VOLUME: return("Volume");
}
return("?");
}
void Rs(double &a[]) { ArrayResize(a,N); ArrayInitialize(a,0.0); }
void Ema(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); if(N==0) return;
double a=2.0/(MathMax(len,1)+1.0); o[0]=s[0];
for(int i=1;i<N;i++) o[i]=a*s[i]+(1.0-a)*o[i-1];
}
void Rma(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); if(N==0) return;
double a=1.0/MathMax(len,1); o[0]=s[0];
for(int i=1;i<N;i++) o[i]=a*s[i]+(1.0-a)*o[i-1];
}
void Sma(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); double sum=0; int L=MathMax(len,1);
for(int i=0;i<N;i++) { sum+=s[i]; if(i>=L) sum-=s[i-L]; o[i]=sum/MathMin(i+1,L); }
}
void SumA(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); double sum=0; int L=MathMax(len,1);
for(int i=0;i<N;i++) { sum+=s[i]; if(i>=L) sum-=s[i-L]; o[i]=sum; }
}
void Wma(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); int L=MathMax(len,1);
for(int i=0;i<N;i++)
{
double num=0,den=0;
for(int k=0;k<L && i-k>=0;k++) { double w=L-k; num+=s[i-k]*w; den+=w; }
o[i]=(den>0?num/den:s[i]);
}
}
void Vwma(const double &s[],const int len,double &o[])
{
double sv[],a[],b[]; Rs(sv);
for(int i=0;i<N;i++) sv[i]=s[i]*g_v[i];
SumA(sv,len,a); SumA(g_v,len,b); ArrayResize(o,N);
for(int i=0;i<N;i++) o[i]=(b[i]>0?a[i]/b[i]:s[i]);
}
void Hma(const double &s[],const int len,double &o[])
{
double a[],b[],d[]; int L=MathMax(len,2);
Wma(s,L/2,a); Wma(s,L,b); Rs(d);
for(int i=0;i<N;i++) d[i]=2*a[i]-b[i];
Wma(d,(int)MathRound(MathSqrt(L)),o);
}
void Ehma(const double &s[],const int len,double &o[])
{
double a[],b[],d[]; int L=MathMax(len,2);
Ema(s,L/2,a); Ema(s,L,b); Rs(d);
for(int i=0;i<N;i++) d[i]=2*a[i]-b[i];
Ema(d,(int)MathRound(MathSqrt(L)),o);
}
void Thma(const double &s[],const int len,double &o[])
{
double a[],b[],c[],d[]; int L=MathMax(len,3);
Wma(s,L/3,a); Wma(s,L/2,b); Wma(s,L,c); Rs(d);
for(int i=0;i<N;i++) d[i]=a[i]*3-b[i]-c[i];
Wma(d,L,o);
}
void Tema(const double &s[],const int len,double &o[])
{
double e1[],e2[],e3[]; Ema(s,len,e1); Ema(e1,len,e2); Ema(e2,len,e3); ArrayResize(o,N);
for(int i=0;i<N;i++) o[i]=3*e1[i]-3*e2[i]+e3[i];
}
void MaT(const double &s[],const int len,const int type,double &o[])
{
switch(type)
{
case MA_SMA: Sma(s,len,o); break;
case MA_EMA: Ema(s,len,o); break;
case MA_RMA: Rma(s,len,o); break;
case MA_WMA: Wma(s,len,o); break;
case MA_HMA: Hma(s,len,o); break;
default: Vwma(s,len,o); break;
}
}
void Stdev(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); double sum=0,sq=0; int L=MathMax(len,1);
for(int i=0;i<N;i++)
{
sum+=s[i]; sq+=s[i]*s[i];
if(i>=L) { sum-=s[i-L]; sq-=s[i-L]*s[i-L]; }
int n=MathMin(i+1,L); double m=sum/n; double v=sq/n-m*m;
o[i]=(v>0?MathSqrt(v):0);
}
}
void Highest(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); int L=MathMax(len,1);
for(int i=0;i<N;i++) { double m=s[i]; for(int k=1;k<L && i-k>=0;k++) if(s[i-k]>m) m=s[i-k]; o[i]=m; }
}
void Lowest(const double &s[],const int len,double &o[])
{
ArrayResize(o,N); int L=MathMax(len,1);
for(int i=0;i<N;i++) { double m=s[i]; for(int k=1;k<L && i-k>=0;k++) if(s[i-k]<m) m=s[i-k]; o[i]=m; }
}
void Atr(const int len,double &o[]) { Rma(g_tr,len,o); }
void RsiA(const double &s[],const int len,double &o[])
{
double up[],dn[],ru[],rd[]; Rs(up); Rs(dn);
for(int i=1;i<N;i++) { double ch=s[i]-s[i-1]; up[i]=MathMax(ch,0); dn[i]=-MathMin(ch,0); }
Rma(up,len,ru); Rma(dn,len,rd); ArrayResize(o,N);
for(int i=0;i<N;i++) o[i]=(rd[i]==0?100.0:(ru[i]==0?0.0:100.0-100.0/(1.0+ru[i]/rd[i])));
}
void StochS(const double &s[],const double &hi[],const double &lo[],const int len,double &o[])
{
double hh[],ll[]; Highest(hi,len,hh); Lowest(lo,len,ll); ArrayResize(o,N);
for(int i=0;i<N;i++) { double r=hh[i]-ll[i]; o[i]=(r>0?100.0*(s[i]-ll[i])/r:(i>0?o[i-1]:50.0)); }
}
double LinRegAt(const double &s[],const int i,const int len)
{
int L=MathMin(len,i+1); if(L<2) return(s[i]);
double sx=0,sy=0,sxy=0,sxx=0;
for(int k=0;k<L;k++) { double x=k; double y=s[i-L+1+k]; sx+=x; sy+=y; sxy+=x*y; sxx+=x*x; }
double den=L*sxx-sx*sx; if(den==0) return(s[i]);
double b=(L*sxy-sx*sy)/den; double a=(sy-b*sx)/L;
return(a+b*(L-1));
}
double LinSlopeAt(const double &s[],const int i,const int len)
{
int L=MathMin(len,i+1); if(L<2) return(0);
double sx=0,sy=0,sxy=0,sxx=0;
for(int k=0;k<L;k++) { double x=k; double y=s[i-L+1+k]; sx+=x; sy+=y; sxy+=x*y; sxx+=x*x; }
double den=L*sxx-sx*sx; return(den==0?0:(L*sxy-sx*sy)/den);
}
bool CrossOver(const double &a[],const double &b[],const int i) { return(i>0 && a[i]>b[i] && a[i-1]<=b[i-1]); }
bool CrossUnder(const double &a[],const double &b[],const int i) { return(i>0 && a[i]<b[i] && a[i-1]>=b[i-1]); }
bool PivotHigh(const double &a[],const int p,const int left,const int right)
{
if(p-left<0 || p+right>=N) return(false);
double v=a[p];
for(int k=1;k<=left;k++) if(a[p-k]>=v) return(false);
for(int k=1;k<=right;k++) if(a[p+k]>v) return(false);
return(true);
}
bool PivotLow(const double &a[],const int p,const int left,const int right)
{
if(p-left<0 || p+right>=N) return(false);
double v=a[p];
for(int k=1;k<=left;k++) if(a[p-k]<=v) return(false);
for(int k=1;k<=right;k++) if(a[p+k]<v) return(false);
return(true);
}
void Prep(const int id)
{
ArrayResize(g_sig[id].L,N); ArrayResize(g_sig[id].S,N);
ArrayInitialize(g_sig[id].L,(char)0); ArrayInitialize(g_sig[id].S,(char)0);
g_done[id]=true;
}
void SS(const int id,const int i,const bool l,const bool s) { g_sig[id].L[i]=(char)(l?1:0); g_sig[id].S[i]=(char)(s?1:0); }
void CalcRangeFilter()
{
int id=CF_RANGE_FILTER; Prep(id); Rs(g_rf); Rs(g_rfc);
if(InpRFType==RF_DEFAULT)
{
double ad[],e1[],sm[]; Rs(ad);
for(int i=1;i<N;i++) ad[i]=MathAbs(g_c[i]-g_c[i-1]);
Ema(ad,InpRFPer,e1); Ema(e1,InpRFPer*2-1,sm);
int up=0,dn=0;
for(int i=0;i<N;i++)
{
double r=sm[i]*InpRFMult, x=g_c[i], p=(i>0?g_rf[i-1]:x);
if(x>p) g_rf[i]=(x-r<p?p:x-r); else g_rf[i]=(x+r>p?p:x+r);
if(i>0) { if(g_rf[i]>g_rf[i-1]) { up++; dn=0; } else if(g_rf[i]<g_rf[i-1]) { dn++; up=0; } }
g_rfc[i]=(up>0?0:(dn>0?1:2));
SS(id,i,x>g_rf[i] && up>0, x<g_rf[i] && dn>0);
}
}
else
{
double ad[],ac[],sm[]; Rs(ad);
for(int i=1;i<N;i++) ad[i]=MathAbs(g_c[i]-g_c[i-1]);
Ema(ad,InpRFDWPer,ac); Ema(ac,InpRFDWSm,sm);
int dir=0;
for(int i=0;i<N;i++)
{
double r=sm[i]*InpRFDWQty, p=(i>0?g_rf[i-1]:g_c[i]);
g_rf[i]=p;
if(g_c[i]-r>p) g_rf[i]=g_c[i]-r;
if(g_c[i]+r<p) g_rf[i]=g_c[i]+r;
if(i>0) { if(g_rf[i]>g_rf[i-1]) dir=1; else if(g_rf[i]<g_rf[i-1]) dir=-1; }
g_rfc[i]=(dir==1?0:(dir==-1?1:2));
SS(id,i,dir==1,dir==-1);
}
}
}
void CalcRQK()
{
int id=CF_RQK; Prep(id); double y[]; Rs(y);
double h=InpRQKLook, r=InpRQKWeight; int span=1+InpRQKStart;
double w[]; ArrayResize(w,span+1);
for(int j=0;j<=span;j++) w[j]=MathPow(1.0+(j*j)/(h*h*2.0*r),-r);
for(int i=0;i<N;i++)
{
double cw=0,cu=0;
for(int j=0;j<=span && i-j>=0;j++) { cw+=g_c[i-j]*w[j]; cu+=w[j]; }
y[i]=(cu>0?cw/cu:g_c[i]);
if(i>0) SS(id,i,y[i-1]<y[i],y[i-1]>y[i]);
}
}
void CalcSupertrend()
{
int id=CF_SUPERTREND; Prep(id); Rs(g_stu); Rs(g_std);
double atr[]; if(InpSTWilder) Atr(InpSTPer,atr); else Sma(g_tr,InpSTPer,atr);
double up=0,dn=0,pu=0,pd=0; int tr=1;
for(int i=0;i<N;i++)
{
up=g_hl2[i]-InpSTMult*atr[i]; dn=g_hl2[i]+InpSTMult*atr[i];
double up1=(i>0?pu:up), dn1=(i>0?pd:dn);
if(i>0 && g_c[i-1]>up1) up=MathMax(up,up1);
if(i>0 && g_c[i-1]<dn1) dn=MathMin(dn,dn1);
if(tr==-1 && g_c[i]>dn1) tr=1; else if(tr==1 && g_c[i]<up1) tr=-1;
g_stu[i]=(tr==1?up:EMPTY_VALUE); g_std[i]=(tr==-1?dn:EMPTY_VALUE);
pu=up; pd=dn;
SS(id,i,tr==1,tr!=1);
}
}
void CalcHalfTrend()
{
int id=CF_HALFTREND; Prep(id); Rs(g_ht); Rs(g_htc);
double atr[],hma[],lma[],hp[],lp[]; Atr(100,atr); Sma(g_h,InpHTAmp,hma); Sma(g_l,InpHTAmp,lma);
Highest(g_h,InpHTAmp,hp); Lowest(g_l,InpHTAmp,lp);
int trend=0,next=0,prevTrend=0; double maxLow=g_l[0],minHigh=g_h[0],up=0,dn=0,pUp=0,pDn=0;
for(int i=0;i<N;i++)
{
double pl=(i>0?g_l[i-1]:g_l[i]), ph=(i>0?g_h[i-1]:g_h[i]);
if(next==1)
{
maxLow=MathMax(lp[i],maxLow);
if(hma[i]<maxLow && g_c[i]<pl) { trend=1; next=0; minHigh=hp[i]; }
}
else
{
minHigh=MathMin(hp[i],minHigh);
if(lma[i]>minHigh && g_c[i]>ph) { trend=0; next=1; maxLow=lp[i]; }
}
if(trend==0) { if(i>0 && prevTrend!=0) up=pDn; else up=(pUp==0?maxLow:MathMax(maxLow,pUp)); }
else { if(i>0 && prevTrend!=1) dn=pUp; else dn=(pDn==0?minHigh:MathMin(minHigh,pDn)); }
g_ht[i]=(trend==0?up:dn); g_htc[i]=(trend==0?0:1);
pUp=up; pDn=dn; prevTrend=trend;
SS(id,i,trend==0,trend!=0);
}
}
void Donch(const int len,double &o[])
{
double hh[],ll[]; Highest(g_h,len,hh); Lowest(g_l,len,ll); ArrayResize(o,N);
for(int i=0;i<N;i++) o[i]=(hh[i]+ll[i])/2.0;
}
void CalcIchimoku()
{
int id=CF_ICHIMOKU; Prep(id);
Donch(InpIchiConv,g_tk); Donch(InpIchiBase,g_kj); Donch(InpIchiSpanB,g_sb); Rs(g_sa);
for(int i=0;i<N;i++) g_sa[i]=(g_tk[i]+g_kj[i])/2.0;
int d=InpIchiDisp-1;
for(int i=50;i<N;i++)
{
if(i-d<0) continue;
bool l=g_tk[i]>g_kj[i] && g_sa[i]>g_sb[i] && g_c[i]>g_sa[i-d] && g_c[i]>g_sb[i-d] && g_c[i]>g_sa[i-50] && g_c[i]>g_sb[i-50];
bool s=g_tk[i]<g_kj[i] && g_sa[i]<g_sb[i] && g_c[i]<g_sa[i-d] && g_c[i]<g_sb[i-d] && g_c[i]<g_sb[i-50] && g_c[i]<g_sa[i-50];
SS(id,i,l,s);
}
}
void SIAvg(const int len,const double mult,double &o[])
{
double atr[]; Atr(len,atr); ArrayResize(o,N);
double upper=0,lower=0,mx=0,mn=0,pspt=0; int os=0;
for(int i=0;i<N;i++)
{
double a=atr[i]*mult, up=g_hl2[i]+a, dn=g_hl2[i]-a;
double nu=(i>0 && g_c[i-1]<upper)?MathMin(up,upper):up;
double nl=(i>0 && g_c[i-1]>lower)?MathMax(dn,lower):dn;
upper=nu; lower=nl;
os=(g_c[i]>upper?1:(g_c[i]<lower?0:os));
double spt=(os==1?lower:upper);
bool cr=(i>0 && ((g_c[i]>spt && g_c[i-1]<=pspt) || (g_c[i]<spt && g_c[i-1]>=pspt)));
if(i==0) { mx=g_c[i]; mn=g_c[i]; }
double nmx=cr?MathMax(g_c[i],mx):(os==1?MathMax(g_c[i],mx):spt);
double nmn=cr?MathMin(g_c[i],mn):(os==0?MathMin(g_c[i],mn):spt);
mx=nmx; mn=nmn; pspt=spt;
o[i]=(mx+mn)/2.0;
}
}
void CalcSuperIchi()
{
int id=CF_SUPERICHI; Prep(id);
double tk[],kj[],sb[],sa[]; SIAvg(InpSITenkan,InpSITenkanM,tk); SIAvg(InpSIKijun,InpSIKijunM,kj); SIAvg(InpSISpanB,InpSISpanBM,sb); Rs(sa);
for(int i=0;i<N;i++) sa[i]=(tk[i]+kj[i])/2.0;
int d=InpIchiDisp-1;
for(int i=50;i<N;i++)
{
if(i-d<0) continue;
bool l=tk[i]>kj[i] && sa[i]>sb[i] && g_c[i]>sa[i-d] && g_c[i]>sb[i-d] && g_c[i]>sa[i-50] && g_c[i]>sb[i-50];
bool s=tk[i]<kj[i] && sa[i]<sb[i] && g_c[i]<sa[i-d] && g_c[i]<sb[i-d] && g_c[i]<sb[i-50] && g_c[i]<sa[i-50];
SS(id,i,l,s);
}
}
void CalcTSI()
{
int id=CF_TSI; Prep(id);
double pc[],apc[],a1[],a2[],b1[],b2[],tsi[],sig[]; Rs(pc); Rs(apc);
for(int i=1;i<N;i++) { pc[i]=g_c[i]-g_c[i-1]; apc[i]=MathAbs(pc[i]); }
Ema(pc,InpTSILong,a1); Ema(a1,InpTSIShort,a2); Ema(apc,InpTSILong,b1); Ema(b1,InpTSIShort,b2); Rs(tsi);
for(int i=0;i<N;i++) tsi[i]=(b2[i]!=0?100.0*a2[i]/b2[i]:0);
Ema(tsi,InpTSISig,sig);
for(int i=1;i<N;i++)
{
if(InpTSIType==TSI_SIGNAL) SS(id,i,tsi[i]>sig[i],tsi[i]<sig[i]);
else SS(id,i,tsi[i]>sig[i] && tsi[i]>0,tsi[i]<sig[i] && tsi[i]<0);
}
}
void CalcTDFI()
{
int id=CF_TDFI; Prep(id);
double p[],mma[],smma[],tdf[],atdf[],hh[]; Rs(p);
for(int i=0;i<N;i++) p[i]=g_c[i]*1000.0;
Ema(p,InpTDFIMma,mma); Ema(mma,InpTDFISmma,smma); Rs(tdf); Rs(atdf);
for(int i=1;i<N;i++)
{
double im=mma[i]-mma[i-1], is=smma[i]-smma[i-1], dv=MathAbs(mma[i]-smma[i]), av=(im+is)/2.0;
tdf[i]=dv*MathPow(av,InpTDFIN); atdf[i]=MathAbs(tdf[i]);
}
Highest(atdf,InpTDFILook*InpTDFIN,hh);
for(int i=1;i<N;i++) { double s=(hh[i]>0?tdf[i]/hh[i]:0); SS(id,i,s>InpTDFIHigh,s<InpTDFILow); }
}
void CalcTrendline()
{
int id=CF_TRENDLINE; Prep(id);
double atr[]; Atr(InpTLLen,atr);
int L=InpTLLen; double upper=0,lower=0,sph=0,spl=0; int upos[],dnos[]; ArrayResize(upos,N); ArrayResize(dnos,N);
int uo=0,dno=0;
for(int i=0;i<N;i++)
{
double slope=atr[i]/L*InpTLSlope;
int p=i-L; bool ph=(p>=0 && PivotHigh(g_h,p,L,L)); bool pl=(p>=0 && PivotLow(g_l,p,L,L));
if(ph) sph=slope; if(pl) spl=slope;
upper=ph?g_h[p]:upper-sph; lower=pl?g_l[p]:lower+spl;
uo=ph?0:(g_c[i]>upper-sph*L?1:uo);
dno=pl?0:(g_c[i]<lower+spl*L?1:dno);
upos[i]=uo; dnos[i]=dno;
int e=MathMax(InpExpiry,1);
if(i-e>=0) SS(id,i,upos[i]>upos[i-e],dnos[i]>dnos[i-e]);
}
}
void CalcRangeDet()
{
int id=CF_RANGE_DET; Prep(id); Rs(g_rdt); Rs(g_rdb); g_nRD=0; ArrayResize(g_rdBoxes,0);
double atr[],ma[]; Atr(InpRDAtr,atr); Sma(g_c,InpRDLen,ma);
int prevCount=-1; double rmax=EMPTY_VALUE,rmin=EMPTY_VALUE;
int cur=-1;
for(int i=0;i<N;i++)
{
double a=atr[i]*InpRDMult; int cnt=0;
for(int k=0;k<InpRDLen;k++) { if(i-k<0) { cnt++; continue; } if(MathAbs(g_c[i-k]-ma[i])>a) cnt++; }
if(cnt==0 && prevCount!=0)
{
if(cur>=0 && i-InpRDLen<=g_rdBoxes[cur].r)
{
rmax=MathMax(ma[i]+a,g_rdBoxes[cur].top); rmin=MathMin(ma[i]-a,g_rdBoxes[cur].bot);
g_rdBoxes[cur].top=rmax; g_rdBoxes[cur].bot=rmin; g_rdBoxes[cur].r=i; g_rdBoxes[cur].os=0;
}
else
{
rmax=ma[i]+a; rmin=ma[i]-a;
ArrayResize(g_rdBoxes,g_nRD+1); cur=g_nRD; g_nRD++;
g_rdBoxes[cur].l=MathMax(0,i-InpRDLen); g_rdBoxes[cur].r=i; g_rdBoxes[cur].top=rmax; g_rdBoxes[cur].bot=rmin; g_rdBoxes[cur].os=0;
}
}
else if(cnt==0 && cur>=0) g_rdBoxes[cur].r=i;
if(cur>=0) { if(g_c[i]>g_rdBoxes[cur].top) g_rdBoxes[cur].os=1; else if(g_c[i]<g_rdBoxes[cur].bot) g_rdBoxes[cur].os=-1; }
prevCount=cnt;
g_rdt[i]=rmax; g_rdb[i]=rmin;
if(rmax!=EMPTY_VALUE) SS(id,i,g_c[i]>rmax,g_c[i]<rmin);
}
}
void CalcHACOLT()
{
int id=CF_HACOLT; Prep(id);
double hao[],hac[],th[],tl[],tth[],ttl[],hs[],ls[],ema[];
Rs(hao); Rs(hac);
for(int i=0;i<N;i++)
{
hao[i]=((i>0?hao[i-1]:g_hl2[i])+g_hl2[i])/2.0;
hac[i]=(hao[i]+MathMax(g_h[i],hao[i])+MathMin(g_l[i],hao[i])+g_hl2[i])/4.0;
}
Tema(hac,InpHATema,th); Tema(g_hl2,InpHATema,tl); Tema(th,InpHATema,tth); Tema(tl,InpHATema,ttl); Rs(hs); Rs(ls);
for(int i=0;i<N;i++) { hs[i]=2*th[i]-tth[i]; ls[i]=2*tl[i]-ttl[i]; }
Ema(g_c,InpHAEma,ema);
bool kn1p=false,ka1p=false,kn2p=false,ka2p=false,utrp=false,dtrp=false,upwo=false,neu=false;
for(int i=1;i<N;i++)
{
bool sc=MathAbs(g_c[i]-g_o[i])<((g_h[i]-g_l[i])*InpHACandle);
bool kn1=(hac[i]>=hao[i] && hac[i-1]>=hao[i-1]) || g_c[i]>=hac[i] || g_h[i]>g_h[i-1] || g_l[i]>g_l[i-1] || ls[i]>=hs[i];
bool ka1=kn1 || (kn1p && g_c[i]>=g_o[i]) || g_c[i]>=g_c[i-1];
bool k13=sc && g_h[i]>=g_l[i-1];
bool utr=ka1 || (ka1p && k13);
bool kn2=(hac[i]<hao[i] && hac[i-1]<hao[i-1]) || ls[i]<hs[i];
bool k23=sc && g_l[i]<=g_h[i-1];
bool ka2=kn2 || (kn2p && g_c[i]<g_o[i]) || g_c[i]<g_c[i-1];
bool dtr=ka2 || (ka2p && k23);
bool upw=dtr && dtrp && utr;
bool dnw=utr && utrp && dtr;
upwo=(upw!=dnw)?upw:upwo;
bool buy=upw || (!dnw && upwo);
bool lts=g_c[i]<ema[i];
neu=buy || (lts?false:neu);
int v=buy?1:(neu?0:-1);
SS(id,i,v>0,v<0);
kn1p=kn1; ka1p=ka1; kn2p=kn2; ka2p=ka2; utrp=utr; dtrp=dtr;
}
}
void CalcDonchian()
{
int id=CF_DONCHIAN; Prep(id); double hh[],ll[]; Highest(g_h,InpDonLen,hh); Lowest(g_l,InpDonLen,ll);
int tr=0;
for(int i=1;i<N;i++) { tr=(g_c[i]>hh[i-1]?1:(g_c[i]<ll[i-1]?-1:tr)); SS(id,i,tr==1,tr==-1); }
}
void CalcStoch()
{
int id=CF_STOCH; Prep(id); double st[],k[],d[]; StochS(g_c,g_h,g_l,InpStoLen,st); Sma(st,InpStoK,k); Sma(k,InpStoD,d);
for(int i=1;i<N;i++)
{
bool l=false,s=false;
if(InpStoType==STO_CROSS) { l=k[i-1]<d[i-1] && k[i]>d[i]; s=k[i-1]>d[i-1] && k[i]<d[i]; }
else if(InpStoType==STO_OBOS) { l=k[i-1]<d[i-1] && k[i-1]<InpStoOS && k[i]>d[i] && k[i]>InpStoOS; s=k[i-1]>d[i-1] && k[i-1]>InpStoOB && k[i]<d[i] && k[i]<InpStoOB; }
else { l=k[i]>d[i]; s=k[i]<d[i]; }
SS(id,i,l,s);
}
}
void CalcRSIFamily()
{
Prep(CF_RSI); Prep(CF_RSI_MADIR); Prep(CF_RSI_LIMIT); Prep(CF_RSI_MALIMIT);
double rsi[],rma[]; RsiA(g_c,InpRSILen,rsi); MaT(rsi,InpRSIMaLen,InpRSIMaType,rma);
for(int i=1;i<N;i++)
{
bool l=false,s=false;
if(InpRSIType==RSI_MACROSS) { l=rsi[i]>rma[i]; s=rsi[i]<rma[i]; }
else if(InpRSIType==RSI_EXIT) { l=rsi[i]>InpRSIOS && rsi[i-1]<InpRSIOS; s=rsi[i]<InpRSIOB && rsi[i-1]>InpRSIOB; }
else { l=rsi[i]>InpRSIMid; s=rsi[i]<InpRSIMid; }
SS(CF_RSI,i,l,s);
SS(CF_RSI_MADIR,i,rma[i]>=rma[i-1],rma[i]<=rma[i-1]);
SS(CF_RSI_LIMIT,i,rsi[i]>=InpRSILimUp,rsi[i]<=InpRSILimDn);
SS(CF_RSI_MALIMIT,i,rma[i]>=InpRSIMaLimUp,rma[i]<=InpRSIMaLimDn);
}
}
void CalcROC()
{
int id=CF_ROC; Prep(id);
for(int i=InpROCLen;i<N;i++) { double r=(g_c[i-InpROCLen]!=0?100.0*(g_c[i]-g_c[i-InpROCLen])/g_c[i-InpROCLen]:0); SS(id,i,r>0,r<0); }
}
int AnchorKey(const datetime t)
{
MqlDateTime d; TimeToStruct(t,d);
if(InpVWAnchor==VW_SESSION) return(d.year*1000+d.day_of_year);
if(InpVWAnchor==VW_MONTH) return(d.year*100+d.mon);
return((int)((t-259200)/604800)); // weeks starting Monday
}
void CalcVWAP()
{
int id=CF_VWAP; Prep(id); Rs(g_vwap);
double spv=0,sv=0; int key=-*;
for(int i=0;i<N;i++)
{
int k=AnchorKey(g_t[i]); if(k!=key) { spv=0; sv=0; key=k; }
spv+=g_hlc3[i]*g_v[i]; sv+=g_v[i];
g_vwap[i]=(sv>0?spv/sv:g_hlc3[i]);
SS(id,i,g_c[i]>g_vwap[i],g_c[i]<g_vwap[i]);
}
}
void CalcCCI()
{
int id=CF_CCI; Prep(id); double ma[]; Sma(g_hlc3,InpCCILen,ma);
for(int i=InpCCILen;i<N;i++)
{
double md=0; for(int k=0;k<InpCCILen;k++) md+=MathAbs(g_hlc3[i-k]-ma[i]); md/=InpCCILen;
double cci=(md>0?(g_hlc3[i]-ma[i])/(0.015*md):0);
SS(id,i,cci>InpCCIUp,cci<InpCCIDn);
}
}
void CalcEMA2()
{
int id=CF_EMA2; Prep(id); double f[],s[]; Ema(g_c,InpE2Fast,f); Ema(g_c,InpE2Slow,s);
int lb=MathMax(InpE2Look,1);
for(int i=1;i<N;i++)
{
if(InpE2Mode==E2_DEFAULT) { SS(id,i,CrossOver(f,s,i),CrossUnder(f,s,i)); continue; }
int j=i-lb; if(j<1) continue;
bool cu=f[j]>s[j] && f[j-1]<=s[j-1], cd=f[j]<s[j] && f[j-1]>=s[j-1];
bool none=true;
for(int k=j+1;k<=i;k++) if((f[k]>s[k] && f[k-1]<=s[k-1]) || (f[k]<s[k] && f[k-1]>=s[k-1])) { none=false; break; }
SS(id,i,cu && none && f[i]>s[i],cd && none && f[i]<s[i]);
}
}
void CalcEMA3()
{
int id=CF_EMA3; Prep(id); double a[],b[],c[]; Ema(g_c,InpE3a,a); Ema(g_c,InpE3b,b); Ema(g_c,InpE3c,c);
for(int i=0;i<N;i++) SS(id,i,a[i]>b[i] && a[i]>c[i] && b[i]>c[i],a[i]<b[i] && a[i]<c[i] && b[i]<c[i]);
}
void T3(const double &s[],const int len,double &o[])
{
double e1[],e2[],e3[],e4[],e5[],e6[];
Ema(s,len,e1); Ema(e1,len,e2); Ema(e2,len,e3); Ema(e3,len,e4); Ema(e4,len,e5); Ema(e5,len,e6);
double b=0.7, c1=-b*b*b, c2=3*b*b+3*b*b*b, c3=-6*b*b-3*b-3*b*b*b, c4=1+3*b+b*b*b+3*b*b;
ArrayResize(o,N); for(int i=0;i<N;i++) o[i]=c1*e6[i]+c2*e5[i]+c3*e4[i]+c4*e3[i];
}
void CalПоказано первые 50% кода (символов: 83069)