How to check open profit?
1件の返信
Is there a way check the total open account profit?
For example, if I have 4, 5 or 10 open trades, over different currencies, AUDUSD, USDJPY etc …, some in profit, some in loss, I want to close all trades if my open profit is at some level.
I was using Open P/L (in pips), with magic number set to 0, but it only seemed to read the profit for the one currency.
何か意見はありますか?
ありがとう。.
0
こんにちは、,
it is possible only using custom function. Open the file {EA Wizard installation}/code/CustomFunctions.mq4
and add the following function there:
double sqGetTotalOpenPLInPips() {
double pl = 0;
for (int cc = OrdersTotal() - 1; cc >= 0; cc--) {
if (!OrderSelect(cc, SELECT_BY_POS) ) continue;
if(OrderType() != OP_BUY && OrderType() != OP_SELL) continue;
if(OrderType() == OP_BUY) {
pl += Bid – OrderOpenPrice();
} else {
pl += OrderOpenPrice() – Ask;
}
}
return(pl*gPointPow);
}
this will add new function to the program that will be attached to every EA generated by EA Wizard.
Then you can call this new function in Functions -> Custom Function or Then actions -> Other -> Custom Action.
You’ll call it normally like GetTotalOpenPLInPips()
Your condition could be for example:
IF Custom Function: GetTotalOpenPLInPips() > 1000
それから
…do something
マーク
StrategyQuantアーキテクト
0
1件の返信を表示中 - 1 - 1件目 (全1件中)