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.

Drawing text on Chart object
 Post subject: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 10:09 

User rating: 5
Joined: Fri 22 Oct, 2010, 09:54
Posts: 24
Dear Support,

I would need some help in the following problem. I would like to create an 'indicator' which is displayed on an Instrument chart on every timeframe. This indicator displays information about this instrument from some timeframe, but displays the same information on every time frame. For example, the current chart is EURUSD H1 and this 'indicator' a small window on the upper-left corner of the chart displays the current SMA200, 50SMA values of Daily, H4, H1 and M15 chart, like this.

Daily H4 H1 M15
SMA50 10 20 30 40
SMA200 20 23 25 11

If I change the current chart from EURUSD H1 to EURUSD H4 I would see the same information, de 'indicator' window should not be changed.

What kind of interfaces do you suggest to do this? IStrategy? IIndicator? How could I draw a text to the upper left corner of the chartt? Could I get the other time frame infromations from a custom indicator? Can I use other indicator values from my custom indicator?

Best regards,
Kirilla


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 12:40 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Strategy.

Use IChart, IChartObject, with types 'text' or 'label' or possibly 'comment', and set their attributes accordingly.


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 13:28 

User rating: 5
Joined: Fri 22 Oct, 2010, 09:54
Posts: 24
Thank you for your answer. IChart and IChartObject requires time and price as "coordinates". Do I have to calculate these values every redraw? What happens if user scrolling left or right the chart? Do I have to listen to these events too? I would like to put this window on the upper left corner of the chart as it would be on a layer. Is there any simpler way to do it? Or do I misunderstand something?

Best regards,
Kirilla


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 13:59 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Since newer versions of the api, it seems to be possible to set x, y coordinates on objects explicitly through attributes, e.g. Enum IChartObject.ATTR_INT.

Another method would possibly be to put things into the so called glass pane; there you are free to put in all java object (no restriction by the jforex api). The glass pane is transparent and always stays on top / not related to the chart(s).


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 14:29 

User rating: 5
Joined: Fri 22 Oct, 2010, 09:54
Posts: 24
Thank you very much! this glass pane is a very good idea. I need exactly this solution, if it is working. Thank you again.


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Fri 22 Oct, 2010, 14:47 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
You're welcome. Yes it will work - I use it myself to implement a trading interface.

Like so:

JFrame frame = userInterface.getMainFrame();

JPanel glass = (JPanel) frame.getGlassPane();

glass.setLayout(null);

Then you add to the glass what you want.. and at the end, make it visible:

glass.setVisible(true);


 
 Post subject: Re: Drawing text on Chart object Post rating: 0   New post Posted: Sat 23 Oct, 2010, 15:38 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
very interesting solution with the GlassPane.

If your indicator just has to do the following:
Quote:
this 'indicator' a small window on the upper-left corner of the chart displays the current SMA200, 50SMA values of Daily, H4, H1 and M15 chart, like this.

Daily H4 H1 M15
SMA50 10 20 30 40
SMA200 20 23 25 11


you could just use IChart.comment("Daily H4 H1 M15\r\nSMA50 ....... \r\nSMA200 .....")

to accomplish what you intend.

Best, RR.


 

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