Nice job!Centaur wrote: Sat Feb 25, 2023 6:04 pm Cong Adaptive Moving Average (CAMA)
https://in.tradingview.com/script/hOCmX ... g-Average/
Code: Select all
//+------------------------------------------------------------------+ //| Cong Adaptive Moving Average (CAMA) | //+------------------------------------------------------------------+ int maCongAdaptive(const int rates_total, const int prev_calculated, const int value_length, // min val: 1; default val: 10 const double &source_price[], const double &source_high[], const double &source_low[], const double &source_close[], double &temp_true_range[], double &result_value[], double &result_color[]) { //--- bar index start int bar_index; if(prev_calculated == 0) bar_index = 0; else bar_index = prev_calculated - 1; //--- main loop for(int i = bar_index; i < rates_total && !_StopFlag; i++) { temp_true_range[i] = i < 1 ? source_high[i] - source_low[i] : fmax(source_high[i] - source_low[i], fmax(fabs(source_high[i] - source_close[i - 1]), fabs(source_low[i] - source_close[i - 1]))); if(i < value_length) { result_value[i] = source_price[i]; result_color[i] = EMPTY_VALUE; } else { double denom = 0.0, hh = -DBL_MAX, ll = DBL_MAX; for(int k = 0; k < value_length; k++) { denom += temp_true_range[i - k]; hh = source_high[i - k] > hh ? source_high[i - k] : hh; ll = source_low[i - k] < ll ? source_low[i - k] : ll; } double num = hh - ll; double alpha = num / denom; result_value[i] = alpha == 1.0 ? alpha * source_price[i] : alpha * source_price[i] + (1.0 - alpha) * result_value[i - 1]; result_color[i] = StringToDouble(DoubleToString(result_value[i], _Digits)) > StringToDouble(DoubleToString(result_value[i - 1], _Digits)) ? 0.0 : StringToDouble(DoubleToString(result_value[i], _Digits)) < StringToDouble(DoubleToString(result_value[i - 1], _Digits)) ? 1.0 : result_color[i - 1]; } } return(rates_total); }
Re: No Nonsense Forex - Indicators
171- These users thanked the author mrtools for the post (total 2):
- Chickenspicy, Banzai