mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-25 18:28:04 +00:00
new files added
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
|||||||
|
//+------------------------------------------------------------------+
|
||||||
|
//| StochasticSlow_on_LaguerreRSI_Pro.mq5 |
|
||||||
|
//| Copyright 2026, xxxxxxxx|
|
||||||
|
//+------------------------------------------------------------------+
|
||||||
|
#property copyright "Copyright 2026, xxxxxxxx"
|
||||||
|
#property version "1.10" // Renamed to full title and added volume support for VWMA slowing/signals
|
||||||
|
#property description "Slow Stochastic applied on Laguerre RSI."
|
||||||
|
#property description "Combines the smoothness of Laguerre RSI with 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: %K line (Slow)
|
||||||
|
#property indicator_label1 "Slow %K"
|
||||||
|
#property indicator_type1 DRAW_LINE
|
||||||
|
#property indicator_color1 clrDodgerBlue
|
||||||
|
#property indicator_style1 STYLE_SOLID
|
||||||
|
#property indicator_width1 1
|
||||||
|
|
||||||
|
//--- Plot 2: %D line (Signal)
|
||||||
|
#property indicator_label2 "Signal %D"
|
||||||
|
#property indicator_type2 DRAW_LINE
|
||||||
|
#property indicator_color2 clrCoral
|
||||||
|
#property indicator_style2 STYLE_SOLID
|
||||||
|
#property indicator_width2 1
|
||||||
|
|
||||||
|
#include <MyIncludes\StochasticSlow_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 InpSlowingPeriod = 3; // Smoothing for %K (Slow)
|
||||||
|
input int InpDPeriod = 3; // Signal Line Period
|
||||||
|
|
||||||
|
input group "MA Types"
|
||||||
|
input ENUM_MA_TYPE InpSlowingMAType = SMA;
|
||||||
|
input ENUM_MA_TYPE InpDMAType = SMA;
|
||||||
|
|
||||||
|
//--- Buffers
|
||||||
|
double BufferK[];
|
||||||
|
double BufferD[];
|
||||||
|
|
||||||
|
//--- Global Object
|
||||||
|
CStochasticSlowOnLaguerreRSICalculator *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 CStochasticSlowOnLaguerreRSICalculator_HA();
|
||||||
|
else
|
||||||
|
g_calculator = new CStochasticSlowOnLaguerreRSICalculator();
|
||||||
|
|
||||||
|
//--- Initialize
|
||||||
|
if(CheckPointer(g_calculator) == POINTER_INVALID ||
|
||||||
|
!g_calculator.Init(InpGamma, InpKPeriod, InpSlowingPeriod, InpSlowingMAType, InpDPeriod, InpDMAType))
|
||||||
|
{
|
||||||
|
Print("Failed to initialize Calculator.");
|
||||||
|
return(INIT_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- Shortname
|
||||||
|
string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : "";
|
||||||
|
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("StochSlow on LagRSI%s(%.2f, %d, %d)", type, InpGamma, InpKPeriod, InpSlowingPeriod));
|
||||||
|
|
||||||
|
//--- Visuals
|
||||||
|
int draw_begin = InpKPeriod + InpSlowingPeriod + 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 Slowing/Signal
|
||||||
|
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