mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-07-27 20:47:44 +00:00
new files added
This commit is contained in:
+138
@@ -0,0 +1,138 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| StochasticFast_on_LaguerreRSI_Pro.mq5 |
|
||||
//| Copyright 2026, xxxxxxxx|
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2026, xxxxxxxx"
|
||||
#property version "1.00" // Fully volume-aligned Fast Stochastic applied on Laguerre RSI
|
||||
#property description "Fast Stochastic applied on Laguerre RSI."
|
||||
#property description "Combines the smoothness of Laguerre RSI with Fast Stochastic cycle detection."
|
||||
|
||||
#property indicator_separate_window
|
||||
#property indicator_buffers 2
|
||||
#property indicator_plots 2
|
||||
#property indicator_level1 10.0
|
||||
#property indicator_level2 20.0
|
||||
#property indicator_level3 50.0
|
||||
#property indicator_level4 80.0
|
||||
#property indicator_level5 90.0
|
||||
#property indicator_levelstyle STYLE_DOT
|
||||
#property indicator_minimum 0.0
|
||||
#property indicator_maximum 100.0
|
||||
|
||||
//--- Plot 1: Fast %K
|
||||
#property indicator_label1 "Fast %K"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrSteelBlue
|
||||
#property indicator_style1 STYLE_SOLID
|
||||
#property indicator_width1 1
|
||||
|
||||
//--- Plot 2: Signal %D
|
||||
#property indicator_label2 "Signal %D"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_color2 clrLightCoral
|
||||
#property indicator_style2 STYLE_SOLID
|
||||
#property indicator_width2 1
|
||||
|
||||
#include <MyIncludes\StochasticFast_on_LaguerreRSI_Calculator.mqh>
|
||||
|
||||
//--- Input Parameters
|
||||
input group "Laguerre RSI Settings"
|
||||
input double InpGamma = 0.5;
|
||||
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
|
||||
|
||||
input group "Stochastic Settings"
|
||||
input int InpKPeriod = 14; // Lookback for High/Low
|
||||
input int InpDPeriod = 3; // Signal Line Period
|
||||
input ENUM_MA_TYPE InpDMAType = SMA; // Method for Signal %D
|
||||
|
||||
//--- Buffers
|
||||
double BufferK[];
|
||||
double BufferD[];
|
||||
|
||||
//--- Global Object
|
||||
CStochasticFastOnLaguerreRSICalculator *g_calculator;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| OnInit |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
SetIndexBuffer(0, BufferK, INDICATOR_DATA);
|
||||
SetIndexBuffer(1, BufferD, INDICATOR_DATA);
|
||||
ArraySetAsSeries(BufferK, false);
|
||||
ArraySetAsSeries(BufferD, false);
|
||||
|
||||
//--- Factory Logic
|
||||
if(InpSourcePrice <= PRICE_HA_CLOSE)
|
||||
g_calculator = new CStochasticFastOnLaguerreRSICalculator_HA();
|
||||
else
|
||||
g_calculator = new CStochasticFastOnLaguerreRSICalculator();
|
||||
|
||||
//--- Initialize
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID ||
|
||||
!g_calculator.Init(InpGamma, InpKPeriod, InpDPeriod, InpDMAType))
|
||||
{
|
||||
Print("Failed to initialize Calculator.");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
|
||||
//--- Shortname
|
||||
string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : "";
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("StochFast on LagRSI%s(%.2f, %d, %d)", type, InpGamma, InpKPeriod, InpDPeriod));
|
||||
|
||||
//--- Visuals
|
||||
int draw_begin = InpKPeriod + InpDPeriod;
|
||||
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin);
|
||||
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, draw_begin);
|
||||
IndicatorSetInteger(INDICATOR_DIGITS, 2);
|
||||
|
||||
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 < InpKPeriod)
|
||||
return(0);
|
||||
|
||||
ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ?
|
||||
(ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) :
|
||||
(ENUM_APPLIED_PRICE)InpSourcePrice;
|
||||
|
||||
//--- Determine best volume array (Use Real Volume if available, otherwise fallback to Tick Volume)
|
||||
long volume_limit = (long)SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_LIMIT);
|
||||
|
||||
//--- Delegate calculations dynamically to support volume-weighted types (VWMA) on Signal %D
|
||||
if(volume_limit > 0)
|
||||
{
|
||||
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, volume, BufferK, BufferD);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, tick_volume, BufferK, BufferD);
|
||||
}
|
||||
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user