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.

access to drawn objects
 Post subject: access to drawn objects Post rating: 0   New post Posted: Fri 04 Mar, 2011, 12:54 

User rating: -
Hi,

How can I access a horizontal line object drawn by hand on the chart from within a strategy ? The chart.getAll() function cannot do it.


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Mon 07 Mar, 2011, 16:08 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
After a chart object creation it is necessary to add it to to the main chart. Please consider the following code for creating and getting the horizontal line object:
IChart.addToMainChart(chart.getChartObjectFactory().createHorizontalLine("key123"));
IChartObject object = chart.get("key123");
List<IChartObject> objects  =chart.getAll();
for (IChartObject chartObject: objects){
    console.getOut().println("Chart object from collect: " + chartObject);
}


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Tue 08 Mar, 2011, 08:49 

User rating: -
Support wrote:
Hi,
After a chart object creation it is necessary to add it to to main chart. Please consider the following code for creating and getting the horizontal line object:
IChart.addToMainChart(chart.getChartObjectFactory().createHorizontalLine("key123"));
IChartObject object = chart.get("key123");
List<IChartObject> objects  =chart.getAll();
for (IChartObject chartObject: objects){
    console.getOut().println("Chart object from collect: " + chartObject);
}



Hi Support,

It does not seem to work. I want to add several horizontal lines to my chart while my strategy is running . My strategy should get all horizontal line objects on the fly then. Is that possible with jForex? I had a feeling that no hand drawn object can be accessed from within the strategy.

Thanks!


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Thu 10 Mar, 2011, 08:42 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Guest wrote:
I want to add several horizontal lines to my chart while my strategy is running . My strategy should get all horizontal line objects on the fly then. Is that possible with jForex? I had a feeling that no hand drawn object can be accessed from within the strategy.

Thanks!

Currently you can add a horizontal line to the chart using the IChart.draw method:
IChart.draw("hLine", IChart.Type.HLINE, history.getLastTick(Instrument.EURUSD).getTime(), history.getLastTick(Instrument.EURUSD).getAsk());

IChartObjectFactory.createHorizontalLine(String key) will be available soon.

For more details about IChart interface, please assume the following JForex Wiki page: https://www.dukascopy.com/wiki/index.php?title=IChart


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Thu 10 Mar, 2011, 10:06 

User rating: -
Support wrote:
Currently you can add a horizontal line to the chart using the IChart.draw method:
IChart.draw("hLine", IChart.Type.HLINE, history.getLastTick(Instrument.EURUSD).getTime(), history.getLastTick(Instrument.EURUSD).getAsk());

IChartObjectFactory.createHorizontalLine(String key) will be available soon.

For more details about IChart interface, please assume the following JForex Wiki page: https://www.dukascopy.com/wiki/index.php?title=IChart



Hi Support,

Another question: if I selected a horizontal line object from the "Drawings" Toolbox of Jforex platform and draw it using my mouse on the chart. How can get the price of that horizontal trendline from within my strategy? I cannot get that horizontal line object with chart.getAll() function inside my strategy, it gives me "0".

Thanks!


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Mon 14 Mar, 2011, 11:22 

User rating: -
Hi Support,

If I drew a horizontal line on the same chart from the "Drawings" Jforex platform menu how can I get the price of that horizontal line in my strategy?
The chart.getAll() function returns 0 only. Is it possible at all? if yes how?

Thanks


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Tue 15 Mar, 2011, 20:50 
User avatar

User rating: 3
Joined: Wed 18 May, 2011, 16:25
Posts: 331
Location: SwitzerlandSwitzerland
Hi,

as of now you can only access objects that have been created by the strategy.
However, you can add objects from within the strategy that you then can move manually by using addToMainChartUnlocked().
I've registered a feature request a long time ago to be able to retrieve chart objects that have been added manually from within strategies, but such a feature is not available as of yet.

Hope this helps...
Best, RR.


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Wed 16 Mar, 2011, 15:47 

User rating: 0
Joined: Thu 19 May, 2011, 16:00
Posts: 37
Location: UkraineUkraine
Hello!

draw method from IChart was market as deprecated. Could you please provide some examples of usage ChartObjectFactory because wiki contains only outdated information.
What we a looking is possibility draw horizontal lines through all screen.


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Mon 21 Mar, 2011, 15:19 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Please have a look at the following code:
  import java.awt.Color;
  import com.dukascopy.api.drawings.IChartObjectFactory;
  import com.dukascopy.api.drawings.IHorizontalLineChartObject;
  ...
  this.history = context.getHistory();
  ...
  double price = history.getLastTick(Instrument.EURUSD).getAsk();
  IChart chart = context.getChart(Instrument.EURUSD);   
  IChartObjectFactory factory = chart.getChartObjectFactory();   
  IHorizontalLineChartObject hline = factory.createHorizontalLine("hline", price);
  hline.setColor(Color.RED);
  chart.addToMainChartUnlocked(hline);


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Mon 22 Aug, 2011, 15:52 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Hello Support,

IChart method addToMainChartUnlocked() is depricated according to JavaDoc - see https://www.dukascopy.com/client/javadoc ... Unlocked(T) .
But if I use addToMainChart() instead I'm not able to access the automatically created horizontal line in the chart, that is drag the line per mouse is not possible. Only if I create the HLine with addToMainChartUnlocked() I can access it manually.

Regards
AbsoluteReturner


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Tue 23 Aug, 2011, 08:09 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please be advised that the deprecation of the method is in force starting with JForex API 2.6.43, which is currently available only in standalone version. The JForex client uses JForex API 2.6.38, so that is why there is no such deprecation and that is why the suggested deprecated method alternative does not work. The change will be in force in JForex client with the next release, follow the release information here: viewforum.php?f=71


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Mon 10 Oct, 2011, 16:43 

User rating: 1
Joined: Tue 12 Jul, 2011, 20:43
Posts: 51
Location: Germany,
Hello Support,

is it possible to lock a ChartObject [which was added to chart using addToMainChartUnlocked()] temporarily at runtime ? If yes - can you please provide a solution how to do this, both in current API version 2.6.38 and in futher version 2.6.43 ?
I want to use a HorizontalLineChartObject in a strategy to determine an initial stoploss level per mouse. Then I want to open a trade with a click on a button created in the BottomTab. During the trade is open the HorizontalLineChartObject should be locked, and after the trade is closed it should be unlocked agin.

If this is not possible, a function like
IChart.setChartObjectEnabled(IChartObject object, boolean enabled) and / or
IChart.setChartObjectEnabled(String key, boolean enabled)
would be helpful.

Regards
AbsoluteReturner


 
 Post subject: Re: access to drawn objects Post rating: 0   New post Posted: Tue 11 Oct, 2011, 08:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see the following example in JForex wiki:
https://www.dukascopy.com/wiki/index.php ... rt_objects


 

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