Anchored Vwap , Tv version looks good. I didn't find mql5 version.
Re: No Nonsense Forex - Indicators
111- These users thanked the author tradd for the post:
- nathanvbasko
I love achored VWAP! Like most trading tools there's a degree of subjectivity to it but it's great for identifying pullbacks by anchoring to the recent swing high or swing low. I have a strategy for it that I might post some day. Though I find the MIDAS channel version better than the simple VWAP line. It would be great to see the forex-station legends create one that we could beef up with a ton of settings. Here's hoping!tradd wrote: Fri Dec 02, 2022 3:47 am Anchored Vwap , Tv version looks good. I didn't find mql5 version.
Code: Select all
//+------------------------------------------------------------------+
//| Indicator: Kaufman's Adaptive Moving Average (KAMA) |
//+------------------------------------------------------------------+
int inKAMA(const int rates_total, const int prev_calculated, const int len, const double &in_buf[], double &out_buf[])
{
//--- check period
if(rates_total < len)
return(0);
//--- calculate start position
int bar;
double fast_sc = StringToDouble(DoubleToString(2.0 / 3.0, 4)), slow_sc = StringToDouble(DoubleToString(2.0 / 31.0, 4));
if(prev_calculated == 0)
bar = 0;
else
bar = prev_calculated - 1;
//--- main loop
for(int i = bar; i < rates_total && !_StopFlag; i++)
{
if(i < len)
out_buf[i] = in_buf[i];
else
{
double direction = in_buf[i] - in_buf[i - len];
double volatility = 0.0;
for(int k = 0; k < len; k++)
volatility += fabs(in_buf[i - k] - in_buf[i - k - 1]);
double er = volatility == 0.0 ? 0.0 : direction == volatility ? 0.9999999999999 : direction == 0.0 ? 0.0000000000001 : fabs(direction / volatility);
double ssc = pow(er * (fast_sc - slow_sc) + slow_sc, 2);
out_buf[i] = out_buf[i - 1] + ssc * (in_buf[i] - out_buf[i - 1]);
}
}
return(rates_total);
}
Thanks for the wonderful work as usual.Centaur wrote: Fri Dec 02, 2022 7:35 pm Kaufman's Adaptive Moving Average (KAMA)
Just some final words on the KAMA, I've found a lot of different calculations for the indicator, but I believe this below to be as true to the original works as possible, written as a function. I've attached the original works of Kaufman.
Also the Fast EMA period and the Slow EMA period really is not to be adjusted or optimized, this only gives a range of plotting seeing your scaled smoothing constant is squared this would be equivalent to an ema of 900 periods in a range bound market (flat, no reaction to price action), and an ema of 4 periods in a very trending market (very reactive to price action), so I've removed it as input and made them fix smoothing constants. The only input is the lookback period.
Kaufman also recommends to trade on the change of the KAMA value. Buy when the KAMA turns up, and sell when the KAMA turns down, to prevent whipsaws in range bound markets Kaufman introduced a filter based on the standard deviation of the change of the KAMA value times a percentage, this percentage can be an input.
You'll notice I've bounded the efficiency ration between 0.000001 and 0.9999999. In other words the efficiency ratio is close to 0.0 but never 0.0 and close to 1.0 but never 1.0. Also checking for a divide by 0.0 error, in reality this can never be due to the calculation, but just in case.
Code: Select all
//+------------------------------------------------------------------+ //| Indicator: Kaufman's Adaptive Moving Average (KAMA) | //+------------------------------------------------------------------+ int inKAMA(const int rates_total, const int prev_calculated, const int len, const double &in_buf[], double &out_buf[]) { //--- check period if(rates_total < len) return(0); //--- calculate start position int bar; double fast_sc = StringToDouble(DoubleToString(2.0 / 3.0, 4)), slow_sc = StringToDouble(DoubleToString(2.0 / 31.0, 4)); if(prev_calculated == 0) bar = 0; else bar = prev_calculated - 1; //--- main loop for(int i = bar; i < rates_total && !_StopFlag; i++) { if(i < len) out_buf[i] = in_buf[i]; else { double direction = in_buf[i] - in_buf[i - len]; double volatility = 0.0; for(int k = 0; k < len; k++) volatility += fabs(in_buf[i - k] - in_buf[i - k - 1]); double er = volatility == 0.0 ? 0.0 : direction == volatility ? 0.9999999999999 : direction == 0.0 ? 0.0000000000001 : fabs(direction / volatility); double ssc = pow(er * (fast_sc - slow_sc) + slow_sc, 2); out_buf[i] = out_buf[i - 1] + ssc * (in_buf[i] - out_buf[i - 1]); } } return(rates_total); }
My version was purely based on NNFX rules for baseline, but yes I agree and will do another based on Kaufman's work. Kaufman calls this a moving average but in essence it's not. This is actually an entry / confirmation indicator.xpf2003 wrote: Fri Dec 02, 2022 7:51 pm Thanks for the wonderful work as usual.
I have a question - the filter you mentioned in the third paragraph, have you built that in your version of the indicator? If not, it could be a good idea to add that and expose a threshold value as a input. What do you think?
Works great as a noise filter as well, see Darwinex video's, the only change I would recommend is instead of using the efficiency ratio as a stand alone indicator is to use the KAMA. The stand alone efficiency ratio is based on a arbitrary fixed horizontal level to differentiate between high noise and low noise which most definitely will change between different asset classes. The KAMA slope adjust itself between different asset classes and timeframes.Centaur wrote: Fri Dec 02, 2022 8:30 pm My version was purely based on NNFX rules for baseline, but yes I agree and will do another based on Kaufman's work. Kaufman calls this a moving average but in essence it's not. This is actually an entry / confirmation indicator.
How exactly would you use this as a noise filter? Using the slope of KAMA?Centaur wrote: Fri Dec 02, 2022 8:38 pm Works great as a noise filter as well, see Darwinex video's, the only change I would recommend is instead of using the efficiency ratio as a stand alone indicator is to use the KAMA. The stand alone efficiency ratio is based on a arbitrary fixed horizontal level to differentiate between high noise and low noise which most definitely will change between different asset classes. The KAMA slope adjust itself between different asset classes and timeframes.
Yes exactly.xpf2003 wrote: Fri Dec 02, 2022 8:42 pm How exactly would you use this as a noise filter? Using the slope of KAMA?
tradd wrote: Fri Dec 02, 2022 3:47 am Anchored Vwap , Tv version looks good. I didn't find mql5 version.