TickBarTicksRemaining.java

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



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

import com.dukascopy.api.*;
import com.dukascopy.api.feed.*;

/**
 現在のティックバーの残ティック数を表示します
 */
public class TickBarTicksRemaining implements IStrategy {

    @Configurable("通貨ペア")
    public Instrument instrument = Instrument.EURUSD;    
    
    private IConsole console;
    private IChart chart;
    private IHistory history;
    
    @Override
    public void onStart(IContext context) throws JFException {        
        console = context.getConsole();
        history = context.getHistory();
        chart   = context.getChart(instrument);
    }

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {        
        if(instrument != this.instrument){
            return;
        }
         
        if(chart == null || chart.getTickBarSize() == null){
            print("ティックバーチャートが開かれていません。");
            return;
        }
        
        ITickBar currentTickBar = history.getTickBar(instrument, OfferSide.BID, chart.getTickBarSize(), 0);
        int remaining =  (int) (chart.getTickBarSize().getSize() - currentTickBar.getFormedElementsCount());

        print("残ティック: " + remaining + " 現在のティックバー: " + currentTickBar);

        chart.comment("残ティック " + remaining);

    }
    
    private void print(Object o){
        console.getOut().println(o);
    }

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

}








スポンサーリンク

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


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


Top

inserted by FC2 system