HLineKeyRemove.java

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



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

import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IHorizontalLineChartObject;

/**
 ストラテジーは水平線オブジェクトをプロットし、5秒後にオブジェクトをチャートから削除します。
 オブジェクトの削除はキーによるものと、レファレンスによるものの2パターンで行います。
 */
@RequiresFullAccess
public class HLineKeyRemove implements IStrategy {

    private IChart chart;
    private IHistory history;
    private IConsole console;
    
    @Override
    public void onStart(IContext context) throws JFException {
        this.chart   = context.getChart(Instrument.EURUSD);
        this.history = context.getHistory();
        console       = context.getConsole();

        plotAndRemoveHLine(false);
        plotAndRemoveHLine(true);
    }
    
    private void plotAndRemoveHLine(boolean byKey) throws JFException{
        ITick tick = history.getLastTick(Instrument.EURUSD);    
        
        String key = "hLineKey";
        IHorizontalLineChartObject hLine = chart.getChartObjectFactory().createHorizontalLine(key, tick.getBid());  
        chart.addToMainChartUnlocked(hLine);
        
        // 5秒待ち後に削除
        console.getOut().println("5秒経過後に" + (byKey ? "key" : "reference") + "によってオブジェクト削除します。");

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace(console.getErr());
        }

        if(byKey){
            chart.remove(key);
        } else {
            chart.remove(hLine);
        }
    }
    

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {    }
    @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
    @Override
    public void onMessage(IMessage message) throws JFException {}
    @Override
    public void onAccount(IAccount account) throws JFException {}
    @Override
    public void onStop() throws JFException {}

}








スポンサーリンク

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


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


Top

inserted by FC2 system