implement all props ...

This commit is contained in:
2024-12-25 00:11:25 +03:30
parent b5021a80d7
commit 0a4859982b
4 changed files with 981 additions and 360 deletions
+681 -161
View File
@@ -58,6 +58,258 @@ class XC121SMCExpert : public XCBaseExpert
//
// Getter(s) / Setter(s) ...
//
// Signalling Props ...
/**
* Get Allow Long Signals State ...
*
* @return ( bool )
*/
bool AllowLong()
{
return mAllowLong;
}
/**
* Set Allow Long Signals State ...
*
* @param value: Boolean ...
*/
void AllowLong(bool value)
{
//
mAllowLong = value;
ReConfigure();
}
/**
* Get Allow Short Signals State ...
*
* @return ( bool )
*/
bool AllowShort()
{
return mAllowShort;
}
/**
* Set Allow Short Signals State ...
*
* @param value: Boolean ...
*/
void AllowShort(bool value)
{
//
mAllowShort = value;
ReConfigure();
}
/**
* Get Max Allowed Long Signals ...
* 0 => Unlimited ...
*
* @return ( int )
*/
int MaxAllowedLongs()
{
return mMaxAllowedLongs;
}
/**
* Set Max Allowed Long Signals ...
*
* @param value: Integer ...
* 0 => Unlimited ...
*/
void MaxAllowedLongs(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mMaxAllowedLongs = value;
ReConfigure();
}
/**
* Get Max Allowed Short Signals ...
* 0 => Unlimited ...
*
* @return ( int )
*/
int MaxAllowedShorts()
{
return mMaxAllowedShorts;
}
/**
* Set Max Allowed Short Signals ...
*
* @param value: Integer ...
* 0 => Unlimited ...
*/
void MaxAllowedShorts(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mMaxAllowedShorts = value;
ReConfigure();
}
/**
* Get Use Max Allowed Signal Types Per Symbol State ...
*
* @return ( bool )
*/
bool UseMaxAllowedSignalsPerSymbol()
{
return mUseMaxAllowedSignalsPerSymbol;
}
/**
* Set Use Max Allowed Signal Types Per Symbol State ...
*
* @param value: Boolean ...
*/
void UseMaxAllowedSignalsPerSymbol(bool value)
{
//
mUseMaxAllowedSignalsPerSymbol = false;
ReConfigure();
}
/**
* Get Last Position Profit In Points for Accept new Signal ...
* 0 => Accept All ...
*
* @return ( double )
*/
double LastPositionProfitForAcceptNextInPoint()
{
return mLastPositionProfitForAcceptNextInPoint;
}
/**
* Set Last Position Profit In Points for Accept new Signal ...
*
* @param value: Double ...
* 0 => Accept All ...
*/
void LastPositionProfitForAcceptNextInPoint(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mLastPositionProfitForAcceptNextInPoint = value;
ReConfigure();
}
/**
* Get Delay between two Signals in Bars ...
* 0 => Accept All ...
*
* @return ( int )
*/
int DelaysBetweenTwoSignalsInBar()
{
return mDelaysBetweenTwoSignalsInBar;
}
/**
* Set Delay between two Signals in Bars ...
*
* @param value: Integer ...
* 0 => Accept All ...
*/
void DelaysBetweenTwoSignalsInBar(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mDelaysBetweenTwoSignalsInBar = value;
ReConfigure();
}
/**
* Get Max Allowed Spread for Signalling ...
* 0 => Accept All ...
*
* @return ( double )
*/
double MaxAllowedSpread()
{
return mMaxAllowedSpread;
}
/**
* Set Max Allowed Spread for Signalling ...
*
* @param value: Double ...
* 0 => Accept All ...
*/
void MaxAllowedSpread(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mMaxAllowedSpread = value;
ReConfigure();
}
/**
* Get Minimum Spread Verification for Signalling ...
* 0 => Ignore ...
*
* @return ( int )
*/
int MinRequiredVerificationForSpreadPass()
{
return mMinRequiredVerificationForSpreadPass;
}
/**
* Set Minimum Spread Verification for Signalling ...
*
* @param value: Integer ...
* 0 => Ignore ...
*/
void MinRequiredVerificationForSpreadPass(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mMinRequiredVerificationForSpreadPass = value;
ReConfigure();
}
//
// Risk Management Props ...
/**
* Get Risk to Reward Ratio ...
*
@@ -83,128 +335,7 @@ class XC121SMCExpert : public XCBaseExpert
//
mR2R = value;
ReConfigureAllStrategies();
}
/**
* Get Use Dynamic Volume State ...
*
* @return ( bool )
*/
bool UseDynamicVolume()
{
return mUseDynamicVolume;
}
/**
* Set Use Dynamic Volume State ...
*
* @param value: Boolean ...
*/
void UseDynamicVolume(bool value)
{
mUseDynamicVolume = value;
}
/**
* Get Increase Volume Step ...
*
* @return ( double )
*/
double DynamicVolumeStep()
{
return mDynamicVolumeStep;
}
/**
* Set Increase Volume Step ...
*
* @param value: Double ...
*/
void DynamicVolumeStep(double value)
{
//
if (value < 0.01)
{
value = 0.01;
}
//
mDynamicVolumeStep = value;
}
/**
* Get Balance Factor for Generate Dynamic Volume ...
*
* @return ( double )
*/
double DynamicVolumeBalanceFactor()
{
return mDynamicVolumeBalanceFactor;
}
/**
* Set Balance Factor for Generate Dynamic Volume ...
*
* @param value: Double ...
*/
void DynamicVolumeBalanceFactor(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mDynamicVolumeBalanceFactor = value;
}
/**
* Get Risk Percent Per Balance in Each Trade ...
*
* @return ( double )
*/
double RiskPercentPerBalance()
{
return mRiskPercentPerBalance;
}
/**
* Set Risk Percent Per Balance in Each Trade ...
*
* @param value: Double
*/
void RiskPercentPerBalance(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mRiskPercentPerBalance = value;
}
/**
* Get Dynamic Risk Management State ...
*
* @return ( bool )
*/
bool DynamicRiskManagement()
{
return mDynamicRiskManagement;
}
/**
* Set Dynamic Risk Management State ...
*
* @param value: Boolean ...
*/
void DynamicRiskManagement(bool value)
{
mDynamicRiskManagement = value;
ReConfigure();
}
/**
@@ -232,6 +363,362 @@ class XC121SMCExpert : public XCBaseExpert
//
mVolume = value;
ReConfigure();
}
/**
* Get Risk Percent Per Balance in Each Trade ...
*
* @return ( double )
*/
double RiskPercentPerBalance()
{
return mRiskPercentPerBalance;
}
/**
* Set Risk Percent Per Balance in Each Trade ...
*
* @param value: Double
*/
void RiskPercentPerBalance(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mRiskPercentPerBalance = value;
ReConfigure();
}
/**
* Get Dynamic Risk Management State ...
*
* @return ( bool )
*/
bool DynamicRiskManagement()
{
return mDynamicRiskManagement;
}
/**
* Set Dynamic Risk Management State ...
*
* @param value: Boolean ...
*/
void DynamicRiskManagement(bool value)
{
//
mDynamicRiskManagement = value;
ReConfigure();
}
/**
* Get Use Dynamic Volume State ...
*
* @return ( bool )
*/
bool UseDynamicVolume()
{
return mUseDynamicVolume;
}
/**
* Set Use Dynamic Volume State ...
*
* @param value: Boolean ...
*/
void UseDynamicVolume(bool value)
{
//
mUseDynamicVolume = value;
ReConfigure();
}
/**
* Get Increase Volume Step ...
*
* @return ( double )
*/
double DynamicVolumeStep()
{
return mDynamicVolumeStep;
}
/**
* Set Increase Volume Step ...
*
* @param value: Double ...
*/
void DynamicVolumeStep(double value)
{
//
if (value < 0.01)
{
value = 0.01;
}
//
mDynamicVolumeStep = value;
ReConfigure();
}
/**
* Get Balance Factor for Generate Dynamic Volume ...
*
* @return ( double )
*/
double DynamicVolumeBalanceFactor()
{
return mDynamicVolumeBalanceFactor;
}
/**
* Set Balance Factor for Generate Dynamic Volume ...
*
* @param value: Double ...
*/
void DynamicVolumeBalanceFactor(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mDynamicVolumeBalanceFactor = value;
ReConfigure();
}
/**
* Get Max Allowed Drawdown Percent for Open Trades ...
* 0 => Ignore ...
* min => 0 ...
* max => 100 ...
*
* @return ( double )
*/
double MaxAllowedDrawdownToOpenTrades()
{
return mMaxAllowedDrawdownToOpenTrades;
}
/**
* Set Max Allowed Drawdown Percent for Open Trades ...
*
* @param value: Double ...
* 0 => Ignore ...
* min => 0 ...
* max => 100 ...
*/
void MaxAllowedDrawdownToOpenTrades(double value)
{
//
if (value < 0)
{
value = 0;
}
//
if (value > 50)
{
value = 50;
}
//
mMaxAllowedDrawdownToOpenTrades = value;
ReConfigure();
}
/**
* Get Max Allowed SL for Pause Signalling Per Symbol ...
* 0 => Unlimited ...
*
* @return ( int )
*/
int MaxAllowedSLToPauseSignallingPerSymbol()
{
return mMaxAllowedSLToPauseSignallingPerSymbol;
}
/**
* Set Max Allowed SL for Pause Signalling Per Symbol ...
*
* @param value: Integer ...
* 0 => Unlimited ...
*/
void MaxAllowedSLToPauseSignallingPerSymbol(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mMaxAllowedSLToPauseSignallingPerSymbol = value;
ReConfigure();
}
/**
* Get Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds ...
* 0 => Ignore ...
*
* @return ( int )
*/
int PauseSignallingAfterReachesMaxAllowedSLInSecconds()
{
return mPauseSignallingAfterReachesMaxAllowedSLInSecconds;
}
/**
* Set Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds ...
*
* @param value: Integer ...
* 0 => Ignore ...
*/
void PauseSignallingAfterReachesMaxAllowedSLInSecconds(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mPauseSignallingAfterReachesMaxAllowedSLInSecconds = value;
ReConfigure();
}
//
// Protection Props ...
/**
* Get Allow Hedge Positions State ...
*
* @return ( bool )
*/
bool AllowHedging()
{
return mAllowHedging;
}
/**
* Set Allow Hedge Positions State ...
*
* @param value: Boolean ...
*/
void AllowHedging(bool value)
{
//
mAllowHedging = value;
ReConfigure();
}
/**
* Get Minimum Open Positions for Hedging ...
* 0 => Ignore ...
*
* @return ( int )
*/
int MinOpenTradesFroHedging()
{
return mMinOpenTradesFroHedging;
}
/**
* Set Minimum Open Positions for Hedging ...
*
* @param value: Integer ...
* 0 => Ignore ...
*/
void MinOpenTradesFroHedging(int value)
{
//
if (value < 0)
{
value = 0;
}
//
mMinOpenTradesFroHedging = value;
ReConfigure();
}
/**
* Get Minimum Volume Step for Hedging ...
* 0 => Ignore ...
*
* @return ( double )
*/
double HedgingMinVolumeStep()
{
return mHedgingMinVolumeStep;
}
/**
* Set Minimum Volume Step for Hedging ...
*
* @param value: Double ...
* 0 => Ignore ...
*/
void HedgingMinVolumeStep(double value)
{
//
if (value < 0)
{
value = 0;
}
//
if (value > 0 && value < 0.01)
{
value = 0.01;
}
//
if (value > 0 && value > 0.1)
{
value = 0.1;
}
//
mHedgingMinVolumeStep = value;
ReConfigure();
}
/**
* Get Minimum Required Profit Per Volume Step for Hedging ...
* 0 => Ignore ...
*
* @return ( double )
*/
double HedgeingMinRequiredProfitPerVolumeStep()
{
return mHedgeingMinRequiredProfitPerVolumeStep;
}
/**
* Set Minimum Required Profit Per Volume Step for Hedging ...
*
* @param value: Double ...
* 0 => Ignore ...
*/
void HedgeingMinRequiredProfitPerVolumeStep(double value)
{
//
if (value < 0)
{
value = 0;
}
//
mHedgeingMinRequiredProfitPerVolumeStep = value;
ReConfigure();
}
//
@@ -541,37 +1028,7 @@ class XC121SMCExpert : public XCBaseExpert
mTradeHandler.SaveConditions(true);
//
// Configure Alerts ...
mTradeHandler.SetAlertPrefix(GetTag());
mTradeHandler.SetAlertEnableAlerts(GetAlertEnableAlerts());
mTradeHandler.SetAlertLogAlerts(GetAlertLogAlerts());
mTradeHandler.SetAlertMailAlerts(GetAlertMailAlerts());
mTradeHandler.SetAlertPushAlerts(GetAlertPushAlerts());
mTradeHandler.SetAlertTerminalAlerts(GetAlertTerminalAlerts());
//
mTradeHandler.MaxAllowedSLToPause(0);
mTradeHandler.DelayBarBetweenTwoSignal(7);
mTradeHandler.MaxAllowedSLReachedPauseDelay(HoursToSeconds(24));
//
// Configure Trade Management ...
mTradeHandler.AllowLong(AllowLong());
mTradeHandler.AllowShort(AllowShort());
mTradeHandler.MaxAllowedLongs(0);
mTradeHandler.MaxAllowedShorts(0);
mTradeHandler.UseMaxAllowedTradesPerSymbol(true);
mTradeHandler.MaxDrawdownPercentForOpenTrades(5);
//
// Configure Position Protector ...
//
// Configure Hedging ...
mTradeHandler.AllowHedge(true);
mTradeHandler.HedgeMinVolumeStep(0.01);
mTradeHandler.MinimumOpenPositionsForHedge(2);
mTradeHandler.HedgeMinProfitPerVolumeStep(0.2);
ReConfigureTradeHandler();
//
// Parsers ...
@@ -1034,6 +1491,38 @@ class XC121SMCExpert : public XCBaseExpert
}
}
/**
* Re Configure Trade Handler ...
*/
void ReConfigureTradeHandler()
{
//
// Configure Alerts ...
mTradeHandler.SetAlertPrefix(GetTag());
mTradeHandler.SetAlertEnableAlerts(GetAlertEnableAlerts());
mTradeHandler.SetAlertLogAlerts(GetAlertLogAlerts());
mTradeHandler.SetAlertMailAlerts(GetAlertMailAlerts());
mTradeHandler.SetAlertPushAlerts(GetAlertPushAlerts());
mTradeHandler.SetAlertTerminalAlerts(GetAlertTerminalAlerts());
//
mTradeHandler.AllowLong(AllowLong());
mTradeHandler.AllowShort(AllowShort());
mTradeHandler.MaxAllowedLongs(MaxAllowedLongs());
mTradeHandler.MaxAllowedShorts(MaxAllowedShorts());
mTradeHandler.UseMaxAllowedSignalsPerSymbol(UseMaxAllowedSignalsPerSymbol());
mTradeHandler.LastPositionProfitForAcceptNextInPoint(LastPositionProfitForAcceptNextInPoint());
mTradeHandler.DelaysBetweenTwoSignalsInBar(DelaysBetweenTwoSignalsInBar());
mTradeHandler.MaxAllowedSpread(MaxAllowedSpread());
mTradeHandler.MaxAllowedDrawdownToOpenTrades(MaxAllowedDrawdownToOpenTrades());
mTradeHandler.MaxAllowedSLToPauseSignallingPerSymbol(MaxAllowedSLToPauseSignallingPerSymbol());
mTradeHandler.PauseSignallingAfterReachesMaxAllowedSLInSecconds(PauseSignallingAfterReachesMaxAllowedSLInSecconds());
mTradeHandler.AllowHedging(AllowHedging());
mTradeHandler.MinOpenTradesFroHedging(MinOpenTradesFroHedging());
mTradeHandler.HedgingMinVolumeStep(HedgingMinVolumeStep());
mTradeHandler.HedgeingMinRequiredProfitPerVolumeStep(HedgeingMinRequiredProfitPerVolumeStep());
}
//
private:
//
@@ -1042,14 +1531,45 @@ class XC121SMCExpert : public XCBaseExpert
// Props ...
//
// Volume Management ...
double mR2R; // Signallers Risk to Reward Ratio ...
bool mUseDynamicVolume; // Use Dynamic Volume ...
double mDynamicVolumeStep; // Increase Volume Step ...
double mDynamicVolumeBalanceFactor; // Balance Factor for Generate Dynamic Volume ...
double mVolume; // Static Volume ...
bool mDynamicRiskManagement; // Dynamic Risk Management ...
double mRiskPercentPerBalance; // Risk Percent Per Balance in Each Trade ...
// Signalling Props ...
bool mAllowLong; // Allow Long Signals ...
bool mAllowShort; // Allow Short Signals ...
int mMaxAllowedLongs; // Max Allowed Long Signals ...
int mMaxAllowedShorts; // Max Allowed Short Signals ...
bool mUseMaxAllowedSignalsPerSymbol; // Use Max Allowed Signal Types Per Symbol ...
double mLastPositionProfitForAcceptNextInPoint; // Last Position Profit In Points for Accept new Signal ...
int mDelaysBetweenTwoSignalsInBar; // Delay between two Signals in Bars ...
double mMaxAllowedSpread; // Max Allowed Spread for Signalling ...
int mMinRequiredVerificationForSpreadPass; // Minimum Spread Verification for Signalling ...
//
// Risk Management Props ...
double mR2R; // Signallers Risk to Reward Ratio ...
double mVolume; // Static Volume ...
double mRiskPercentPerBalance; // Risk Percent Per Balance in Each Trade ...
bool mDynamicRiskManagement; // Dynamic Risk Management ...
bool mUseDynamicVolume; // Use Dynamic Volume ...
double mDynamicVolumeStep; // Increase Volume Step ...
double mDynamicVolumeBalanceFactor; // Balance Factor for Generate Dynamic Volume ...
double mMaxAllowedDrawdownToOpenTrades; // Max Allowed Drawdown for Open Trades ...
int mMaxAllowedSLToPauseSignallingPerSymbol; // Max Allowed SL for Pause Signalling Per Symbol ...
int mPauseSignallingAfterReachesMaxAllowedSLInSecconds; // Pause Signalling Per Symbol afte Max Allowed SL Reached In Seconds ...
//
// Protection Props ...
bool mAllowHedging; // Allow Hedge Positions ...
int mMinOpenTradesFroHedging; // Minimum Open Positions for Hedging ...
double mHedgingMinVolumeStep; // Minimum Volume Step for Hedging ...
double mHedgeingMinRequiredProfitPerVolumeStep; // Minimum Required Profit Per Volume Step for Hedging ...
//
// Reconfigure Class On Properties Change ...
void ReConfigure()
{
//
ReConfigureTradeHandler();
ReConfigureAllStrategies();
}
//
double CalculateAdditionalVolumeMultiplier(XSignal &signal)