読み取り専用

フォーラムは現在、読み取り専用のアーカイブとなっています。.

バグ報告やプラットフォームに関する質問はこちら → [email protected]

私たちのコミュニティはDiscordとYouTubeで活動しています。ぜひ参加してください!

ご参加ください Discord YouTube

Orders Average Price (Multiple Magic Numbers)

4件の返信

ラマカン

Subscriber, bbp_participant, community, 72 replies.

プロフィールを表示

13年前 #111190

How can I calculate the Orders Average Price (Multiple Magic Numbers) weighted by lots?

よろしくお願いいたします。.

0

マーク・フリック

管理者、sq-ultimate、2件の返信.

プロフィールを表示

13年前 #121712

you can check the function sqGetOrdersAveragePrice() in the EA generated code.

マーク
StrategyQuantアーキテクト

0

ラマカン

Subscriber, bbp_participant, community, 72 replies.

プロフィールを表示

13年前 #121731

マーク、,

 

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

マーク・フリック

管理者、sq-ultimate、2件の返信.

プロフィールを表示

13年前 #121833

こんにちは,

 

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

ラマカン

Subscriber, bbp_participant, community, 72 replies.

プロフィールを表示

13年前 #121843

Thanks for the detailed instructions.

 

よろしくお願いいたします。.

 

0

4件の返信を表示中 - 1 - 4件目 (全4件中)