new files added

This commit is contained in:
Toh4iem9
2026-01-27 12:00:10 +01:00
parent 02d8e7c7e7
commit f5724f2a0d
@@ -0,0 +1,134 @@
//+------------------------------------------------------------------+
//| KAMA_Channel_Pro.mq5 |
//| Copyright 2026, xxxxxxxx|
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, xxxxxxxx"
#property version "1.00"
#property description "KAMA Channel (Keltner Concept): KAMA Middle Line + ATR Bands."
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots 3
//--- Plot 1: Upper Band
#property indicator_label1 "Upper Band"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDarkOrange
#property indicator_style1 STYLE_DOT
#property indicator_width1 1
//--- Plot 2: Lower Band
#property indicator_label2 "Lower Band"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrDarkOrange
#property indicator_style2 STYLE_DOT
#property indicator_width2 1
//--- Plot 3: Middle Band (KAMA)
#property indicator_label3 "KAMA"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrCrimson
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
#include <MyIncludes\KAMA_Channel_Calculator.mqh>
//--- Input Parameters
input group "KAMA Settings"
input int InpErPeriod = 10; // Efficiency Ratio Period
input int InpFastEmaPeriod = 2; // Fastest EMA Period
input int InpSlowEmaPeriod = 30; // Slowest EMA Period
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
input group "Channel (ATR) Settings"
input int InpAtrPeriod = 14;
input double InpMultiplier = 2.0;
input ENUM_ATR_SOURCE InpAtrSource = ATR_SOURCE_STANDARD;
//--- Buffers
double BufferUpper[];
double BufferLower[];
double BufferMiddle[];
//--- Global Object
CKamaChannelCalculator *g_calculator;
//+------------------------------------------------------------------+
//| OnInit |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0, BufferUpper, INDICATOR_DATA);
SetIndexBuffer(1, BufferLower, INDICATOR_DATA);
SetIndexBuffer(2, BufferMiddle, INDICATOR_DATA);
ArraySetAsSeries(BufferUpper, false);
ArraySetAsSeries(BufferLower, false);
ArraySetAsSeries(BufferMiddle, false);
//--- Factory Logic
if(InpSourcePrice <= PRICE_HA_CLOSE)
g_calculator = new CKamaChannelCalculator_HA();
else
g_calculator = new CKamaChannelCalculator();
//--- Initialize
if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpErPeriod, InpFastEmaPeriod, InpSlowEmaPeriod, InpAtrPeriod, InpMultiplier, InpAtrSource))
{
Print("Failed to initialize KAMA Channel Calculator.");
return(INIT_FAILED);
}
//--- Shortname
string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : "";
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("KAMA Ch%s(%d, ATR %d)", type, InpErPeriod, InpAtrPeriod));
//--- Visuals
int draw_begin = MathMax(InpErPeriod, InpAtrPeriod);
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, InpErPeriod);
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| OnDeinit |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
if(CheckPointer(g_calculator) != POINTER_INVALID)
delete g_calculator;
}
//+------------------------------------------------------------------+
//| OnCalculate |
//+------------------------------------------------------------------+
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[])
{
if(rates_total < MathMax(InpErPeriod, InpAtrPeriod))
return(0);
ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ?
(ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) :
(ENUM_APPLIED_PRICE)InpSourcePrice;
g_calculator.Calculate(rates_total, prev_calculated, open, high, low, close, price_type,
BufferMiddle, BufferUpper, BufferLower);
return(rates_total);
}
//+------------------------------------------------------------------+