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.

ITesterExecutionControl function doesn't work?
 Post subject: ITesterExecutionControl function doesn't work? Post rating: 0   New post Posted: Fri 29 Jun, 2018, 19:47 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Hi. I tried use ITesterExecutionControl function in my strategy code but something is wrong.
This function not working. I want to use this https://www.dukascopy.com/client/javado ... ntrol.html and play / pause strategy from my own button.
How to put this strategy controller to my own buttons?
Yes, I can use context.pause() but how to control this function and play again in my function pause_play_btn_event()
This is my little code

package jforex;

import java.util.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.concurrent.Callable;

import com.dukascopy.api.*;

import com.dukascopy.api.system.tester.*;

import com.dukascopy.api.drawings.ICustomWidgetChartObject;

public class myStrategy_errorTester implements IStrategy, ITesterExecution {
    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    private IChart chart;
   
    private ITesterExecutionControl executionControl = null;
   
    JButton btn = new JButton(" test ");
   
    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();
        this.chart = context.getChart(Instrument.EURUSD);
       
        ICustomWidgetChartObject obj = chart.getChartObjectFactory().createChartWidget();
        obj.setFillOpacity(0.3f);
        obj.setColor(Color.BLACK.darker());
       
        JPanel panel = obj.getContentPanel();
        panel.setLayout(null);
       
        btn.setAlignmentX(Component.CENTER_ALIGNMENT);
        btn.setBounds(20, 20, 120, 30);
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    pause_play_btn_event();
                } catch (Exception ex) {
                    // print error
                }
            }
        });
       
        panel.add(Box.createRigidArea(new Dimension(0,5)));
        panel.add(btn);
        panel.setSize(new Dimension(160, 160));
        panel.setMinimumSize(new Dimension(160, 160));
        panel.setMaximumSize(new Dimension(160, 160));
        chart.add(obj);
       
    }
   
    @Override
    public void setExecutionControl(ITesterExecutionControl executionControl) {
        this.executionControl = executionControl;
    }

    private boolean _pause = false;
    private int click = 0;
    public void pause_play_btn_event() throws JFException {     
        if (click == 0) {
            click = 1;
            btn.setText(" Play ");
            if (_pause == false) {
                //context.pause();
                print( 1 );
                executionControl.pauseExecution();
                _pause = true;
            }
        } else if (click == 1) {
            click = 0;
            _pause = false;
            print( 2 );
            btn.setText(" Pause ");
        }
    }

    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 {}
   
    public void print(Object o) {
        console.getOut().println( o );
    }
   
}

How does it looks like... I used ChartWidget.

Image


Attachments:
jforex error2.png [74.89 KiB]
Downloaded 290 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: ITesterExecutionControl function doesn't work? Post rating: 0   New post Posted: Sun 01 Jul, 2018, 01:15 

User rating: 2
Joined: Fri 06 Apr, 2018, 17:06
Posts: 23
Location: Poland,
Maybe use Thread.sleep( time ), but how to use properly this in JForex?
I have no experience with this function, when I tried to use this one time ago my computer and HDD slow down, that was wierd.
I put time as global variable in srategy, on the top of code, next I was create jframe and change time in textField from 1 to 5000 again and again, but probably this was mistake becouse I put Thread.sleep( time - I get this from global variable, and change in textField ) to onBar() heh. Maybe that's why the system has crashed.

And how to control manually SPEED TEST in strategy, how to change in strategy code value of speed bar and control tester speed form 0 to max ?

Image


Attachments:
speed bar.png [1.34 KiB]
Downloaded 279 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.
 

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