Update
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, MetaQuotes Ltd."
|
||||
#property link "https://www.mql5.com"
|
||||
#property version "1.07"
|
||||
#property version "1.17"
|
||||
#property strict
|
||||
|
||||
#include <Trade\Trade.mqh>
|
||||
@@ -20,6 +20,8 @@ double g_RC_LotSize;
|
||||
double g_RM_LotSize;
|
||||
double g_DB_LotSize;
|
||||
double g_DynMultLast = 1.0;
|
||||
double g_equityPeakHighWater = 0.0; // for drawdown lot cap (updated each tick via Refresh)
|
||||
datetime g_ddLotCapAnchorTime = 0; // tester/attach start — grace period before DD cap may apply
|
||||
|
||||
// Include strategy implementations early so structs are available
|
||||
#include "Strategies/DarvasBoxStrategy.mqh"
|
||||
@@ -28,6 +30,8 @@ double g_DynMultLast = 1.0;
|
||||
#include "Strategies/RSIMidPointHijackStrategy.mqh"
|
||||
#include "Strategies/RSIScalpingStrategy.mqh"
|
||||
#include "Strategies/RSIReversalAsianStrategy.mqh"
|
||||
#include "Strategies/RSISecretSauceStrategy.mqh"
|
||||
#include "Strategies/SuperEMAStrategy.mqh"
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Strategy Enable/Disable Switches |
|
||||
@@ -42,8 +46,41 @@ input bool EnableRSIScalpingBTCUSD = true;
|
||||
input bool EnableRSIScalpingNVDA = true;
|
||||
input bool EnableRSIScalpingTSLA = true;
|
||||
input bool EnableRSIScalpingXAUUSD = true;
|
||||
input bool EnableRSIReversalAsianEURUSD = true;
|
||||
input bool EnableRSIReversalAsianAUDUSD = true;
|
||||
input bool EnableRSIReversalEURUSD = true; // RSI Reversal Asian session (EURUSD)
|
||||
input bool EnableRSIReversalAUDUSD = true; // RSI Reversal Asian session (AUDUSD)
|
||||
input bool EnableRSISecretSauceXAUUSD = true;
|
||||
input bool EnableSuperEMA = true;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| SuperEMA — EMA + CCI + MACD (XAUUSD default) |
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== SuperEMA (EMA + CCI + MACD) ==="
|
||||
input string SE_Symbol = "XAUUSD";
|
||||
input ENUM_TIMEFRAMES SE_Timeframe = PERIOD_M15;
|
||||
input double SE_LotSize = 0.01;
|
||||
input int SE_SlippagePoints = 55;
|
||||
input int SE_MagicNumber = 940001;
|
||||
input int SE_EmaFast = 40;
|
||||
input int SE_EmaMid = 180;
|
||||
input int SE_EmaSlow = 125;
|
||||
input int SE_EmaTrendBars = 3;
|
||||
input int SE_CciPeriod = 17;
|
||||
input double SE_CciOverbought = 80.0;
|
||||
input double SE_CciOversold = -140.0;
|
||||
input int SE_PullbackCciLookback = 20;
|
||||
input int SE_MacdFast = 14;
|
||||
input int SE_MacdSlow = 38;
|
||||
input int SE_MacdSignal = 9;
|
||||
input ENUM_SE_ENTRY_STYLE SE_EntryStyle = SE_ENTRY_LAMBERT;
|
||||
input bool SE_OneTradeOnly = true;
|
||||
input bool SE_UseStructuralSL = false;
|
||||
input double SE_SlBufferPoints = 110;
|
||||
input bool SE_ExitOnTrendFlip = false;
|
||||
input bool SE_ExitOnMacdFlip = false;
|
||||
input bool SE_ExitOnCciZeroCross = true;
|
||||
input int SE_MaxHoldingBars = 168;
|
||||
input bool SE_ExitBelowMidEma = false;
|
||||
input bool SE_DebugLogs = false;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Dynamic lot sizing — scale base lots vs reference deposit |
|
||||
@@ -58,6 +95,21 @@ input double InpDynamicMaxMult = 0.0; // <=0 动态倍数不封
|
||||
input bool InpDynamicUseEquity = true; // true=ACCOUNT_EQUITY, false=ACCOUNT_BALANCE
|
||||
input double InpDynamicStockLotCap = 0.0; // Extra cap for stock CFDs (0 = none)
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Lot cap: optional account-wide DD from peak, and/or per-strategy |
|
||||
//| (last *closed* calendar month losing for that magic). |
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== Drawdown / loser lot cap ==="
|
||||
input bool InpDdLotCapEnable = true; // master: allow clamping when a mode below triggers
|
||||
input bool InpDdLotCapGlobalEquityEnable = false; // cap *all* robots when equity DD from peak >= X% (after grace)
|
||||
input bool InpDdLotCapPerStratEnable = true; // cap only robots whose last closed month was red (by magic)
|
||||
input bool InpDdLotCapUseEquity = true; // true=ACCOUNT_EQUITY, false=BALANCE (global mode + peak tracking)
|
||||
input double InpDdLotCapFromPeakPercent = 7.0; // global: trigger if (peak-equity)/peak*100 >= this
|
||||
input double InpDdLotCapMaxLots = 0.01; // max volume per order while that mode is triggered
|
||||
input int InpDdLotCapGraceDays = 90; // global only: wait N days from attach before DD cap can apply (0=immediate)
|
||||
input double InpDdLotCapStratLossThreshold = 0.0; // per-strat: month P/L < -this counts as losing (0 = any loss)
|
||||
input int InpDdLotCapUpdateSeconds = 3600; // min 60; refresh last-month P/L when adaptive monthly is off
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Strategy 1: DarvasBoxXAUUSD |
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -267,12 +319,34 @@ input int RS_XAUUSD_MagicNumber = 129102315;
|
||||
input int RS_XAUUSD_Slippage = 3;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Strategy 11-12: RSI Reversal Asian Strategies |
|
||||
//| Each RSI Reversal Asian strategy trades on its own symbol: |
|
||||
//| - EURUSD: Euro/USD |
|
||||
//| - AUDUSD: Australian Dollar/USD |
|
||||
//| Strategy: RSI Secret Sauce XAUUSD (leave zone → re-entry peak/bottom) |
|
||||
//| Defaults match secret_sauce.set except symbol stays XAUUSD here. |
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== RSI Reversal Asian EURUSD ==="
|
||||
input group "=== RSI Secret Sauce XAUUSD ==="
|
||||
input string RSS_XAUUSD_Symbol = "XAUUSD"; // not BTCUSD — gold chart / portfolio default
|
||||
input double RSS_XAUUSD_LotSize = 0.1;
|
||||
input int RSS_XAUUSD_MagicNumber = 789012;
|
||||
input int RSS_XAUUSD_Slippage = 10;
|
||||
input ENUM_TIMEFRAMES RSS_XAUUSD_Timeframe = PERIOD_M30;
|
||||
input int RSS_XAUUSD_RSIPeriod = 16;
|
||||
input double RSS_XAUUSD_RSIOverbought = 72.5;
|
||||
input double RSS_XAUUSD_RSIOversold = 32.5;
|
||||
input int RSS_XAUUSD_RSILookback = 60;
|
||||
input int RSS_XAUUSD_PeakBars = 2;
|
||||
input bool RSS_XAUUSD_RequireDivergence = false;
|
||||
input double RSS_XAUUSD_StopLossATR = 2.75;
|
||||
input double RSS_XAUUSD_TakeProfitATR = 5.0;
|
||||
input int RSS_XAUUSD_ATRPeriod = 14;
|
||||
input bool RSS_XAUUSD_UseSwingStopLoss = false;
|
||||
input int RSS_XAUUSD_SwingLookback = 30;
|
||||
input int RSS_XAUUSD_MaxPositions = 1;
|
||||
input int RSS_XAUUSD_MinBarsBetweenTrades = 7;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Strategy 11-12: RSI Reversal (Asian session) EURUSD & AUDUSD |
|
||||
//| Same logic as RSIReversalAsianEURUSD / RSIReversalAsianAUDUSD EAs |
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== RSI Reversal EURUSD (Asian session) ==="
|
||||
input string RRA_EURUSD_Symbol = "EURUSD";
|
||||
input int RRA_EURUSD_RSIPeriod = 28;
|
||||
input double RRA_EURUSD_OverboughtLevel = 60;
|
||||
@@ -291,7 +365,7 @@ input ENUM_TIMEFRAMES RRA_EURUSD_TimeFrame = PERIOD_M15;
|
||||
input int RRA_EURUSD_MagicNumber = 30001;
|
||||
input int RRA_EURUSD_Slippage = 3;
|
||||
|
||||
input group "=== RSI Reversal Asian AUDUSD ==="
|
||||
input group "=== RSI Reversal AUDUSD (Asian session) ==="
|
||||
input string RRA_AUDUSD_Symbol = "AUDUSD";
|
||||
input int RRA_AUDUSD_RSIPeriod = 28;
|
||||
input double RRA_AUDUSD_OverboughtLevel = 68;
|
||||
@@ -310,6 +384,46 @@ input ENUM_TIMEFRAMES RRA_AUDUSD_TimeFrame = PERIOD_M15;
|
||||
input int RRA_AUDUSD_MagicNumber = 30002;
|
||||
input int RRA_AUDUSD_Slippage = 3;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Chart panel: closed-deal P&L by strategy (magic) + optional open |
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== Chart profit panel (by magic) ==="
|
||||
input bool UnitedPanel_Enable = false; // OBJ_LABEL + background on chart
|
||||
input int UnitedPanel_Seconds = 60; // refresh interval (min 5); history scan once per tick
|
||||
input int UnitedPanel_Corner = 0; // ENUM_BASE_CORNER e.g. 0=left upper
|
||||
input int UnitedPanel_X = 8;
|
||||
input int UnitedPanel_Y = 24;
|
||||
input int UnitedPanel_Width = 360;
|
||||
input int UnitedPanel_FontSize = 9;
|
||||
input int UnitedPanel_XMargin = 6;
|
||||
input int UnitedPanel_YMargin = 6;
|
||||
input bool UnitedPanel_ShowFloating = false; // open P/L+swap per magic
|
||||
|
||||
enum ENUM_ADAPTIVE_STREAK_UNIT
|
||||
{
|
||||
ADAPTIVE_STREAK_BY_MONTH = 0, // consecutive closed calendar months
|
||||
ADAPTIVE_STREAK_BY_DAY = 1 // consecutive closed calendar days (server time)
|
||||
};
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Pause strategies after consecutive losing periods (month or day)|
|
||||
//+------------------------------------------------------------------+
|
||||
input group "=== Adaptive regime (per robot / magic) ==="
|
||||
input bool InpAdaptiveEnable = true; // If false, every other InpAdaptive* input is ignored (no streak / canary / pause). Set true to optimize or use adaptive regime.
|
||||
input ENUM_ADAPTIVE_STREAK_UNIT InpAdaptiveStreakUnit = ADAPTIVE_STREAK_BY_DAY;
|
||||
input int InpAdaptiveRedStreak = 5; // consecutive red months OR red days (see streak unit)
|
||||
input double InpAdaptiveRedThreshold = 0.0; // period P/L < -threshold counts red (0 = any loss)
|
||||
input int InpAdaptiveLookbackMonths = 14; // if unit=MONTH: history depth in months (>= streak+1)
|
||||
input int InpAdaptiveLookbackDays = 36; // if unit=DAY: closed days of history (>= streak+1)
|
||||
input int InpAdaptiveUpdateSeconds = 3600; // min 60; how often to recompute
|
||||
input double InpAdaptiveCanaryLotMult = 0.07; // probation: scale lots (0 = hard pause on streak, no canary)
|
||||
input int InpAdaptiveHardRetryMonths = 3; // if unit=MONTH: 0=no auto retry; else retry after N months
|
||||
input int InpAdaptiveHardRetryDays = 32; // if unit=DAY: 0=no auto retry; else retry after N days
|
||||
input int InpAdaptivePostCanaryCooldownDays = 37; // after successful canary, block re-arming another canary (days)
|
||||
|
||||
#include "UnitedProfitPanel.mqh"
|
||||
#include "AdaptiveMonthlyRegime.mqh"
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Global Variables - DarvasBox |
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -412,6 +526,8 @@ RSIScalpingData rsXAUUSDData;
|
||||
//+------------------------------------------------------------------+
|
||||
RSIReversalAsianData rraEURUSDData;
|
||||
RSIReversalAsianData rraAUDUSDData;
|
||||
RSISecretSauceData rsSecretSauceXAUUSDData;
|
||||
SuperEMAData seData;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Dynamic lot helpers |
|
||||
@@ -444,6 +560,53 @@ double NormalizeVolumeForSymbol(const string symbol, double lots)
|
||||
return lots;
|
||||
}
|
||||
|
||||
void UpdateEquityPeakForDdCap()
|
||||
{
|
||||
if(!InpDdLotCapEnable || !InpDdLotCapGlobalEquityEnable)
|
||||
return;
|
||||
const double cur = InpDdLotCapUseEquity ? AccountInfoDouble(ACCOUNT_EQUITY) : AccountInfoDouble(ACCOUNT_BALANCE);
|
||||
if(cur > g_equityPeakHighWater)
|
||||
g_equityPeakHighWater = cur;
|
||||
}
|
||||
|
||||
// After dynamic sizing: global equity DD and/or per-strategy last-month loser -> clamp to InpDdLotCapMaxLots.
|
||||
double LotsAfterDrawdownCap(const string symbol, const double lotsRaw, const int ddStratId = -1)
|
||||
{
|
||||
double lots = NormalizeVolumeForSymbol(symbol, lotsRaw);
|
||||
if(!InpDdLotCapEnable)
|
||||
return lots;
|
||||
|
||||
bool needCap = false;
|
||||
|
||||
if(InpDdLotCapGlobalEquityEnable)
|
||||
{
|
||||
bool globalCheck = true;
|
||||
if(InpDdLotCapGraceDays > 0 && g_ddLotCapAnchorTime > 0)
|
||||
{
|
||||
const long needSec = (long)InpDdLotCapGraceDays * 86400L;
|
||||
if((long)(TimeCurrent() - g_ddLotCapAnchorTime) < needSec)
|
||||
globalCheck = false;
|
||||
}
|
||||
if(globalCheck && g_equityPeakHighWater > 0.0)
|
||||
{
|
||||
const double cur = InpDdLotCapUseEquity ? AccountInfoDouble(ACCOUNT_EQUITY) : AccountInfoDouble(ACCOUNT_BALANCE);
|
||||
if(cur < g_equityPeakHighWater)
|
||||
{
|
||||
const double ddPct = 100.0 * (g_equityPeakHighWater - cur) / g_equityPeakHighWater;
|
||||
if(ddPct >= InpDdLotCapFromPeakPercent)
|
||||
needCap = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(InpDdLotCapPerStratEnable && ddStratId >= 0 && UnitedAdaptive_StratLastMonthIsLosing(ddStratId))
|
||||
needCap = true;
|
||||
|
||||
if(!needCap)
|
||||
return lots;
|
||||
return NormalizeVolumeForSymbol(symbol, MathMin(lots, InpDdLotCapMaxLots));
|
||||
}
|
||||
|
||||
double GetDynamicMultiplier()
|
||||
{
|
||||
if(!InpDynamicLotEnable)
|
||||
@@ -460,31 +623,33 @@ double GetDynamicMultiplier()
|
||||
}
|
||||
|
||||
// baseLot = size at reference deposit; optionalCap 0 = no extra ceiling (broker min/max still apply)
|
||||
double DynamicLotForSymbol(const string symbol, const double baseLot, const double optionalCap = 0.0)
|
||||
double DynamicLotForSymbol(const string symbol, const double baseLot, const double optionalCap = 0.0, const int ddStratId = -1)
|
||||
{
|
||||
double mult = GetDynamicMultiplier();
|
||||
g_DynMultLast = mult;
|
||||
double v = baseLot * mult;
|
||||
if(optionalCap > 0.0 && v > optionalCap)
|
||||
v = optionalCap;
|
||||
return NormalizeVolumeForSymbol(symbol, v);
|
||||
return LotsAfterDrawdownCap(symbol, v, ddStratId);
|
||||
}
|
||||
|
||||
void RefreshDynamicStrategyLots()
|
||||
{
|
||||
UpdateEquityPeakForDdCap();
|
||||
|
||||
if(!InpDynamicLotEnable)
|
||||
{
|
||||
g_ES_LotSize = NormalizeVolumeForSymbol(ES_Symbol, ES_LotGröße);
|
||||
g_RC_LotSize = NormalizeVolumeForSymbol(RC_Symbol, RC_lotSize);
|
||||
g_RM_LotSize = NormalizeVolumeForSymbol(RM_Symbol, RM_InpLotSize);
|
||||
g_DB_LotSize = NormalizeVolumeForSymbol(DB_Symbol, DB_BaseLotSize);
|
||||
g_ES_LotSize = LotsAfterDrawdownCap(ES_Symbol, ES_LotGröße * UnitedAdaptive_GetLotMult(UNITED_AD_ES), UNITED_AD_ES);
|
||||
g_RC_LotSize = LotsAfterDrawdownCap(RC_Symbol, RC_lotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RC), UNITED_AD_RC);
|
||||
g_RM_LotSize = LotsAfterDrawdownCap(RM_Symbol, RM_InpLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RM), UNITED_AD_RM);
|
||||
g_DB_LotSize = LotsAfterDrawdownCap(DB_Symbol, DB_BaseLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_DARVAS), UNITED_AD_DARVAS);
|
||||
g_DynMultLast = 1.0;
|
||||
return;
|
||||
}
|
||||
g_ES_LotSize = DynamicLotForSymbol(ES_Symbol, ES_LotGröße);
|
||||
g_RC_LotSize = DynamicLotForSymbol(RC_Symbol, RC_lotSize);
|
||||
g_RM_LotSize = DynamicLotForSymbol(RM_Symbol, RM_InpLotSize);
|
||||
g_DB_LotSize = DynamicLotForSymbol(DB_Symbol, DB_BaseLotSize);
|
||||
g_ES_LotSize = DynamicLotForSymbol(ES_Symbol, ES_LotGröße * UnitedAdaptive_GetLotMult(UNITED_AD_ES), 0.0, UNITED_AD_ES);
|
||||
g_RC_LotSize = DynamicLotForSymbol(RC_Symbol, RC_lotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RC), 0.0, UNITED_AD_RC);
|
||||
g_RM_LotSize = DynamicLotForSymbol(RM_Symbol, RM_InpLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RM), 0.0, UNITED_AD_RM);
|
||||
g_DB_LotSize = DynamicLotForSymbol(DB_Symbol, DB_BaseLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_DARVAS), 0.0, UNITED_AD_DARVAS);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -493,7 +658,16 @@ void RefreshDynamicStrategyLots()
|
||||
int OnInit()
|
||||
{
|
||||
int initResult = INIT_SUCCEEDED;
|
||||
|
||||
|
||||
UnitedAdaptive_Init();
|
||||
|
||||
g_equityPeakHighWater = InpDdLotCapUseEquity ? AccountInfoDouble(ACCOUNT_EQUITY) : AccountInfoDouble(ACCOUNT_BALANCE);
|
||||
if(g_equityPeakHighWater <= 0.0)
|
||||
g_equityPeakHighWater = MathMax(InpDynamicRefDeposit, 1.0);
|
||||
g_ddLotCapAnchorTime = TimeCurrent();
|
||||
|
||||
UnitedAdaptive_UpdateIfDue();
|
||||
|
||||
RefreshDynamicStrategyLots();
|
||||
|
||||
// Initialize strategies - log warnings but don't fail entire EA if symbol unavailable
|
||||
@@ -530,21 +704,39 @@ int OnInit()
|
||||
InitRSIScalping(rsXAUUSDData, RS_XAUUSD_Symbol, RS_XAUUSD_TimeFrame, RS_XAUUSD_RSI_Period, RS_XAUUSD_RSI_Applied_Price, RS_XAUUSD_MagicNumber, RS_XAUUSD_Slippage);
|
||||
|
||||
// Initialize RSI Reversal Asian strategies
|
||||
if(EnableRSIReversalAsianEURUSD)
|
||||
if(EnableRSIReversalEURUSD)
|
||||
if(!InitRSIReversalAsian(rraEURUSDData, RRA_EURUSD_Symbol, RRA_EURUSD_RSIPeriod, RRA_EURUSD_OverboughtLevel, RRA_EURUSD_OversoldLevel,
|
||||
RRA_EURUSD_TakeProfitPips, RRA_EURUSD_StopLossPips, RRA_EURUSD_MaxLotSize,
|
||||
RRA_EURUSD_MaxSpread, RRA_EURUSD_MaxDuration, RRA_EURUSD_UseStopLoss,
|
||||
RRA_EURUSD_UseTakeProfit, RRA_EURUSD_UseRSIExit, RRA_EURUSD_RSIExitLevel,
|
||||
RRA_EURUSD_CloseOutsideSession, RRA_EURUSD_TimeFrame, RRA_EURUSD_MagicNumber, RRA_EURUSD_Slippage))
|
||||
Print("Warning: RSIReversalAsianEURUSD strategy failed to initialize for symbol '", RRA_EURUSD_Symbol, "'");
|
||||
Print("Warning: RSIReversalEURUSD strategy failed to initialize for symbol '", RRA_EURUSD_Symbol, "'");
|
||||
|
||||
if(EnableRSIReversalAsianAUDUSD)
|
||||
if(EnableRSIReversalAUDUSD)
|
||||
if(!InitRSIReversalAsian(rraAUDUSDData, RRA_AUDUSD_Symbol, RRA_AUDUSD_RSIPeriod, RRA_AUDUSD_OverboughtLevel, RRA_AUDUSD_OversoldLevel,
|
||||
RRA_AUDUSD_TakeProfitPips, RRA_AUDUSD_StopLossPips, RRA_AUDUSD_MaxLotSize,
|
||||
RRA_AUDUSD_MaxSpread, RRA_AUDUSD_MaxDuration, RRA_AUDUSD_UseStopLoss,
|
||||
RRA_AUDUSD_UseTakeProfit, RRA_AUDUSD_UseRSIExit, RRA_AUDUSD_RSIExitLevel,
|
||||
RRA_AUDUSD_CloseOutsideSession, RRA_AUDUSD_TimeFrame, RRA_AUDUSD_MagicNumber, RRA_AUDUSD_Slippage))
|
||||
Print("Warning: RSIReversalAsianAUDUSD strategy failed to initialize for symbol '", RRA_AUDUSD_Symbol, "'");
|
||||
Print("Warning: RSIReversalAUDUSD strategy failed to initialize for symbol '", RRA_AUDUSD_Symbol, "'");
|
||||
|
||||
if(EnableRSISecretSauceXAUUSD)
|
||||
if(!InitRSISecretSauce(rsSecretSauceXAUUSDData, RSS_XAUUSD_Symbol, RSS_XAUUSD_Timeframe, RSS_XAUUSD_RSIPeriod,
|
||||
RSS_XAUUSD_RSIOverbought, RSS_XAUUSD_RSIOversold, RSS_XAUUSD_RSILookback, RSS_XAUUSD_PeakBars,
|
||||
RSS_XAUUSD_RequireDivergence, RSS_XAUUSD_StopLossATR, RSS_XAUUSD_TakeProfitATR, RSS_XAUUSD_ATRPeriod,
|
||||
RSS_XAUUSD_UseSwingStopLoss, RSS_XAUUSD_SwingLookback, RSS_XAUUSD_MaxPositions,
|
||||
RSS_XAUUSD_MinBarsBetweenTrades, RSS_XAUUSD_MagicNumber, RSS_XAUUSD_Slippage))
|
||||
Print("Warning: RSISecretSauceXAUUSD failed to initialize for symbol '", RSS_XAUUSD_Symbol, "'");
|
||||
|
||||
if(EnableSuperEMA)
|
||||
if(!InitSuperEMA(seData, SE_Symbol, SE_Timeframe, SE_SlippagePoints, SE_MagicNumber,
|
||||
SE_EmaFast, SE_EmaMid, SE_EmaSlow, SE_EmaTrendBars,
|
||||
SE_CciPeriod, SE_CciOverbought, SE_CciOversold, SE_PullbackCciLookback,
|
||||
SE_MacdFast, SE_MacdSlow, SE_MacdSignal,
|
||||
SE_EntryStyle, SE_OneTradeOnly, SE_UseStructuralSL, SE_SlBufferPoints,
|
||||
SE_ExitOnTrendFlip, SE_ExitOnMacdFlip, SE_ExitOnCciZeroCross,
|
||||
SE_MaxHoldingBars, SE_ExitBelowMidEma, SE_DebugLogs))
|
||||
Print("Warning: SuperEMA failed to initialize for symbol '", SE_Symbol, "'");
|
||||
|
||||
string acctCur = AccountInfoString(ACCOUNT_CURRENCY);
|
||||
double eq0 = AccountInfoDouble(ACCOUNT_EQUITY);
|
||||
@@ -554,7 +746,7 @@ int OnInit()
|
||||
capInit = refvInit;
|
||||
double ratioInit = capInit / refvInit;
|
||||
double rawPowInit = MathPow(ratioInit, InpDynamicExponent);
|
||||
Print("United EA v1.07 ", acctCur, " equity=", DoubleToString(eq0, 2), " equity/ref=", DoubleToString(ratioInit, 6),
|
||||
Print("United EA v1.17 ", acctCur, " equity=", DoubleToString(eq0, 2), " equity/ref=", DoubleToString(ratioInit, 6),
|
||||
" raw^exp=", DoubleToString(rawPowInit, 6), " multOut=", DoubleToString(g_DynMultLast, 6),
|
||||
" minM=", InpDynamicMinMult, " maxM=", InpDynamicMaxMult, " ref=", InpDynamicRefDeposit, " exp=", InpDynamicExponent,
|
||||
" lots ES=", g_ES_LotSize, " RC=", g_RC_LotSize, " RM=", g_RM_LotSize, " DB=", g_DB_LotSize);
|
||||
@@ -568,9 +760,29 @@ int OnInit()
|
||||
(EnableRSIScalpingNVDA ? "RSIScalpingNVDA " : ""),
|
||||
(EnableRSIScalpingTSLA ? "RSIScalpingTSLA " : ""),
|
||||
(EnableRSIScalpingXAUUSD ? "RSIScalpingXAUUSD " : ""),
|
||||
(EnableRSIReversalAsianEURUSD ? "RSIReversalAsianEURUSD " : ""),
|
||||
(EnableRSIReversalAsianAUDUSD ? "RSIReversalAsianAUDUSD " : ""));
|
||||
|
||||
(EnableRSIReversalEURUSD ? "RSIReversalEURUSD " : ""),
|
||||
(EnableRSIReversalAUDUSD ? "RSIReversalAUDUSD " : ""),
|
||||
(EnableRSISecretSauceXAUUSD ? "RSISecretSauceXAUUSD " : ""),
|
||||
(EnableSuperEMA ? "SuperEMA " : ""));
|
||||
|
||||
EventSetTimer(0);
|
||||
int timerSec = 0;
|
||||
if(UnitedPanel_Enable)
|
||||
timerSec = MathMax(5, UnitedPanel_Seconds);
|
||||
if(InpAdaptiveEnable)
|
||||
{
|
||||
const int adSec = MathMax(60, InpAdaptiveUpdateSeconds);
|
||||
timerSec = (timerSec == 0) ? adSec : MathMin(timerSec, adSec);
|
||||
}
|
||||
if(InpDdLotCapEnable && InpDdLotCapPerStratEnable && !InpAdaptiveEnable)
|
||||
{
|
||||
const int ddSec = MathMax(60, InpDdLotCapUpdateSeconds);
|
||||
timerSec = (timerSec == 0) ? ddSec : MathMin(timerSec, ddSec);
|
||||
}
|
||||
if(timerSec > 0)
|
||||
EventSetTimer(timerSec);
|
||||
UnitedProfitPanelInit();
|
||||
|
||||
return initResult;
|
||||
}
|
||||
|
||||
@@ -579,6 +791,9 @@ int OnInit()
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
EventSetTimer(0);
|
||||
UnitedProfitPanelDeinit();
|
||||
|
||||
if(EnableDarvasBox)
|
||||
DeinitDarvasBox();
|
||||
|
||||
@@ -606,11 +821,17 @@ void OnDeinit(const int reason)
|
||||
if(EnableRSIScalpingXAUUSD)
|
||||
DeinitRSIScalping(rsXAUUSDData);
|
||||
|
||||
if(EnableRSIReversalAsianEURUSD)
|
||||
if(EnableRSIReversalEURUSD)
|
||||
DeinitRSIReversalAsian(rraEURUSDData);
|
||||
|
||||
if(EnableRSIReversalAsianAUDUSD)
|
||||
if(EnableRSIReversalAUDUSD)
|
||||
DeinitRSIReversalAsian(rraAUDUSDData);
|
||||
|
||||
if(EnableRSISecretSauceXAUUSD)
|
||||
DeinitRSISecretSauce(rsSecretSauceXAUUSDData);
|
||||
|
||||
if(EnableSuperEMA)
|
||||
DeinitSuperEMA(seData);
|
||||
|
||||
Print("United EA deinitialized. Reason: ", reason);
|
||||
}
|
||||
@@ -620,56 +841,84 @@ void OnDeinit(const int reason)
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
UnitedAdaptive_ProcessCanaryTransitions();
|
||||
RefreshDynamicStrategyLots();
|
||||
|
||||
if(EnableDarvasBox)
|
||||
if(EnableDarvasBox && UnitedAdaptive_StrategyActive(UNITED_AD_DARVAS))
|
||||
ProcessDarvasBox(DB_Symbol);
|
||||
|
||||
if(EnableEMASlopeDistance)
|
||||
if(EnableEMASlopeDistance && UnitedAdaptive_StrategyActive(UNITED_AD_ES))
|
||||
ProcessEMASlopeDistance(ES_Symbol);
|
||||
|
||||
if(EnableRSICrossOverReversal)
|
||||
if(EnableRSICrossOverReversal && UnitedAdaptive_StrategyActive(UNITED_AD_RC))
|
||||
ProcessRSICrossOverReversal(RC_Symbol);
|
||||
|
||||
if(EnableRSIMidPointHijack)
|
||||
if(EnableRSIMidPointHijack && UnitedAdaptive_StrategyActive(UNITED_AD_RM))
|
||||
ProcessRSIMidPointHijack(RM_Symbol);
|
||||
|
||||
if(EnableRSIScalpingAPPL)
|
||||
if(EnableRSIScalpingAPPL && UnitedAdaptive_StrategyActive(UNITED_AD_RS_APPL))
|
||||
ProcessRSIScalping(rsAPPLData, RS_APPL_Symbol, RS_APPL_TimeFrame, RS_APPL_RSI_Period, RS_APPL_RSI_Applied_Price,
|
||||
RS_APPL_RSI_Overbought, RS_APPL_RSI_Oversold, RS_APPL_RSI_Target_Buy, RS_APPL_RSI_Target_Sell,
|
||||
RS_APPL_BarsToWait,
|
||||
DynamicLotForSymbol(RS_APPL_Symbol, RS_APPL_LotSize, InpDynamicStockLotCap),
|
||||
DynamicLotForSymbol(RS_APPL_Symbol, RS_APPL_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RS_APPL), InpDynamicStockLotCap, UNITED_AD_RS_APPL),
|
||||
RS_APPL_MagicNumber);
|
||||
|
||||
if(EnableRSIScalpingBTCUSD)
|
||||
if(EnableRSIScalpingBTCUSD && UnitedAdaptive_StrategyActive(UNITED_AD_RS_BTC))
|
||||
ProcessRSIScalping(rsBTCUSDData, RS_BTCUSD_Symbol, RS_BTCUSD_TimeFrame, RS_BTCUSD_RSI_Period, RS_BTCUSD_RSI_Applied_Price,
|
||||
RS_BTCUSD_RSI_Overbought, RS_BTCUSD_RSI_Oversold, RS_BTCUSD_RSI_Target_Buy, RS_BTCUSD_RSI_Target_Sell,
|
||||
RS_BTCUSD_BarsToWait, DynamicLotForSymbol(RS_BTCUSD_Symbol, RS_BTCUSD_LotSize), RS_BTCUSD_MagicNumber);
|
||||
RS_BTCUSD_BarsToWait, DynamicLotForSymbol(RS_BTCUSD_Symbol, RS_BTCUSD_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RS_BTC), 0.0, UNITED_AD_RS_BTC), RS_BTCUSD_MagicNumber);
|
||||
|
||||
if(EnableRSIScalpingNVDA)
|
||||
if(EnableRSIScalpingNVDA && UnitedAdaptive_StrategyActive(UNITED_AD_RS_NVDA))
|
||||
ProcessRSIScalping(rsNVDAData, RS_NVDA_Symbol, RS_NVDA_TimeFrame, RS_NVDA_RSI_Period, RS_NVDA_RSI_Applied_Price,
|
||||
RS_NVDA_RSI_Overbought, RS_NVDA_RSI_Oversold, RS_NVDA_RSI_Target_Buy, RS_NVDA_RSI_Target_Sell,
|
||||
RS_NVDA_BarsToWait,
|
||||
DynamicLotForSymbol(RS_NVDA_Symbol, RS_NVDA_LotSize, InpDynamicStockLotCap),
|
||||
DynamicLotForSymbol(RS_NVDA_Symbol, RS_NVDA_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RS_NVDA), InpDynamicStockLotCap, UNITED_AD_RS_NVDA),
|
||||
RS_NVDA_MagicNumber);
|
||||
|
||||
if(EnableRSIScalpingTSLA)
|
||||
if(EnableRSIScalpingTSLA && UnitedAdaptive_StrategyActive(UNITED_AD_RS_TSLA))
|
||||
ProcessRSIScalping(rsTSLAData, RS_TSLA_Symbol, RS_TSLA_TimeFrame, RS_TSLA_RSI_Period, RS_TSLA_RSI_Applied_Price,
|
||||
RS_TSLA_RSI_Overbought, RS_TSLA_RSI_Oversold, RS_TSLA_RSI_Target_Buy, RS_TSLA_RSI_Target_Sell,
|
||||
RS_TSLA_BarsToWait,
|
||||
DynamicLotForSymbol(RS_TSLA_Symbol, RS_TSLA_LotSize, InpDynamicStockLotCap),
|
||||
DynamicLotForSymbol(RS_TSLA_Symbol, RS_TSLA_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RS_TSLA), InpDynamicStockLotCap, UNITED_AD_RS_TSLA),
|
||||
RS_TSLA_MagicNumber);
|
||||
|
||||
if(EnableRSIScalpingXAUUSD)
|
||||
if(EnableRSIScalpingXAUUSD && UnitedAdaptive_StrategyActive(UNITED_AD_RS_XAU))
|
||||
ProcessRSIScalping(rsXAUUSDData, RS_XAUUSD_Symbol, RS_XAUUSD_TimeFrame, RS_XAUUSD_RSI_Period, RS_XAUUSD_RSI_Applied_Price,
|
||||
RS_XAUUSD_RSI_Overbought, RS_XAUUSD_RSI_Oversold, RS_XAUUSD_RSI_Target_Buy, RS_XAUUSD_RSI_Target_Sell,
|
||||
RS_XAUUSD_BarsToWait, DynamicLotForSymbol(RS_XAUUSD_Symbol, RS_XAUUSD_LotSize), RS_XAUUSD_MagicNumber);
|
||||
RS_XAUUSD_BarsToWait, DynamicLotForSymbol(RS_XAUUSD_Symbol, RS_XAUUSD_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RS_XAU), 0.0, UNITED_AD_RS_XAU), RS_XAUUSD_MagicNumber);
|
||||
|
||||
if(EnableRSIReversalAsianEURUSD)
|
||||
ProcessRSIReversalAsian(rraEURUSDData, DynamicLotForSymbol(RRA_EURUSD_Symbol, RRA_EURUSD_MaxLotSize));
|
||||
if(EnableRSIReversalEURUSD && UnitedAdaptive_StrategyActive(UNITED_AD_RRA_EUR))
|
||||
ProcessRSIReversalAsian(rraEURUSDData, DynamicLotForSymbol(RRA_EURUSD_Symbol, RRA_EURUSD_MaxLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RRA_EUR), 0.0, UNITED_AD_RRA_EUR));
|
||||
|
||||
if(EnableRSIReversalAsianAUDUSD)
|
||||
ProcessRSIReversalAsian(rraAUDUSDData, DynamicLotForSymbol(RRA_AUDUSD_Symbol, RRA_AUDUSD_MaxLotSize));
|
||||
if(EnableRSIReversalAUDUSD && UnitedAdaptive_StrategyActive(UNITED_AD_RRA_AUD))
|
||||
ProcessRSIReversalAsian(rraAUDUSDData, DynamicLotForSymbol(RRA_AUDUSD_Symbol, RRA_AUDUSD_MaxLotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RRA_AUD), 0.0, UNITED_AD_RRA_AUD));
|
||||
|
||||
if(EnableRSISecretSauceXAUUSD && UnitedAdaptive_StrategyActive(UNITED_AD_RSS))
|
||||
ProcessRSISecretSauce(rsSecretSauceXAUUSDData, DynamicLotForSymbol(RSS_XAUUSD_Symbol, RSS_XAUUSD_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_RSS), 0.0, UNITED_AD_RSS));
|
||||
|
||||
if(EnableSuperEMA && UnitedAdaptive_StrategyActive(UNITED_AD_SUPEREMA))
|
||||
ProcessSuperEMA(seData, DynamicLotForSymbol(SE_Symbol, SE_LotSize * UnitedAdaptive_GetLotMult(UNITED_AD_SUPEREMA), 0.0, UNITED_AD_SUPEREMA));
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Timer — refresh profit panel (history scan) |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTimer()
|
||||
{
|
||||
if(InpAdaptiveEnable)
|
||||
UnitedAdaptive_ProcessCanaryTransitions();
|
||||
if(InpAdaptiveEnable || (InpDdLotCapEnable && InpDdLotCapPerStratEnable))
|
||||
UnitedAdaptive_UpdateIfDue();
|
||||
if(UnitedPanel_Enable)
|
||||
UnitedProfitPanelRefresh();
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Chart events — panel layout on resize |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
|
||||
{
|
||||
UnitedProfitPanelOnChartEvent(id);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user