Add:
case 3 : Money_Loss = 100; /* In this case you want to lose only 100 bucks */ break; or case 3 : Money_Loss = Fix_Dollars; /* Where Fix_Dollars is an Extern Variable */ break;
Add:
Can it be this way ?
extern double Risk = 1; extern string Note_1 = "0 - Balance/1 - Equity/2 - Free Margin/3 - Fix_Dollars"; extern int Risk_Basis = 0;
and then:
{ double Money_Loss; switch(Risk_Basis){ case 0 : Money_Loss = AccountBalance()*(Risk/100); break; case 1 : Money_Loss = AccountEquity()*(Risk/100); break; case 2 : Money_Loss = AccountFreeMargin()*(Risk/100); break; case 3 : Money_Loss = Fix_Dollars()*(Risk/100); break: } return(Money_Loss);
Ubzen, I do not have knowledge how to code in MT4 just trying to get EA to be able to use same fixed number e.g account balance from beginning of week for the whole week.
When it is as now it always changes after each trade. Do not want that. Would like to have fixed base for position size calculation with chosen risk level.
Appreciate your help here.
Original EA attached.
Ubzen, I do not have knowledge how to code in MT4 just trying to get EA to be able to use same fixed number e.g account balance from beginning of week for the whole week.
When it is as now it always changes after each trade. Do not want that. Would like to have fixed base for position size calculation with chosen risk level.
Appreciate your help here.
Original EA attached.
Made the following changes.
extern double Risk = 1; extern string Note_1 = "0 - Balance/1 - Equity/2 - Free Margin/3 - Fix_Dollars"; extern int Risk_Basis = 0; extern double Fix_Dollars = 0;
You need to know the amount in dollars. Easiest to just modify the number of the Fix_Dollars Parameter.
Then also modify the Function.
double Cash_Risk() { double Money_Loss; switch(Risk_Basis){ case 0 : Money_Loss = AccountBalance()*(Risk/100); break; case 1 : Money_Loss = AccountEquity()*(Risk/100); break; case 2 : Money_Loss = AccountFreeMargin()*(Risk/100); break; case 3 : Money_Loss = Fix_Dollars*(Risk/100); if(Fix_Dollars==0){ Alert( "Fix_Dollars Cannot Be Zero "+ "Enter Real Value And Try Again" ); } break; } return(Money_Loss); }Its up to you now to test it.
Made the following changes.
You need to know the amount in dollars. Easiest to just modify the number of the Fix_Dollars Parameter.
Then also modify the Function.
Its up to you now to test it.
Great thank you.
Will test it and advise.
Ubzen, EA after your help, works very well with fix number, however, when I want to use script to automate opening order as per data set by EA, get error message. It does not work.
Can you advise what to do please ?
attached is script and also will post EA after amendment
Ubzen, EA after your help, works very well with fix number, however, when I want to use script to automate opening order as per data set by EA, get error message. It does not work.
Can you advise what to do please ?
attached is script and also will post EA after amendment
Expert file.
Ubzen, EA after your help, works very well with fix number, however, when I want to use script to automate opening order as per data set by EA, get error message. It does not work.
Can you advise what to do please ?
attached is script and also will post EA after amendment
What data set by EA?
What error# do you get?
Also, your script does-not compile. Error: 'Fix_Dollars' - variable not defined
Ubzen,
It works like this. EA is attached to a chart and there is a line which can be pulled as a intended stop level. Once in place EA will indicate, based on distance from price and level of risk chosen, position size.
Then I hit Ctr T which is shortcut to script to perform trade.
Now I get error message. Will need to wait till Monday, as do not remeber number of error message.
Always appreciate your help.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can somebody help to amend EA code to have possibility to open position based on fixed/constant number ? Want to be able use it for certain period of time with not always changing base for position size calculation.
Would like to add case 3: .....be able to write amount of money and keep it till manually changed.
//+------------------------------------------------------------------+
double Cash_Risk()
{
double
Money_Loss;
switch(Risk_Basis){
case 0 : Money_Loss = AccountBalance()*(Risk/100);
break;
case 1 : Money_Loss = AccountEquity()*(Risk/100);
break;
case 2 : Money_Loss = AccountFreeMargin()*(Risk/100);
break;
}
return(Money_Loss);
}
//+------------------------------------------------------------------+
Thanks a lot.