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.

How to draw arbitrary values to chart and subwindow?
 Post subject: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Sun 10 May, 2015, 19:30 
User avatar

User rating: 11
Joined: Tue 27 Mar, 2012, 17:47
Posts: 111
Location: GermanyGermany
Hello Support,

could you show me how one can draw arbitrary values (connected with a line) into a tick chart window and a subwindow of the same chart?
Consider this example where the comments explain what I want to achieve:
package jforex;

import java.util.Random;

import com.dukascopy.api.IAccount;
import com.dukascopy.api.IBar;
import com.dukascopy.api.IConsole;
import com.dukascopy.api.IContext;
import com.dukascopy.api.IEngine;
import com.dukascopy.api.IHistory;
import com.dukascopy.api.IIndicators;
import com.dukascopy.api.IMessage;
import com.dukascopy.api.IStrategy;
import com.dukascopy.api.ITick;
import com.dukascopy.api.IUserInterface;
import com.dukascopy.api.Instrument;
import com.dukascopy.api.JFException;
import com.dukascopy.api.Period;

public class MyStrategy implements IStrategy {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    final Random rnd = new Random();

    @Override
    public void onStart(final 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();

        // Must be something done here to attach to the EURUSD chart?
    }

    @Override
    public void onAccount(final IAccount account) throws JFException {
    }

    @Override
    public void onMessage(final IMessage message) throws JFException {
    }

    @Override
    public void onStop() throws JFException {
    }

    @Override
    public void onTick(final Instrument instrument, final ITick tick) throws JFException {
        if (instrument == Instrument.EURUSD) {
            final double valueForChart = rnd.nextDouble();
            final double valueForSubwindow = rnd.nextDouble();
            // Plot valueForChart onto the EURUSD tick chart and connect with a line???
            // Plot valueForSubwindow onto a subwindow of the EURUSD tick chart and connect with a line???
        }
    }

    @Override
    public void onBar(final Instrument instrument, final Period period, final IBar askBar, final IBar bidBar) throws JFException {
    }
}

I do not need an indicator since the values are already computed.
Is there a simple way to do this?
Can you show me a working example?

Thanks for help,
Juergen


 
 Post subject: Re: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Tue 12 May, 2015, 12:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please see the attached strategy


Attachments:
MyStrategy.java [5.14 KiB]
Downloaded 62 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Tue 12 May, 2015, 19:20 
User avatar

User rating: 11
Joined: Tue 27 Mar, 2012, 17:47
Posts: 111
Location: GermanyGermany
Hello Support,

thank you very much for this example!
The chart drawing works but not the panel drawing.
When I run this strategy the following gets printed: "Subchart for EUR/USD is not found!"
Maybe there is a misunderstanding here, I want to automatically open a new panel under the chart.
Consider these steps:
1) Open JForex platform(no charts are active)
2) User opens EUR/USD tick chart
3) User starts your strategy
4) Panel is created under the tick chart and updated on every tick

Do I have to manually add an arbitrary indicator to create a new panel?
Thank you for feedback


 
 Post subject: Re: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Wed 13 May, 2015, 08:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Here is a description on how to add an indicator on chart.
https://www.dukascopy.com/wiki/#Add_indicators_on_chart


 
 Post subject: Re: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Wed 13 May, 2015, 10:23 
User avatar

User rating: 11
Joined: Tue 27 Mar, 2012, 17:47
Posts: 111
Location: GermanyGermany
I know this description but I don't understand how I can plot arbitrary values as you have provided in the strategy.
When I add an indicator in a panel it will plot something.
But I want my precomputed values to be plotted wihtout the indicator output.
Do I have to create a custom indicator which outputs nothing?


 
 Post subject: Re: How to draw arbitrary values to chart and subwindow? Post rating: 0   New post Posted: Fri 15 May, 2015, 10:56 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes the easiest way is to create dummy indicator. It is not possible to open IIndicatorPanel without an indicator.


 

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