Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

chart drawing problems
 Post subject: chart drawing problems Post rating: 0   New post Posted: Sat 14 Aug, 2010, 11:16 

User rating: 0
Joined: Wed 18 May, 2011, 11:25
Posts: 60
Location: DE
Hi,

i tried to draw some IChartObejects to the chart. But only PRICEMAKER, HLINE and TEXT
works well. LONG_LINE, SHORT_LINE and RECTANGLE well never be drawn, FIBO has no
lines, only points. what's wrong with my code?


package jforex;

import java.util.*;
import java.awt.*;
import com.dukascopy.api.*;


public class SpreadStrategy implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   private IUserInterface userInterface;
   
   public void onStart(IContext context) throws JFException {
      this.engine = context.getEngine();
      this.console = context.getConsole();
      this.history = context.getHistory();
      this.context = context;
      this.indicators = context.getIndicators();
      this.userInterface = context.getUserInterface();
       
        Color lineColor = new Color(255,155,205);
       
        IChart chart = context.getChart(Instrument.EURUSD);
        chart.remove("Spread");
        chart.remove("Ask");
        chart.remove("Bid");
        chart.remove("Line");
       
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_MONTH, 13);
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 1);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        IChartObject spread = chart.draw("Spread", IChart.Type.TEXT, cal.getTimeInMillis(), 1.27537);
        spread.setText("2.0", new Font(Font.SANS_SERIF, Font.BOLD, 24));
       
        Calendar cal1 = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_MONTH, 13);
        cal.set(Calendar.HOUR_OF_DAY, 22);
        cal.set(Calendar.MINUTE, 20);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        Calendar cal2 = Calendar.getInstance();
        cal.set(Calendar.DAY_OF_MONTH, 13);
        cal.set(Calendar.HOUR_OF_DAY, 22);
        cal.set(Calendar.MINUTE, 50);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        //IChartObject line = chart.draw("LineTest", IChart.Type.LONG_LINE, cal1.getTimeInMillis(), 1.2750, cal2.getTimeInMillis() , 1.2760);
        IChartObject bid = chart.draw("Bid", IChart.Type.PRICEMARKER, cal1.getTimeInMillis(), 1.2753);
        bid.setColor(lineColor);
       
        IChartObject ask = chart.draw("Ask", IChart.Type.HLINE, cal1.getTimeInMillis(), 1.2755);
        ask.setColor(lineColor);       
       
        IChartObject longLine = chart.draw("LongLine", IChart.Type.LONG_LINE, cal1.getTimeInMillis(), 1.2755, cal2.getTimeInMillis() , 1.2762);
        longLine.setColor(Color.BLUE);
       
        IChartObject shortLine = chart.draw("ShortLine", IChart.Type.SHORT_LINE, cal1.getTimeInMillis(), 1.2750, cal2.getTimeInMillis() , 1.2757);
        shortLine.setColor(Color.BLUE);
       
        IChartObject fibo = chart.draw("Fibo", IChart.Type.FIBO, cal1.getTimeInMillis(), 1.2750, cal2.getTimeInMillis() , 1.2762);
        fibo.setColor(Color.BLUE);
       
        IChartObject box = chart.draw("Box", IChart.Type.RECTANGLE, cal1.getTimeInMillis(), 1.2750, cal2.getTimeInMillis() , 1.2760);
        box.setColor(Color.GREEN);
   }

   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 {
    }
}


 
 Post subject: Re: chart drawing problems Post rating: 0   New post Posted: Sat 14 Aug, 2010, 11:42 

User rating: 0
Joined: Wed 18 May, 2011, 11:25
Posts: 60
Location: DE
lol i'm so stupid, i always set the cal-object and not the cal1 and cal2 ... now it works fine ;-)


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com