Set input for trading closing level

This commit is contained in:
Nkondog Anselme
2021-11-16 00:23:31 +01:00
parent 59670dd17e
commit 1fa283c934
3 changed files with 5 additions and 2 deletions
Binary file not shown.
@@ -23,6 +23,7 @@ input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Positi
input double InpDefaultLotSize=1; //Position Size (if fixed or if no stop loss defined) input double InpDefaultLotSize=1; //Position Size (if fixed or if no stop loss defined)
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
input double InpProfitPercent=1;
input double InpMinLotSize=0.01; //Min Lot Size input double InpMinLotSize=0.01; //Min Lot Size
input double InpMaxLotSize=100; //Max Lot Size input double InpMaxLotSize=100; //Max Lot Size
@@ -31,6 +31,7 @@ protected:
double mMaxLotSize; double mMaxLotSize;
double mMinLotSize; double mMinLotSize;
double mMaxRiskPerTrade; double mMaxRiskPerTrade;
double mProfitPercent;
double lastBuyOrderPrice; double lastBuyOrderPrice;
@@ -147,6 +148,7 @@ public: // Default properties
virtual void SetMaxLotSize(double maxLotSize) {mMaxLotSize = maxLotSize;} virtual void SetMaxLotSize(double maxLotSize) {mMaxLotSize = maxLotSize;}
virtual void SetMinLotSize(double minLotSize) {mMinLotSize = minLotSize;} virtual void SetMinLotSize(double minLotSize) {mMinLotSize = minLotSize;}
virtual void SetMaxRiskPerTrade(double maxRiskPerTrade) {mMaxRiskPerTrade = maxRiskPerTrade;} virtual void SetMaxRiskPerTrade(double maxRiskPerTrade) {mMaxRiskPerTrade = maxRiskPerTrade;}
virtual void SetProfitPercent(double profitPercent) {mProfitPercent = profitPercent;}
virtual void SetUseTradingSession(ENUM_TRADING_SESSION useTradingSession) {mUseTradingSession = useTradingSession;} virtual void SetUseTradingSession(ENUM_TRADING_SESSION useTradingSession) {mUseTradingSession = useTradingSession;}
@@ -733,7 +735,7 @@ void CExpertBase::TradeWatcher(void)
double floatingProfitPercent = ((AccountInfoDouble(ACCOUNT_EQUITY) - AccountInfoDouble(ACCOUNT_BALANCE))*100)/AccountInfoDouble(ACCOUNT_BALANCE); double floatingProfitPercent = ((AccountInfoDouble(ACCOUNT_EQUITY) - AccountInfoDouble(ACCOUNT_BALANCE))*100)/AccountInfoDouble(ACCOUNT_BALANCE);
// Check if profit is at least the mMaxRiskPerTrade // Check if profit is at least the mMaxRiskPerTrade
Print(" MaxRiskPerTrade ",mMaxRiskPerTrade, " Floating profit percent ", floatingProfitPercent, " Account equity ", AccountInfoDouble(ACCOUNT_EQUITY), " Account balance ", AccountInfoDouble(ACCOUNT_BALANCE)); Print(" Profit Percent ",InpProfitPercent, " Floating profit percent ", floatingProfitPercent, " Account equity ", AccountInfoDouble(ACCOUNT_EQUITY), " Account balance ", AccountInfoDouble(ACCOUNT_BALANCE));
//The number of buy pending order should be twice the opened sell positions; and vice versa //The number of buy pending order should be twice the opened sell positions; and vice versa
realOCountBuy = pCountSell+1; realOCountBuy = pCountSell+1;
@@ -776,7 +778,7 @@ void CExpertBase::TradeWatcher(void)
{ {
//When there are multiple positions, check is the account is making enough profit //When there are multiple positions, check is the account is making enough profit
Print("floatingProfitPercent ", floatingProfitPercent, " mMaxRiskPerTrade ", mMaxRiskPerTrade); Print("floatingProfitPercent ", floatingProfitPercent, " mMaxRiskPerTrade ", mMaxRiskPerTrade);
if(floatingProfitPercent > mMaxRiskPerTrade) if(floatingProfitPercent > mProfitPercent)
{ {
exitSignal = OFX_SIGNAL_ALL; exitSignal = OFX_SIGNAL_ALL;
Print("Exit on profit target"); Print("Exit on profit target");