How to add Money Management to existing EA?

 
I'm currently using an EA that gives me good results, but in the settings window I have to choose the number of Lots to be traded, while I would prefer to have a % of available cash to set to my convenience. How can I modify the EA to obtain this? Any help truly appreciate, I can give you a copy of the EA to check and to keep for your use. Thank you.
 
Arirang88:
I'm currently using an EA that gives me good results, but in the settings window I have to choose the number of Lots to be traded, while I would prefer to have a % of available cash to set to my convenience. How can I modify the EA to obtain this? Any help truly appreciate, I can give you a copy of the EA to check and to keep for your use. Thank you.

Very common calculation:

 

Lots=AccountEquity()*MaxRisk/Stop* MarketInfo(Symbol(),MODE_TICKSIZE) / MarketInfo(Symbol(),MODE_TICKVALUE);

 

Many programmers use this, where:

 

MaxRisk: Fraction of the equity you want to risk on a single trade

 

Stop: absolute value Open price less Stop price

 
jtcash:

Very common calculation:

 

Lots=AccountEquity()*MaxRisk/Stop* MarketInfo(Symbol(),MODE_TICKSIZE) / MarketInfo(Symbol(),MODE_TICKVALUE);

 

Many programmers use this, where:

 

MaxRisk: Fraction of the equity you want to risk on a single trade

 

Stop: absolute value Open price less Stop price


Thank you jtcash! But how can I insert this Money Manager into my EA so that the risk is the same for every trade, even if balance changes, automatically?
 
jtcash: Lots=AccountEquity()*MaxRisk/Stop* MarketInfo(Symbol(),MODE_TICKSIZE) / MarketInfo(Symbol(),MODE_TICKVALUE);
Arirang88: But how can I insert this Money Manager into my EA so that the risk is the same for every trade, even if balance changes, automatically?
  1. AccountBalance * percent + commission = Risk = (OrderOpenPrice - OrderStopLoss)*Direction() * DeltaPerLot() * lotsize. Solve for lotsize and normalize properly.
  2. Note that OrderOpenPrice - OrderStopLoss includes the spread. Cash, make sure your Stop does also. You also must normalize it to lotstep and check minlot.
  3. Ari, You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support. And solve for lots. What part of AccountEquity() or AccoutBalance() don't you understand in the two equations?
Reason: