refactor: Upgraded with 3-digit Gamma precision and strict chronological state safety

This commit is contained in:
Toh4iem9
2026-06-30 14:34:45 +02:00
parent 255daa3e3d
commit 99f135fd6b
@@ -3,7 +3,7 @@
//| Copyright 2026, xxxxxxxx| //| Copyright 2026, xxxxxxxx|
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
#property copyright "Copyright 2026, xxxxxxxx" #property copyright "Copyright 2026, xxxxxxxx"
#property version "1.00" // Fully volume-aligned Fast Stochastic applied on Laguerre RSI #property version "1.10" // Upgraded with 3-digit Gamma precision and strict chronological state safety
#property description "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 description "Combines the smoothness of Laguerre RSI with Fast Stochastic cycle detection."
@@ -37,12 +37,12 @@
//--- Input Parameters //--- Input Parameters
input group "Laguerre RSI Settings" input group "Laguerre RSI Settings"
input double InpGamma = 0.5; input double InpGamma = 0.5; // Gamma (0.0 - 1.0, e.g. 0.236, 0.382)
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; // Price Source
input group "Stochastic Settings" input group "Stochastic Settings"
input int InpKPeriod = 14; // Lookback for High/Low input int InpKPeriod = 14; // Lookback for High/Low
input int InpDPeriod = 3; // Signal Line Period input int InpDPeriod = 3; // Signal Line Period
input ENUM_MA_TYPE InpDMAType = SMA; // Method for Signal %D input ENUM_MA_TYPE InpDMAType = SMA; // Method for Signal %D
//--- Buffers //--- Buffers
@@ -76,9 +76,9 @@ int OnInit()
return(INIT_FAILED); return(INIT_FAILED);
} }
//--- Shortname //--- Shortname - Updated format string to %.3f to support exact Fibonacci decimals
string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : ""; string type = (InpSourcePrice <= PRICE_HA_CLOSE) ? " HA" : "";
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("StochFast on LagRSI%s(%.2f, %d, %d)", type, InpGamma, InpKPeriod, InpDPeriod)); IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("StochFast on LagRSI%s(%.3f, %d, %d)", type, InpGamma, InpKPeriod, InpDPeriod));
//--- Visuals //--- Visuals
int draw_begin = InpKPeriod + InpDPeriod; int draw_begin = InpKPeriod + InpDPeriod;
@@ -115,6 +115,16 @@ int OnCalculate(const int rates_total,
if(rates_total < InpKPeriod) if(rates_total < InpKPeriod)
return(0); return(0);
if(CheckPointer(g_calculator) == POINTER_INVALID)
return(0);
//--- Force strict chronological indexing for state-safety on input price arrays
ArraySetAsSeries(time, false);
ArraySetAsSeries(open, false);
ArraySetAsSeries(high, false);
ArraySetAsSeries(low, false);
ArraySetAsSeries(close, false);
ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ? ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ?
(ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) :
(ENUM_APPLIED_PRICE)InpSourcePrice; (ENUM_APPLIED_PRICE)InpSourcePrice;
@@ -135,4 +145,3 @@ int OnCalculate(const int rates_total,
return(rates_total); return(rates_total);
} }
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+
//+------------------------------------------------------------------+