Orders Average Price (Multiple Magic Numbers)
4件の返信
How can I calculate the Orders Average Price (Multiple Magic Numbers) weighted by lots?
よろしくお願いいたします。.
0
you can check the function sqGetOrdersAveragePrice() in the EA generated code.
マーク
StrategyQuantアーキテクト
0
マーク、,
Are you saying I should use sqGetOrdersAveragePrice() in the Custom Function area? Bear with me since I am not a programmer, please give me an example of how to retrieve the average price weighted by lots for Magic#1 and Magic#2.
よろしくお願いいたします。.
0
こんにちは,
sorry for insufficient reply.
You can add the following code to the {EA Wizard}/code/CustomFunctions.mq4 file.
This will make EA Wizard add this function to every EA code generated.
double GetMultiOrdersAveragePrice(int magic1, int magic2) {
double sum = 0.0;
double cnt = 0.0;
for (int cc = OrdersTotal() - 1; cc >= 0; cc--) {
if (!OrderSelect(cc, SELECT_BY_POS) ) continue;
if((OrderMagicNumber() == magic1 || OrderMagicNumber() == magic2) && OrderSymbol() == Symbol()) {
if(OrderType() == OP_BUY && OrderCloseTime() == 0) {
sum += OrderLots() * OrderOpenPrice ();
cnt += OrderLots();
}
if(OrderType() == OP_SELL && OrderCloseTime() == 0) {
sum += OrderLots() * OrderOpenPrice ();
cnt += OrderLots();
}
}
}
if (NormalizeDouble (cnt, Digits) == 0) return (0);
return(sum / cnt);
}
Then in EA Wizard rules you can use this new function like Functions -> Custom Function: GetMultiOrdersAveragePrice(1000, 2000)
to get the average price of orders with magic numbers 1000 and 2000.
マーク
マーク
StrategyQuantアーキテクト
0
Thanks for the detailed instructions.
よろしくお願いいたします。.
0
4件の返信を表示中 - 1 - 4件目 (全4件中)