OptInputValueRange2.java

注意事項:
サンプルソースコードには実際にオーダーを発注するものがあります。
サンプルソースコードのストラテジーを起動する場合は、注意して下さい。



// Copyright (c) 2009 Dukascopy (Suisse) SA. All Rights Reserved.
package jforex.test;

import java.util.Arrays;

import com.dukascopy.api.*;
import com.dukascopy.api.indicators.*;

// indNameで指定したインジケータのメタデータを取得し、パラメータ値の範囲とデフォルト値をログ出力します。

@RequiresFullAccess
public class OptInputValueRange2 implements IStrategy {

    private IConsole    console;
    private IIndicators indicators;

    @Configurable("Indicator name")
    public String indName = "BBANDS";

    public void onStart(IContext context) throws JFException {
        this.console    = context.getConsole();
        this.indicators = context.getIndicators();      
        
        IIndicator    indicator     = indicators.getIndicator(indName);        
        IndicatorInfo info          = indicator.getIndicatorInfo();
        int           optInputCount = info.getNumberOfOptionalInputs();
        
        for(int i = 0; i < optInputCount; i++){
            OptInputParameterInfo optInfo      = indicator.getOptInputParameterInfo(i);
            OptInputDescription   descr        = optInfo.getDescription();
            String               rangeInfoStr = "";

            if(descr instanceof IntegerRangeDescription){
                IntegerRangeDescription d = ((IntegerRangeDescription)descr);
                rangeInfoStr = String.format("最小=%s, 最大=%s", d.getMin(), d.getMax());

            } else if (descr instanceof DoubleRangeDescription){
                DoubleRangeDescription d = ((DoubleRangeDescription)descr);
                rangeInfoStr = String.format("最小=%.5f, 最大=%.5f", d.getMin(), d.getMax());

            } else if (descr instanceof BooleanOptInputDescription){
                rangeInfoStr = ""; // ブーリアンなので範囲無し

            } else if (descr instanceof IntegerListDescription){
                IntegerListDescription d = ((IntegerListDescription)descr);
                rangeInfoStr = String.format("名前=%s, 値=%s", Arrays.asList(d.getValueNames()), Arrays.toString(d.getValues()));

            } else if (descr instanceof DoubleListDescription){
                DoubleListDescription d = ((DoubleListDescription)descr);
                rangeInfoStr = String.format("名前=%s, 値=%s", Arrays.asList(d.getValueNames()), Arrays.toString(d.getValues()));

            }

            print("オプションインプット: %s, 範囲: %s, デフォルト値= %s",
                   optInfo.getName(), rangeInfoStr, descr.getOptInputDefaultValue());
        }         
    }
    
    private void print(String format, Object...args){
        print(String.format(format, args));
    }

    private void print(Object message) {
        console.getOut().println(message);
    }
    
    public void onAccount(IAccount account) throws JFException {    }
    public void onMessage(IMessage message) throws JFException {    }
    public void onStop() throws JFException {    }
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {    }
}






BBANDSインジケータ



スポンサーリンク

スポンサーリンク
検索
リファレンスツリー


Copyright ©2016 JForexAPIで自動売買させ隊! All Rights Reserved.


Top

inserted by FC2 system