「月別フィルター」とは?
4件の返信
今、新しい「What If」条件を追加したサンプルコードを公開しています。この条件では、月に分けることができます。.
QuantEditorを起動し、新しい「What If」ファイルを作成してその内容をコピーします:
import java.util.ArrayList;
import java.util.Iterator;
import com.sonarbytes.eaa.logic.whatif.WhatIf;
import com.sonarbytes.strategy.Order;
import com.sonarbytes.strategy.StrategyStatsData;
import com.sonarbytes.windows.panels.propertyPanel.CComboBoxItemList;
import com.sonarbytes.utils.SQTime;
public class ByMonth extends WhatIf {
public ByMonth() {
setName("By month");
addIntParameter("_JAN_", "January", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_FEB_", "February", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_MAR_", "March", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_APR_", "April", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_MAY_", "May", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_JUN_", "Jun", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_JUL_", "July", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_AUG_", "August", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_SEP_", "September", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_OCT_", "October", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_NOV_", "November", 1, 1, Integer.MAX_VALUE, 1);
addIntParameter("_DEC_", "December", 1, 1, Integer.MAX_VALUE, 1);
// set name of this method that will be displayed with parameter(s)
setFormatedName("By month");
}
/**
* Function receives list of all orders sorted by open time and it could manipulate
* the list and remove any order that matches certain filter from the list.
*
*
* Order structure:
* .ticket - order ticket (integer number)
* .size - order size
* .type - order type: 1 - long trade, 2 - short trade
* .pl - trade resulting Profit/Loss in $
* .pctPL - trade resulting Profit/Loss in %
* .pipsPL - trade resulting Profit/Loss in pips
* .openPrice - opening price of an order
* .openTime - opening time of an order (in seconds from 1.1.1970)
* .stoploss - stop loss level set on the trade
* .takeprofit - profit target level set on the trade
* .closePrice - closing price of an order
* .closeTime - closing time of an order (in seconds from 1.1.1970)
* .closeType - closing type
* .DD - drawdown during this trade in $
* .pctDD - drawdown during this trade in %
* .pipsDD - drawdown during this trade in pips
* .accountBalance - account balance during this trade
* .symbol - instrument symbol (for example "EURUSD")
*
* @param originalOrders - list of original orders that can be changed. Each order has the order properties specified above
*/
@Override
public void filter(ArrayList<Order> originalOrders) {
int jan = getIntParameterValue("_JAN_");
int feb = getIntParameterValue("_FEB_");
int mar = getIntParameterValue("_MAR_");
int apr = getIntParameterValue("_APR_");
int may = getIntParameterValue("_MAY_");
int jun = getIntParameterValue("_JUN_");
int jul = getIntParameterValue("_JUL_");
int aug = getIntParameterValue("_AUG_");
int sep = getIntParameterValue("_SEP_");
int oct = getIntParameterValue("_OCT_");
int nov = getIntParameterValue("_NOV_");
int dec = getIntParameterValue("_DEC_");
for(Iterator<Order> i = originalOrders.listIterator(); i.hasNext() ;) {
Order order = (Order)i.next();
SQTime time = new SQTime(order.openTime);
int orderMonth = time.getMonth();
if(orderMonth == 0 && jan != 1) i.remove();
if(orderMonth == 1 && feb != 1) i.remove();
if(orderMonth == 2 && mar != 1) i.remove();
if(orderMonth == 3 && apr != 1) i.remove();
if(orderMonth == 4 && may != 1) i.remove();
if(orderMonth == 5 && jun != 1) i.remove();
if(orderMonth == 6 && jul != 1) i.remove();
if(orderMonth == 7 && aug != 1) i.remove();
if(orderMonth == 8 && sep != 1) i.remove();
if(orderMonth == 9 && oct != 1) i.remove();
if(orderMonth == 10 && nov != 1) i.remove();
if(orderMonth == 11 && dec != 1) i.remove();
}
}
}
マーク
StrategyQuantアーキテクト
0
これと同じようなコードをもうすでにいくつか書いてあるのではないでしょうか……?…
ヨッシ
0
プログラム内ですでに使用されているすべての「What-if」オプションのコードを確認できます。EA AnalyzerでQuantEditorを開くだけで済みます。.
マーク
StrategyQuantアーキテクト
0
このエラーが出ました。 Mark:
class classByMonth は公開であり、ByMonth.java という名前のファイル内で宣言する必要があります。
0
はい、どこで作ったのかわかりませんが、QuantEditorでByMonth.javaという名前のファイルを作成して、このコードをそこに配置する必要があります。.
ファイル名はクラス名と同じである必要があります。.
マーク
StrategyQuantアーキテクト
0
4件の返信を表示中 - 1 - 4件目 (全4件中)