CalculateParticularIndicator.java

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



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

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

@RequiresFullAccess
public class CalculateParticularIndicator implements IStrategy {

    private IConsole console;
    private IIndicators indicators;
    @Configurable("インジケータ名")
    public String indName = "ALLIGATOR";
    @Configurable("通貨ペア")
    public Instrument instrument = Instrument.EURUSD;
    @Configurable("時間軸")
    public Period period = Period.ONE_MIN;
    @Configurable("適用価格")
    public AppliedPrice appliedPrice = AppliedPrice.CLOSE;
    @Configurable("オファーサイド")
    public OfferSide side = OfferSide.BID;

    public void onStart(IContext context) throws JFException {
        this.console = context.getConsole();
        this.indicators = context.getIndicators();        

        IIndicator indicator = indicators.getIndicator(indName); 
        
        //パラメータインプット - 1つの要素を持った配列を作成
        AppliedPrice[] inputTypes = new AppliedPrice[] { appliedPrice };
        OfferSide[]    offerSides = new OfferSide[]    { side         };
        
        //オプションインプット - オプションインプット(ジョータイム期間・トゥースタイム期間・リップタイム期間)の3つはデフォルト値を使用
        Object[] optParams = new Object[] {13, 8, 5};
        
        int shift = 0;
        Object[] outputs = indicators.calculateIndicator(
                               instrument,
                               period,
                               offerSides,
                               indName,
                               inputTypes,
                               optParams,
                               shift
                           );
        
        //アウトプット - 3つのアウトプットは全てDOUBLE型
        for(int i = 0; i < 3; i++){
            String outputName = indicator.getOutputParameterInfo(i).getName();
            print("%s=%.5f", outputName, (Double)outputs[i]);
        }       
    }
    
    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 {    }
}







スポンサーリンク

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


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


Top

inserted by FC2 system