Translate the below HTML to English, keep format html, the result is not in markdown code and not break line, convert standard decode before translate: 口座残高の〇パーセントで決済したい!
Hello. This is a little fx.
Well, as the title suggests,EA ToolI created a logic that takes profits as a percentage of account balance based on the source code output by
which I think will be useful when the target profit for today is 5%!
Now, let's get started.
In advanceEA Toolwill create the closing processing source code for us.
Roughly, something like this.
* I created two close processes: buy position close and sell position close.
EA ToolFrom the source created, I will search for the closing parts.
lots = Lots;
take_profit = TakeProfit;
stop_loss = StopLoss;
signal = 0;
if(getOrderProfit("0", 0, true) >= Number_value_1_1_2) signal = 1;
if(signal != 0 && getOpenLots(Magic1, OP_BUY) != 0) {
closePosition(Magic1, OP_BUY);
}To close at the specified profit, modify the closing part “if(getOrderProfit("0", 0, true) >= Number_value_1_1_2) signal = 1;” to be closed by the already prepared “take_profit.”
lots = Lots;
take_profit = TakeProfit;
stop_loss = StopLoss;
signal = 0;
if(getOrderProfit("0", 0, true) >= take_profit) signal = 1;
if(signal != 0 && getOpenLots(Magic1, OP_BUY) != 0) {
closePosition(Magic1, OP_BUY);
}“take_profit = TakeProfit;” part should be changed to be a percentage of the account balance
take_profit = AccountBalance() * (TakeProfit / 100);
“AccountBalance()” is a convenient function to obtain the account balance.
lots = Lots;
take_profit = AccountBalance() * (TakeProfit / 100);
stop_loss = StopLoss;
signal = 0;
if(getOrderProfit("0", 0, true) >= take_profit) signal = 1;
if(signal != 0 && getOpenLots(Magic1, OP_BUY) != 0) {
closePosition(Magic1, OP_BUY);
}
Now, the default pips setting of “input” for “TakeProfit” can be specified as a percentage.
Simple, isn’t it.
File download is available from below.