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.

setAttrInt() methods do not work on label.
 Post subject: setAttrInt() methods do not work on label. Post rating: 0   New post Posted: Thu 23 Dec, 2010, 14:11 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Cannot assign CORNER, X- and YDISTANCE attribute to IChartObject.Type.LABEL. What is the problem (see code)? BTW, the built-in editor is a nightmare; it shlould not convert tabs into spaces!

package jforex;

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

public class Hello implements IStrategy {
   private IEngine engine;
   private IConsole console;
   private IHistory history;
   private IContext context;
   private IIndicators indicators;
   private IUserInterface userInterface;
   private Font font = new Font("Arial Black", Font.BOLD, 12);
   
   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();
   }
   public void onAccount(IAccount account) throws JFException {
   }
   public void onMessage(IMessage message) throws JFException {
   }
   public void onStop() throws JFException {
      context.getChart(Instrument.EURUSD).remove("hello");
   }   
   public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
   }
   public void onTick(Instrument instrument, ITick tick) throws JFException {
      if(instrument == Instrument.EURUSD){
         IChart chart;
         IChartObject hello;
         try{
            chart = context.getChart(instrument);
            hello = chart.get("hello");
            if (hello != null) {
               //hello.move(tick.getTime(), tick.getBid());
               hello.setAttrColor(IChartObject.ATTR_COLOR.COLOR, Color.RED); // works
               hello.setAttrInt(IChartObject.ATTR_INT.CORNER, 0); // no effect
               hello.setAttrInt(IChartObject.ATTR_INT.XDISTANCE, 100); // no effect
               hello.setAttrInt(IChartObject.ATTR_INT.YDISTANCE, 100); // no effect
               console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.CORNER));
               console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.XDISTANCE));
               console.getOut().println(hello.getAttrInt(IChartObject.ATTR_INT.YDISTANCE));
            }else{
               chart.draw("hello", IChart.Type.LABEL, tick.getTime(), tick.getBid()).setText("Hello World!", font);     
            }
         }catch(Exception ex){
            console.getOut().println(ex);
         }
      }
   }
}


 
 Post subject: Re: JFOREX-2569 setAttrInt() methods do not work on label. Post rating: 0   New post Posted: Tue 08 Feb, 2011, 12:24 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
Please fix this,
setAttrDouble(IChartObject.ATTR_DOUBLE field, double value) is also not working any more!
Example
double price = 1.3456;
setAttrDouble(IChartObject.ATTR_DOUBLE.PRICE1, price)


Same problem is with getAttrColor(IChartObject.ATTR_COLOR field)

I need this functions urgently back, I have to use dirty work arounds otherwise.


 
 Post subject: Re: JFOREX-2569 setAttrInt() methods do not work on label. Post rating: 0   New post Posted: Tue 22 Mar, 2011, 16:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
IChartObject.setAttr<TYPE> methods are deprecated.
Please use direct methods specified for each chart object interface.


 

Jump to:  

  © 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