2026-06-27 11:57:11 +02:00
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
//| KAMA_Anchored_Calculator.mqh |
|
|
|
|
|
//| Engine for Session-Anchored Kaufman's Adaptive MA (AKAMA) |
|
|
|
|
|
//| Copyright 2026, xxxxxxxx|
|
2026-06-27 11:57:11 +02:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#property copyright "Copyright 2026, xxxxxxxx"
|
2026-08-24 21:51:39 +02:00
|
|
|
#property version "1.10" // Deterministic Stateless Engine with Robust Custom Session Logic
|
2026-06-27 11:57:11 +02:00
|
|
|
|
|
|
|
|
#ifndef KAMA_ANCHORED_CALCULATOR_MQH
|
|
|
|
|
#define KAMA_ANCHORED_CALCULATOR_MQH
|
|
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
#include <MyIncludes\HeikinAshi_Tools.mqh>
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
//--- Enum for Anchor Reset Period ---
|
2026-06-27 11:57:11 +02:00
|
|
|
enum ENUM_ANCHOR_PERIOD
|
|
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
ANCHOR_PERIOD_SESSION, // Reset every day (with timezone shift)
|
|
|
|
|
ANCHOR_PERIOD_WEEK, // Reset every week
|
|
|
|
|
ANCHOR_PERIOD_MONTH, // Reset every month
|
|
|
|
|
ANCHOR_PERIOD_CUSTOM_SESSION // Reset based on custom start/end times
|
2026-06-27 11:57:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//+==================================================================+
|
2026-08-24 16:14:48 +02:00
|
|
|
//| CLASS: CKamaAnchoredCalculator |
|
2026-06-27 11:57:11 +02:00
|
|
|
//+==================================================================+
|
2026-08-24 16:14:48 +02:00
|
|
|
class CKamaAnchoredCalculator
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
private:
|
|
|
|
|
ENUM_ANCHOR_PERIOD m_anchor_period;
|
|
|
|
|
ENUM_APPLIED_PRICE_HA_ALL m_source_price;
|
|
|
|
|
long m_tz_shift_seconds;
|
|
|
|
|
int m_er_period;
|
|
|
|
|
double m_fastest_sc;
|
|
|
|
|
double m_slowest_sc;
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
//--- Custom Session Configuration
|
2026-08-24 16:14:48 +02:00
|
|
|
int m_start_hour, m_start_min;
|
|
|
|
|
int m_end_hour, m_end_min;
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
//--- Persistent Price Buffers
|
2026-08-24 16:14:48 +02:00
|
|
|
double m_price[];
|
|
|
|
|
double m_ha_open[], m_ha_high[], m_ha_low[], m_ha_close[];
|
|
|
|
|
|
|
|
|
|
//--- Composition Engine
|
|
|
|
|
CHeikinAshi_Calculator m_ha_engine;
|
|
|
|
|
|
|
|
|
|
//--- Internal Methods
|
|
|
|
|
bool PreparePriceSeries(const int rates_total,
|
|
|
|
|
const int start_index,
|
|
|
|
|
const double &open[],
|
|
|
|
|
const double &high[],
|
|
|
|
|
const double &low[],
|
|
|
|
|
const double &close[]);
|
2026-06-27 11:57:11 +02:00
|
|
|
|
|
|
|
|
public:
|
2026-08-24 16:14:48 +02:00
|
|
|
CKamaAnchoredCalculator(void);
|
|
|
|
|
~CKamaAnchoredCalculator(void) {};
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
bool Init(const ENUM_ANCHOR_PERIOD anchor_p,
|
|
|
|
|
const int tz_shift_hours,
|
|
|
|
|
const string custom_start,
|
|
|
|
|
const string custom_end,
|
|
|
|
|
const int er_p,
|
|
|
|
|
const int fast_p,
|
|
|
|
|
const int slow_p,
|
|
|
|
|
const ENUM_APPLIED_PRICE_HA_ALL source);
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
bool IsTimeInCustomSession(const datetime bar_time);
|
|
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
void Calculate(const int rates_total,
|
|
|
|
|
const int prev_calculated,
|
|
|
|
|
const datetime &time[],
|
|
|
|
|
const double &open[],
|
|
|
|
|
const double &high[],
|
|
|
|
|
const double &low[],
|
|
|
|
|
const double &close[],
|
|
|
|
|
double &kama_odd[],
|
|
|
|
|
double &kama_even[],
|
|
|
|
|
double &out_price[]);
|
2026-06-27 11:57:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Constructor |
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
CKamaAnchoredCalculator::CKamaAnchoredCalculator(void) : m_anchor_period(ANCHOR_PERIOD_SESSION),
|
|
|
|
|
m_source_price(PRICE_CLOSE_STD),
|
|
|
|
|
m_tz_shift_seconds(0),
|
|
|
|
|
m_er_period(10),
|
|
|
|
|
m_fastest_sc(0.6667),
|
|
|
|
|
m_slowest_sc(0.0645),
|
|
|
|
|
m_start_hour(8), m_start_min(0),
|
|
|
|
|
m_end_hour(17), m_end_min(0)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
ArraySetAsSeries(m_price, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_open, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_high, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_low, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_close, false);
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
//| Initialization |
|
2026-06-27 11:57:11 +02:00
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
bool CKamaAnchoredCalculator::Init(const ENUM_ANCHOR_PERIOD anchor_p,
|
|
|
|
|
const int tz_shift_hours,
|
|
|
|
|
const string custom_start,
|
|
|
|
|
const string custom_end,
|
|
|
|
|
const int er_p,
|
|
|
|
|
const int fast_p,
|
|
|
|
|
const int slow_p,
|
|
|
|
|
const ENUM_APPLIED_PRICE_HA_ALL source)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
m_anchor_period = anchor_p;
|
|
|
|
|
m_source_price = source;
|
|
|
|
|
m_tz_shift_seconds = (long)tz_shift_hours * 3600;
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
m_er_period = (er_p < 1) ? 1 : er_p;
|
|
|
|
|
int fast_len = (fast_p < 1) ? 1 : fast_p;
|
|
|
|
|
int slow_len = (slow_p < 1) ? 1 : slow_p;
|
|
|
|
|
|
|
|
|
|
m_fastest_sc = 2.0 / (fast_len + 1.0);
|
|
|
|
|
m_slowest_sc = 2.0 / (slow_len + 1.0);
|
|
|
|
|
|
|
|
|
|
if(m_anchor_period == ANCHOR_PERIOD_CUSTOM_SESSION)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
string start_parts[], end_parts[];
|
|
|
|
|
if(StringSplit(custom_start, ':', start_parts) == 2)
|
|
|
|
|
{
|
|
|
|
|
m_start_hour = (int)StringToInteger(start_parts[0]);
|
|
|
|
|
m_start_min = (int)StringToInteger(start_parts[1]);
|
|
|
|
|
}
|
|
|
|
|
if(StringSplit(custom_end, ':', end_parts) == 2)
|
|
|
|
|
{
|
|
|
|
|
m_end_hour = (int)StringToInteger(end_parts[0]);
|
|
|
|
|
m_end_min = (int)StringToInteger(end_parts[1]);
|
|
|
|
|
}
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
2026-08-24 16:14:48 +02:00
|
|
|
|
2026-06-27 11:57:11 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 21:51:39 +02:00
|
|
|
//| Custom Session In-Time Check (Stateless) |
|
2026-06-27 11:57:11 +02:00
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 21:51:39 +02:00
|
|
|
bool CKamaAnchoredCalculator::IsTimeInCustomSession(const datetime bar_time)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
MqlDateTime dt;
|
|
|
|
|
TimeToStruct(bar_time + (datetime)m_tz_shift_seconds, dt);
|
|
|
|
|
|
2026-06-27 11:57:11 +02:00
|
|
|
int current_min = dt.hour * 60 + dt.min;
|
2026-08-24 16:14:48 +02:00
|
|
|
int start_min = m_start_hour * 60 + m_start_min;
|
|
|
|
|
int end_min = m_end_hour * 60 + m_end_min;
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
if(end_min > start_min)
|
|
|
|
|
{
|
|
|
|
|
// Standard intraday session (e.g. 08:00 to 17:00)
|
2026-08-24 16:14:48 +02:00
|
|
|
return (current_min >= start_min && current_min < end_min);
|
2026-08-24 21:51:39 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if(end_min < start_min)
|
|
|
|
|
{
|
|
|
|
|
// Overnight session spanning midnight (e.g. 22:00 to 06:00)
|
|
|
|
|
return (current_min >= start_min || current_min < end_min);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Full 24-hour session
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
//| Prepare Price Series (Standard / Heikin Ashi) |
|
2026-06-27 11:57:11 +02:00
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 16:14:48 +02:00
|
|
|
bool CKamaAnchoredCalculator::PreparePriceSeries(const int rates_total,
|
|
|
|
|
const int start_index,
|
|
|
|
|
const double &open[],
|
|
|
|
|
const double &high[],
|
|
|
|
|
const double &low[],
|
|
|
|
|
const double &close[])
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
|
|
|
|
if(ArraySize(m_price) != rates_total)
|
|
|
|
|
{
|
|
|
|
|
ArrayResize(m_price, rates_total);
|
2026-08-24 16:14:48 +02:00
|
|
|
ArraySetAsSeries(m_price, false);
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
bool is_heikin_ashi = (m_source_price <= PRICE_HA_CLOSE);
|
|
|
|
|
|
|
|
|
|
if(is_heikin_ashi)
|
|
|
|
|
{
|
|
|
|
|
if(ArraySize(m_ha_open) != rates_total)
|
|
|
|
|
{
|
|
|
|
|
ArrayResize(m_ha_open, rates_total);
|
|
|
|
|
ArrayResize(m_ha_high, rates_total);
|
|
|
|
|
ArrayResize(m_ha_low, rates_total);
|
|
|
|
|
ArrayResize(m_ha_close, rates_total);
|
|
|
|
|
|
|
|
|
|
ArraySetAsSeries(m_ha_open, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_high, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_low, false);
|
|
|
|
|
ArraySetAsSeries(m_ha_close, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ha_engine.Calculate(rates_total, start_index, open, high, low, close,
|
|
|
|
|
m_ha_open, m_ha_high, m_ha_low, m_ha_close);
|
|
|
|
|
|
|
|
|
|
for(int i = start_index; i < rates_total; i++)
|
|
|
|
|
{
|
|
|
|
|
switch(m_source_price)
|
|
|
|
|
{
|
|
|
|
|
case PRICE_HA_OPEN:
|
|
|
|
|
m_price[i] = m_ha_open[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_HIGH:
|
|
|
|
|
m_price[i] = m_ha_high[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_LOW:
|
|
|
|
|
m_price[i] = m_ha_low[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_MEDIAN:
|
|
|
|
|
m_price[i] = (m_ha_high[i] + m_ha_low[i]) / 2.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_TYPICAL:
|
|
|
|
|
m_price[i] = (m_ha_high[i] + m_ha_low[i] + m_ha_close[i]) / 3.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_WEIGHTED:
|
|
|
|
|
m_price[i] = (m_ha_high[i] + m_ha_low[i] + 2.0 * m_ha_close[i]) / 4.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HA_CLOSE:
|
|
|
|
|
default:
|
|
|
|
|
m_price[i] = m_ha_close[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for(int i = start_index; i < rates_total; i++)
|
|
|
|
|
{
|
|
|
|
|
switch(m_source_price)
|
|
|
|
|
{
|
|
|
|
|
case PRICE_OPEN_STD:
|
|
|
|
|
m_price[i] = open[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_HIGH_STD:
|
|
|
|
|
m_price[i] = high[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_LOW_STD:
|
|
|
|
|
m_price[i] = low[i];
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_MEDIAN_STD:
|
|
|
|
|
m_price[i] = (high[i] + low[i]) / 2.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_TYPICAL_STD:
|
|
|
|
|
m_price[i] = (high[i] + low[i] + close[i]) / 3.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_WEIGHTED_STD:
|
|
|
|
|
m_price[i] = (high[i] + low[i] + 2.0 * close[i]) / 4.0;
|
|
|
|
|
break;
|
|
|
|
|
case PRICE_CLOSE_STD:
|
|
|
|
|
default:
|
|
|
|
|
m_price[i] = close[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-08-24 21:51:39 +02:00
|
|
|
//| Deterministic Anchored KAMA Calculation |
|
2026-08-24 16:14:48 +02:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void CKamaAnchoredCalculator::Calculate(const int rates_total,
|
|
|
|
|
const int prev_calculated,
|
|
|
|
|
const datetime &time[],
|
|
|
|
|
const double &open[],
|
|
|
|
|
const double &high[],
|
|
|
|
|
const double &low[],
|
|
|
|
|
const double &close[],
|
|
|
|
|
double &kama_odd[],
|
|
|
|
|
double &kama_even[],
|
|
|
|
|
double &out_price[])
|
|
|
|
|
{
|
|
|
|
|
if(rates_total < 2)
|
2026-06-27 11:57:11 +02:00
|
|
|
return;
|
|
|
|
|
|
2026-08-24 16:14:48 +02:00
|
|
|
int start_index = (prev_calculated == 0) ? 0 : (prev_calculated - 1);
|
|
|
|
|
|
|
|
|
|
if(!PreparePriceSeries(rates_total, start_index, open, high, low, close))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Export price series for band variance calculations
|
|
|
|
|
if(ArraySize(out_price) != rates_total)
|
|
|
|
|
{
|
|
|
|
|
ArrayResize(out_price, rates_total);
|
|
|
|
|
ArraySetAsSeries(out_price, false);
|
|
|
|
|
}
|
|
|
|
|
ArrayCopy(out_price, m_price, start_index, start_index, rates_total - start_index);
|
|
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
// Full deterministic scan across all historical sessions
|
|
|
|
|
int period_index = 0;
|
|
|
|
|
int anchor_bar = 0;
|
|
|
|
|
double current_kama = 0.0;
|
|
|
|
|
bool in_session = false;
|
2026-08-24 16:14:48 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
for(int i = 0; i < rates_total; i++)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
|
|
|
|
bool new_period = false;
|
|
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
if(m_anchor_period == ANCHOR_PERIOD_CUSTOM_SESSION)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
bool is_inside = IsTimeInCustomSession(time[i]);
|
|
|
|
|
if(is_inside && !in_session)
|
|
|
|
|
new_period = true;
|
|
|
|
|
in_session = is_inside;
|
2026-08-24 16:14:48 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
in_session = true;
|
|
|
|
|
if(i == 0)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
new_period = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch(m_anchor_period)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
case ANCHOR_PERIOD_SESSION:
|
|
|
|
|
{
|
|
|
|
|
datetime curr_t = time[i] + (datetime)m_tz_shift_seconds;
|
|
|
|
|
datetime prev_t = time[i - 1] + (datetime)m_tz_shift_seconds;
|
|
|
|
|
MqlDateTime dt_c, dt_p;
|
|
|
|
|
TimeToStruct(curr_t, dt_c);
|
|
|
|
|
TimeToStruct(prev_t, dt_p);
|
|
|
|
|
if(dt_c.day_of_year != dt_p.day_of_year || dt_c.year != dt_p.year)
|
|
|
|
|
new_period = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ANCHOR_PERIOD_WEEK:
|
|
|
|
|
{
|
|
|
|
|
MqlDateTime dt_c, dt_p;
|
|
|
|
|
TimeToStruct(time[i], dt_c);
|
|
|
|
|
TimeToStruct(time[i - 1], dt_p);
|
|
|
|
|
if(dt_c.day_of_week < dt_p.day_of_week)
|
|
|
|
|
new_period = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ANCHOR_PERIOD_MONTH:
|
|
|
|
|
{
|
|
|
|
|
MqlDateTime dt_c, dt_p;
|
|
|
|
|
TimeToStruct(time[i], dt_c);
|
|
|
|
|
TimeToStruct(time[i - 1], dt_p);
|
|
|
|
|
if(dt_c.mon != dt_p.mon || dt_c.year != dt_p.year)
|
|
|
|
|
new_period = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
// Handle Period Reset
|
2026-06-27 11:57:11 +02:00
|
|
|
if(new_period)
|
|
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
period_index++;
|
|
|
|
|
anchor_bar = i;
|
2026-08-24 16:14:48 +02:00
|
|
|
current_kama = m_price[i];
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
2026-08-24 21:51:39 +02:00
|
|
|
|
|
|
|
|
// Compute KAMA within Session Scope
|
|
|
|
|
if(in_session)
|
2026-06-27 11:57:11 +02:00
|
|
|
{
|
2026-08-24 21:51:39 +02:00
|
|
|
int bars_in_session = i - anchor_bar;
|
|
|
|
|
if(bars_in_session == 0)
|
|
|
|
|
{
|
|
|
|
|
current_kama = m_price[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int lookback = MathMin(bars_in_session, m_er_period);
|
|
|
|
|
double direction = MathAbs(m_price[i] - m_price[i - lookback]);
|
|
|
|
|
double volatility = 0.0;
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
for(int j = 0; j < lookback; j++)
|
|
|
|
|
volatility += MathAbs(m_price[i - j] - m_price[i - j - 1]);
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
double er = (volatility > 1.0e-9) ? (direction / volatility) : 0.0;
|
|
|
|
|
double sc = MathPow(er * (m_fastest_sc - m_slowest_sc) + m_slowest_sc, 2.0);
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
current_kama = current_kama + sc * (m_price[i] - current_kama);
|
|
|
|
|
}
|
2026-06-27 11:57:11 +02:00
|
|
|
|
2026-08-24 21:51:39 +02:00
|
|
|
// Gapped Line Plotting (Odd / Even)
|
|
|
|
|
if(period_index % 2 != 0)
|
2026-08-24 16:14:48 +02:00
|
|
|
{
|
|
|
|
|
kama_odd[i] = current_kama;
|
|
|
|
|
kama_even[i] = EMPTY_VALUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
kama_even[i] = current_kama;
|
|
|
|
|
kama_odd[i] = EMPTY_VALUE;
|
|
|
|
|
}
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-08-24 16:14:48 +02:00
|
|
|
kama_odd[i] = EMPTY_VALUE;
|
|
|
|
|
kama_even[i] = EMPTY_VALUE;
|
2026-06-27 11:57:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // KAMA_ANCHORED_CALCULATOR_MQH
|
|
|
|
|
//+------------------------------------------------------------------+
|