Thanks for making this Money Management Graphic Tool available. I'm trying to add a leverage limiting feature to it.
Using the variables from the order_graphic_tool_v5_5basic_visual_mod_for_1920x10802 plus some new variables I added, below is my initial attempt to calculate the real leverage of a new trade as the variable NewTradeRealLeverage and then compare that NewTradeRealLeverage to the MaximumPerTradeLeverage and limit the new trade leverage to the MaximumPerTradeLeverage.
I'm no expert like Willam Roeder and others in this thread, so if anyone of you can figure out how to integrate this idea properly into the order_graphic_tool, I will really appreciate if you would share it with us. Thanks.
enum Money{ Balance, Equity };
externdouble ogt_AccountBalance = 0; // Use amount ($) different than account balance
externdouble InitialPercent = 1.0; // Percentage Initial Risk
externbool RiskBasis = Balance; // Risk basis
externdouble MaximumPerTradeLeverage = 10; // Maximum Per Trade Leverage
double dVpL = tickValue / tickSize; // DeltaValuePerlot
string USD = AccountInfoString(ACCOUNT_CURRENCY);
string balance = RiskBasis == Balance ? "Balance" : "Equity";
double money = ogt_AccountBalance == 0 ? AccountInfoDouble(RiskBasis == Balance ? ACCOUNT_BALANCE : ACCOUNT_EQUITY):ogt_AccountBalance;
double risk = money * InitialPercent / 100.0; // Risk in the ACCOUNT_CURRENCYdouble maxLots = normalize_lots( risk / (sl * dVpL + CommissionPerLot) ); // div 0double lotsize = 0; // MarketInfo(Symbol(), MODE_LOTSIZE);
double BaseDEP = 0; // Rate of the Base Currency in terms of the ACCOUNT_CURRENCYdouble NewPositionSize = 0; // NewPositionSize in the ACCOUNT_CURRENCYdouble NewTradeRealLeverage = 0;
while(true)
{
lotsize = MarketInfo(Symbol(), MODE_LOTSIZE);
BaseDEP = iClose(Symbol(),0,0)*dVpL/lotsize; // Rate of the Base Currency in terms of the ACCOUNT_CURRENCY
NewPositionSize = maxLots*lotsize*BaseDEP; // NewPositionSize in the ACCOUNT_CURRENCY
NewTradeRealLeverage = NewPositionSize/(money-risk);
// Keep the new trade real leverage at or below the MaximumPerTradeLeverage
if(MaximumPerTradeLeverage>0 && NewTradeRealLeverage>MaximumPerTradeLeverage)
{
maxLots*=0.99; // Must still round to lotStep.
continue;
}
break;
} // while (true)
Reduce the resolution of your screen. Very little code adjusts for high res and I haven't researched it yet.
Yes. You can't modify the one OrderSend or have it done?
Updated version adds the following:
Hey guys I started working on converting some of the code to MT5 because I needed it to work in MT5 for my own use. I have attached the code below.
Update: Added changes to most recent MT4 version of the code, file "order_graphic_tool_v5_5basic_visual_mod_for_1920x10802"
//| 15-Feb-2021 Updated by pcfxalerts (pcfxalerts@gmail.com)
//| - Added external input to set the account balance to something other than the balance you have with the broker.
//| - added separators to inputs
//| - added input to turn on / off sounds
//| - added input "Default Stop Loss Pips"
Hi all,
Thanks for making this Money Management Graphic Tool available. I'm trying to add a leverage limiting feature to it.
Using the variables from the order_graphic_tool_v5_5basic_visual_mod_for_1920x10802 plus some new variables I added, below is my initial attempt to calculate the real leverage of a new trade as the variable NewTradeRealLeverage and then compare that NewTradeRealLeverage to the MaximumPerTradeLeverage and limit the new trade leverage to the MaximumPerTradeLeverage.
I'm no expert like Willam Roeder and others in this thread, so if anyone of you can figure out how to integrate this idea properly into the order_graphic_tool, I will really appreciate if you would share it with us. Thanks.
Hi,
There is an option in the input
Risk basis - true or false
If it is set to FALSE - it will be based on Balance or Equity?
Thank you for EA
It is actually a bug. It should have been an enumeration and not a boolean ...
However, as a boolean, false is Balance and true is Equity.