Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information
As you see, "stopInPips" is used in the equation. This function: MarketInfo(Symbol(),MODE_TICKVALUE) returns the value of 1 pip when you have 1 lot.
Since you were a mathematical analyst, let's do some math:
For USD/JPY:
$25k free margin, with a 1.5% risk, 50 pip stop loss:
(25,000 * .015)/(8.68 * 50) = 375/434 = .86 lots
.86 lots * 8.68 = 7.47 pip value (1 pip = $7.47)
50 pips * $7.47 = $373.50 (due to rounding, not quite $375)
So, let's see what happens with a 100 pip stop loss:
(25,000 * .015)/(8.68 * 100) = 375/868 = .43 lots
.43 lots * 8.68 = 3.73 pip value (1 pip = $3.73)
100 pips * $3.73 = $373 (again, due to rounding, not quite $375)
No matter what stoploss you put in, the dollar amount risked remains constant for this size account using this risk percent. As your account size changes, so will the dollar amount risked, but the percent risked remains the same. The stoploss does not affect the percent risked, only how much currency you buy.
If you see fault with my calculations, please tell me.
Thanks,
burn0050
You are right, I used nix AutoLots function.
I now have one more change to MM. I will now add your code as well and have a switch to chose which to test.
There is a problem with your LotSize function that I have seen before.
It will not work with IBFX or those brokers no longer using lots. IBFX uses 1 for a minilots in a mini account while FXDD uses .1 for a minilot in a mini account. FXDD does not allow partial lots in a standard account while I believe IBFX does.
Some brokers are now using actual dollar amounts like $10000 instead of lots..
This causes problems writing MM functions in EAs.
For now I will simply post the code as is. I will work on figuring how to use your method with IBFX and update the EA for repost.
All results posted were using Nix version of AutoLots.
I know many of you are waiting for this so I am posting it now.
The next phase of development will be finding a good exit method. The current method exits on the opposite signal from the two zigzag indicators.
For MM the input for Risk should be small for Burns method and can be larger for Nix version.
I hope the other inputs are obvious. The various strings are menus to chose what you want to test.
The best results tested on GBPJPY were using the default settings.
Using 3% Risk and Burns MM method did return $8695 on $10K account with drawdown of 15%. Largest profit was 2262, largest loss 438.
Average profit was 1328, average loss was 250.
Using 4% risk and nix MM method returned $8798 with drawdown of 7.8%. Largest profit was 2602, largest loss was 512.
Average profit was 1225, average loss was 171.
I am open to suggestions for removing code from the EA. If things like HA, HAS, CCI or Stochastics filters should be removed let me know. We should also work toward a single MM function.
Some of the filter indicators will be tested for exit as well. I am ecen thinking of using confirmation of arrow similar to entry rule.
That might allow some trades to reach greater profit, especially those trades that have many exit arrows after the first exit signal.
Suggestions for other exit methods are also welcome.
I will be coding a few myself.
I am open to suggestions for removing code from the EA. If things like HA, HAS, CCI or Stochastics filters should be removed let me know. We should also work toward a single MM function.
Some of the filter indicators will be tested for exit as well. I am ecen thinking of using confirmation of arrow similar to entry rule.
That might allow some trades to reach greater profit, especially those trades that have many exit arrows after the first exit signal.
Suggestions for other exit methods are also welcome.
I will be coding a few myself.
Robert
Hello MrPip
I have this mm in some of my ea's. I don't know if it would help you or not but I will post it just in case:
This bit goes at the top so that the user can choose which type they want
Code:
//////
/* Here is the MM settings...look at notes...if set to 0 then ea will trade with a fixed lot size..the size specified
in the above "extern double Lots = 1.0;" line. Might want to change this to 0.1.
If 1 then it will trade a fixed percentage of the account balance
If 2 then it will use a fractional portion (not to sure on this one..must look at code again)
If 3 then a fractional fixed size meaning 1 lot for every 500 in account or so...the 500 is set below
in the LotsDepoForOne - i.e. How many lots for each deposit amount of =
You must play around with it..cannot remember exact settings but I likes the setting to trade 1 lot for each $xx in account.
Easy to maintain a say 500:1 ratio with it.
*/
extern int LotsWayChoice = 3; // Lot size selection:
// 0-fixed lot size,
// 1-% from deposit,
// 2-fractional proportional,
// 3-fractional fixed lot size,
extern int LotsPercent=0; // % from deposit
extern int LotsDeltaDepo=500; // factor of deposit increase
extern int LotsDepoForOne=500; // deposit size for 1 mini lot
extern int LotsMax=100; // Max number of mini lots
double ldLot;
then some of the ea code till you get to the buy and sell part and enter in the following
///////////////////////////////////////////////////////////////////////////////////////
// This part is the function where the lot size is calculated
double GetSizeLot() {
double dLot;
if (LotsWayChoice==0) dLot=Lots;
// fixed % from deposit
if (LotsWayChoice==1) {
dLot=MathCeil(AccountFreeMargin()/10000*LotsPercent)/10;
}
// fractional proportional
if (LotsWayChoice==2) {
int k=LotsDepoForOne;
for (double i=2; i<=LotsMax; i++) {
k=k+i*LotsDeltaDepo;
if (k>AccountFreeMargin()) {
dLot=(i-1)/10; break;
}
}
}
// fractional fixed
if (LotsWayChoice==3) {
dLot=MathCeil((AccountFreeMargin()-LotsDepoForOne)/LotsDeltaDepo)/10;
}
if (dLot<0.1) dLot=0.1;
if (dLot>LotsMax) dLot=LotsMax;
return(dLot);
}
I know many of you are waiting for this so I am posting it now.
The next phase of development will be finding a good exit method. The current method exits on the opposite signal from the two zigzag indicators.
For MM the input for Risk should be small for Burns method and can be larger for Nix version.
I hope the other inputs are obvious. The various strings are menus to chose what you want to test.
The best results tested on GBPJPY were using the default settings.
Using 3% Risk and Burns MM method did return $8695 on $10K account with drawdown of 15%. Largest profit was 2262, largest loss 438.
Average profit was 1328, average loss was 250.
Using 4% risk and nix MM method returned $8798 with drawdown of 7.8%. Largest profit was 2602, largest loss was 512.
Average profit was 1225, average loss was 171.
Let the testing begin.
Robert
Thanks for posting this, hopefully I can give it a try this afternoon.
There is a problem with your LotSize function that I have seen before.
It will not work with IBFX or those brokers no longer using lots. IBFX uses 1 for a minilots in a mini account while FXDD uses .1 for a minilot in a mini account. FXDD does not allow partial lots in a standard account while I believe IBFX does.
Some brokers are now using actual dollar amounts like $10000 instead of lots..
This causes problems writing MM functions in EAs.
For now I will simply post the code as is. I will work on figuring how to use your method with IBFX and update the EA for repost.
All results posted were using Nix version of AutoLots.
Robert
This modification of my previous AutoLot function should do the trick and takes the StopLoss value into consideration: