Download MetaTrader 5
To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
Arirang88
10
Arirang88 2014.07.02 07:22 
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.
Jaume Torne
89
Jaume Torne 2014.07.02 10:36  
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

Arirang88
10
Arirang88 2014.07.02 12:59  
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?
whroeder1
13644
whroeder1 2014.07.03 16:18  
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?
/
To add comments, please log in or register