IndicatorPanelAddStochAndHLines.java
注意事項:
サンプルソースコードには実際にオーダーを発注するものがあります。
サンプルソースコードのストラテジーを起動する場合は、注意して下さい。
package jforex.charts;
import java.awt.Color;
import com.dukascopy.api.*;
import com.dukascopy.api.drawings.IHorizontalLineChartObject;
import com.dukascopy.api.indicators.IIndicator;
import com.dukascopy.api.indicators.IndicatorInfo;
import com.dukascopy.api.indicators.OutputParameterInfo.DrawingStyle;
public class IndicatorPanelAddStochAndHLines implements IStrategy {
@Configurable("通貨ペア")
public Instrument instrument = Instrument.EURUSD;
private IChart chart;
private IConsole console;
private IIndicators indicators;
@Override
public void onStart(IContext context) throws JFException {
this.chart = context.getChart(instrument);
this.console = context.getConsole();
this.indicators = context.getIndicators();
if(chart == null){
console.getErr().println(instrument + "のチャートが開かれていません");
context.stop();
}
IChartPanel rsiPanel = chart.add(
indicators.getIndicator("RSI"),
new Object[]{15}
);
rsiPanel.add(
indicators.getIndicator("RSI"),
new Object[]{30},
new Color[]{Color.MAGENTA},
new DrawingStyle[]{DrawingStyle.LINE},
new int[]{1}
);
IHorizontalLineChartObject hLine = chart.getChartObjectFactory().createHorizontalLine("subHLine", 50);
hLine.setColor(Color.RED);
hLine.setLineStyle(LineStyle.DASH_DOT_DOT);
rsiPanel.add(hLine);
IndicatorInfo emaInfo = indicators.getIndicator("EMA").getIndicatorInfo();
if(emaInfo.isOverChart() && rsiPanel instanceof IIndicatorPanel){
console.getOut().println( emaInfo.getName() +
"は、メインチャートへのプロットのみ可能なので、インジケータパネルに追加できません。");
}
}
@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 {
while(chart.getIndicatorPanels().size() > 0){
IChartPanel panel = chart.getIndicatorPanels().get(0);
for (IIndicator indicator : panel.getIndicators()) {
panel.removeIndicator(indicator);
}
}
}
}
スポンサーリンク
注意事項:
当サイトはJForexAPIを紹介している非公式サイトです。
自動売買を行うストラテジーや売買シグナルのソフトウェアの配布などは行っておりません。
投資助言も行っておりません、投資助言を必要としている方は投資助言業者に相談して下さい。
当サイトに掲載している情報やサンプルソース利用によって損害が生じてもサイト管理人は責任を負いませんので、全て自己責任でお願い致します。
FX(外国為替保証金取引)は金融商品取引法に規定される通貨関連店頭デリバティブ取引です。
元本あるいは利益を保証した金融商品ではありません。
為替変動・金利変動・アルゴリズムによる急変動・各国要人の気まぐれ発言による暴落等のリスクにより、損失が生じるおそれがあります。
FXは少ない保証金を担保として大きな金額を取引出来る為、投資金額以上の損失を被る可能性があります。
詳細は証券会社の契約締結前交付書面・約款等を熟読して下さい。