Re: No Nonsense Forex - Indicators

112
tradd wrote: Fri Dec 02, 2022 3:47 am Anchored Vwap , Tv version looks good. I didn't find mql5 version.
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!

Re: No Nonsense Forex - Indicators

113
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);
  }
These users thanked the author Centaur for the post:
tradd
半人馬座
Bàn rénmǎzuò

If you enjoy my work please hit the like button, to show some support.
All comments, criticism, advise or general ideas are more than welcome. In fact its crucial to have a continues learning / developing mechanism not just for me but all fellow market enthusiasts.

Re: No Nonsense Forex - Indicators

114
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);
  }
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?

Re: No Nonsense Forex - Indicators

115
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?
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.
These users thanked the author Centaur for the post:
xpf2003
半人馬座
Bàn rénmǎzuò

If you enjoy my work please hit the like button, to show some support.
All comments, criticism, advise or general ideas are more than welcome. In fact its crucial to have a continues learning / developing mechanism not just for me but all fellow market enthusiasts.


Re: No Nonsense Forex - Indicators

116
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.
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.
半人馬座
Bàn rénmǎzuò

If you enjoy my work please hit the like button, to show some support.
All comments, criticism, advise or general ideas are more than welcome. In fact its crucial to have a continues learning / developing mechanism not just for me but all fellow market enthusiasts.

Re: No Nonsense Forex - Indicators

117
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.
How exactly would you use this as a noise filter? Using the slope of KAMA?

Re: No Nonsense Forex - Indicators

118
xpf2003 wrote: Fri Dec 02, 2022 8:42 pm How exactly would you use this as a noise filter? Using the slope of KAMA?
Yes exactly.
半人馬座
Bàn rénmǎzuò

If you enjoy my work please hit the like button, to show some support.
All comments, criticism, advise or general ideas are more than welcome. In fact its crucial to have a continues learning / developing mechanism not just for me but all fellow market enthusiasts.

Re: No Nonsense Forex - Indicators

119
Kaufman's Adaptive Moving Average (KAMA) - Original

Herewith the full KAMA as described by Kaufman, applying the suggested filter.
These users thanked the author Centaur for the post (total 2):
xpf2003, Ricstar_8
半人馬座
Bàn rénmǎzuò

If you enjoy my work please hit the like button, to show some support.
All comments, criticism, advise or general ideas are more than welcome. In fact its crucial to have a continues learning / developing mechanism not just for me but all fellow market enthusiasts.

Re: No Nonsense Forex - Indicators

120
tradd wrote: Fri Dec 02, 2022 3:47 am Anchored Vwap , Tv version looks good. I didn't find mql5 version.


Using it under the MT4 platform... An anchored VWAP using standard VWAP with the option to use Adaptive True Range (ATR) price adaptive calculation. With an added "twist": It is using Perry Kaufman's Efficiency Ratio to calculate ATR".

And it becomes an Anchored VWAP or uses the so-called MVWAP with a twist... Even more, Inside or outside of the twist, there is a lot, but it would be an overkill to mention it here ; )- I mean, literally as it really kills. Thus, not worth to mention ; )-

All of these are just part of the tool within my trading system to generate my own technical baseline bias

These users thanked the author nathanvbasko for the post (total 2):
Chickenspicy, tradd
Since Frank Sinatra sings in his own way, my charts sing... ♪  I did it, My... Way...  ♬ ; )─


Who is online

Users browsing this forum: pytason, Trendiction [Bot] and 8 guests