Gaussian Channel [DW] in MQL5 — converted from Pine Script
The Gaussian Channel [DW] indicator by DonovanWall, published on TradingView under the Mozilla Public License 2.0, converted to MetaTrader 5 by the Stratlate engine. The conversion was executed against the original on 500 synthetic bars and compared value by value: equivalent (fidelity 1.000).
██████╗ ██╗ ██╗ ██╔══██╗██║ ██║ ██║ ██║██║ █╗ ██║ ██║ ██║██║███╗██║ ██████╔╝╚███╔███╔╝ ╚═════╝ ╚══╝╚══╝
Inputs
| Input | Default |
|---|---|
| Source | hlc3 |
Converted MQL5
Save as gaussian-channel.mq5 next to PineRuntime.mqh (included with every conversion), compile in MetaEditor, then review and backtest before trading. Output of the engine alone; the AI review available after sign-in may improve it further.
//+------------------------------------------------------------------+
//| pine-transpiler 0.6.46 (pinec) - generated code
//| source sha256: d6f9e95acefa status: CLEAN
//| notes: 0 unsupported, 0 warn, 6 info
//| Review, compile and backtest before trading.
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Gaussian Channel [DW]
//| Converted from Pine Script by pine-transpiler.
//| Review before trading: see the accompanying report for every
//| construct that was approximated or could not be converted.
//+------------------------------------------------------------------+
#property copyright "Converted by pine-transpiler"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_plots 4
#property indicator_label1 "Channel Fill"
#property indicator_type1 DRAW_FILLING
#property indicator_color1 clrDodgerBlue
#property indicator_width1 1
#property indicator_label2 "Filter"
#property indicator_type2 DRAW_COLOR_LINE
#property indicator_color2 clrDodgerBlue
#property indicator_width2 3
#property indicator_label3 "Filtered True Range High Band"
#property indicator_type3 DRAW_COLOR_LINE
#property indicator_color3 clrDodgerBlue
#property indicator_width3 1
#property indicator_label4 "Filtered True Range Low Band"
#property indicator_type4 DRAW_COLOR_LINE
#property indicator_color4 clrDodgerBlue
#property indicator_width4 1
#include "PineRuntime.mqh"
//--- plot buffers
double PineFill0[];
double PineFill1[];
double Buf2[];
double Buf3[];
double Buf4[];
double Buf5[];
double Buf6[];
double Buf7[];
color __pal1[64]; // the colours plot 1 has drawn so far; see pine_color_slot
int __paln1 = 0;
color __pal2[64]; // the colours plot 2 has drawn so far; see pine_color_slot
int __paln2 = 0;
color __pal3[64]; // the colours plot 3 has drawn so far; see pine_color_slot
int __paln3 = 0;
//--- script-level state
// The newest bar's index: `last_bar_index` and `barstate.islast`.
int __pineLastBar = 0;
// Series-valued names are arrays because their history is read;
// the rest stay scalars.
double beta = PINE_NA;
double alpha = PINE_NA;
double lag = PINE_NA;
double srcdata = PINE_NA;
double trdata = PINE_NA;
double filtn = PINE_NA;
double filt1 = PINE_NA;
double filtntr = PINE_NA;
double filt1tr = PINE_NA;
double filt[];
double filttr = PINE_NA;
double hband = PINE_NA;
double lband = PINE_NA;
color color1 = clrNONE;
color color2 = clrNONE;
color color3 = clrNONE;
color color4 = clrNONE;
color fcolor = clrNONE;
color barcolor = clrNONE;
//--- live-tick rollback: the state each bar started from
double __sv_beta;
double __si_beta;
double __sv_alpha;
double __si_alpha;
double __sv_lag;
double __si_lag;
double __sv_srcdata;
double __si_srcdata;
double __sv_trdata;
double __si_trdata;
double __sv_filtn;
double __si_filtn;
double __sv_filt1;
double __si_filt1;
double __sv_filtntr;
double __si_filtntr;
double __sv_filt1tr;
double __si_filt1tr;
double __sv_filttr;
double __si_filttr;
double __sv_hband;
double __si_hband;
double __sv_lband;
double __si_lband;
color __sv_color1;
color __si_color1;
color __sv_color2;
color __si_color2;
color __sv_color3;
color __si_color3;
color __sv_color4;
color __si_color4;
color __sv_fcolor;
color __si_fcolor;
color __sv_barcolor;
color __si_barcolor;
int __pineSnapBar = -1;
void __pineSaveState()
{
__sv_beta = beta;
__sv_alpha = alpha;
__sv_lag = lag;
__sv_srcdata = srcdata;
__sv_trdata = trdata;
__sv_filtn = filtn;
__sv_filt1 = filt1;
__sv_filtntr = filtntr;
__sv_filt1tr = filt1tr;
__sv_filttr = filttr;
__sv_hband = hband;
__sv_lband = lband;
__sv_color1 = color1;
__sv_color2 = color2;
__sv_color3 = color3;
__sv_color4 = color4;
__sv_fcolor = fcolor;
__sv_barcolor = barcolor;
pine_draw_mark();
__pineSaveGen++; // helpers' static arrays snapshot lazily
}
void __pineRestoreState()
{
beta = __sv_beta;
alpha = __sv_alpha;
lag = __sv_lag;
srcdata = __sv_srcdata;
trdata = __sv_trdata;
filtn = __sv_filtn;
filt1 = __sv_filt1;
filtntr = __sv_filtntr;
filt1tr = __sv_filt1tr;
filttr = __sv_filttr;
hband = __sv_hband;
lband = __sv_lband;
color1 = __sv_color1;
color2 = __sv_color2;
color3 = __sv_color3;
color4 = __sv_color4;
fcolor = __sv_fcolor;
barcolor = __sv_barcolor;
pine_draw_rollback();
__pineRestoreGen++;
__pineRestoreSaveGen = __pineSaveGen;
}
void __pineSaveInitial()
{
__si_beta = beta;
__si_alpha = alpha;
__si_lag = lag;
__si_srcdata = srcdata;
__si_trdata = trdata;
__si_filtn = filtn;
__si_filt1 = filt1;
__si_filtntr = filtntr;
__si_filt1tr = filt1tr;
__si_filttr = filttr;
__si_hband = hband;
__si_lband = lband;
__si_color1 = color1;
__si_color2 = color2;
__si_color3 = color3;
__si_color4 = color4;
__si_fcolor = fcolor;
__si_barcolor = barcolor;
pine_draw_save_initial();
}
void __pineRestoreInitial()
{
beta = __si_beta;
alpha = __si_alpha;
lag = __si_lag;
srcdata = __si_srcdata;
trdata = __si_trdata;
filtn = __si_filtn;
filt1 = __si_filt1;
filtntr = __si_filtntr;
filt1tr = __si_filt1tr;
filttr = __si_filttr;
hband = __si_hband;
lband = __si_lband;
color1 = __si_color1;
color2 = __si_color2;
color3 = __si_color3;
color4 = __si_color4;
fcolor = __si_fcolor;
barcolor = __si_barcolor;
pine_draw_reset();
__pineInitGen++;
}
double __st0[]; // accumulator for one stateful call site
double __stb0[]; // secondary buffer (e.g. true range for ATR)
double __st1[]; // accumulator for one stateful call site
double __stb1[]; // secondary buffer (e.g. true range for ATR)
double __st2[]; // accumulator for one stateful call site
double __stb2[]; // secondary buffer (e.g. true range for ATR)
double __st3[]; // accumulator for one stateful call site
double __stb3[]; // secondary buffer (e.g. true range for ATR)
double __src[]; // Pine's `src` as a real series, filled per bar
double __fl_f_filt9x__f[]; // history of `_f`, a local of f_filt9x() the script reads with [n]
double __fl_f_filt9x__site1__f[]; // history of `_f`, a local of f_filt9x__site1() the script reads with [n]
double __fl_f_filt9x__site2__f[]; // history of `_f`, a local of f_filt9x__site2() the script reads with [n]
double __fl_f_filt9x__site3__f[]; // history of `_f`, a local of f_filt9x__site3() the script reads with [n]
double __fl_f_filt9x__site4__f[]; // history of `_f`, a local of f_filt9x__site4() the script reads with [n]
double __fl_f_filt9x__site5__f[]; // history of `_f`, a local of f_filt9x__site5() the script reads with [n]
double __fl_f_filt9x__site6__f[]; // history of `_f`, a local of f_filt9x__site6() the script reads with [n]
double __fl_f_filt9x__site7__f[]; // history of `_f`, a local of f_filt9x__site7() the script reads with [n]
double __fl_f_filt9x__site8__f[]; // history of `_f`, a local of f_filt9x__site8() the script reads with [n]
double __fl_f_filt9x__site9__f[]; // history of `_f`, a local of f_filt9x__site9() the script reads with [n]
double __fl_f_filt9x__site1__site1__f[]; // history of `_f`, a local of f_filt9x__site1__site1() the script reads with [n]
double __fl_f_filt9x__site2__site1__f[]; // history of `_f`, a local of f_filt9x__site2__site1() the script reads with [n]
double __fl_f_filt9x__site3__site1__f[]; // history of `_f`, a local of f_filt9x__site3__site1() the script reads with [n]
double __fl_f_filt9x__site4__site1__f[]; // history of `_f`, a local of f_filt9x__site4__site1() the script reads with [n]
double __fl_f_filt9x__site5__site1__f[]; // history of `_f`, a local of f_filt9x__site5__site1() the script reads with [n]
double __fl_f_filt9x__site6__site1__f[]; // history of `_f`, a local of f_filt9x__site6__site1() the script reads with [n]
double __fl_f_filt9x__site7__site1__f[]; // history of `_f`, a local of f_filt9x__site7__site1() the script reads with [n]
double __fl_f_filt9x__site8__site1__f[]; // history of `_f`, a local of f_filt9x__site8__site1() the script reads with [n]
double __ts0[]; // materialised ta.* source: pine_tr_na(high, low, close, __pineBar, true)
//--- inputs
input ENUM_APPLIED_PRICE src = PRICE_TYPICAL; // Source
input int N = 4; // Poles
input int per = 144; // Sampling Period
input double mult = 1.414; // Filtered True Range Multiplier
input bool modeLag = false; // Reduced Lag Mode
input bool modeFast = false; // Fast Response Mode
//--- user functions
double f_filt9x(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__f[__pineBar];
return PINE_NA;
}
void f_pole(const double _a, const double _s, const int _i, const int __pineBar, double &__out0, double &__out1)
{
double _f1 = f_filt9x(_a, _s, 1, __pineBar);
double _f2 = ((_i >= 2) ? f_filt9x__site1(_a, _s, 2, __pineBar) : 0);
double _f3 = ((_i >= 3) ? f_filt9x__site2(_a, _s, 3, __pineBar) : 0);
double _f4 = ((_i >= 4) ? f_filt9x__site3(_a, _s, 4, __pineBar) : 0);
double _f5 = ((_i >= 5) ? f_filt9x__site4(_a, _s, 5, __pineBar) : 0);
double _f6 = ((_i >= 6) ? f_filt9x__site5(_a, _s, 6, __pineBar) : 0);
double _f7 = ((_i >= 2) ? f_filt9x__site6(_a, _s, 7, __pineBar) : 0);
double _f8 = ((_i >= 8) ? f_filt9x__site7(_a, _s, 8, __pineBar) : 0);
double _f9 = ((_i == 9) ? f_filt9x__site8(_a, _s, 9, __pineBar) : 0);
double _fn = ((_i == 1) ? _f1 : ((_i == 2) ? _f2 : ((_i == 3) ? _f3 : ((_i == 4) ? _f4 : ((_i == 5) ? _f5 : ((_i == 6) ? _f6 : ((_i == 7) ? _f7 : ((_i == 8) ? _f8 : ((_i == 9) ? _f9 : PINE_NA)))))))));
__out0 = _fn;
__out1 = _f1;
return;
}
double f_filt9x__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site2(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site2__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site2__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site2__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site2__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site3(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site3__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site3__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site3__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site3__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site4(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site4__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site4__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site4__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site4__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site5(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site5__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site5__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site5__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site5__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site6(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site6__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site6__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site6__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site6__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site7(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site7__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site7__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site7__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site7__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site8(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site8__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site8__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site8__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site8__f[__pineBar];
return PINE_NA;
}
void f_pole__site1(const double _a, const double _s, const int _i, const int __pineBar, double &__out0, double &__out1)
{
double _f1 = f_filt9x__site9(_a, _s, 1, __pineBar);
double _f2 = ((_i >= 2) ? f_filt9x__site1__site1(_a, _s, 2, __pineBar) : 0);
double _f3 = ((_i >= 3) ? f_filt9x__site2__site1(_a, _s, 3, __pineBar) : 0);
double _f4 = ((_i >= 4) ? f_filt9x__site3__site1(_a, _s, 4, __pineBar) : 0);
double _f5 = ((_i >= 5) ? f_filt9x__site4__site1(_a, _s, 5, __pineBar) : 0);
double _f6 = ((_i >= 6) ? f_filt9x__site5__site1(_a, _s, 6, __pineBar) : 0);
double _f7 = ((_i >= 2) ? f_filt9x__site6__site1(_a, _s, 7, __pineBar) : 0);
double _f8 = ((_i >= 8) ? f_filt9x__site7__site1(_a, _s, 8, __pineBar) : 0);
double _f9 = ((_i == 9) ? f_filt9x__site8__site1(_a, _s, 9, __pineBar) : 0);
double _fn = ((_i == 1) ? _f1 : ((_i == 2) ? _f2 : ((_i == 3) ? _f3 : ((_i == 4) ? _f4 : ((_i == 5) ? _f5 : ((_i == 6) ? _f6 : ((_i == 7) ? _f7 : ((_i == 8) ? _f8 : ((_i == 9) ? _f9 : PINE_NA)))))))));
__out0 = _fn;
__out1 = _f1;
return;
}
double f_filt9x__site9(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site9__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site9__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site9__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site9__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site1__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site1__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site1__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site1__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site1__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site2__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site2__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site2__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site2__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site2__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site3__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site3__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site3__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site3__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site3__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site4__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site4__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site4__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site4__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site4__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site5__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site5__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site5__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site5__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site5__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site6__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site6__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site6__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site6__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site6__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site7__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site7__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site7__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site7__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site7__site1__f[__pineBar];
return PINE_NA;
}
double f_filt9x__site8__site1(const double _a, const double _s, const int _i, const int __pineBar)
{
int _m2 = 0;
int _m3 = 0;
int _m4 = 0;
int _m5 = 0;
int _m6 = 0;
int _m7 = 0;
int _m8 = 0;
int _m9 = 0;
__fl_f_filt9x__site8__site1__f[__pineBar] = 0.0;
double _x = (1 - _a);
_m2 = ((_i == 9) ? 36 : ((_i == 8) ? 28 : ((_i == 7) ? 21 : ((_i == 6) ? 15 : ((_i == 5) ? 10 : ((_i == 4) ? 6 : ((_i == 3) ? 3 : ((_i == 2) ? 1 : 0))))))));
_m3 = ((_i == 9) ? 84 : ((_i == 8) ? 56 : ((_i == 7) ? 35 : ((_i == 6) ? 20 : ((_i == 5) ? 10 : ((_i == 4) ? 4 : ((_i == 3) ? 1 : 0)))))));
_m4 = ((_i == 9) ? 126 : ((_i == 8) ? 70 : ((_i == 7) ? 35 : ((_i == 6) ? 15 : ((_i == 5) ? 5 : ((_i == 4) ? 1 : 0))))));
_m5 = ((_i == 9) ? 126 : ((_i == 8) ? 56 : ((_i == 7) ? 21 : ((_i == 6) ? 6 : ((_i == 5) ? 1 : 0)))));
_m6 = ((_i == 9) ? 84 : ((_i == 8) ? 28 : ((_i == 7) ? 7 : ((_i == 6) ? 1 : 0))));
_m7 = ((_i == 9) ? 36 : ((_i == 8) ? 8 : ((_i == 7) ? 1 : 0)));
_m8 = ((_i == 9) ? 9 : ((_i == 8) ? 1 : 0));
_m9 = ((_i == 9) ? 1 : 0);
__fl_f_filt9x__site8__site1__f[__pineBar] = ((((((((((MathPow(_a, _i) * pine_nz(_s)) + ((_i * _x) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(1))))) - ((_i >= 2) ? ((_m2 * MathPow(_x, 2)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(2)))) : 0)) + ((_i >= 3) ? ((_m3 * MathPow(_x, 3)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(3)))) : 0)) - ((_i >= 4) ? ((_m4 * MathPow(_x, 4)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(4)))) : 0)) + ((_i >= 5) ? ((_m5 * MathPow(_x, 5)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(5)))) : 0)) - ((_i >= 6) ? ((_m6 * MathPow(_x, 6)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(6)))) : 0)) + ((_i >= 7) ? ((_m7 * MathPow(_x, 7)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(7)))) : 0)) - ((_i >= 8) ? ((_m8 * MathPow(_x, 8)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(8)))) : 0)) + ((_i == 9) ? ((_m9 * MathPow(_x, 9)) * pine_nz(pine_hist(__fl_f_filt9x__site8__site1__f, __pineBar, (int)(9)))) : 0));
return __fl_f_filt9x__site8__site1__f[__pineBar];
return PINE_NA;
}
int OnInit()
{
if(N < 1) { Print("Poles", " must be at least 1"); return INIT_PARAMETERS_INCORRECT; }
if(N > 9) { Print("Poles", " must be at most 9"); return INIT_PARAMETERS_INCORRECT; }
if(per < 2) { Print("Sampling Period", " must be at least 2"); return INIT_PARAMETERS_INCORRECT; }
if(mult < 0) { Print("Filtered True Range Multiplier", " must be at least 0"); return INIT_PARAMETERS_INCORRECT; }
beta = pine_div((1 - MathCos(pine_div((4 * MathArcsin(1)), per))), (MathPow(1.414, pine_div(2, N)) - 1));
lag = pine_div((per - 1), (2 * N));
color1 = C'10,255,104';
color2 = C'0,117,45';
color3 = C'255,10,90';
color4 = C'153,0,50';
SetIndexBuffer(0, PineFill0, INDICATOR_DATA);
SetIndexBuffer(1, PineFill1, INDICATOR_DATA);
SetIndexBuffer(2, Buf2, INDICATOR_DATA);
SetIndexBuffer(3, Buf3, INDICATOR_COLOR_INDEX);
SetIndexBuffer(4, Buf4, INDICATOR_DATA);
SetIndexBuffer(5, Buf5, INDICATOR_COLOR_INDEX);
SetIndexBuffer(6, Buf6, INDICATOR_DATA);
SetIndexBuffer(7, Buf7, INDICATOR_COLOR_INDEX);
PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetDouble(3, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(0, PLOT_SHOW_DATA, false);
IndicatorSetString(INDICATOR_SHORTNAME, "Gaussian Channel [DW]");
__pineSaveInitial();
return INIT_SUCCEEDED;
}
//--- one bar == one evaluation of the original Pine script
void PineBar(const int __pineBar,
const double &open[], const double &high[],
const double &low[], const double &close[],
const long &volume[],
const datetime &time[])
{
__src[__pineBar] = pine_source(src, open, high, low, close, __pineBar);
__ts0[__pineBar] = pine_tr_na(high, low, close, __pineBar, true);
if(__pineBar > 0)
{
filt[__pineBar] = filt[__pineBar - 1];
}
beta = pine_div((1 - MathCos(pine_div((4 * MathArcsin(1)), per))), (MathPow(1.414, pine_div(2, N)) - 1));
alpha = ((-beta) + MathSqrt((MathPow(beta, 2) + (2 * beta))));
lag = pine_div((per - 1), (2 * N));
srcdata = (modeLag ? (pine_source(src, open, high, low, close, __pineBar) + (pine_source(src, open, high, low, close, __pineBar) - pine_hist(__src, __pineBar, (int)(lag)))) : pine_source(src, open, high, low, close, __pineBar));
trdata = (modeLag ? (pine_tr_na(high, low, close, __pineBar, true) + (pine_tr_na(high, low, close, __pineBar, true) - pine_hist(__ts0, __pineBar, (int)(lag)))) : pine_tr_na(high, low, close, __pineBar, true));
double __tc0_0 = PINE_NA;
double __tc0_1 = PINE_NA;
f_pole(alpha, srcdata, N, __pineBar, __tc0_0, __tc0_1);
filtn = __tc0_0;
filt1 = __tc0_1;
double __tc1_0 = PINE_NA;
double __tc1_1 = PINE_NA;
f_pole__site1(alpha, trdata, N, __pineBar, __tc1_0, __tc1_1);
filtntr = __tc1_0;
filt1tr = __tc1_1;
filt[__pineBar] = (modeFast ? pine_div((filtn + filt1), 2) : filtn);
filttr = (modeFast ? pine_div((filtntr + filt1tr), 2) : filtntr);
hband = (filt[__pineBar] + (filttr * mult));
lband = (filt[__pineBar] - (filttr * mult));
color1 = C'10,255,104';
color2 = C'0,117,45';
color3 = C'255,10,90';
color4 = C'153,0,50';
fcolor = ((filt[__pineBar] > pine_hist(filt, __pineBar, (int)(1))) ? C'10,255,104' : ((filt[__pineBar] < pine_hist(filt, __pineBar, (int)(1))) ? C'255,10,90' : C'204,204,204'));
barcolor = ((((((((pine_source(src, open, high, low, close, __pineBar) > pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) > filt[__pineBar]) ? 1 : 0)) != 0) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) < hband) ? 1 : 0)) != 0) ? C'10,255,104' : (((((pine_source(src, open, high, low, close, __pineBar) > pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) >= hband) ? 1 : 0)) != 0) ? C'10,255,27' : (((((pine_source(src, open, high, low, close, __pineBar) <= pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) > filt[__pineBar]) ? 1 : 0)) != 0) ? C'0,117,45' : ((((((((pine_source(src, open, high, low, close, __pineBar) < pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) < filt[__pineBar]) ? 1 : 0)) != 0) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) > lband) ? 1 : 0)) != 0) ? C'255,10,90' : (((((pine_source(src, open, high, low, close, __pineBar) < pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) <= lband) ? 1 : 0)) != 0) ? C'255,10,17' : (((((pine_source(src, open, high, low, close, __pineBar) >= pine_hist(__src, __pineBar, (int)(1))) ? 1 : 0) & ((pine_source(src, open, high, low, close, __pineBar) < filt[__pineBar]) ? 1 : 0)) != 0) ? C'153,0,50' : C'204,204,204'))))));
0 /* barcolor dropped: visual only */;
double __pinePlotValue1 = filt[__pineBar];
double __pinePlotColour1 = (double)(fcolor);
Buf2[__pineBar] = __pinePlotValue1;
Buf3[__pineBar] = pine_color_slot(1, pine_na(__pinePlotColour1) ? clrNONE : (color)__pinePlotColour1, __pal1, __paln1);
double __pinePlotValue2 = hband;
double __pinePlotColour2 = (double)(fcolor);
Buf4[__pineBar] = __pinePlotValue2;
Buf5[__pineBar] = pine_color_slot(2, pine_na(__pinePlotColour2) ? clrNONE : (color)__pinePlotColour2, __pal2, __paln2);
double __pinePlotValue3 = lband;
double __pinePlotColour3 = (double)(fcolor);
Buf6[__pineBar] = __pinePlotValue3;
Buf7[__pineBar] = pine_color_slot(3, pine_na(__pinePlotColour3) ? clrNONE : (color)__pinePlotColour3, __pal3, __paln3);
PineFill0[__pineBar] = Buf4[__pineBar];
PineFill1[__pineBar] = Buf6[__pineBar];
}
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[])
{
// Pine evaluates oldest-to-newest. MQL4 hands OnCalculate
// SERIES-indexed arrays (0 == newest) while MQL5 hands over
// oldest-first, so the direction is forced explicitly rather
// than relying on either default. `x[n]` is then index i - n
// in both dialects, and the generated logic is identical.
ArraySetAsSeries(open, false);
ArraySetAsSeries(high, false);
ArraySetAsSeries(low, false);
ArraySetAsSeries(close, false);
ArraySetAsSeries(tick_volume, false);
ArraySetAsSeries(volume, false);
ArraySetAsSeries(time, false);
ArrayResize(filt, rates_total);
ArrayResize(__st0, rates_total);
ArrayResize(__stb0, rates_total);
ArrayResize(__st1, rates_total);
ArrayResize(__stb1, rates_total);
ArrayResize(__st2, rates_total);
ArrayResize(__stb2, rates_total);
ArrayResize(__st3, rates_total);
ArrayResize(__stb3, rates_total);
ArrayResize(__src, rates_total);
ArrayResize(__fl_f_filt9x__f, rates_total);
ArrayResize(__fl_f_filt9x__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site2__f, rates_total);
ArrayResize(__fl_f_filt9x__site3__f, rates_total);
ArrayResize(__fl_f_filt9x__site4__f, rates_total);
ArrayResize(__fl_f_filt9x__site5__f, rates_total);
ArrayResize(__fl_f_filt9x__site6__f, rates_total);
ArrayResize(__fl_f_filt9x__site7__f, rates_total);
ArrayResize(__fl_f_filt9x__site8__f, rates_total);
ArrayResize(__fl_f_filt9x__site9__f, rates_total);
ArrayResize(__fl_f_filt9x__site1__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site2__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site3__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site4__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site5__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site6__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site7__site1__f, rates_total);
ArrayResize(__fl_f_filt9x__site8__site1__f, rates_total);
ArrayResize(__ts0, rates_total);
if(prev_calculated == 0)
{
ArrayInitialize(filt, PINE_NA);
ArrayInitialize(__st0, PINE_NA);
ArrayInitialize(__stb0, PINE_NA);
ArrayInitialize(__st1, PINE_NA);
ArrayInitialize(__stb1, PINE_NA);
ArrayInitialize(__st2, PINE_NA);
ArrayInitialize(__stb2, PINE_NA);
ArrayInitialize(__st3, PINE_NA);
ArrayInitialize(__stb3, PINE_NA);
ArrayInitialize(__src, PINE_NA);
ArrayInitialize(__fl_f_filt9x__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site2__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site3__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site4__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site5__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site6__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site7__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site8__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site9__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site1__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site2__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site3__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site4__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site5__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site6__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site7__site1__f, PINE_NA);
ArrayInitialize(__fl_f_filt9x__site8__site1__f, PINE_NA);
ArrayInitialize(__ts0, PINE_NA);
}
__pineLastBar = rates_total - 1;
const int start = (prev_calculated > 1) ? prev_calculated - 1 : 0;
static bool __pineRealVolume = false;
if(start == 0)
{
__pineRestoreInitial();
__pineSnapBar = -1;
__pineRealVolume = rates_total > 0 && volume[rates_total - 1] > 0;
}
__pineRealtime = prev_calculated > 0;
for(int __pineBar = start; __pineBar < rates_total; __pineBar++)
{
if(__pineBar == __pineSnapBar)
__pineRestoreState(); // a re-run of this bar: back to its start
else if(__pineBar == __pineLastBar)
{
__pineSaveState(); // the forming bar: remember the state it starts from
__pineSnapBar = __pineBar;
}
if(__pineRealVolume) PineBar(__pineBar, open, high, low, close, volume, time);
else PineBar(__pineBar, open, high, low, close, tick_volume, time);
}
return rates_total;
}Original Pine Script
© DonovanWall — Mozilla Public License 2.0. Reproduced for attribution and comparison; the converted code above is a derivative work offered under the same licence.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DonovanWall
//██████╗ ██╗ ██╗
//██╔══██╗██║ ██║
//██║ ██║██║ █╗ ██║
//██║ ██║██║███╗██║
//██████╔╝╚███╔███╔╝
//╚═════╝ ╚══╝╚══╝
//@version=4
study(title="Gaussian Channel [DW]", shorttitle="GC [DW]", overlay=true)
// This study is an experiment utilizing the Ehlers Gaussian Filter technique combined with lag reduction techniques and true range to analyze trend activity.
// Gaussian filters, as Ehlers explains it, are simply exponential moving averages applied multiple times.
// First, beta and alpha are calculated based on the sampling period and number of poles specified. The maximum number of poles available in this script is 9.
// Next, the data being analyzed is given a truncation option for reduced lag, which can be enabled with "Reduced Lag Mode".
// Then the alpha and source values are used to calculate the filter and filtered true range of the dataset.
// Filtered true range with a specified multiplier is then added to and subtracted from the filter, generating a channel.
// Lastly, a one pole filter with a N pole alpha is averaged with the filter to generate a faster filter, which can be enabled with "Fast Response Mode".
//Custom bar colors are included.
//Note: Both the sampling period and number of poles directly affect how much lag the indicator has, and how smooth the output is.
// Larger inputs will result in smoother outputs with increased lag, and smaller inputs will have noisier outputs with reduced lag.
// For the best results, I recommend not setting the sampling period any lower than the number of poles + 1. Going lower truncates the equation.
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Updates:
// Huge shoutout to @e2e4mfck for taking the time to improve the calculation method!
// -> migrated to v4
// -> pi is now calculated using trig identities rather than being explicitly defined.
// -> The filter calculations are now organized into functions rather than being individually defined.
// -> Revamped color scheme.
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions - courtesy of @e2e4mfck
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Filter function
f_filt9x (_a, _s, _i) =>
int _m2 = 0, int _m3 = 0, int _m4 = 0, int _m5 = 0, int _m6 = 0,
int _m7 = 0, int _m8 = 0, int _m9 = 0, float _f = .0, _x = (1 - _a)
// Weights.
// Initial weight _m1 is a pole number and equal to _i
_m2 := _i == 9 ? 36 : _i == 8 ? 28 : _i == 7 ? 21 : _i == 6 ? 15 : _i == 5 ? 10 : _i == 4 ? 6 : _i == 3 ? 3 : _i == 2 ? 1 : 0
_m3 := _i == 9 ? 84 : _i == 8 ? 56 : _i == 7 ? 35 : _i == 6 ? 20 : _i == 5 ? 10 : _i == 4 ? 4 : _i == 3 ? 1 : 0
_m4 := _i == 9 ? 126 : _i == 8 ? 70 : _i == 7 ? 35 : _i == 6 ? 15 : _i == 5 ? 5 : _i == 4 ? 1 : 0
_m5 := _i == 9 ? 126 : _i == 8 ? 56 : _i == 7 ? 21 : _i == 6 ? 6 : _i == 5 ? 1 : 0
_m6 := _i == 9 ? 84 : _i == 8 ? 28 : _i == 7 ? 7 : _i == 6 ? 1 : 0
_m7 := _i == 9 ? 36 : _i == 8 ? 8 : _i == 7 ? 1 : 0
_m8 := _i == 9 ? 9 : _i == 8 ? 1 : 0
_m9 := _i == 9 ? 1 : 0
// filter
_f := pow(_a, _i) * nz(_s) +
_i * _x * nz(_f[1]) - (_i >= 2 ?
_m2 * pow(_x, 2) * nz(_f[2]) : 0) + (_i >= 3 ?
_m3 * pow(_x, 3) * nz(_f[3]) : 0) - (_i >= 4 ?
_m4 * pow(_x, 4) * nz(_f[4]) : 0) + (_i >= 5 ?
_m5 * pow(_x, 5) * nz(_f[5]) : 0) - (_i >= 6 ?
_m6 * pow(_x, 6) * nz(_f[6]) : 0) + (_i >= 7 ?
_m7 * pow(_x, 7) * nz(_f[7]) : 0) - (_i >= 8 ?
_m8 * pow(_x, 8) * nz(_f[8]) : 0) + (_i == 9 ?
_m9 * pow(_x, 9) * nz(_f[9]) : 0)
//9 var declaration fun
f_pole (_a, _s, _i) =>
_f1 = f_filt9x(_a, _s, 1), _f2 = (_i >= 2 ? f_filt9x(_a, _s, 2) : 0), _f3 = (_i >= 3 ? f_filt9x(_a, _s, 3) : 0)
_f4 = (_i >= 4 ? f_filt9x(_a, _s, 4) : 0), _f5 = (_i >= 5 ? f_filt9x(_a, _s, 5) : 0), _f6 = (_i >= 6 ? f_filt9x(_a, _s, 6) : 0)
_f7 = (_i >= 2 ? f_filt9x(_a, _s, 7) : 0), _f8 = (_i >= 8 ? f_filt9x(_a, _s, 8) : 0), _f9 = (_i == 9 ? f_filt9x(_a, _s, 9) : 0)
_fn = _i == 1 ? _f1 : _i == 2 ? _f2 : _i == 3 ? _f3 :
_i == 4 ? _f4 : _i == 5 ? _f5 : _i == 6 ? _f6 :
_i == 7 ? _f7 : _i == 8 ? _f8 : _i == 9 ? _f9 : na
[_fn, _f1]
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Source
src = input(defval=hlc3, title="Source")
//Poles
int N = input(defval=4, title="Poles", minval=1, maxval=9)
//Period
int per = input(defval=144, title="Sampling Period", minval=2)
//True Range Multiplier
float mult = input(defval=1.414, title="Filtered True Range Multiplier", minval=0)
//Lag Reduction
bool modeLag = input(defval=false, title="Reduced Lag Mode")
bool modeFast = input(defval=false, title="Fast Response Mode")
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Beta and Alpha Components
beta = (1 - cos(4*asin(1)/per)) / (pow(1.414, 2/N) - 1)
alpha = - beta + sqrt(pow(beta, 2) + 2*beta)
//Lag
lag = (per - 1)/(2*N)
//Data
srcdata = modeLag ? src + (src - src[lag]) : src
trdata = modeLag ? tr(true) + (tr(true) - tr(true)[lag]) : tr(true)
//Filtered Values
[filtn, filt1] = f_pole(alpha, srcdata, N)
[filtntr, filt1tr] = f_pole(alpha, trdata, N)
//Lag Reduction
filt = modeFast ? (filtn + filt1)/2 : filtn
filttr = modeFast ? (filtntr + filt1tr)/2 : filtntr
//Bands
hband = filt + filttr*mult
lband = filt - filttr*mult
// Colors
color1 = #0aff68
color2 = #00752d
color3 = #ff0a5a
color4 = #990032
fcolor = filt > filt[1] ? #0aff68 : filt < filt[1] ? #ff0a5a : #cccccc
barcolor = (src > src[1]) and (src > filt) and (src < hband) ? #0aff68 : (src > src[1]) and (src >= hband) ? #0aff1b : (src <= src[1]) and (src > filt) ? #00752d :
(src < src[1]) and (src < filt) and (src > lband) ? #ff0a5a : (src < src[1]) and (src <= lband) ? #ff0a11 : (src >= src[1]) and (src < filt) ? #990032 : #cccccc
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Filter Plot
filtplot = plot(filt, title="Filter", color=fcolor, linewidth=3)
//Band Plots
hbandplot = plot(hband, title="Filtered True Range High Band", color=fcolor)
lbandplot = plot(lband, title="Filtered True Range Low Band", color=fcolor)
//Channel Fill
fill(hbandplot, lbandplot, title="Channel Fill", color=fcolor, transp=80)
//Bar Color
barcolor(barcolor)Convert your own Pine Script to MQL5
Your first conversion is free, in either direction. Paste a TradingView indicator or strategy and get MQL5 or MQL4 source, with every construct the engine could not map flagged by line.
Open the converterMore: all example conversions · how Pine Script maps to MQL5 · how the engine measures